CODE STYLE, workflow/engine/methods/services/

FILES:
cases_StartExternal.php
demoSoap.php
login_getStarted.php
processHeartBeat_Ajax.php
soap.php
soap2.php
unavailableService.php
upload.php
webdav.php
wsdl.php
wsdl2.php
wso2.php
xpdl.php
This commit is contained in:
jennylee
2012-10-17 14:21:55 -04:00
parent 9b55347f30
commit 665fd4d25d
13 changed files with 1528 additions and 1497 deletions

View File

@@ -1,66 +1,57 @@
<?php <?php
try { try {
require_once ( "classes/model/Task.php" ); require_once ("classes/model/Task.php");
require_once ( "classes/model/Users.php" ); require_once ("classes/model/Users.php");
G::LoadClass('case'); G::LoadClass( 'case' );
G::LoadClass('derivation'); G::LoadClass( 'derivation' );
$oTask = new Task(); $oTask = new Task();
$TaskFields = $oTask->load( $_POST['TASKS'] ); $TaskFields = $oTask->load( $_POST['TASKS'] );
$aDerivation['NEXT_TASK'] = $TaskFields; $aDerivation['NEXT_TASK'] = $TaskFields;
$oDerivation = new Derivation(); $oDerivation = new Derivation();
$deriva = $oDerivation->getNextAssignedUser($aDerivation); $deriva = $oDerivation->getNextAssignedUser( $aDerivation );
$oCase = new Cases(); $oCase = new Cases();
$aData = $oCase->startCase( $_POST['TASKS'], $deriva['USR_UID'] ); $aData = $oCase->startCase( $_POST['TASKS'], $deriva['USR_UID'] );
$case = $oCase->loadCase( $aData['APPLICATION'], 1 );
$case = $oCase->loadCase($aData['APPLICATION'], 1); $Fields = array ();
$Fields['APP_NUMBER'] = $case['APP_NUMBER'];
$Fields['APP_PROC_STATUS'] = 'draft';
$Fields['APP_DATA'] = $_POST['form'];
$Fields['DEL_INDEX'] = 1;
$Fields['TAS_UID'] = $_POST['TASKS'];
//$Fields = $oCase->loadCase($aData['APPLICATION'], 1);
$oCase->updateCase( $aData['APPLICATION'], $Fields );
$Fields = array(); $s = 0;
$Fields['APP_NUMBER'] = $case['APP_NUMBER']; if (isset( $_SERVER['HTTP_REFERER'] )) {
$Fields['APP_PROC_STATUS'] = 'draft'; $dir = explode( '?', $_SERVER['HTTP_REFERER'] );
$Fields['APP_DATA'] = $_POST['form']; if ($dir[1] == '__flag__=1') {
$Fields['DEL_INDEX'] = 1; $s = 1;
$Fields['TAS_UID'] = $_POST['TASKS']; } else {
//$Fields = $oCase->loadCase($aData['APPLICATION'], 1); $dire = explode( '&', $dir[1] );
$oCase->updateCase( $aData['APPLICATION'], $Fields ); for ($i = 0; $i <= count( $dire ); $i ++) {
if ($dire[$i] == '__flag__=1')
$s = 1;
}
}
$s=0; //if(strpos($_SERVER['HTTP_REFERER'],'?') !== false)
if(isset($_SERVER['HTTP_REFERER'])) if ($s == 1) {
{ G::header( 'location: ' . $_SERVER['HTTP_REFERER'] );
$dir = explode('?', $_SERVER['HTTP_REFERER']); } else {
if($dir[1]=='__flag__=1') G::header( 'location: ' . $_SERVER['HTTP_REFERER'] . '?__flag__=1' );
{ $s=1; }
} } else
else echo G::LoadTranslation( 'ID_REQUEST_SENT' );
{
$dire = explode('&', $dir[1]);
for($i=0; $i<=count($dire); $i++)
{
if($dire[$i]=='__flag__=1')
$s=1;
}
}
//if(strpos($_SERVER['HTTP_REFERER'],'?') !== false) } catch (Exception $e) {
if($s==1) $G_PUBLISH = new Publisher();
{ G::header('location: ' . $_SERVER['HTTP_REFERER']); $aMessage['MESSAGE'] = $e->getMessage();
} $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
else G::RenderPage( 'publish' );
{ G::header('location: ' . $_SERVER['HTTP_REFERER'] . '?__flag__=1'); }
}
}
else
echo G::LoadTranslation('ID_REQUEST_SENT');
}
catch ( Exception $e ) {
$G_PUBLISH = new Publisher;
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish' );
}
?>

View File

@@ -1,258 +1,273 @@
<html> <html>
<head> <head>
<title> SugarCRM test webservices </title> <title>SugarCRM test webservices</title>
</head> </head>
<style type="text/css"> <style type="text/css">
ul.krumo-node { ul.krumo-node {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
background-color: white; background-color: white;
} }
ul.krumo-node ul { ul.krumo-node ul {
margin-left: 20px; margin-left: 20px;
} }
* html ul.krumo-node ul { * html ul.krumo-node ul {
margin-left: 24px; margin-left: 24px;
} }
div.krumo-root { div.krumo-root {
border: solid 1px black; border: solid 1px black;
margin: 1em 0em; margin: 1em 0em;
text-align: left; text-align: left;
} }
ul.krumo-first { ul.krumo-first {
font: normal 11px tahoma, verdana; font: normal 11px tahoma, verdana;
border: solid 1px white; border: solid 1px white;
} }
li.krumo-child { li.krumo-child {
display:block; display: block;
list-style: none; list-style: none;
padding: 0px; padding: 0px;
margin: 0px; margin: 0px;
overflow:hidden; overflow: hidden;
} }
div.krumo-element {
cursor:default;
display:block;
clear:both;
white-space:nowrap;
div.krumo-element {
cursor: default;
display: block;
clear: both;
white-space: nowrap;
background-color: white; background-color: white;
background-image: url(/Krumo/skins/schablon.com/empty.gif); background-image: url(/Krumo/skins/schablon.com/empty.gif);
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 6px 5px; background-position: 6px 5px;
padding: 2px 0px 3px 20px; padding: 2px 0px 3px 20px;
} }
* html div.krumo-element { * html div.krumo-element {
padding-bottom: 3px; padding-bottom: 3px;
line-height: 13px; line-height: 13px;
} }
a.krumo-name { a.krumo-name {
color:navy; color: navy;
font: bold 13px courier new; font: bold 13px courier new;
line-height:12px; line-height: 12px;
} }
</style> </style>
<?php <?php
if ( isset ( $_POST["epr"] ) ) { if (isset( $_POST["epr"] )) {
$_SESSION['END_POINT'] = $_POST["epr"]; $_SESSION['END_POINT'] = $_POST["epr"];
} }
$endpoint = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : 'http://sugar.opensource.colosa.net/soap.php'; $endpoint = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : 'http://sugar.opensource.colosa.net/soap.php';
$sessionId = isset( $_SESSION['SESSION_ID'] ) ? $_SESSION['SESSION_ID'] : ''; $sessionId = isset( $_SESSION['SESSION_ID'] ) ? $_SESSION['SESSION_ID'] : '';
?> ?>
<form method="post" action=""> <form method="post" action="">
<div class="krumo-root"> <div class="krumo-root">
<ul class="krumo-node krumo-first"> <ul class="krumo-node krumo-first">
<div class="krumo-element" > <div class="krumo-element">
End Point <input type="text" size="80" maxlength="160" name="epr" End Point <input type="text" size="80" maxlength="160" name="epr"
value="<?php echo $endpoint ?>" > value="<?php echo $endpoint ?>"> <input type="submit"
<input type="submit" value="change endpoint" name="action"> value="change endpoint" name="action">
</div> </div>
</ul> </ul>
</div> </div>
</form > </form>
<form method="post" action=""> <form method="post" action="">
<div class="krumo-root"> <div class="krumo-root">
<a class="krumo-name">login</a> <a class="krumo-name">login</a>
<ul class="krumo-node krumo-first"> <ul class="krumo-node krumo-first">
<div > <div>
User Id <input type="text" size="16" maxlength="20" name="user" value="admin"> User Id <input type="text" size="16" maxlength="20" name="user"
Password <input type="text" size="16" maxlength="20" name="pass" value="sample"> value="admin"> Password <input type="text" size="16" maxlength="20"
<input type="submit" value="login" name="action"> name="pass" value="sample"> <input type="submit" value="login"
</div> name="action">
</ul> </div>
</div> </ul>
</form > </div>
</form>
<form method="post" action=""> <form method="post" action="">
<div class="krumo-root"> <div class="krumo-root">
<a class="krumo-name">createUser</a> <a class="krumo-name">createUser</a>
<ul class="krumo-node krumo-first"> <ul class="krumo-node krumo-first">
<div class="krumo-element" > <div class="krumo-element">
Session Id <input type="text" size="36" maxlength="32" name="sessionid" value="<?php print $sessionId ?>"> Session Id <input type="text" size="36" maxlength="32"
</div> name="sessionid" value="<?php print $sessionId ?>">
<div class="krumo-element" > </div>
User Id <input type="text" size="16" maxlength="20" name="userid" value=""> <div class="krumo-element">
<img src="/Krumo/skins/schablon.com/empty.gif" > User Id <input type="text" size="16" maxlength="20" name="userid"
First Name <input type="text" size="16" maxlength="20" name="firstname" value=""> value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> First
<img src="/Krumo/skins/schablon.com/empty.gif" > Name <input type="text" size="16" maxlength="20" name="firstname"
Last Name <input type="text" size="16" maxlength="20" name="lastname" value=""> value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> Last Name
<img src="/Krumo/skins/schablon.com/empty.gif" > <input type="text" size="16" maxlength="20" name="lastname" value="">
Email <input type="text" size="16" maxlength="20" name="email" value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> Email <input
<img src="/Krumo/skins/schablon.com/empty.gif" > type="text" size="16" maxlength="20" name="email" value=""> <img
Role <input type="text" size="16" maxlength="20" name="role" value=""> src="/Krumo/skins/schablon.com/empty.gif"> Role <input type="text"
<img src="/Krumo/skins/schablon.com/empty.gif" > size="16" maxlength="20" name="role" value=""> <img
<input type="submit" value="createUser" name="action"> src="/Krumo/skins/schablon.com/empty.gif"> <input type="submit"
</div> value="createUser" name="action">
</ul> </div>
</div> </ul>
</form > </div>
</form>
<form method="post" action=""> <form method="post" action="">
<div class="krumo-root"> <div class="krumo-root">
<a class="krumo-name">assignUserToGroup</a> <a class="krumo-name">assignUserToGroup</a>
<ul class="krumo-node krumo-first"> <ul class="krumo-node krumo-first">
<div class="krumo-element" > <div class="krumo-element">
Session Id <input type="text" size="36" maxlength="32" name="sessionid" value="<?php print $sessionId ?>"> Session Id <input type="text" size="36" maxlength="32"
</div> name="sessionid" value="<?php print $sessionId ?>">
<div class="krumo-element" > </div>
User Id <input type="text" size="16" maxlength="20" name="userid" value=""> <div class="krumo-element">
<img src="/Krumo/skins/schablon.com/empty.gif" > User Id <input type="text" size="16" maxlength="20" name="userid"
Group Id <input type="text" size="16" maxlength="20" name="groupid" value=""> value=""> <img src="/Krumo/skins/schablon.com/empty.gif"> Group Id
<input type="submit" value="assignUserToGroup" name="action"> <input type="text" size="16" maxlength="20" name="groupid" value="">
</div> <input type="submit" value="assignUserToGroup" name="action">
</ul> </div>
</div> </ul>
</form > </div>
</form>
<form method="post" action=""> <form method="post" action="">
<div class="krumo-root"> <div class="krumo-root">
<a class="krumo-name">newCase</a> <a class="krumo-name">newCase</a>
<ul class="krumo-node krumo-first"> <ul class="krumo-node krumo-first">
<div class="krumo-element" > <div class="krumo-element">
Session Id <input type="text" size="36" maxlength="32" name="sessionid" value="<?php print $sessionId ?>"> Session Id <input type="text" size="36" maxlength="32"
</div> name="sessionid" value="<?php print $sessionId ?>">
<div class="krumo-element" > </div>
Process Id <input type="text" size="16" maxlength="20" name="processid" value=""> <div class="krumo-element">
<img src="/Krumo/skins/schablon.com/empty.gif" > Process Id <input type="text" size="16" maxlength="20"
Variables <input type="text" size="16" maxlength="20" name="variables" value=""> name="processid" value=""> <img
<input type="submit" value="newCase" name="action"> src="/Krumo/skins/schablon.com/empty.gif"> Variables <input
</div> type="text" size="16" maxlength="20" name="variables" value=""> <input
</ul> type="submit" value="newCase" name="action">
</div> </div>
</form > </ul>
</div>
</form>
<?php <?php
if ( ! isset ( $_POST["action"] ) or $_POST["action"] == 'change endpoint' ) { if (! isset( $_POST["action"] ) or $_POST["action"] == 'change endpoint') {
die; die();
} }
$action = $_POST["action"]; $action = $_POST["action"];
//krumo ($_POST); //krumo ($_POST);
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
switch ( $action ) {
case 'login' :
$user = $_POST["user"];
$pass = md5($_POST["pass"]);
$wsdl = $endpoint;
//$client = new SoapClient( $endpoint );
$client = new SoapClient( null, array(
'location' => $endpoint,
'uri' => 'http://www.sugarcrm.com/sugarcrm',
'soap_version' => SOAP_1_1, //SOAP_1_2 - 1.2 not supported by sugar nusoap
'trace' => 1,
'exceptions' => 0,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5 ) );
$params = array('user_name'=>$user, 'password'=>$pass , 'version'=>'1' );
$result = $client->__SoapCall('login', array('user_auth'=>$params, 'application_name'=>'ProcessMaker'));
if ( $result->error->number == 0 ) {
$_SESSION['SESSION_ID'] = $result->id;
$session = $result->id;
$res = $client->__getFunctions();
krumo ( $res );
$params = array('session'=>$result->id);
$res = $client->__SoapCall('is_user_admin', array($session) );
if ( $res == 1 ) print "is Administrator user";
$first_name = 'juan'; ini_set( "soap.wsdl_cache_enabled", "0" ); // disabling WSDL cache
$last_name = 'perez';
$phone = '7235131';
$fax = '2454545';
$companyname = 'ABC company';
$prod_desc = 'descripcion del prod 1 ';
$user_guid = '';
$set_entry_params = array(
'session' => $session,
'module_name' => 'Leads',
'name_value_list'=>array(
array('name'=>'last_name', 'value'=> $last_name ),
array('name'=>'status', 'value'=> 'New' ),
array('name'=>'phone_work', 'value'=> $phone ),
array('name'=>'phone_fax', 'value'=> $fax ),
array('name'=>'account_name', 'value'=> $companyname ),
array('name'=>'lead_source', 'value'=> 'Web Site' ),
array('name'=>'description', 'value'=> $prod_desc ),
array('name'=>'email1', 'value'=> 'juan@colosa.com' ),
array('name'=>'assigned_user_id', 'value'=> $user_guid )));
$res = $client->__SoapCall('set_entry', $set_entry_params );
krumo ( $res );
//$query = "contacts.email1 != '' ";
//$orderby = 'email1 desc ';
$query = '';
$orderby = '';
$fields = array('id','first_name','last_name','account_name','account_id','email1','phone_work' );
$params = array($session, 'Leads', $query, $orderby, 0, $fields, 100, false );
$res = $client->__SoapCall('get_entry_list', $params );
krumo ($res);
}
break;
case 'processList' :
$wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl";
$endpoint = $wsdl;
$client = new SoapClient( $endpoint );
$params = array('sessionId'=> $sessionId );
$result = $client->__SoapCall('processesList', array($params));
krumo ( $result ); switch ($action) {
die; case 'login':
break; $user = $_POST["user"];
default : $pass = md5( $_POST["pass"] );
krumo ( $_POST );die; $wsdl = $endpoint;
} //$client = new SoapClient( $endpoint );
$client = new SoapClient( null, array ('location' => $endpoint,'uri' => 'http://www.sugarcrm.com/sugarcrm','soap_version' => SOAP_1_1, //SOAP_1_2 - 1.2 not supported by sugar nusoap
'trace' => 1,'exceptions' => 0,'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5
) );
$params = array ('user_name' => $user,'password' => $pass,'version' => '1'
);
$result = $client->__SoapCall( 'login', array ('user_auth' => $params,'application_name' => 'ProcessMaker'
) );
if ($result->error->number == 0) {
$_SESSION['SESSION_ID'] = $result->id;
$session = $result->id;
$res = $client->__getFunctions();
krumo( $res );
$params = array ('session' => $result->id
);
$res = $client->__SoapCall( 'is_user_admin', array ($session
) );
if ($res == 1)
print "is Administrator user";
$first_name = 'juan';
$last_name = 'perez';
$phone = '7235131';
$fax = '2454545';
$companyname = 'ABC company';
$prod_desc = 'descripcion del prod 1 ';
$user_guid = '';
$set_entry_params = array ('session' => $session,'module_name' => 'Leads',
'name_value_list' => array (array ('name' => 'last_name','value' => $last_name
),array ('name' => 'status','value' => 'New'
),array ('name' => 'phone_work','value' => $phone
),array ('name' => 'phone_fax','value' => $fax
),array ('name' => 'account_name','value' => $companyname
),array ('name' => 'lead_source','value' => 'Web Site'
),array ('name' => 'description','value' => $prod_desc
),array ('name' => 'email1','value' => 'juan@colosa.com'
),array ('name' => 'assigned_user_id','value' => $user_guid
)
)
);
$res = $client->__SoapCall( 'set_entry', $set_entry_params );
krumo( $res );
//$query = "contacts.email1 != '' ";
//$orderby = 'email1 desc ';
$query = '';
$orderby = '';
$fields = array ('id','first_name','last_name','account_name','account_id','email1','phone_work'
);
$params = array ($session,'Leads',$query,$orderby,0,$fields,100,false
);
$res = $client->__SoapCall( 'get_entry_list', $params );
krumo( $res );
}
break;
case 'processList':
$wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl";
$endpoint = $wsdl;
$client = new SoapClient( $endpoint );
$params = array ('sessionId' => $sessionId
);
$result = $client->__SoapCall( 'processesList', array ($params
) );
krumo( $result );
die();
break;
default:
krumo( $_POST );
die();
}
?> ?>
<div class="krumo-root"> <div class="krumo-root">
<ul class="krumo-node krumo-first"> <ul class="krumo-node krumo-first">
<li class="krumo-child"> <li class="krumo-child">
<div class="krumo-element" > <div class="krumo-element">
status_code status_code (<em class="krumo-type">Integer</em>) <strong
(<em class="krumo-type">Integer</em>) class="krumo-integer"><?php echo $result->error->number ?></strong>
<strong class="krumo-integer"><?php echo $result->error->number ?></strong> </div>
</div> <div class="krumo-element">
<div class="krumo-element" > message (<em class="krumo-type">string</em>) <strong
message class="krumo-integer"><?php echo $result->error->name ?></strong>
(<em class="krumo-type">string</em>) </div>
<strong class="krumo-integer"><?php echo $result->error->name ?></strong> <div class="krumo-element">
</div> timestamp (<em class="krumo-type">string</em>) <strong
<div class="krumo-element" > class="krumo-integer"><?php echo $result->error->description ?></strong>
timestamp </div>
(<em class="krumo-type">string</em>) </li>
<strong class="krumo-integer"><?php echo $result->error->description ?></strong>
</div>
</li>
</ul> </ul>
</div> </div>

View File

@@ -12,26 +12,24 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher();
$oTemplatePower = new TemplatePower(PATH_TPL . 'services/login_getStarted.html'); $oTemplatePower = new TemplatePower( PATH_TPL . 'services/login_getStarted.html' );
$oTemplatePower->prepare(); $oTemplatePower->prepare();
/* /*
$oTemplatePower->newBlock('users'); $oTemplatePower->newBlock('users');
$oTemplatePower->assign('USR_UID', $aUser['USR_UID']); $oTemplatePower->assign('USR_UID', $aUser['USR_UID']);
$oTemplatePower->assign('USR_FULLNAME', $aData['USR_FIRSTNAME'] . ' ' . $aData['USR_LASTNAME'] . ' (' . $aData['USR_USERNAME'] . ')'); $oTemplatePower->assign('USR_FULLNAME', $aData['USR_FIRSTNAME'] . ' ' . $aData['USR_LASTNAME'] . ' (' . $aData['USR_USERNAME'] . ')');
*/ */
$G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower); $G_PUBLISH->AddContent( 'template', '', '', '', $oTemplatePower );
G::RenderPage('publish','raw'); G::RenderPage( 'publish', 'raw' );
?>

View File

@@ -1,140 +1,143 @@
<?php <?php
$request = isset($_REQUEST['action'])? $_REQUEST['action'] : ""; $request = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : "";
G::LoadClass('serverConfiguration'); G::LoadClass( 'serverConfiguration' );
$oServerConf = &serverConf::getSingleton(); $oServerConf = &serverConf::getSingleton();
$oServerConf->setHeartbeatProperty('HB_BEAT_URL', 'http://heartbeat.processmaker.com/syspmLicenseSrv/en/green/services/beat', 'HEART_BEAT_CONF'); $oServerConf->setHeartbeatProperty( 'HB_BEAT_URL', 'http://heartbeat.processmaker.com/syspmLicenseSrv/en/green/services/beat', 'HEART_BEAT_CONF' );
switch ($request) { switch ($request) {
case 'processInformation': case 'processInformation':
try{ try {
$heartBeatUrl = $oServerConf->getHeartbeatProperty('HB_BEAT_URL','HEART_BEAT_CONF'); $heartBeatUrl = $oServerConf->getHeartbeatProperty( 'HB_BEAT_URL', 'HEART_BEAT_CONF' );
//Test connection //Test connection
if(!(validateConnectivity($heartBeatUrl))){ if (! (validateConnectivity( $heartBeatUrl ))) {
$oServerConf->setHeartbeatProperty('HB_NEXT_BEAT_DATE',strtotime ( "+1 day" ),'HEART_BEAT_CONF'); $oServerConf->setHeartbeatProperty( 'HB_NEXT_BEAT_DATE', strtotime( "+1 day" ), 'HEART_BEAT_CONF' );
throw new Exception("Heartbeat::No connection"); throw new Exception( "Heartbeat::No connection" );
} }
//Build Data to be sent //Build Data to be sent
$params=buildData(); $params = buildData();
//Send the information //Send the information
postHeartBeat($params); postHeartBeat( $params );
} catch (Exception $e) { } catch (Exception $e) {
G::pr($e->getMessage()); G::pr( $e->getMessage() );
} }
break; break;
} }
function validateConnectivity($url){ function validateConnectivity ($url)
ini_set('allow_url_fopen', 1); {
$sContent = file_get_conditional_contents($url); ini_set( 'allow_url_fopen', 1 );
$sw_connect=true; $sContent = file_get_conditional_contents( $url );
//if ($sContent == '' || $sContent === false || strpos ( $sContent, 'address location' ) === false ) { 4 $sw_connect = true;
if ($sContent == '' || $sContent === false ) { //if ($sContent == '' || $sContent === false || strpos ( $sContent, 'address location' ) === false ) { 4
$sw_connect=false; if ($sContent == '' || $sContent === false) {
} $sw_connect = false;
return $sw_connect; }
return $sw_connect;
} }
function file_get_conditional_contents($szURL){
function file_get_conditional_contents ($szURL)
{
$pCurl = curl_init (); $pCurl = curl_init();
curl_setopt ( $pCurl, CURLOPT_URL, $szURL ); curl_setopt( $pCurl, CURLOPT_URL, $szURL );
curl_setopt ( $pCurl, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $pCurl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $pCurl, CURLOPT_HEADER, true ); curl_setopt( $pCurl, CURLOPT_HEADER, true );
curl_setopt ( $pCurl, CURLOPT_FOLLOWLOCATION, false ); curl_setopt( $pCurl, CURLOPT_FOLLOWLOCATION, false );
curl_setopt ( $pCurl, CURLOPT_AUTOREFERER, true ); curl_setopt( $pCurl, CURLOPT_AUTOREFERER, true );
//To avoid SSL error //To avoid SSL error
curl_setopt ( $pCurl, CURLOPT_SSL_VERIFYHOST, 0 ); curl_setopt( $pCurl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt ( $pCurl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt( $pCurl, CURLOPT_SSL_VERIFYPEER, 0 );
//To avoid timeouts //To avoid timeouts
curl_setopt ( $pCurl, CURLOPT_CONNECTTIMEOUT, 10 ); curl_setopt( $pCurl, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt ( $pCurl, CURLOPT_TIMEOUT, 20 ); curl_setopt( $pCurl, CURLOPT_TIMEOUT, 20 );
curl_setopt ( $pCurl, CURLOPT_NOPROGRESS, false); curl_setopt( $pCurl, CURLOPT_NOPROGRESS, false );
curl_setopt ( $pCurl, CURLOPT_VERBOSE, true); curl_setopt( $pCurl, CURLOPT_VERBOSE, true );
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
curl_setopt($pCurl, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); curl_setopt( $pCurl, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
if ($sysConf['proxy_port'] != '') { if ($sysConf['proxy_port'] != '') {
curl_setopt($pCurl, CURLOPT_PROXYPORT, $sysConf['proxy_port']); curl_setopt( $pCurl, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
} }
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt($pCurl, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); curl_setopt( $pCurl, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($pCurl, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $pCurl, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$szContents = curl_exec($pCurl); $szContents = curl_exec( $pCurl );
$aInfo = curl_getinfo($pCurl); $aInfo = curl_getinfo( $pCurl );
$curl_session = curl_getinfo($pCurl, CURLINFO_HTTP_CODE); $curl_session = curl_getinfo( $pCurl, CURLINFO_HTTP_CODE );
$headers = curl_getinfo ( $pCurl ); $headers = curl_getinfo( $pCurl );
$header = substr ( $szContents, 0, $headers ['header_size'] ); $header = substr( $szContents, 0, $headers['header_size'] );
$content = substr ( $szContents, $headers ['header_size'] ); $content = substr( $szContents, $headers['header_size'] );
if ($aInfo['http_code'] === 200) {
if($aInfo['http_code'] === 200)
{
return $content; return $content;
} }
return false; return false;
} }
function buildData(){
require_once ("classes/model/Users.php");
G::LoadClass("serverConfiguration"); function buildData ()
G::LoadClass("system"); {
require_once ("classes/model/Users.php");
$oServerConf = &serverConf::getSingleton(); G::LoadClass( "serverConfiguration" );
G::LoadClass( "system" );
$oServerConf = &serverConf::getSingleton();
$os = ''; $os = '';
if (file_exists ( '/etc/redhat-release' )) { if (file_exists( '/etc/redhat-release' )) {
$fnewsize = filesize ( '/etc/redhat-release' ); $fnewsize = filesize( '/etc/redhat-release' );
$fp = fopen ( '/etc/redhat-release', 'r' ); $fp = fopen( '/etc/redhat-release', 'r' );
$os = trim ( fread ( $fp, $fnewsize ) ); $os = trim( fread( $fp, $fnewsize ) );
fclose ( $fp ); fclose( $fp );
} }
$os .= " (" . PHP_OS . ")"; $os .= " (" . PHP_OS . ")";
$params = array (); $params = array ();
$params ['ip'] = getenv ( 'SERVER_ADDR' ); $params['ip'] = getenv( 'SERVER_ADDR' );
$oServerConf->setHeartbeatProperty('HB_BEAT_INDEX',intval($oServerConf->getHeartbeatProperty('HB_BEAT_INDEX','HEART_BEAT_CONF'))+1,'HEART_BEAT_CONF'); $oServerConf->setHeartbeatProperty( 'HB_BEAT_INDEX', intval( $oServerConf->getHeartbeatProperty( 'HB_BEAT_INDEX', 'HEART_BEAT_CONF' ) ) + 1, 'HEART_BEAT_CONF' );
$params ['index'] = $oServerConf->getHeartbeatProperty('HB_BEAT_INDEX','HEART_BEAT_CONF');//$this->index; $params['index'] = $oServerConf->getHeartbeatProperty( 'HB_BEAT_INDEX', 'HEART_BEAT_CONF' ); //$this->index;
$params ['beatType'] = is_null($oServerConf->getHeartbeatProperty('HB_BEAT_TYPE','HEART_BEAT_CONF'))?"starting":$oServerConf->getHeartbeatProperty('HB_BEAT_TYPE','HEART_BEAT_CONF');//1;//$this->beatType; $params['beatType'] = is_null( $oServerConf->getHeartbeatProperty( 'HB_BEAT_TYPE', 'HEART_BEAT_CONF' ) ) ? "starting" : $oServerConf->getHeartbeatProperty( 'HB_BEAT_TYPE', 'HEART_BEAT_CONF' ); //1;//$this->beatType;
$params ['date'] = date ( 'Y-m-d H:i:s' ); $params['date'] = date( 'Y-m-d H:i:s' );
$params ['host'] = getenv ( 'SERVER_NAME' ); $params['host'] = getenv( 'SERVER_NAME' );
$params ['os'] = $os; $params['os'] = $os;
$params ['webserver'] = getenv ( 'SERVER_SOFTWARE' ); $params['webserver'] = getenv( 'SERVER_SOFTWARE' );
$params ['php'] = phpversion (); $params['php'] = phpversion();
$params ['pmVersion'] = System::getVersion(); $params['pmVersion'] = System::getVersion();
if(class_exists('pmLicenseManager')){ if (class_exists( 'pmLicenseManager' )) {
$params ['pmProduct'] = 'PMEE'; $params['pmProduct'] = 'PMEE';
}else{ } else {
$params ['pmProduct'] = 'PMCE'; $params['pmProduct'] = 'PMCE';
} }
$params ['logins'] = $oServerConf->logins; $params['logins'] = $oServerConf->logins;
$params ['workspaces'] = serialize ( $oServerConf->getWSList () ); $params['workspaces'] = serialize( $oServerConf->getWSList() );
$params ['plugins'] = serialize ( $oServerConf->getPluginsList () ); $params['plugins'] = serialize( $oServerConf->getPluginsList() );
$params ['dbVersion'] = $oServerConf->getDBVersion(); $params['dbVersion'] = $oServerConf->getDBVersion();
//$params ['errors'] = serialize( $oServerConf->errors ); //$params ['errors'] = serialize( $oServerConf->errors );
if($licInfo=$oServerConf->getProperty('LICENSE_INFO')){ if ($licInfo = $oServerConf->getProperty( 'LICENSE_INFO' )) {
$params ['license'] = serialize ( $licInfo ); $params['license'] = serialize( $licInfo );
} }
/////// ///////
$criteria = new Criteria("workflow"); $criteria = new Criteria( "workflow" );
$criteria->addSelectColumn("COUNT(USERS.USR_UID) AS USERS_NUMBER"); $criteria->addSelectColumn( "COUNT(USERS.USR_UID) AS USERS_NUMBER" );
$criteria->add(UsersPeer::USR_UID, null, Criteria::ISNOTNULL); $criteria->add( UsersPeer::USR_UID, null, Criteria::ISNOTNULL );
$rs = UsersPeer::doSelectRS($criteria); $rs = UsersPeer::doSelectRS( $criteria );
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next(); $rs->next();
$row = $rs->getRow(); $row = $rs->getRow();
@@ -143,14 +146,13 @@ function buildData(){
/////// ///////
$ee = null; $ee = null;
if (file_exists(PATH_PLUGINS . "enterprise" . PATH_SEP . "VERSION")) { if (file_exists( PATH_PLUGINS . "enterprise" . PATH_SEP . "VERSION" )) {
$ee = trim(file_get_contents(PATH_PLUGINS . "enterprise" . PATH_SEP . "VERSION")); $ee = trim( file_get_contents( PATH_PLUGINS . "enterprise" . PATH_SEP . "VERSION" ) );
} } else {
else { $pluginRegistry = &PMPluginRegistry::getSingleton();
$pluginRegistry = &PMPluginRegistry::getSingleton(); $details = $pluginRegistry->getPluginDetails( "enterprise.php" );
$details = $pluginRegistry->getPluginDetails("enterprise.php");
$ee = (!($details == null))? $details->iVersion : null; $ee = (! ($details == null)) ? $details->iVersion : null;
} }
$params["ee"] = $ee; $params["ee"] = $ee;
@@ -161,67 +163,68 @@ function buildData(){
$pluginRegistry = &PMPluginRegistry::getSingleton(); $pluginRegistry = &PMPluginRegistry::getSingleton();
$arrayAddon = array(); $arrayAddon = array ();
if (file_exists(PATH_DATA_SITE . "ee")) { if (file_exists( PATH_DATA_SITE . "ee" )) {
$arrayAddon = unserialize(trim(file_get_contents(PATH_DATA_SITE . "ee"))); $arrayAddon = unserialize( trim( file_get_contents( PATH_DATA_SITE . "ee" ) ) );
$arrayAddon["enterprise"] = array("sFilename" => "enterprise-1.tar"); $arrayAddon["enterprise"] = array ("sFilename" => "enterprise-1.tar"
);
} }
foreach ($arrayAddon as $addon) { foreach ($arrayAddon as $addon) {
$sFileName = substr($addon["sFilename"], 0, strpos($addon["sFilename"], "-")); $sFileName = substr( $addon["sFilename"], 0, strpos( $addon["sFilename"], "-" ) );
if (file_exists(PATH_PLUGINS . $sFileName . ".php")) { if (file_exists( PATH_PLUGINS . $sFileName . ".php" )) {
$addonDetails = $pluginRegistry->getPluginDetails($sFileName . ".php"); $addonDetails = $pluginRegistry->getPluginDetails( $sFileName . ".php" );
$enabled = 0; $enabled = 0;
if ($addonDetails) { if ($addonDetails) {
$enabled = ($addonDetails->enabled)? 1 : 0; $enabled = ($addonDetails->enabled) ? 1 : 0;
}
if ($enabled == 1) {
$addonEnabledNumber = $addonEnabledNumber + 1;
}
$addonNumber = $addonNumber + 1;
} }
if ($enabled == 1) {
$addonEnabledNumber = $addonEnabledNumber + 1;
}
$addonNumber = $addonNumber + 1;
}
} }
$params["addonNumber"] = $addonNumber; $params["addonNumber"] = $addonNumber;
$params["addonEnabledNumber"] = $addonEnabledNumber; $params["addonEnabledNumber"] = $addonEnabledNumber;
/////// ///////
$licenseID = null; $licenseID = null;
$licenseType = null; $licenseType = null;
$licenseDomainWorkspace = null; $licenseDomainWorkspace = null;
$licenseNumber = 0; $licenseNumber = 0;
if (file_exists(PATH_PLUGINS . "enterprise" . PATH_SEP . "class.pmLicenseManager.php") && class_exists('enterprisePlugin')) { if (file_exists( PATH_PLUGINS . "enterprise" . PATH_SEP . "class.pmLicenseManager.php" ) && class_exists( 'enterprisePlugin' )) {
$licenseManager = &pmLicenseManager::getSingleton(); $licenseManager = &pmLicenseManager::getSingleton();
preg_match("/^license_(.*).dat$/", $licenseManager->file, $matches); preg_match( "/^license_(.*).dat$/", $licenseManager->file, $matches );
$licenseID = $matches[1]; $licenseID = $matches[1];
$licenseType = $licenseManager->type; $licenseType = $licenseManager->type;
$licenseDomainWorkspace = $licenseManager->info["DOMAIN_WORKSPACE"]; $licenseDomainWorkspace = $licenseManager->info["DOMAIN_WORKSPACE"];
/////// ///////
$criteria = new Criteria("workflow"); $criteria = new Criteria( "workflow" );
$criteria->addSelectColumn("COUNT(LICENSE_MANAGER.LICENSE_UID) AS LICENSE_NUMBER"); $criteria->addSelectColumn( "COUNT(LICENSE_MANAGER.LICENSE_UID) AS LICENSE_NUMBER" );
$criteria->add(LicenseManagerPeer::LICENSE_UID, null, Criteria::ISNOTNULL); $criteria->add( LicenseManagerPeer::LICENSE_UID, null, Criteria::ISNOTNULL );
$rs = LicenseManagerPeer::doSelectRS($criteria); $rs = LicenseManagerPeer::doSelectRS( $criteria );
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next(); $rs->next();
$row = $rs->getRow(); $row = $rs->getRow();
/////// ///////
$licenseNumber = ($row["LICENSE_NUMBER"] > 0)? $row["LICENSE_NUMBER"] : count(glob(PATH_DATA_SITE . "licenses" . PATH_SEP . "*.dat")); $licenseNumber = ($row["LICENSE_NUMBER"] > 0) ? $row["LICENSE_NUMBER"] : count( glob( PATH_DATA_SITE . "licenses" . PATH_SEP . "*.dat" ) );
} }
$params["licenseID"] = $licenseID; $params["licenseID"] = $licenseID;
$params["licenseType"] = $licenseType; $params["licenseType"] = $licenseType;
$params["licenseDomainWorkspace"] = $licenseDomainWorkspace; $params["licenseDomainWorkspace"] = $licenseDomainWorkspace;
$params["licenseNumber"] = $licenseNumber; $params["licenseNumber"] = $licenseNumber;
@@ -229,66 +232,71 @@ function buildData(){
/////// ///////
return $params; return $params;
} }
function postHeartBeat($params) {
if(is_array($params)){
//No matter what happens with the result let's set the nextBeat to 2 hours from now
G::LoadClass ( 'serverConfiguration' );
$oServerConf = & serverConf::getSingleton ();
$oServerConf->setHeartbeatProperty('HB_NEXT_BEAT_DATE',strtotime ( "+2 hour" ),'HEART_BEAT_CONF');
$nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE','HEART_BEAT_CONF');
$heartBeatUrl = $oServerConf->getHeartbeatProperty('HB_BEAT_URL','HEART_BEAT_CONF'); function postHeartBeat ($params)
{
if (is_array( $params )) {
//No matter what happens with the result let's set the nextBeat to 2 hours from now
G::LoadClass( 'serverConfiguration' );
$oServerConf = & serverConf::getSingleton();
$oServerConf->setHeartbeatProperty( 'HB_NEXT_BEAT_DATE', strtotime( "+2 hour" ), 'HEART_BEAT_CONF' );
$nextBeatDate = $oServerConf->getHeartbeatProperty( 'HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF' );
$ch = curl_init (); $heartBeatUrl = $oServerConf->getHeartbeatProperty( 'HB_BEAT_URL', 'HEART_BEAT_CONF' );
curl_setopt ( $ch, CURLOPT_URL, $heartBeatUrl );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_HEADER, true );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, false );
curl_setopt ( $ch, CURLOPT_AUTOREFERER, true );
//To avoid SSL error
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt ( $ch, CURLOPT_POST, 1 ); $ch = curl_init();
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params ); curl_setopt( $ch, CURLOPT_URL, $heartBeatUrl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HEADER, true );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, false );
curl_setopt( $ch, CURLOPT_AUTOREFERER, true );
//To avoid SSL error
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
//To avoid timeouts curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 10 ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
curl_setopt ( $ch, CURLOPT_TIMEOUT, 20 );
//To avoid timeouts
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt( $ch, CURLOPT_TIMEOUT, 20 );
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
curl_setopt( $ch, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
if ($sysConf['proxy_port'] != '') {
curl_setopt( $ch, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
}
if ($sysConf['proxy_user'] != '') {
curl_setopt( $ch, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
}
curl_setopt( $ch, CURLOPT_HTTPHEADER, array ('Expect:'
) );
}
$response = curl_exec( $ch );
$curl_session = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
$headers = curl_getinfo( $ch );
$header = substr( $response, 0, $headers['header_size'] );
$content = substr( $response, $headers['header_size'] );
curl_close( $ch );
if ($headers['http_code'] == 200) {
$oServerConf->setHeartbeatProperty( 'HB_BEAT_TYPE', 'beat', 'HEART_BEAT_CONF' );
$oServerConf->resetLogins();
$oServerConf->setHeartbeatProperty( 'HB_NEXT_BEAT_DATE', strtotime( "+7 day" ), 'HEART_BEAT_CONF' );
//Reset Errors
} else {
//Catch the error
$oServerConf->setHeartbeatProperty( 'HB_NEXT_BEAT_DATE', strtotime( "+1 day" ), 'HEART_BEAT_CONF' );
}
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
curl_setopt($ch, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
if ($sysConf['proxy_port'] != '') {
curl_setopt($ch, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
}
if ($sysConf['proxy_user'] != '') {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
} }
$response = curl_exec ( $ch );
$curl_session = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$headers = curl_getinfo ( $ch );
$header = substr ( $response, 0, $headers ['header_size'] );
$content = substr ( $response, $headers ['header_size'] );
curl_close ( $ch );
if ($headers ['http_code'] == 200) {
$oServerConf->setHeartbeatProperty('HB_BEAT_TYPE','beat','HEART_BEAT_CONF');
$oServerConf->resetLogins ();
$oServerConf->setHeartbeatProperty('HB_NEXT_BEAT_DATE',strtotime ( "+7 day" ),'HEART_BEAT_CONF');
//Reset Errors
} else {
//Catch the error
$oServerConf->setHeartbeatProperty('HB_NEXT_BEAT_DATE',strtotime ( "+1 day" ),'HEART_BEAT_CONF');
}
}
/* /*
$ch = curl_init (); $ch = curl_init ();
@@ -329,4 +337,5 @@ function buildData(){
$this->saveSingleton (); $this->saveSingleton ();
*/ */
} }

View File

@@ -1,449 +1,466 @@
<?php <?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache ini_set( "soap.wsdl_cache_enabled", "0" ); // disabling WSDL cache
$wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl";
require_once ( "classes/model/Application.php" ); $wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl";
require_once ( "classes/model/AppDelegation.php" );
require_once ( "classes/model/AppThread.php" );
require_once ( "classes/model/Dynaform.php" );
require_once ( "classes/model/Groupwf.php" );
require_once ( "classes/model/InputDocument.php" );
require_once ( "classes/model/Language.php" );
require_once ( "classes/model/OutputDocument.php" );
require_once ( "classes/model/Process.php" );
require_once ( "classes/model/ReportTable.php");
require_once ( "classes/model/ReportVar.php");
require_once ( "classes/model/Step.php" );
require_once ( "classes/model/StepTrigger.php" );
require_once ( "classes/model/Task.php" );
require_once ( "classes/model/TaskUser.php" );
require_once ( "classes/model/Triggers.php" );
require_once ( "classes/model/Users.php" );
require_once ( "classes/model/Session.php" );
require_once ( "classes/model/Content.php" );
function login( $params ) { require_once ("classes/model/Application.php");
G::LoadClass('wsBase'); require_once ("classes/model/AppDelegation.php");
$ws = new wsBase (); require_once ("classes/model/AppThread.php");
require_once ("classes/model/Dynaform.php");
require_once ("classes/model/Groupwf.php");
require_once ("classes/model/InputDocument.php");
require_once ("classes/model/Language.php");
require_once ("classes/model/OutputDocument.php");
require_once ("classes/model/Process.php");
require_once ("classes/model/ReportTable.php");
require_once ("classes/model/ReportVar.php");
require_once ("classes/model/Step.php");
require_once ("classes/model/StepTrigger.php");
require_once ("classes/model/Task.php");
require_once ("classes/model/TaskUser.php");
require_once ("classes/model/Triggers.php");
require_once ("classes/model/Users.php");
require_once ("classes/model/Session.php");
require_once ("classes/model/Content.php");
function login ($params)
{
G::LoadClass( 'wsBase' );
$ws = new wsBase();
$res = $ws->login( $params->userid, $params->password ); $res = $ws->login( $params->userid, $params->password );
return $res->getPayloadArray ( ); return $res->getPayloadArray();
} }
function ProcessList( $params ) { function ProcessList ($params)
$x = ifPermission( $params->sessionId, 'PM_FACTORY'); {
$x = ifPermission( $params->sessionId, 'PM_FACTORY' );
//if you are not an admin user, then this function will return only //if you are not an admin user, then this function will return only
//your valid process //your valid process
if ( $x==0 ) { if ($x == 0) {
G::LoadClass('sessions'); G::LoadClass( 'sessions' );
$oSessions = new Sessions(); $oSessions = new Sessions();
$session = $oSessions->getSessionUser($params->sessionId); $session = $oSessions->getSessionUser( $params->sessionId );
$userId = $session['USR_UID']; $userId = $session['USR_UID'];
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->processListVerified( $userId ); $res = $ws->processListVerified( $userId );
return $res; return $res;
} }
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->processList( ); $res = $ws->processList();
return array("processes" => $res ); return array ("processes" => $res
} );
}
function RoleList( $params ) { function RoleList ($params)
$x = ifPermission( $params->sessionId, 'PM_USERS'); {
if($x==0) $x = ifPermission( $params->sessionId, 'PM_USERS' );
{ if ($x == 0) {
$result[] = array ( 'guid' => 24, 'name' => 'You do not have privileges' ); $result[] = array ('guid' => 24,'name' => 'You do not have privileges'
return $result; );
} return $result;
}
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->roleList( ); $res = $ws->roleList();
return array("roles" => $res ); return array ("roles" => $res
} );
}
function GroupList( $params ) { function GroupList ($params)
$x = ifPermission( $params->sessionId, 'PM_USERS'); {
if($x==0) $x = ifPermission( $params->sessionId, 'PM_USERS' );
{ if ($x == 0) {
$result[] = array ( 'guid' => 24, 'name' => 'You do not have privileges' ); $result[] = array ('guid' => 24,'name' => 'You do not have privileges'
return $result; );
} return $result;
}
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->groupList( ); $res = $ws->groupList();
return array("groups" => $res ); return array ("groups" => $res
} );
}
function CaseList( $params ) { function CaseList ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ if ($x == 0) {
G::LoadClass('wsResponse'); G::LoadClass( 'wsResponse' );
return new wsResponse (9, 'Session expired'); return new wsResponse( 9, 'Session expired' );
} }
G::LoadClass('sessions'); G::LoadClass( 'sessions' );
$oSessions = new Sessions(); $oSessions = new Sessions();
$session = $oSessions->getSessionUser($params->sessionId); $session = $oSessions->getSessionUser( $params->sessionId );
$userId = $session['USR_UID']; $userId = $session['USR_UID'];
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->caseList( $userId ); $res = $ws->caseList( $userId );
return array("cases" => $res ); return array ("cases" => $res
} );
}
function UserList( $params ) { function UserList ($params)
$x = ifPermission( $params->sessionId, 'PM_USERS'); {
if($x==0) $x = ifPermission( $params->sessionId, 'PM_USERS' );
{ if ($x == 0) {
$result[] = array ( 'guid' => 24, 'name' => 'You do not have privileges' ); $result[] = array ('guid' => 24,'name' => 'You do not have privileges'
return $result; );
} return $result;
}
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->userList( ); $res = $ws->userList();
return array("users" => $res ); return array ("users" => $res
} );
}
function SendMessage( $params ) { function SendMessage ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
} return $result;
G::LoadClass('wsBase'); }
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$res = $ws->sendMessage( $params->caseId, $ws = new wsBase();
$params->from, $res = $ws->sendMessage( $params->caseId, $params->from, $params->to, $params->cc, $params->bcc, $params->subject, $params->template );
$params->to, return $res->getPayloadArray();
$params->cc, }
$params->bcc,
$params->subject,
$params->template);
return $res->getPayloadArray ( ) ;
}
function getCaseInfo( $params ) { function getCaseInfo ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
} return $result;
G::LoadClass('wsBase'); }
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$ws = new wsBase();
$res = $ws->getCaseInfo( $params->caseId, $params->delIndex ); $res = $ws->getCaseInfo( $params->caseId, $params->delIndex );
return $res; return $res;
} }
function SendVariables( $params ) { function SendVariables ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
return $result;
} }
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$variables = $params->variables; $variables = $params->variables;
if ( is_object ($variables) ) { if (is_object( $variables )) {
$Fields[ $variables->name ]= $variables->value ; $Fields[$variables->name] = $variables->value;
}
if ( is_array ( $variables) ) {
foreach ( $variables as $key=>$val ){
$name = $val->name;
$value = $val->value;
eval('$Fields[ ' . $val->name . ' ]= $val->value ;');
}
}
$params->variables = $Fields;
$res = $ws->sendVariables($params->caseId, $params->variables);
return $res->getPayloadArray ( ) ;
}
function GetVariables( $params ) {
ifSessionExpiredBreakThis($params->sessionId);
$x = ifPermission( $params->sessionId, 'PM_CASES');
if($x==0)
{ G::LoadClass('wsResponse');
$result = new wsResponse (24, "You do not have privileges");
return $result;
} }
G::LoadClass('wsBase'); if (is_array( $variables )) {
$ws = new wsBase (); foreach ($variables as $key => $val) {
$name = $val->name;
$res = $ws->getVariables($params->caseId, $params->variables); $value = $val->value;
return array("variables" => $res ); eval( '$Fields[ ' . $val->name . ' ]= $val->value ;' );
}
function DerivateCase( $params ) {
ifSessionExpiredBreakThis($params->sessionId);
$x = ifPermission( $params->sessionId, 'PM_CASES');
if($x==0)
{ G::LoadClass('wsResponse');
$result = new wsResponse (24, "You do not have privileges");
return $result;
} }
}
$params->variables = $Fields;
$res = $ws->sendVariables( $params->caseId, $params->variables );
return $res->getPayloadArray();
}
function GetVariables ($params)
{
ifSessionExpiredBreakThis( $params->sessionId );
$x = ifPermission( $params->sessionId, 'PM_CASES' );
if ($x == 0) {
G::LoadClass( 'wsResponse' );
$result = new wsResponse( 24, "You do not have privileges" );
return $result;
}
G::LoadClass( 'wsBase' );
$ws = new wsBase();
$res = $ws->getVariables( $params->caseId, $params->variables );
return array ("variables" => $res
);
}
function DerivateCase ($params)
{
ifSessionExpiredBreakThis( $params->sessionId );
$x = ifPermission( $params->sessionId, 'PM_CASES' );
if ($x == 0) {
G::LoadClass( 'wsResponse' );
$result = new wsResponse( 24, "You do not have privileges" );
return $result;
}
$oSession = new Sessions(); $oSession = new Sessions();
$user = $oSession->getSessionUser($params->sessionId); $user = $oSession->getSessionUser( $params->sessionId );
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->derivateCase($user['USR_UID'], $params->caseId, $params->delIndex); $res = $ws->derivateCase( $user['USR_UID'], $params->caseId, $params->delIndex );
return $res; return $res;
//return $res->getPayloadArray ( ); //return $res->getPayloadArray ( );
} }
function executeTrigger ( $params ) { function executeTrigger ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
} return $result;
}
$oSession = new Sessions(); $oSession = new Sessions();
$user = $oSession->getSessionUser($params->sessionId); $user = $oSession->getSessionUser( $params->sessionId );
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$delIndex = ( isset ( $params->delIndex ) ) ? $params->delIndex : 1 ; $delIndex = (isset( $params->delIndex )) ? $params->delIndex : 1;
$res = $ws->executeTrigger( $user['USR_UID'], $params->caseId, $params->triggerIndex, $delIndex); $res = $ws->executeTrigger( $user['USR_UID'], $params->caseId, $params->triggerIndex, $delIndex );
return $res->getPayloadArray ( ); return $res->getPayloadArray();
} }
function NewCaseImpersonate( $params ) { function NewCaseImpersonate ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
} return $result;
G::LoadClass('wsBase'); }
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$ws = new wsBase();
$variables = $params->variables; $variables = $params->variables;
foreach ( $variables as $key=>$val ){ foreach ($variables as $key => $val) {
$name = $val->name; $name = $val->name;
$value = $val->value; $value = $val->value;
eval('$Fields[ ' . $val->name . ' ]= $val->value ;'); eval( '$Fields[ ' . $val->name . ' ]= $val->value ;' );
} }
$params->variables = $Fields; $params->variables = $Fields;
$res = $ws->newCaseImpersonate($params->processId, $params->userId, $params->variables); $res = $ws->newCaseImpersonate( $params->processId, $params->userId, $params->variables );
return $res->getPayloadArray ( ) ; return $res->getPayloadArray();
} }
function NewCase( $params ) { function NewCase ($params)
G::LoadClass('wsBase'); {
G::LoadClass('sessions'); G::LoadClass( 'wsBase' );
ifSessionExpiredBreakThis($params->sessionId); G::LoadClass( 'sessions' );
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ if ($x == 0) {
G::LoadClass('wsResponse'); G::LoadClass( 'wsResponse' );
$result = new wsResponse (24, "You do not have privileges"); $result = new wsResponse( 24, "You do not have privileges" );
return $result; return $result;
} }
$oSessions = new Sessions(); $oSessions = new Sessions();
$session = $oSessions->getSessionUser($params->sessionId); $session = $oSessions->getSessionUser( $params->sessionId );
$userId = $session['USR_UID']; $userId = $session['USR_UID'];
$variables = $params->variables; $variables = $params->variables;
if (!isset($params->variables) ) { if (! isset( $params->variables )) {
$variables = array(); $variables = array ();
$Fields = array(); $Fields = array ();
} } else {
else { if (is_object( $variables )) {
if ( is_object ($variables) ) { /*foreach ( $variables as $key=>$val ) {
/*foreach ( $variables as $key=>$val ) { $name = $val->name;
$name = $val->name; $value = $val->value;
$value = $val->value; $Fields[ $val->name ]= $val->value ;
$Fields[ $val->name ]= $val->value ; }*/
}*/ $Fields[$variables->name] = $variables->value;
$Fields[ $variables->name ]= $variables->value ; }
}
if (is_array( $variables )) {
if ( is_array ( $variables) ) { foreach ($variables as $key => $val) {
foreach ( $variables as $key=>$val ) { $name = $val->name;
$name = $val->name; $value = $val->value;
$value = $val->value; if (! is_object( $val->value )) {
if (!is_object($val->value)) eval( '$Fields[ ' . $val->name . ' ]= $val->value ;' );
{ } else {
eval('$Fields[ ' . $val->name . ' ]= $val->value ;'); if (is_array( $val->value->item )) {
} $i = 1;
else foreach ($val->value->item as $key1 => $val1) {
{ if (isset( $val1->value )) {
if (is_array($val->value->item)) { if (is_array( $val1->value->item )) {
$i = 1; foreach ($val1->value->item as $key2 => $val2) {
foreach ($val->value->item as $key1 => $val1) { $Fields[$val->name][$i][$val2->key] = $val2->value;
if (isset($val1->value)) { }
if (is_array($val1->value->item)) { }
foreach ($val1->value->item as $key2 => $val2) { }
$Fields[$val->name][$i][$val2->key] = $val2->value; $i ++;
} }
} }
} }
$i++; }
}
}
}
} }
}
} }
$params->variables = $Fields; $params->variables = $Fields;
//$result = new wsResponse (900, print_r($params->variables,1)); //$result = new wsResponse (900, print_r($params->variables,1));
//return $result; //return $result;
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->newCase($params->processId, $userId, $params->taskId, $params->variables); $res = $ws->newCase( $params->processId, $userId, $params->taskId, $params->variables );
return $res; return $res;
} }
function AssignUserToGroup( $params ) { function AssignUserToGroup ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_USERS'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_USERS' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
} return $result;
G::LoadClass('sessions'); }
$sessions = new Sessions; G::LoadClass( 'sessions' );
$user=$sessions->getSessionUser($params->sessionId); $sessions = new Sessions();
if(!is_array($user)) $user = $sessions->getSessionUser( $params->sessionId );
{ G::LoadClass('wsResponse'); if (! is_array( $user )) {
return new wsResponse (3, 'User not registered in the system'); G::LoadClass( 'wsResponse' );
} return new wsResponse( 3, 'User not registered in the system' );
}
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->assignUserToGroup( $params->userId, $params->groupId); $res = $ws->assignUserToGroup( $params->userId, $params->groupId );
return $res->getPayloadArray ( ) ; return $res->getPayloadArray();
} }
function CreateUser( $params ) { function CreateUser ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_USERS'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_USERS' );
{ G::LoadClass('wsResponse'); if ($x == 0) {
$result = new wsResponse (24, "You do not have privileges"); G::LoadClass( 'wsResponse' );
return $result; $result = new wsResponse( 24, "You do not have privileges" );
} return $result;
G::LoadClass('wsBase'); }
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$res = $ws->createUser( $params->userId, $params->firstname, $params->lastname, $params->email, $params->role, $params->password); $ws = new wsBase();
return $res->getPayloadArray ( ) ; $res = $ws->createUser( $params->userId, $params->firstname, $params->lastname, $params->email, $params->role, $params->password );
} return $res->getPayloadArray();
}
function TaskList( $params ) { function TaskList ($params)
$x = ifPermission( $params->sessionId, 'PM_CASES'); {
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ if ($x == 0) {
$result[] = array ( 'guid' => 24, 'name' => 'You do not have privileges' ); $result[] = array ('guid' => 24,'name' => 'You do not have privileges'
return $result; );
} return $result;
G::LoadClass('wsBase'); }
G::LoadClass('sessions'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); G::LoadClass( 'sessions' );
$ws = new wsBase();
$oSessions = new Sessions(); $oSessions = new Sessions();
$session = $oSessions->getSessionUser($params->sessionId); $session = $oSessions->getSessionUser( $params->sessionId );
$userId = $session['USR_UID']; $userId = $session['USR_UID'];
$res = $ws->taskList( $userId ); $res = $ws->taskList( $userId );
return array("tasks" => $res ); return array ("tasks" => $res
} );
}
function TaskCase( $params ) { function TaskCase ($params)
ifSessionExpiredBreakThis($params->sessionId); {
$x = ifPermission( $params->sessionId, 'PM_CASES'); ifSessionExpiredBreakThis( $params->sessionId );
if($x==0) $x = ifPermission( $params->sessionId, 'PM_CASES' );
{ if ($x == 0) {
$result[] = array ( 'guid' => 24, 'name' => 'You do not have privileges' ); $result[] = array ('guid' => 24,'name' => 'You do not have privileges'
return $result; );
} return $result;
G::LoadClass('wsBase'); }
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$ws = new wsBase();
$res = $ws->taskCase( $params->caseId ); $res = $ws->taskCase( $params->caseId );
return array("taskCases" => $res ); return array ("taskCases" => $res
} );
}
function ReassignCase( $params ) { function ReassignCase ($params)
ifSessionExpiredBreakThis($params->sessionId); {
ifSessionExpiredBreakThis( $params->sessionId );
//G::LoadClass('wsResponse'); //G::LoadClass('wsResponse');
//return new wsResponse (1, print_r($params,1)); //return new wsResponse (1, print_r($params,1));
G::LoadClass('wsBase'); G::LoadClass( 'wsBase' );
$ws = new wsBase (); $ws = new wsBase();
$res = $ws->reassignCase($params->sessionId, $params->caseId, $params->delIndex, $params->userIdSource, $params->userIdTarget ); $res = $ws->reassignCase( $params->sessionId, $params->caseId, $params->delIndex, $params->userIdSource, $params->userIdTarget );
return $res ; return $res;
} }
function ifSessionExpiredBreakThis($sessionId){ #added By Erik AO <erik@colosa.com> in datetime 26.06.2008 10:00:00 function ifSessionExpiredBreakThis ($sessionId)
G::LoadClass('sessions'); { #added By Erik AO <erik@colosa.com> in datetime 26.06.2008 10:00:00
$oSessions = new Sessions(); G::LoadClass( 'sessions' );
$session = $oSessions->verifySession($sessionId); $oSessions = new Sessions();
if($session == '') { $session = $oSessions->verifySession( $sessionId );
G::LoadClass('wsResponse'); if ($session == '') {
return new wsResponse (9, 'Session expired'); G::LoadClass( 'wsResponse' );
return new wsResponse( 9, 'Session expired' );
}
}
function ifPermission ($sessionId, $permission)
{
global $RBAC;
$RBAC->initRBAC();
G::LoadClass( 'sessions' );
$oSession = new Sessions();
$user = $oSession->getSessionUser( $sessionId );
$oRBAC = RBAC::getSingleton();
$oRBAC->loadUserRolePermission( $oRBAC->sSystem, $user['USR_UID'] );
$aPermissions = $oRBAC->aUserInfo[$oRBAC->sSystem]['PERMISSIONS'];
$sw = 0;
foreach ($aPermissions as $aPermission) {
if ($aPermission['PER_CODE'] == $permission) {
$sw = 1;
} }
} }
return $sw;
function ifPermission( $sessionId, $permission ){ }
global $RBAC;
$RBAC->initRBAC();
G::LoadClass('sessions');
$oSession = new Sessions();
$user = $oSession->getSessionUser($sessionId);
$oRBAC = RBAC::getSingleton();
$oRBAC->loadUserRolePermission($oRBAC->sSystem, $user['USR_UID']);
$aPermissions = $oRBAC->aUserInfo[$oRBAC->sSystem]['PERMISSIONS'];
$sw=0;
foreach ($aPermissions as $aPermission) {
if ($aPermission['PER_CODE'] == $permission)
{
$sw=1;
}
}
return $sw;
}
$server = new SoapServer( $wsdl ); $server = new SoapServer( $wsdl );
$server->addFunction("Login"); $server->addFunction( "Login" );
$server->addFunction("ProcessList"); $server->addFunction( "ProcessList" );
$server->addFunction("CaseList"); $server->addFunction( "CaseList" );
$server->addFunction("RoleList"); $server->addFunction( "RoleList" );
$server->addFunction("GroupList"); $server->addFunction( "GroupList" );
$server->addFunction("UserList"); $server->addFunction( "UserList" );
$server->addFunction("SendMessage"); $server->addFunction( "SendMessage" );
$server->addFunction("SendVariables"); $server->addFunction( "SendVariables" );
$server->addFunction("GetVariables"); $server->addFunction( "GetVariables" );
$server->addFunction("DerivateCase"); $server->addFunction( "DerivateCase" );
$server->addFunction("executeTrigger"); $server->addFunction( "executeTrigger" );
$server->addFunction("NewCaseImpersonate"); $server->addFunction( "NewCaseImpersonate" );
$server->addFunction("NewCase"); $server->addFunction( "NewCase" );
$server->addFunction("AssignUserToGroup"); $server->addFunction( "AssignUserToGroup" );
$server->addFunction("CreateUser"); $server->addFunction( "CreateUser" );
$server->addFunction("getCaseInfo"); $server->addFunction( "getCaseInfo" );
$server->addFunction("TaskList"); $server->addFunction( "TaskList" );
$server->addFunction("TaskCase"); $server->addFunction( "TaskCase" );
$server->addFunction("ReassignCase"); $server->addFunction( "ReassignCase" );
$server->handle(); $server->handle();

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
<?php <?php
$G_PUBLISH = new Publisher(); $G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'services/serviceMessage', '', array() , ''); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'services/serviceMessage', '', array (), '' );
G::RenderPage( 'publish' ); G::RenderPage( 'publish' );
?>

View File

@@ -12,15 +12,14 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
/** /**
@@ -31,137 +30,128 @@
* if the post attached file has error code 0 continue in other case nothing to do. * if the post attached file has error code 0 continue in other case nothing to do.
*/ */
if (isset($_FILES) && $_FILES["ATTACH_FILE"]["error"] == 0) { if (isset( $_FILES ) && $_FILES["ATTACH_FILE"]["error"] == 0) {
try{ try {
G::LoadClass("case"); G::LoadClass( "case" );
$folderId = ""; $folderId = "";
$fileTags = ""; $fileTags = "";
if (isset($_POST["DOC_UID"]) && $_POST["DOC_UID"] != -1) { if (isset( $_POST["DOC_UID"] ) && $_POST["DOC_UID"] != - 1) {
//The document is of an Specific Input Document. Get path and Tag information //The document is of an Specific Input Document. Get path and Tag information
require_once ("classes/model/AppFolder.php"); require_once ("classes/model/AppFolder.php");
require_once ("classes/model/InputDocument.php"); require_once ("classes/model/InputDocument.php");
$oInputDocument = new InputDocument(); $oInputDocument = new InputDocument();
$aID = $oInputDocument->load($_POST["DOC_UID"]); $aID = $oInputDocument->load( $_POST["DOC_UID"] );
//Get the Custom Folder ID (create if necessary) //Get the Custom Folder ID (create if necessary)
$oFolder = new AppFolder(); $oFolder = new AppFolder();
$folderId = $oFolder->createFromPath($aID["INP_DOC_DESTINATION_PATH"], $_POST["APPLICATION"]); $folderId = $oFolder->createFromPath( $aID["INP_DOC_DESTINATION_PATH"], $_POST["APPLICATION"] );
//Tags //Tags
$fileTags = $oFolder->parseTags($aID["INP_DOC_TAGS"], $_POST["APPLICATION"]); $fileTags = $oFolder->parseTags( $aID["INP_DOC_TAGS"], $_POST["APPLICATION"] );
} }
$oAppDocument = new AppDocument(); $oAppDocument = new AppDocument();
if (isset($_POST["APP_DOC_UID"]) && trim($_POST["APP_DOC_UID"]) != "") { if (isset( $_POST["APP_DOC_UID"] ) && trim( $_POST["APP_DOC_UID"] ) != "") {
//Update //Update
echo "[update]"; echo "[update]";
$aFields["APP_DOC_UID"] = $_POST["APP_DOC_UID"]; $aFields["APP_DOC_UID"] = $_POST["APP_DOC_UID"];
$aFields["DOC_VERSION"] = $_POST["DOC_VERSION"]; $aFields["DOC_VERSION"] = $_POST["DOC_VERSION"];
$aFields["APP_DOC_FILENAME"] = $_FILES["ATTACH_FILE"]["name"]; $aFields["APP_DOC_FILENAME"] = $_FILES["ATTACH_FILE"]["name"];
if (isset($_POST["APPLICATION"])) { if (isset( $_POST["APPLICATION"] )) {
$aFields["APP_UID"] = $_POST["APPLICATION"]; $aFields["APP_UID"] = $_POST["APPLICATION"];
} }
if (isset($_POST["INDEX"])) { if (isset( $_POST["INDEX"] )) {
$aFields["DEL_INDEX"] = $_POST["INDEX"]; $aFields["DEL_INDEX"] = $_POST["INDEX"];
} }
if (isset($_POST["USR_UID"])) { if (isset( $_POST["USR_UID"] )) {
$aFields["USR_UID"] = $_POST["USR_UID"]; $aFields["USR_UID"] = $_POST["USR_UID"];
} }
if (isset($_POST["DOC_UID"])) { if (isset( $_POST["DOC_UID"] )) {
$aFields["DOC_UID"] = $_POST["DOC_UID"]; $aFields["DOC_UID"] = $_POST["DOC_UID"];
} }
if (isset($_POST["APP_DOC_TYPE"])) { if (isset( $_POST["APP_DOC_TYPE"] )) {
$aFields["APP_DOC_TYPE"] = $_POST["APP_DOC_TYPE"]; $aFields["APP_DOC_TYPE"] = $_POST["APP_DOC_TYPE"];
} }
$aFields["APP_DOC_CREATE_DATE"] = date("Y-m-d H:i:s"); $aFields["APP_DOC_CREATE_DATE"] = date( "Y-m-d H:i:s" );
$aFields["APP_DOC_COMMENT"] = (isset($_POST["COMMENT"]))? $_POST["COMMENT"] : ""; $aFields["APP_DOC_COMMENT"] = (isset( $_POST["COMMENT"] )) ? $_POST["COMMENT"] : "";
$aFields["APP_DOC_TITLE"] = (isset($_POST["TITLE"]))? $_POST["TITLE"] : ""; $aFields["APP_DOC_TITLE"] = (isset( $_POST["TITLE"] )) ? $_POST["TITLE"] : "";
//$aFields["FOLDER_UID"] = $folderId, //$aFields["FOLDER_UID"] = $folderId,
//$aFields["APP_DOC_TAGS"] = $fileTags //$aFields["APP_DOC_TAGS"] = $fileTags
$aFields["APP_DOC_FIELDNAME"] = $_POST["APP_DOC_FIELDNAME"]; $aFields["APP_DOC_FIELDNAME"] = $_POST["APP_DOC_FIELDNAME"];
} else { } else {
//New record //New record
$aFields = array( $aFields = array ("APP_UID" => $_POST["APPLICATION"],"DEL_INDEX" => $_POST["INDEX"],"USR_UID" => $_POST["USR_UID"],"DOC_UID" => $_POST["DOC_UID"],"APP_DOC_TYPE" => $_POST["APP_DOC_TYPE"],"APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => (isset( $_POST["COMMENT"] )) ? $_POST["COMMENT"] : "","APP_DOC_TITLE" => (isset( $_POST["TITLE"] )) ? $_POST["TITLE"] : "","APP_DOC_FILENAME" => (isset( $_FILES["ATTACH_FILE"]["name"] )) ? $_FILES["ATTACH_FILE"]["name"] : "","FOLDER_UID" => $folderId,"APP_DOC_TAGS" => $fileTags,"APP_DOC_FIELDNAME" => $_POST["APP_DOC_FIELDNAME"]
"APP_UID" => $_POST["APPLICATION"],
"DEL_INDEX" => $_POST["INDEX"],
"USR_UID" => $_POST["USR_UID"],
"DOC_UID" => $_POST["DOC_UID"],
"APP_DOC_TYPE" => $_POST["APP_DOC_TYPE"],
"APP_DOC_CREATE_DATE" => date("Y-m-d H:i:s"),
"APP_DOC_COMMENT" => (isset($_POST["COMMENT"]))? $_POST["COMMENT"] : "",
"APP_DOC_TITLE" => (isset($_POST["TITLE"]))? $_POST["TITLE"] : "",
"APP_DOC_FILENAME" => (isset($_FILES["ATTACH_FILE"]["name"]))? $_FILES["ATTACH_FILE"]["name"] : "",
"FOLDER_UID" => $folderId,
"APP_DOC_TAGS" => $fileTags,
"APP_DOC_FIELDNAME" => $_POST["APP_DOC_FIELDNAME"]
); );
} }
$oAppDocument->create($aFields); $oAppDocument->create( $aFields );
$sAppUid = $oAppDocument->getAppUid(); $sAppUid = $oAppDocument->getAppUid();
$sAppDocUid = $oAppDocument->getAppDocUid(); $sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion(); $iDocVersion = $oAppDocument->getDocVersion();
$info = pathinfo($oAppDocument->getAppDocFilename()); $info = pathinfo( $oAppDocument->getAppDocFilename() );
$ext = (isset($info["extension"]))? $info["extension"] : ""; $ext = (isset( $info["extension"] )) ? $info["extension"] : "";
//Save the file //Save the file
echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP; echo $sPathName = PATH_DOCUMENT . $sAppUid . PATH_SEP;
echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext; echo $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $ext;
print G::uploadFile($_FILES["ATTACH_FILE"]["tmp_name"], $sPathName, $sFileName); print G::uploadFile( $_FILES["ATTACH_FILE"]["tmp_name"], $sPathName, $sFileName );
print("* The file " . $_FILES["ATTACH_FILE"]["name"] . " was uploaded successfully in case " . $sAppUid . " as input document..\n"); print ("* The file " . $_FILES["ATTACH_FILE"]["name"] . " was uploaded successfully in case " . $sAppUid . " as input document..\n") ;
//Get current Application Fields //Get current Application Fields
$application = new Application(); $application = new Application();
$appFields = $application->Load($_POST["APPLICATION"]); $appFields = $application->Load( $_POST["APPLICATION"] );
$appFields = unserialize($appFields["APP_DATA"]); $appFields = unserialize( $appFields["APP_DATA"] );
$_SESSION["APPLICATION"] = $appFields["APPLICATION"]; $_SESSION["APPLICATION"] = $appFields["APPLICATION"];
$_SESSION["PROCESS"] = $appFields["PROCESS"]; $_SESSION["PROCESS"] = $appFields["PROCESS"];
$_SESSION["TASK"] = $appFields["TASK"]; $_SESSION["TASK"] = $appFields["TASK"];
$_SESSION["INDEX"] = $appFields["INDEX"]; $_SESSION["INDEX"] = $appFields["INDEX"];
$_SESSION["USER_LOGGED"] = $appFields["USER_LOGGED"]; //$_POST["USR_UID"] $_SESSION["USER_LOGGED"] = $appFields["USER_LOGGED"]; //$_POST["USR_UID"]
//$_SESSION["USR_USERNAME"] = $appFields["USR_USERNAME"]; //$_SESSION["USR_USERNAME"] = $appFields["USR_USERNAME"];
//$_SESSION["STEP_POSITION"] = 0; //$_SESSION["STEP_POSITION"] = 0;
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry = &PMPluginRegistry::getSingleton(); $oPluginRegistry = &PMPluginRegistry::getSingleton();
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists("uploadDocumentData")) { if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( "uploadDocumentData" )) {
$triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
$documentData = new uploadDocumentData($_POST["APPLICATION"], $_POST["USR_UID"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion); $documentData = new uploadDocumentData( $_POST["APPLICATION"], $_POST["USR_UID"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion );
$uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
if ($uploadReturn) { if ($uploadReturn) {
$aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace; $aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace;
if (!isset($aFields["APP_DOC_UID"])) { if (! isset( $aFields["APP_DOC_UID"] )) {
$aFields["APP_DOC_UID"] = $sAppDocUid; $aFields["APP_DOC_UID"] = $sAppDocUid;
} }
if (!isset($aFields["DOC_VERSION"])) { if (! isset( $aFields["DOC_VERSION"] )) {
$aFields["DOC_VERSION"] = $iDocVersion; $aFields["DOC_VERSION"] = $iDocVersion;
} }
$oAppDocument->update($aFields); $oAppDocument->update( $aFields );
unlink($sPathName . $sFileName); unlink( $sPathName . $sFileName );
} }
} }
//End plugin //End plugin
} catch (Exception $e) { } catch (Exception $e) {
print($e->getMessage()); print ($e->getMessage()) ;
} }
} }

View File

@@ -1,51 +1,52 @@
<?php <?php
ini_set("default_charset", "UTF-8"); ini_set( "default_charset", "UTF-8" );
function AuthenticationBasicHTTP($realm ) { function AuthenticationBasicHTTP ($realm)
if (empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['REDIRECT_REMOTE_USER'])) { {
header('WWW-Authenticate: Basic realm="'.$realm.'"'); if (empty( $_SERVER['PHP_AUTH_USER'] ) && empty( $_SERVER['REDIRECT_REMOTE_USER'] )) {
header('HTTP/1.0 401 Unauthorized'); header( 'WWW-Authenticate: Basic realm="' . $realm . '"' );
die('401 Unauthorized'); header( 'HTTP/1.0 401 Unauthorized' );
} die( '401 Unauthorized' );
}
global $RBAC; global $RBAC;
$uid = $RBAC->VerifyLogin($_SERVER['PHP_AUTH_USER'] , $_SERVER['PHP_AUTH_PW'] ); $uid = $RBAC->VerifyLogin( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] );
if ( $uid > 0 ) { if ($uid > 0) {
// Asign the uid of user to userloggedobj // Asign the uid of user to userloggedobj
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid); $RBAC->loadUserRolePermission( $RBAC->sSystem, $uid );
$res = $RBAC->userCanAccess('PM_WEBDAV'); $res = $RBAC->userCanAccess( 'PM_WEBDAV' );
if ($res != 1 ) { if ($res != 1) {
if ($res == -2) if ($res == - 2)
$msg = G::LoadTranslation ('ID_USER_HAVENT_RIGHTS_SYSTEM'); $msg = G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_SYSTEM' );
else else
$msg = G::LoadTranslation ('ID_USER_HAVENT_RIGHTS_PAGE'); $msg = G::LoadTranslation( 'ID_USER_HAVENT_RIGHTS_PAGE' );
header('WWW-Authenticate: Basic realm="'.$realm.'"'); header( 'WWW-Authenticate: Basic realm="' . $realm . '"' );
header('HTTP/1.0 401 ' . $msg ); header( 'HTTP/1.0 401 ' . $msg );
die('401 ' . $msg); die( '401 ' . $msg );
return FALSE; return false;
die; die();
} }
return TRUE; return true;
} }
header('WWW-Authenticate: Basic realm="'.$realm.'"'); header( 'WWW-Authenticate: Basic realm="' . $realm . '"' );
header('HTTP/1.0 401 Unauthorized'); header( 'HTTP/1.0 401 Unauthorized' );
die('401 Unauthorized'); die( '401 Unauthorized' );
return FALSE; return false;
} }
$realm = 'ProcessMaker Filesystem for Workspace ' . SYS_SYS; $realm = 'ProcessMaker Filesystem for Workspace ' . SYS_SYS;
# Choice an authentification type Digest or Basic # Choice an authentification type Digest or Basic
//AuthenticationDigestHTTP($realm, $users, $phpcgi); //AuthenticationDigestHTTP($realm, $users, $phpcgi);
AuthenticationBasicHTTP($realm ); AuthenticationBasicHTTP( $realm );
G::LoadClass ( "webdav" ); G::LoadClass( "webdav" );
$server = new ProcessMakerWebDav(); $server = new ProcessMakerWebDav();
# Real path of your site # Real path of your site
$server->ServeRequest( ""); $server->ServeRequest( "" );

View File

@@ -1,14 +1,13 @@
<?php <?php
$filewsdl = PATH_METHODS . 'services'. PATH_SEP . 'pmos.wsdl'; $filewsdl = PATH_METHODS . 'services' . PATH_SEP . 'pmos.wsdl';
$content = file_get_contents( $filewsdl ); $content = file_get_contents( $filewsdl );
$lang = defined ('SYS_LANG') ? SYS_LANG : 'en'; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$endpoint = 'http://' .$_SERVER['SERVER_NAME'] . ':' .$_SERVER['SERVER_PORT'] . $endpoint = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . $lang . '/classic/services/soap';
'/sys' .SYS_SYS.'/' .$lang . '/classic/services/soap'; //print $endpoint; die;
//print $endpoint; die; $content = str_replace( "___SOAP_ADDRESS___", $endpoint, $content );
$content = str_replace ( "___SOAP_ADDRESS___", $endpoint, $content );
header("Content-Type: application/xml;"); header( "Content-Type: application/xml;" );
print $content; print $content;

View File

@@ -1,15 +1,14 @@
<?php <?php
$filewsdl = PATH_METHODS . 'services'. PATH_SEP . 'pmos2.wsdl'; $filewsdl = PATH_METHODS . 'services' . PATH_SEP . 'pmos2.wsdl';
$content = file_get_contents( $filewsdl ); $content = file_get_contents( $filewsdl );
$lang = defined ('SYS_LANG') ? SYS_LANG : 'en'; $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
$http = ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) ? 'https' : 'http'; $http = (isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
$endpoint = $http . '://' .$_SERVER['SERVER_NAME'] . ':' .$_SERVER['SERVER_PORT'] . $endpoint = $http . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . $lang . '/classic/services/soap2';
'/sys' .SYS_SYS.'/' .$lang . '/classic/services/soap2';
$content = str_replace ( "___SOAP_ADDRESS___", $endpoint, $content ); $content = str_replace( "___SOAP_ADDRESS___", $endpoint, $content );
header("Content-Type: application/xml;"); header( "Content-Type: application/xml;" );
print $content; print $content;

View File

@@ -1,46 +1,47 @@
<?php <?php
function wsBaseLogin( $username, $password ) { function wsBaseLogin ($username, $password)
G::LoadClass('wsBase'); {
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$ws = new wsBase();
$res = $ws->login( $username, $password ); $res = $ws->login( $username, $password );
return $res->getPayloadArray ( ) ; return $res->getPayloadArray();
} }
function wsBaseProcessList( $studentName ) { function wsBaseProcessList ($studentName)
G::LoadClass('wsBase'); {
$ws = new wsBase (); G::LoadClass( 'wsBase' );
$result = $ws->processList (); $ws = new wsBase();
//$result[] = array ( 'guid' => 'a' . $studentName , 'name' => 'bc' ); $result = $ws->processList();
//$result[] = array ( 'guid' => '2a' , 'name' => '2bc' . $studentName ); //$result[] = array ( 'guid' => 'a' . $studentName , 'name' => 'bc' );
//$result[] = array ( 'guid' => '2a' , 'name' => '2bc' . $studentName ); //$result[] = array ( 'guid' => '2a' , 'name' => '2bc' . $studentName );
return array("processes"=> $result); //$result[] = array ( 'guid' => '2a' , 'name' => '2bc' . $studentName );
return array ("processes" => $result
);
//return array ( "status_code" => 12, "message" => 'abx', "timestamp" => 'aa' ); //return array ( "status_code" => 12, "message" => 'abx', "timestamp" => 'aa' );
} }
/* Map of the service operation "ExamResult" to php function "ExamResult" */ /* Map of the service operation "ExamResult" to php function "ExamResult" */
$operations = array( "processesList" => "wsBaseProcessList", $operations = array ("processesList" => "wsBaseProcessList","login" => "wsBaseLogin"
"login" => "wsBaseLogin" );
);
/* just tell your function parameters should be in mixed format, /* just tell your function parameters should be in mixed format,
that is here parameter will be the string with the name in it*/ that is here parameter will be the string with the name in it*/
$opParams = array("wsBaseProcessList" => "MIXED", $opParams = array ("wsBaseProcessList" => "MIXED","wsBaseLogin" => "MIXED"
"wsBaseLogin" => "MIXED"); );
//$wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl"; //$wsdl = PATH_METHODS . "services" . PATH_SEP . "pmos.wsdl";
$wsdl = "/home/fernando/processmaker/trunk/workflow/engine/methods/services/pmos.wsdl"; $wsdl = "/home/fernando/processmaker/trunk/workflow/engine/methods/services/pmos.wsdl";
echo $wsdl; echo $wsdl;
echo file_get_contents($wsdl); echo file_get_contents( $wsdl );
die(); die();
/* Created the WSService */ /* Created the WSService */
$svr = new WSService(array("wsdl" => $wsdl , $svr = new WSService( array ("wsdl" => $wsdl,"operations" => $operations,"opParams" => $opParams
"operations" => $operations, ) );
"opParams" => $opParams));
/* Reply the client */ /* Reply the client */
$svr->reply(); $svr->reply();
die; die();

View File

@@ -1,184 +1,201 @@
<?php <?php
function addNodox($obj, $padre, $indice, $contenido='', $atributos='')
function addNodox ($obj, $padre, $indice, $contenido = '', $atributos = '')
{ {
if (is_object($padre)) { if (is_object( $padre )) {
if ($contenido=='') { if ($contenido == '') {
$nodo = $obj->createElement($indice); $nodo = $obj->createElement( $indice );
} else { } else {
$nodo = $obj->createElement($indice, $contenido); $nodo = $obj->createElement( $indice, $contenido );
} }
$padre->appendChild($nodo); $padre->appendChild( $nodo );
} else { } else {
if ($contenido=='') { if ($contenido == '') {
$nodo = $obj->createElement($indice); $nodo = $obj->createElement( $indice );
} else { } else {
$nodo = $obj->createElement($indice, $contenido); $nodo = $obj->createElement( $indice, $contenido );
} }
$obj->appendChild($nodo); $obj->appendChild( $nodo );
} }
if (is_array($atributos)) { if (is_array( $atributos )) {
foreach ($atributos as $key => $value) { foreach ($atributos as $key => $value) {
$atributo = $obj->createAttribute($key); $atributo = $obj->createAttribute( $key );
$nodo->appendChild($atributo); $nodo->appendChild( $atributo );
$texto = $obj->createTextNode($value); $texto = $obj->createTextNode( $value );
$atributo->appendChild($texto); $atributo->appendChild( $texto );
} }
} }
return $nodo; return $nodo;
} }
function derivationRules($aRoute, $doc, $nodo_derivationrule) function derivationRules ($aRoute, $doc, $nodo_derivationrule)
{ {
$tam = count($aRoute); $tam = count( $aRoute );
$c=0; $c = 0;
switch ($aRoute[$c]['ROU_TYPE']) switch ($aRoute[$c]['ROU_TYPE']) {
{
case 'SEQUENTIAL': case 'SEQUENTIAL':
$nodo_routeType = addNodox($doc, $nodo_derivationrule, 'Sequential', '', ''); $nodo_routeType = addNodox( $doc, $nodo_derivationrule, 'Sequential', '', '' );
$nodo_nexttask = addNodox($doc, $nodo_routeType, 'NextTask', '', ''); $nodo_nexttask = addNodox( $doc, $nodo_routeType, 'NextTask', '', '' );
if ($aRoute[$c]['ROU_NEXT_TASK'] != -1) { if ($aRoute[$c]['ROU_NEXT_TASK'] != - 1) {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'TaskRef', '', $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'TaskRef', '', array ('TaskId' => 'ID' . $aRoute[$c]['ROU_NEXT_TASK']
array('TaskId'=> 'ID'.$aRoute[$c]['ROU_NEXT_TASK'])); ) );
} else { } else {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'End', '', ''); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'End', '', '' );
} }
break; break;
case 'EVALUATE': case 'EVALUATE':
$nodo_routeType = addNodox($doc, $nodo_derivationrule, 'Evaluations', '', ''); $nodo_routeType = addNodox( $doc, $nodo_derivationrule, 'Evaluations', '', '' );
while ($c < $tam) { while ($c < $tam) {
$nodo_evaluation= addNodox($doc, $nodo_routeType, 'Evaluation', '', array('Condition'=> $aRoute[$c]['ROU_CONDITION'])); $nodo_evaluation = addNodox( $doc, $nodo_routeType, 'Evaluation', '', array ('Condition' => $aRoute[$c]['ROU_CONDITION']
$nodo_nexttask = addNodox($doc, $nodo_evaluation, 'NextTask', '', ''); ) );
if ($aRoute[$c]['ROU_NEXT_TASK'] != -1) { $nodo_nexttask = addNodox( $doc, $nodo_evaluation, 'NextTask', '', '' );
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'TaskRef', '', array('TaskId'=> 'ID'.$aRoute[$c]['ROU_NEXT_TASK'])); if ($aRoute[$c]['ROU_NEXT_TASK'] != - 1) {
$nodo_taskref = addNodox( $doc, $nodo_nexttask, 'TaskRef', '', array ('TaskId' => 'ID' . $aRoute[$c]['ROU_NEXT_TASK']
) );
} else { } else {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'End', '', ''); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'End', '', '' );
} }
$c++; $c ++;
} }
break; break;
case 'SELECT': case 'SELECT':
$nodo_routeType = addNodox($doc, $nodo_derivationrule, 'Selections', '', ''); $nodo_routeType = addNodox( $doc, $nodo_derivationrule, 'Selections', '', '' );
while ($c < $tam) { while ($c < $tam) {
$nodo_selection= addNodox($doc, $nodo_routeType, 'Selection', '', array('Description'=> $aRoute[$c]['ROU_CONDITION'])); $nodo_selection = addNodox( $doc, $nodo_routeType, 'Selection', '', array ('Description' => $aRoute[$c]['ROU_CONDITION']
$nodo_nexttask = addNodox($doc, $nodo_selection, 'NextTask', '', ''); ) );
if ($aRoute[$c]['ROU_NEXT_TASK'] != -1) { $nodo_nexttask = addNodox( $doc, $nodo_selection, 'NextTask', '', '' );
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'TaskRef', '', array('TaskId'=> 'ID'.$aRoute[$c]['ROU_NEXT_TASK'])); if ($aRoute[$c]['ROU_NEXT_TASK'] != - 1) {
$nodo_taskref = addNodox( $doc, $nodo_nexttask, 'TaskRef', '', array ('TaskId' => 'ID' . $aRoute[$c]['ROU_NEXT_TASK']
) );
} else { } else {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'End', '', ''); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'End', '', '' );
} }
$c++; $c ++;
} }
break; break;
case 'PARALLEL': case 'PARALLEL':
$nodo_routeType = addNodox($doc, $nodo_derivationrule, 'ParallelForks', '', ''); $nodo_routeType = addNodox( $doc, $nodo_derivationrule, 'ParallelForks', '', '' );
while ($c < $tam) { while ($c < $tam) {
$nodo_parallelfork= addNodox($doc, $nodo_routeType, 'ParallelFork', '', ''); $nodo_parallelfork = addNodox( $doc, $nodo_routeType, 'ParallelFork', '', '' );
$nodo_nexttask = addNodox($doc, $nodo_parallelfork, 'NextTask', '', ''); $nodo_nexttask = addNodox( $doc, $nodo_parallelfork, 'NextTask', '', '' );
if ($aRoute[$c]['ROU_NEXT_TASK'] != -1) { if ($aRoute[$c]['ROU_NEXT_TASK'] != - 1) {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'TaskRef', '', array('TaskId'=> 'ID'.$aRoute[$c]['ROU_NEXT_TASK'])); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'TaskRef', '', array ('TaskId' => 'ID' . $aRoute[$c]['ROU_NEXT_TASK']
) );
} else { } else {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'End', '', ''); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'End', '', '' );
} }
$c++; $c ++;
} }
break; break;
case 'PARALLEL-BY-EVALUATION': case 'PARALLEL-BY-EVALUATION':
$nodo_routeType = addNodox($doc, $nodo_derivationrule, 'ParallelForksByEvaluation', '', ''); $nodo_routeType = addNodox( $doc, $nodo_derivationrule, 'ParallelForksByEvaluation', '', '' );
while ($c < $tam) { while ($c < $tam) {
$nodo_evaluation= addNodox($doc, $nodo_routeType, 'Evaluation', '', array('Condition'=> $aRoute[$c]['ROU_CONDITION'])); $nodo_evaluation = addNodox( $doc, $nodo_routeType, 'Evaluation', '', array ('Condition' => $aRoute[$c]['ROU_CONDITION']
$nodo_nexttask = addNodox($doc, $nodo_evaluation, 'NextTask', '', ''); ) );
if ($aRoute[$c]['ROU_NEXT_TASK'] != -1) { $nodo_nexttask = addNodox( $doc, $nodo_evaluation, 'NextTask', '', '' );
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'TaskRef', '', array('TaskId'=> 'ID'.$aRoute[$c]['ROU_NEXT_TASK'])); if ($aRoute[$c]['ROU_NEXT_TASK'] != - 1) {
$nodo_taskref = addNodox( $doc, $nodo_nexttask, 'TaskRef', '', array ('TaskId' => 'ID' . $aRoute[$c]['ROU_NEXT_TASK']
) );
} else { } else {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'End', '', ''); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'End', '', '' );
} }
$c++; $c ++;
} }
break; break;
case 'SEC-JOIN': case 'SEC-JOIN':
$nodo_routeType = addNodox($doc, $nodo_derivationrule, 'ParallelJoin', '', ''); $nodo_routeType = addNodox( $doc, $nodo_derivationrule, 'ParallelJoin', '', '' );
$nodo_nexttask = addNodox($doc, $nodo_routeType, 'NextTask', '', ''); $nodo_nexttask = addNodox( $doc, $nodo_routeType, 'NextTask', '', '' );
if ($aRoute[$c]['ROU_NEXT_TASK'] != -1) { if ($aRoute[$c]['ROU_NEXT_TASK'] != - 1) {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'TaskRef', '', array('TaskId'=> 'ID'.$aRoute[$c]['ROU_NEXT_TASK'])); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'TaskRef', '', array ('TaskId' => 'ID' . $aRoute[$c]['ROU_NEXT_TASK']
) );
} else { } else {
$nodo_taskref = addNodox($doc, $nodo_nexttask, 'End', '', ''); $nodo_taskref = addNodox( $doc, $nodo_nexttask, 'End', '', '' );
} }
break; break;
} }
} }
/****-_--__---___----___---__--_-****/ /**
* **-_--__---___----___---__--_-***
*/
G::LoadClass('tasks'); G::LoadClass( 'tasks' );
require_once 'classes/model/Process.php'; require_once 'classes/model/Process.php';
$doc = new DOMDocument('1.0', 'UTF-8'); $doc = new DOMDocument( '1.0', 'UTF-8' );
$nodo_padre = addNodox($doc, '', 'Processes', '', array('xmlns:xsi'=>'http://www.w3.org/2001/XMLSchema-instance','xsi:noNamespaceSchemaLocation'=>'ColosaSchema.xsd')); $nodo_padre = addNodox( $doc, '', 'Processes', '', array ('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance','xsi:noNamespaceSchemaLocation' => 'ColosaSchema.xsd'
) );
$aProcesses = array(); $aProcesses = array ();
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn(ProcessPeer::PRO_UID); $oCriteria->addSelectColumn( ProcessPeer::PRO_UID );
//$oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL); //$oCriteria->add(ProcessPeer::PRO_STATUS, 'DISABLED', Criteria::NOT_EQUAL);
//$oCriteria->add(ProcessPeer::PRO_UID, '946679494980c3d0ba0814088444708'); //$oCriteria->add(ProcessPeer::PRO_UID, '946679494980c3d0ba0814088444708');
$oDataset = ProcessPeer::doSelectRS($oCriteria); $oDataset = ProcessPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
$oProcess = new Process(); $oProcess = new Process();
while ($aRow = $oDataset->getRow()) { while ($aRow = $oDataset->getRow()) {
$aProcess = $oProcess->load($aRow['PRO_UID']); $aProcess = $oProcess->load( $aRow['PRO_UID'] );
$nodo_process = addNodox($doc, $nodo_padre, 'Process', '', array('Title'=> $aProcess['PRO_TITLE'],'Description'=> $aProcess['PRO_DESCRIPTION'])); $nodo_process = addNodox( $doc, $nodo_padre, 'Process', '', array ('Title' => $aProcess['PRO_TITLE'],'Description' => $aProcess['PRO_DESCRIPTION']
$nodo_tasks = addNodox($doc, $nodo_process, 'Tasks', '', ''); ) );
$nodo_tasks = addNodox( $doc, $nodo_process, 'Tasks', '', '' );
$oTask = new Tasks(); $oTask = new Tasks();
$aTasks= $oTask->getAllTasks($aProcess['PRO_UID']); $aTasks = $oTask->getAllTasks( $aProcess['PRO_UID'] );
foreach ($aTasks as $key => $value) { foreach ($aTasks as $key => $value) {
//print_r($value); echo "<br>"; //print_r($value); echo "<br>";
$aRoute = $oTask->getRoute($aProcess['PRO_UID'], $value['TAS_UID']); $aRoute = $oTask->getRoute( $aProcess['PRO_UID'], $value['TAS_UID'] );
//print_r($aRoute[0]['ROU_UID']); echo "<hr>"; //print_r($aRoute[0]['ROU_UID']); echo "<hr>";
/*foreach($aRoute as $k => $v) /*foreach($aRoute as $k => $v)
echo $k."-->".$v."<br>"; echo $k."-->".$v."<br>";
*/ */
if ($value['TAS_TYPE']=='NORMAL') { if ($value['TAS_TYPE'] == 'NORMAL') {
$ini = ($value['TAS_START']=='TRUE') ? 'true' : 'false'; $ini = ($value['TAS_START'] == 'TRUE') ? 'true' : 'false';
$nodo_task = addNodox($doc, $nodo_tasks, 'Task', '', array('Title'=> $value['TAS_TITLE'],'Description'=> $value['TAS_DESCRIPTION'],'Id'=> 'ID'.$value['TAS_UID'],'StartingTask'=> $ini)); $nodo_task = addNodox( $doc, $nodo_tasks, 'Task', '', array ('Title' => $value['TAS_TITLE'],'Description' => $value['TAS_DESCRIPTION'],'Id' => 'ID' . $value['TAS_UID'],'StartingTask' => $ini
$nodo_coordinates = addNodox($doc, $nodo_task, 'Coordinates', '', array('XCoordinate'=> $value['TAS_POSX'],'YCoordinate'=> $value['TAS_POSY'])); ) );
$nodo_derivationrule = addNodox($doc, $nodo_task, 'DerivationRule', '', ''); $nodo_coordinates = addNodox( $doc, $nodo_task, 'Coordinates', '', array ('XCoordinate' => $value['TAS_POSX'],'YCoordinate' => $value['TAS_POSY']
) );
$nodo_derivationrule = addNodox( $doc, $nodo_task, 'DerivationRule', '', '' );
derivationRules($aRoute, $doc, $nodo_derivationrule); derivationRules( $aRoute, $doc, $nodo_derivationrule );
$nodo_assignmentrules = addNodox($doc, $nodo_task, 'AssignmentRules', '', ''); $nodo_assignmentrules = addNodox( $doc, $nodo_task, 'AssignmentRules', '', '' );
$nodo_cyclicalassignment = addNodox($doc, $nodo_assignmentrules, 'CyclicalAssignment', '', ''); $nodo_cyclicalassignment = addNodox( $doc, $nodo_assignmentrules, 'CyclicalAssignment', '', '' );
$nodo_timingcontrol = addNodox($doc, $nodo_task, 'TimingControl', '', array('TaskDuration'=> $value['TAS_DURATION'])); $nodo_timingcontrol = addNodox( $doc, $nodo_task, 'TimingControl', '', array ('TaskDuration' => $value['TAS_DURATION']
$nodo_permissions = addNodox($doc, $nodo_task, 'Permissions', '', ''); ) );
$nodo_caselabels = addNodox($doc, $nodo_task, 'CaseLabels', '', ''); $nodo_permissions = addNodox( $doc, $nodo_task, 'Permissions', '', '' );
$nodo_notifications = addNodox($doc, $nodo_task, 'Notifications', '', ''); $nodo_caselabels = addNodox( $doc, $nodo_task, 'CaseLabels', '', '' );
$nodo_notifications = addNodox( $doc, $nodo_task, 'Notifications', '', '' );
} else { } else {
require_once ( "classes/model/SubProcess.php" ); require_once ("classes/model/SubProcess.php");
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria( 'workflow' );
$oCriteria->add(SubProcessPeer::PRO_PARENT, $value['PRO_UID']); $oCriteria->add( SubProcessPeer::PRO_PARENT, $value['PRO_UID'] );
$oCriteria->add(SubProcessPeer::TAS_PARENT, $value['TAS_UID']); $oCriteria->add( SubProcessPeer::TAS_PARENT, $value['TAS_UID'] );
$oDataset = SubProcessPeer::doSelectRS($oCriteria); $oDataset = SubProcessPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
$aRow = $oDataset->getRow(); $aRow = $oDataset->getRow();
$nodo_task = addNodox($doc, $nodo_tasks, 'SubProcess', '', array('Title'=> $value['TAS_TITLE'],'Description'=> $value['TAS_DESCRIPTION'],'Id'=> 'ID'.$value['TAS_UID'], 'ProcessRef'=>$aRow['PRO_UID'])); $nodo_task = addNodox( $doc, $nodo_tasks, 'SubProcess', '', array ('Title' => $value['TAS_TITLE'],'Description' => $value['TAS_DESCRIPTION'],'Id' => 'ID' . $value['TAS_UID'],'ProcessRef' => $aRow['PRO_UID']
$nodo_coordinates = addNodox($doc, $nodo_task, 'Coordinates', '', array('XCoordinate'=> $value['TAS_POSX'],'YCoordinate'=> $value['TAS_POSY'])); ) );
$nodo_derivationrule = addNodox($doc, $nodo_task, 'DerivationRule', '', ''); $nodo_coordinates = addNodox( $doc, $nodo_task, 'Coordinates', '', array ('XCoordinate' => $value['TAS_POSX'],'YCoordinate' => $value['TAS_POSY']
) );
$nodo_derivationrule = addNodox( $doc, $nodo_task, 'DerivationRule', '', '' );
derivationRules($aRoute, $doc, $nodo_derivationrule); derivationRules( $aRoute, $doc, $nodo_derivationrule );
} }
} }
$oDataset->next(); $oDataset->next();
} }
//die; //die;
$doc->preserveWhiteSpace = false; $doc->preserveWhiteSpace = false;
$doc->formatOutput = true; $doc->formatOutput = true;
$doc->save(PATH_METHODS.'services/test_xpdl.xml'); $doc->save( PATH_METHODS . 'services/test_xpdl.xml' );
echo "xml for xpdl creado!!!<br>"; echo "xml for xpdl creado!!!<br>";