From 9b1f2ced571a57db516754fa74f01d4558a28bb2 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Mon, 2 Jul 2012 18:35:54 -0400 Subject: [PATCH 1/3] BUG Adjustment for standardization of code SOLVED --- workflow/engine/classes/class.pmFunctions.php | 2130 +++++++++-------- .../triggers/triggers_CreateWizard.php | 313 +-- .../triggers/triggers_EditWizard.php | 322 +-- 3 files changed, 1428 insertions(+), 1337 deletions(-) diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index b3c90e75c..e63aeb913 100755 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -58,8 +58,9 @@ * @return date | $date | Current Date (Y-m-d) | It returns the current date as a string value. * */ -function getCurrentDate() { - return G::CurDate('Y-m-d'); +function getCurrentDate() +{ + return G::CurDate('Y-m-d'); } /** * @method @@ -74,8 +75,9 @@ function getCurrentDate() { * @return time | $time | Current Time (H:i:s)| The function returns the current time as a string. * */ -function getCurrentTime() { - return G::CurDate('H:i:s'); +function getCurrentTime() +{ + return G::CurDate('H:i:s'); } /** * @method @@ -90,15 +92,15 @@ function getCurrentTime() { * @return array | $userInfo | User Info | An associative array with Information * */ -function userInfo($user_uid) { - try { - require_once 'classes/model/Users.php'; - $oUser = new Users(); - return $oUser->getAllInformation($user_uid); - } - catch (Exception $oException) { - throw $oException; - } +function userInfo($user_uid) +{ + try { + require_once 'classes/model/Users.php'; + $oUser = new Users(); + return $oUser->getAllInformation($user_uid); + } catch (Exception $oException) { + throw $oException; + } } /** * @method @@ -113,8 +115,9 @@ function userInfo($user_uid) { * @return string | $TextC | Text Converted | Returns a string with the text converted into upper case letters. * */ -function upperCase($sText) { - return G::toUpper($sText); +function upperCase($sText) +{ + return G::toUpper($sText); } /** * @method @@ -129,8 +132,9 @@ function upperCase($sText) { * @return string | $TextC | Text Converted | Returns a string with the text converted into lower case letters. * */ -function lowerCase($sText) { - return G::toLower($sText); +function lowerCase($sText) +{ + return G::toLower($sText); } /** * @method @@ -146,8 +150,9 @@ function lowerCase($sText) { * @return string | $TextC | Text Converted | It returns the introduced text with the first letter capitalized in each word and the subsequent letters into lowercase letters * */ -function capitalize($sText) { - return G::capitalizeWords($sText); +function capitalize($sText) +{ + return G::capitalizeWords($sText); } /** * @method @@ -164,15 +169,16 @@ function capitalize($sText) { * @return string | $formatDate | Date whit format | It returns the passed date according to the given date format. * */ -function formatDate($date, $format='', $lang='en') { - if( !isset($date) or $date == '') { - throw new Exception('function:formatDate::Bad param'); - } - try { - return G::getformatedDate($date, $format, $lang); - } catch (Exception $oException) { - throw $oException; - } +function formatDate($date, $format='', $lang='en') +{ + if ( !isset($date) or $date == '') { + throw new Exception('function:formatDate::Bad param'); + } + try { + return G::getformatedDate($date, $format, $lang); + } catch (Exception $oException) { + throw $oException; + } } /** * @method @@ -188,21 +194,24 @@ function formatDate($date, $format='', $lang='en') { * @return string | $literaDate | Literal date | It returns the literal date as a string value. * */ -function literalDate($date, $lang = 'en') { - if( !isset($date) or $date == '' ) { - throw new Exception('function:formatDate::Bad param'); - } - try { - switch($lang) { - case 'en': $ret = G::getformatedDate($date, 'M d,yyyy', $lang); - break; - case 'es': $ret = G::getformatedDate($date, 'd de M de yyyy', $lang); - break; +function literalDate($date, $lang='en') +{ + if ( !isset($date) or $date == '' ) { + throw new Exception('function:formatDate::Bad param'); + } + try { + switch ($lang) { + case 'en': + $ret = G::getformatedDate($date, 'M d,yyyy', $lang); + break; + case 'es': + $ret = G::getformatedDate($date, 'd de M de yyyy', $lang); + break; + } + return $ret; + } catch (Exception $oException) { + throw $oException; } - return $ret; - } catch (Exception $oException) { - throw $oException; - } } /** * @method @@ -220,24 +229,25 @@ function literalDate($date, $lang = 'en') { * @return None | $none | None | None * */ -function pauseCase($sApplicationUID = '', $iDelegation = 0, $sUserUID = '', $sUnpauseDate = null) {//var_dump($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate);die(':|'); - try { - if ($sApplicationUID == '') { - throw new Exception('The application UID cannot be empty!'); +function pauseCase($sApplicationUID='', $iDelegation=0, $sUserUID='', $sUnpauseDate=null) +{ + //var_dump($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate);die(':|'); + try { + if ($sApplicationUID == '') { + throw new Exception('The application UID cannot be empty!'); + } + if ($iDelegation == 0) { + throw new Exception('The delegation index cannot be 0!'); + } + if ($sUserUID == '') { + throw new Exception('The user UID cannot be empty!'); + } + G::LoadClass('case'); + $oCase = new Cases(); + $oCase->pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate); + } catch (Exception $oException) { + throw $oException; } - if ($iDelegation == 0) { - throw new Exception('The delegation index cannot be 0!'); - } - if ($sUserUID == '') { - throw new Exception('The user UID cannot be empty!'); - } - G::LoadClass('case'); - $oCase = new Cases(); - $oCase->pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate); - } - catch (Exception $oException) { - throw $oException; - } } /** * @method @@ -254,53 +264,53 @@ function pauseCase($sApplicationUID = '', $iDelegation = 0, $sUserUID = '', $sUn * @return array or string | $Resultquery | Result | Result of the query | If executing a SELECT statement, it returns an array of associative arrays * */ -function executeQuery($SqlStatement, $DBConnectionUID = 'workflow', $aParameter = array()) { - $con = Propel::getConnection($DBConnectionUID); - $con->begin(); - try { - $statement = trim($SqlStatement); - $statement = str_replace('(', '', $statement); +function executeQuery($SqlStatement, $DBConnectionUID='workflow', $aParameter=array()) +{ + $con = Propel::getConnection($DBConnectionUID); + $con->begin(); + try { + $statement = trim($SqlStatement); + $statement = str_replace('(', '', $statement); - $result = false; - if (getEngineDataBaseName($con) != 'oracle' ) { - switch(true) { - case preg_match("/^(SELECT|EXECUTE|EXEC|SHOW|DESCRIBE|EXPLAIN|BEGIN)\s/i", $statement): - $rs = $con->executeQuery($SqlStatement); - $con->commit(); + $result = false; + if (getEngineDataBaseName($con) != 'oracle' ) { + switch(true) { + case preg_match("/^(SELECT|EXECUTE|EXEC|SHOW|DESCRIBE|EXPLAIN|BEGIN)\s/i", $statement): + $rs = $con->executeQuery($SqlStatement); + $con->commit(); - $result = Array(); - $i = 1; - while ($rs->next()) { - $result[$i++] = $rs->getRow(); - } - break; - case preg_match("/^INSERT\s/i", $statement): - $rs = $con->executeUpdate($SqlStatement); - $con->commit(); - //$result = $lastId->getId(); - $result = 1; - break; - case preg_match("/^UPDATE\s/i", $statement): - $rs = $con->executeUpdate($SqlStatement); - $con->commit(); - $result = $con->getUpdateCount(); - break; - case preg_match("/^DELETE\s/i", $statement): - $rs = $con->executeUpdate($SqlStatement); - $con->commit(); - $result = $con->getUpdateCount(); - break; - } + $result = Array(); + $i = 1; + while ($rs->next()) { + $result[$i++] = $rs->getRow(); + } + break; + case preg_match("/^INSERT\s/i", $statement): + $rs = $con->executeUpdate($SqlStatement); + $con->commit(); + //$result = $lastId->getId(); + $result = 1; + break; + case preg_match("/^UPDATE\s/i", $statement): + $rs = $con->executeUpdate($SqlStatement); + $con->commit(); + $result = $con->getUpdateCount(); + break; + case preg_match("/^DELETE\s/i", $statement): + $rs = $con->executeUpdate($SqlStatement); + $con->commit(); + $result = $con->getUpdateCount(); + break; + } + } else { + $result = executeQueryOci($SqlStatement, $con, $aParameter); + } + + return $result; + } catch (SQLException $sqle) { + $con->rollback(); + throw $sqle; } - else { - $result = executeQueryOci($SqlStatement, $con, $aParameter); - } - - return $result; - } catch (SQLException $sqle) { - $con->rollback(); - throw $sqle; - } } /** * @method @@ -317,28 +327,29 @@ function executeQuery($SqlStatement, $DBConnectionUID = 'workflow', $aParameter * @return array | $dataM | Grid Sorted | Grid sorted * */ -function orderGrid($dataM, $field, $ord = 'ASC') { - if(!is_array($dataM) or !isset($field) or $field=='') { - throw new Exception('function:orderGrid Error!, bad parameters found!'); - } - for($i=1; $i <= count($dataM)-1; $i++) { - for($j=$i+1; $j <= count($dataM); $j++) { - if(strtoupper($ord) == 'ASC') { - if(strtolower($dataM[$j][$field]) < strtolower($dataM[$i][$field])) { - $swap = $dataM[$i]; - $dataM[$i] = $dataM[$j]; - $dataM[$j] = $swap; - } - } else { - if($dataM[$j][$field] > $dataM[$i][$field]) { - $swap = $dataM[$i]; - $dataM[$i] = $dataM[$j]; - $dataM[$j] = $swap; - } - } +function orderGrid($dataM, $field, $ord='ASC') +{ + if (!is_array($dataM) or !isset($field) or $field=='') { + throw new Exception('function:orderGrid Error!, bad parameters found!'); } - } - return $dataM; + for ($i=1; $i <= count($dataM)-1; $i++) { + for ($j=$i+1; $j <= count($dataM); $j++) { + if (strtoupper($ord) == 'ASC') { + if (strtolower($dataM[$j][$field]) < strtolower($dataM[$i][$field])) { + $swap = $dataM[$i]; + $dataM[$i] = $dataM[$j]; + $dataM[$j] = $swap; + } + } else { + if ($dataM[$j][$field] > $dataM[$i][$field]) { + $swap = $dataM[$i]; + $dataM[$i] = $dataM[$j]; + $dataM[$j] = $swap; + } + } + } + } + return $dataM; } /** * @method @@ -354,23 +365,24 @@ function orderGrid($dataM, $field, $ord = 'ASC') { * @return array | $aGrid | Grid | Grid with executed operation * */ -function evaluateFunction($aGrid, $sExpresion) { - $sExpresion = str_replace('Array','$this->aFields', $sExpresion); - $sExpresion .= ';'; - G::LoadClass('pmScript'); - $pmScript = new PMScript(); - $pmScript->setScript($sExpresion); +function evaluateFunction($aGrid, $sExpresion) +{ + $sExpresion = str_replace('Array','$this->aFields', $sExpresion); + $sExpresion .= ';'; + G::LoadClass('pmScript'); + $pmScript = new PMScript(); + $pmScript->setScript($sExpresion); - for($i=1; $i<=count($aGrid); $i++) { - $aFields = $aGrid[$i]; + for ($i=1; $i<=count($aGrid); $i++) { + $aFields = $aGrid[$i]; - $pmScript->setFields($aFields); + $pmScript->setFields($aFields); - $pmScript->execute(); + $pmScript->execute(); - $aGrid[$i] = $pmScript->aFields; - } - return $aGrid; + $aGrid[$i] = $pmScript->aFields; + } + return $aGrid; } /** Web Services Functions **/ @@ -389,39 +401,39 @@ function evaluateFunction($aGrid, $sExpresion) { * @return string | $unique ID | Unique Id |The unique ID for the initiated session. * */ -function WSLogin($user, $pass, $endpoint = "") { - $client = WSOpen(true); - - $params = array("userid" => $user, "password" => $pass); - - $result = $client->__soapCall("login", array($params)); +function WSLogin($user, $pass, $endpoint="") +{ + $client = WSOpen(true); - if ($result->status_code == 0) { - if ($endpoint != "") { - if (isset($_SESSION["WS_SESSION_ID"])) { - $_SESSION["WS_END_POINT"] = $endpoint; - } + $params = array("userid" => $user, "password" => $pass); + + $result = $client->__soapCall("login", array($params)); + + if ($result->status_code == 0) { + if ($endpoint != "") { + if (isset($_SESSION["WS_SESSION_ID"])) { + $_SESSION["WS_END_POINT"] = $endpoint; + } + } + /* + if (isset($_SESSION["WS_SESSION_ID"])) + return $_SESSION["WS_SESSION_ID"] = $result->message; + else + return $result->message; + */ + + $_SESSION["WS_SESSION_ID"] = $result->message; + + return $result->message; + } else { + if (isset($_SESSION["WS_SESSION_ID"])) { + unset($_SESSION["WS_SESSION_ID"]); + } + + $wp = (trim($pass) != "")? "YES" : "NO"; + + throw new Exception("WSAccess denied! for user $user with password $wp"); } - /* - if (isset($_SESSION["WS_SESSION_ID"])) - return $_SESSION["WS_SESSION_ID"] = $result->message; - else - return $result->message; - */ - - $_SESSION["WS_SESSION_ID"] = $result->message; - - return $result->message; - } - else { - if (isset($_SESSION["WS_SESSION_ID"])) { - unset($_SESSION["WS_SESSION_ID"]); - } - - $wp = (trim($pass) != "")? "YES" : "NO"; - - throw new Exception("WSAccess denied! for user $user with password $wp"); - } } /** * @method @@ -437,21 +449,22 @@ function WSLogin($user, $pass, $endpoint = "") { * @return Object Client | $client | SoapClient object | A SoapClient object. If unable to establish a connection, returns NULL. * */ -function WSOpen($force = false) { - if (isset($_SESSION["WS_SESSION_ID"]) || $force) { - if (!isset($_SESSION["WS_END_POINT"])) { - $defaultEndpoint = "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . "/sys" . SYS_SYS . "/en/classic/services/wsdl2"; +function WSOpen($force=false) +{ + if (isset($_SESSION["WS_SESSION_ID"]) || $force) { + if (!isset($_SESSION["WS_END_POINT"])) { + $defaultEndpoint = "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] + . "/sys" . SYS_SYS . "/en/classic/services/wsdl2"; + } + + $endpoint = isset($_SESSION["WS_END_POINT"])? $_SESSION["WS_END_POINT"] : $defaultEndpoint; + + $client = new SoapClient($endpoint); + + return $client; + } else { + throw new Exception("WS session is not open"); } - - $endpoint = isset($_SESSION["WS_END_POINT"])? $_SESSION["WS_END_POINT"] : $defaultEndpoint; - - $client = new SoapClient($endpoint); - - return $client; - } - else { - throw new Exception("WS session is not open"); - } } /** * @method @@ -466,35 +479,35 @@ function WSOpen($force = false) { * @return array | $rows | Array of tasks open | An array of tasks in the indicated case which have open delegations. * */ -function WSTaskCase($caseId) { - $client = WSOpen(); +function WSTaskCase($caseId) +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId, "caseId" => $caseId); - - $result = $client->__soapCall("taskCase", array($params)); - - $rows = array(); - $i = 0; - - if (isset($result->taskCases)) { - //Processing when it is an array - if (is_array($result->taskCases)) { - foreach ($result->taskCases as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId, "caseId" => $caseId); + + $result = $client->__soapCall("taskCase", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->taskCases)) { + //Processing when it is an array + if (is_array($result->taskCases)) { + foreach ($result->taskCases as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->taskCases)) { + $rows[$i] = array("guid" => $result->taskCases->guid, "name" => $result->taskCases->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->taskCases)) { - $rows[$i] = array("guid" => $result->taskCases->guid, "name" => $result->taskCases->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** * @method @@ -509,35 +522,35 @@ function WSTaskCase($caseId) { * @return array | $rows |List of tasks | This function returns a list of tasks * */ -function WSTaskList() { - $client = WSOpen(); +function WSTaskList() +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId); - - $result = $client->__soapCall("TaskList", array($params)); - - $rows = array(); - $i = 0; - - if (isset($result->tasks)) { - //Processing when it is an array - if (is_array($result->tasks)) { - foreach ($result->tasks as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId); + + $result = $client->__soapCall("TaskList", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->tasks)) { + //Processing when it is an array + if (is_array($result->tasks)) { + foreach ($result->tasks as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->tasks)) { + $rows[$i] = array("guid" => $result->tasks->guid, "name" => $result->tasks->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->tasks)) { - $rows[$i] = array("guid" => $result->tasks->guid, "name" => $result->tasks->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** * @method @@ -551,35 +564,35 @@ function WSTaskList() { * @return array | $rows | List | List of Active users in the workspace * */ -function WSUserList() { - $client = WSOpen(); +function WSUserList() +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId); - - $result = $client->__soapCall("UserList", array($params)); - - $rows = array(); - $i = 0; - - if (isset($result->users)) { - //Processing when it is an array - if (is_array($result->users)) { - foreach ($result->users as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId); + + $result = $client->__soapCall("UserList", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->users)) { + //Processing when it is an array + if (is_array($result->users)) { + foreach ($result->users as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->users)) { + $rows[$i] = array("guid" => $result->users->guid, "name" => $result->users->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->users)) { - $rows[$i] = array("guid" => $result->users->guid, "name" => $result->users->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** * @method @@ -593,35 +606,35 @@ function WSUserList() { * @return array | $rows | List | List of active groups in the workspace * */ -function WSGroupList() { - $client = WSOpen(); +function WSGroupList() +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId); - - $result = $client->__soapCall("GroupList", array($params)); + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId); - $rows = array(); - $i = 0; - - if (isset($result->groups)) { - //Processing when it is an array - if (is_array($result->groups)) { - foreach ($result->groups as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $result = $client->__soapCall("GroupList", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->groups)) { + //Processing when it is an array + if (is_array($result->groups)) { + foreach ($result->groups as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->groups)) { + $rows[$i] = array("guid" => $result->groups->guid, "name" => $result->groups->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->groups)) { - $rows[$i] = array("guid" => $result->groups->guid, "name" => $result->groups->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** @@ -636,35 +649,35 @@ function WSGroupList() { * @return array | $rows | List | List of roles in the workspace * */ -function WSRoleList() { - $client = WSOpen(); +function WSRoleList() +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId); - - $result = $client->__soapCall("RoleList", array($params)); - - $rows = array(); - $i = 0; - - if (isset($result->roles)) { - //Processing when it is an array - if (is_array($result->roles)) { - foreach ($result->roles as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId); + + $result = $client->__soapCall("RoleList", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->roles)) { + //Processing when it is an array + if (is_array($result->roles)) { + foreach ($result->roles as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->roles)) { + $rows[$i] = array("guid" => $result->roles->guid, "name" => $result->roles->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->roles)) { - $rows[$i] = array("guid" => $result->roles->guid, "name" => $result->roles->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** * @method @@ -679,35 +692,35 @@ function WSRoleList() { * @return array | $rows | List of the cases |It returns a list of cases * */ -function WSCaseList() { - $client = WSOpen(); +function WSCaseList() +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId); - - $result = $client->__soapCall("CaseList", array($params)); + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId); - $rows = array(); - $i = 0; - - if (isset($result->cases)) { - //Processing when it is an array - if (is_array($result->cases)) { - foreach ($result->cases as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $result = $client->__soapCall("CaseList", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->cases)) { + //Processing when it is an array + if (is_array($result->cases)) { + foreach ($result->cases as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->cases)) { + $rows[$i] = array("guid" => $result->cases->guid, "name" => $result->cases->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->cases)) { - $rows[$i] = array("guid" => $result->cases->guid, "name" => $result->cases->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** * @method @@ -721,35 +734,35 @@ function WSCaseList() { * @return array | $rows | List of processes | A list of processes * */ -function WSProcessList() { - $client = WSOpen(); +function WSProcessList() +{ + $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId); - - $result = $client->__soapCall("ProcessList", array($params)); + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId); - $rows = array(); - $i = 0; - - if (isset($result->processes)) { - //Processing when it is an array - if (is_array($result->processes)) { - foreach ($result->processes as $key => $obj) { - $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); - $i = $i + 1; - } + $result = $client->__soapCall("ProcessList", array($params)); + + $rows = array(); + $i = 0; + + if (isset($result->processes)) { + //Processing when it is an array + if (is_array($result->processes)) { + foreach ($result->processes as $key => $obj) { + $rows[$i] = array("guid" => $obj->guid, "name" => $obj->name); + $i = $i + 1; + } + } else { + //Processing when it is an object //1 row + if (is_object($result->processes)) { + $rows[$i] = array("guid" => $result->processes->guid, "name" => $result->processes->name); + $i = $i + 1; + } + } } - else { - //Processing when it is an object //1 row - if (is_object($result->processes)) { - $rows[$i] = array("guid" => $result->processes->guid, "name" => $result->processes->name); - $i = $i + 1; - } - } - } - - return $rows; + + return $rows; } /** * @method @@ -764,10 +777,10 @@ function WSProcessList() { * */ //private function to get current email configuration -function getEmailConfiguration() +function getEmailConfiguration() { - G::loadClass('system'); - return System::getEmailConfiguration(); + G::loadClass('system'); + return System::getEmailConfiguration(); } /** @@ -791,19 +804,19 @@ function getEmailConfiguration() * @return int | $result | result | Result of sending email * */ -//@param array | $aFields=array() | An associative array optional | Optional parameter. An associative array where the keys are the variable name and the values are the variable's value. -function PMFSendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $aFields = array(), $aAttachment = array()) { +//@param array | $aFields=array() | An associative array optional | Optional parameter. An associative array where the keys are the variable name and the values are the variable's value. +function PMFSendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $aFields=array(), $aAttachment=array()) +{ - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->sendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $aFields, $aAttachment); + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->sendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplate, $aFields, $aAttachment); - if ( $result->status_code == 0) { - return 1; - } - else { - return 0; - } + if ( $result->status_code == 0) { + return 1; + } else { + return 0; + } } /** * @method @@ -823,30 +836,31 @@ function PMFSendMessage($caseId, $sFrom, $sTo, $sCc, $sBcc, $sSubject, $sTemplat * @return array | $fields | WS Response Associative Array: | The function returns a WS Response associative array. * */ -function WSSendVariables($caseId, $name1, $value1, $name2, $value2) { - $client = WSOpen(); - - $sessionId = $_SESSION["WS_SESSION_ID"]; +function WSSendVariables($caseId, $name1, $value1, $name2, $value2) +{ + $client = WSOpen(); - $v1 = new stdClass(); - $v1->name = $name1; - $v1->value = $value1; - - $v2 = new stdClass(); - $v2->name = $name2; - $v2->value = $value2; - - $variables = array($v1, $v2); - - $params = array("sessionId" => $sessionId, "caseId" => $caseId, "variables" => $variables); - - $result = $client->__soapCall("SendVariables", array($params)); + $sessionId = $_SESSION["WS_SESSION_ID"]; - $fields["status_code"] = $result->status_code; - $fields["message"] = $result->message; - $fields["time_stamp"] = $result->timestamp; - - return $fields; + $v1 = new stdClass(); + $v1->name = $name1; + $v1->value = $value1; + + $v2 = new stdClass(); + $v2->name = $name2; + $v2->value = $value2; + + $variables = array($v1, $v2); + + $params = array("sessionId" => $sessionId, "caseId" => $caseId, "variables" => $variables); + + $result = $client->__soapCall("SendVariables", array($params)); + + $fields["status_code"] = $result->status_code; + $fields["message"] = $result->message; + $fields["time_stamp"] = $result->timestamp; + + return $fields; } /** * @method @@ -863,20 +877,21 @@ function WSSendVariables($caseId, $name1, $value1, $name2, $value2) { * @return array | $fields | WS Response Associative Array | A WS Response associative array. * */ -function WSDerivateCase($caseId, $delIndex) { - $client = WSOpen(); - - $sessionId = $_SESSION["WS_SESSION_ID"]; +function WSDerivateCase($caseId, $delIndex) +{ + $client = WSOpen(); - $params = array("sessionId" => $sessionId, "caseId" => $caseId, "delIndex" => $delIndex); - - $result = $client->__soapCall("DerivateCase", array($params)); + $sessionId = $_SESSION["WS_SESSION_ID"]; - $fields["status_code"] = $result->status_code; - $fields["message"] = $result->message; - $fields["time_stamp"] = $result->timestamp; - - return $fields; + $params = array("sessionId" => $sessionId, "caseId" => $caseId, "delIndex" => $delIndex); + + $result = $client->__soapCall("DerivateCase", array($params)); + + $fields["status_code"] = $result->status_code; + $fields["message"] = $result->message; + $fields["time_stamp"] = $result->timestamp; + + return $fields; } /** * @method @@ -896,32 +911,36 @@ function WSDerivateCase($caseId, $delIndex) { * @return array | $fields | WS Response Associative Array | A WS Response associative array. * */ -function WSNewCaseImpersonate($processId, $userId, $name1, $value1, $name2, $value2) { - $client = WSOpen(); - - $sessionId = $_SESSION["WS_SESSION_ID"]; +function WSNewCaseImpersonate($processId, $userId, $name1, $value1, $name2, $value2) +{ + $client = WSOpen(); - $v1 = new stdClass(); - $v1->name = $name1; - $v1->value = $value1; - - $v2 = new stdClass(); - $v2->name = $name2; - $v2->value = $value2; - - $variables = array($v1, $v2); + $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId, "processId" => $processId, "userId" => $userId, "variables" => $variables); - - $result = $client->__soapCall("NewCaseImpersonate", array($params)); + $v1 = new stdClass(); + $v1->name = $name1; + $v1->value = $value1; - $fields["status_code"] = $result->status_code; - $fields["message"] = $result->message; - $fields["time_stamp"] = $result->timestamp; - $fields["case_id"] = $result->caseId; - $fields["case_number"] = $result->caseNumber; + $v2 = new stdClass(); + $v2->name = $name2; + $v2->value = $value2; - return $fields; + $variables = array($v1, $v2); + + $params = array("sessionId" => $sessionId, + "processId" => $processId, + "userId" => $userId, + "variables" => $variables); + + $result = $client->__soapCall("NewCaseImpersonate", array($params)); + + $fields["status_code"] = $result->status_code; + $fields["message"] = $result->message; + $fields["time_stamp"] = $result->timestamp; + $fields["case_id"] = $result->caseId; + $fields["case_number"] = $result->caseNumber; + + return $fields; } /** * @method @@ -942,31 +961,35 @@ function WSNewCaseImpersonate($processId, $userId, $name1, $value1, $name2, $val * @return array | $fields | WS array | A WS Response associative array. * */ -function WSNewCase($processId, $taskId, $name1, $value1, $name2, $value2) { - $client = WSOpen(); - $sessionId = $_SESSION["WS_SESSION_ID"]; +function WSNewCase($processId, $taskId, $name1, $value1, $name2, $value2) +{ + $client = WSOpen(); + $sessionId = $_SESSION["WS_SESSION_ID"]; - $v1 = new stdClass(); - $v1->name = $name1; - $v1->value = $value1; - - $v2 = new stdClass(); - $v2->name = $name2; - $v2->value = $value2; - - $variables = array($v1, $v2); + $v1 = new stdClass(); + $v1->name = $name1; + $v1->value = $value1; - $params = array("sessionId" => $sessionId, "processId" => $processId, "taskId" => $taskId, "variables" => $variables); - - $result = $client->__soapCall("NewCase", array($params)); + $v2 = new stdClass(); + $v2->name = $name2; + $v2->value = $value2; - $fields["status_code"] = $result->status_code; - $fields["message"] = $result->message; - $fields["time_stamp"] = $result->timestamp; - $fields["case_id"] = $result->caseId; - $fields["case_number"] = $result->caseNumber; - - return $fields; + $variables = array($v1, $v2); + + $params = array("sessionId" => $sessionId, + "processId" => $processId, + "taskId" => $taskId, + "variables" => $variables); + + $result = $client->__soapCall("NewCase", array($params)); + + $fields["status_code"] = $result->status_code; + $fields["message"] = $result->message; + $fields["time_stamp"] = $result->timestamp; + $fields["case_id"] = $result->caseId; + $fields["case_number"] = $result->caseNumber; + + return $fields; } /** * @method @@ -983,20 +1006,21 @@ function WSNewCase($processId, $taskId, $name1, $value1, $name2, $value2) { * @return array | $fields | WS array |A WS Response associative array. * */ -function WSAssignUserToGroup($userId, $groupId) { - $client = WSOpen(); - - $sessionId = $_SESSION["WS_SESSION_ID"]; +function WSAssignUserToGroup($userId, $groupId) +{ + $client = WSOpen(); - $params = array("sessionId" => $sessionId, "userId" => $userId, "groupId" => $groupId); - - $result = $client->__soapCall("AssignUserToGroup", array($params)); + $sessionId = $_SESSION["WS_SESSION_ID"]; - $fields["status_code"] = $result->status_code; - $fields["message"] = $result->message; - $fields["time_stamp"] = $result->timestamp; - - return $fields; + $params = array("sessionId" => $sessionId, "userId" => $userId, "groupId" => $groupId); + + $result = $client->__soapCall("AssignUserToGroup", array($params)); + + $fields["status_code"] = $result->status_code; + $fields["message"] = $result->message; + $fields["time_stamp"] = $result->timestamp; + + return $fields; } /** * @method @@ -1016,19 +1040,26 @@ function WSAssignUserToGroup($userId, $groupId) { * @return array | $fields | WS array | A WS Response associative array. * */ -function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role) { - $client = WSOpen(); - - $sessionId = $_SESSION["WS_SESSION_ID"]; - $params = array("sessionId" => $sessionId, "userId" => $userId, "firstname" => $firstname, "lastname" => $lastname, "email" => $email, "role" => $role, "password" => $password); - - $result = $client->__soapCall("CreateUser", array($params)); +function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role) +{ + $client = WSOpen(); - $fields["status_code"] = $result->status_code; - $fields["message"] = $result->message; - $fields["time_stamp"] = $result->timestamp; - - return $fields; + $sessionId = $_SESSION["WS_SESSION_ID"]; + $params = array("sessionId" => $sessionId, + "userId" => $userId, + "firstname" => $firstname, + "lastname" => $lastname, + "email" => $email, + "role" => $role, + "password" => $password); + + $result = $client->__soapCall("CreateUser", array($params)); + + $fields["status_code"] = $result->status_code; + $fields["message"] = $result->message; + $fields["time_stamp"] = $result->timestamp; + + return $fields; } /** * @method @@ -1042,16 +1073,16 @@ function WSCreateUser($userId, $password, $firstname, $lastname, $email, $role) * @return string | $userId | Sesion ID | The unique ID for the current active session. * */ -function WSGetSession() { - if (isset($_SESSION["WS_SESSION_ID"])) { - return $_SESSION["WS_SESSION_ID"]; - } - else { - throw new Exception("SW session is not open!"); - } +function WSGetSession() +{ + if (isset($_SESSION["WS_SESSION_ID"])) { + return $_SESSION["WS_SESSION_ID"]; + } else { + throw new Exception("SW session is not open!"); + } } -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** Local Services Functions **/ @@ -1070,17 +1101,17 @@ function WSGetSession() { */ function PMFTaskCase($caseId) #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->taskCase($caseId); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->taskCase($caseId); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** * @method @@ -1097,17 +1128,17 @@ function PMFTaskCase($caseId) #its test was successfull */ function PMFTaskList($userId) #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->taskList($userId); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->taskList($userId); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** * @method @@ -1123,17 +1154,17 @@ function PMFTaskList($userId) #its test was successfull */ function PMFUserList() #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->userList(); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->userList(); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** * @method @@ -1147,215 +1178,236 @@ function PMFUserList() #its test was successfull * @return none | $none | None | None * */ -function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = null, $sUserLogged = null) { - if(!$sApplication){ - $sApplication = $_SESSION['APPLICATION']; - } - if(!$index){ - $index = $_SESSION['INDEX']; - } - if(!$sUserLogged){ - $sUserLogged = $_SESSION['USER_LOGGED']; - } - - G::LoadClass('case'); - $oCase = new Cases(); - $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'cases_List'); - - //require_once 'classes/model/OutputDocument.php'; - $oOutputDocument = new OutputDocument(); - $aOD = $oOutputDocument->load($outputID); - $Fields = $oCase->loadCase( $sApplication ); - //The $_GET['UID'] variable is used when a process executes. - //$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; - //$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; - $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); - require_once 'classes/model/AppFolder.php'; - require_once 'classes/model/AppDocument.php'; - - //Get the Custom Folder ID (create if necessary) - $oFolder=new AppFolder(); - //$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH']; - $folderId=$oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication); - //Tags - $fileTags=$oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication); - - //Get last Document Version and apply versioning if is enabled - $oAppDocument= new AppDocument(); - $lastDocVersion=$oAppDocument->getLastDocVersion($outputID, $sApplication); - - $oCriteria = new Criteria('workflow'); - $oCriteria->add(AppDocumentPeer::APP_UID, $sApplication); - //$oCriteria->add(AppDocumentPeer::DEL_INDEX, $index); - $oCriteria->add(AppDocumentPeer::DOC_UID, $outputID); - $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion); - $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); - $oDataset = AppDocumentPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - - if(($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)){//Create new Version of current output - $lastDocVersion++; - if ($aRow = $oDataset->getRow()) { - $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], - 'APP_UID' => $sApplication, - 'DEL_INDEX' => $index, - 'DOC_UID' => $outputID, - 'DOC_VERSION' => $lastDocVersion+1, - 'USR_UID' => $sUserLogged, - 'APP_DOC_TYPE' => 'OUTPUT', - 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), - 'APP_DOC_FILENAME' => $sFilename, - 'FOLDER_UID' => $folderId, - 'APP_DOC_TAGS' => $fileTags); - $oAppDocument = new AppDocument(); - $oAppDocument->create($aFields); - $sDocUID = $aRow['APP_DOC_UID']; +function PMFGenerateOutputDocument($outputID, $sApplication=null, $index=null, $sUserLogged=null) +{ + if (!$sApplication) { + $sApplication = $_SESSION['APPLICATION']; } - }else{//No versioning so Update a current Output or Create new if no exist - if ($aRow = $oDataset->getRow()) { //Update - $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], - 'APP_UID' => $sApplication, - 'DEL_INDEX' => $index, - 'DOC_UID' => $outputID, - 'DOC_VERSION' => $lastDocVersion, - 'USR_UID' => $sUserLogged, - 'APP_DOC_TYPE' => 'OUTPUT', - 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), - 'APP_DOC_FILENAME' => $sFilename, - 'FOLDER_UID' => $folderId, - 'APP_DOC_TAGS' => $fileTags); - $oAppDocument = new AppDocument(); - $oAppDocument->update($aFields); - $sDocUID = $aRow['APP_DOC_UID']; - }else{ - //we are creating the appdocument row - //create - if($lastDocVersion==0) $lastDocVersion++; - $aFields = array('APP_UID' => $sApplication, - 'DEL_INDEX' => $index, - 'DOC_UID' => $outputID, - 'DOC_VERSION' => $lastDocVersion, - 'USR_UID' => $sUserLogged, - 'APP_DOC_TYPE' => 'OUTPUT', - 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), - 'APP_DOC_FILENAME' => $sFilename, - 'FOLDER_UID' => $folderId, - 'APP_DOC_TAGS' => $fileTags); - $oAppDocument = new AppDocument(); - $aFields['APP_DOC_UID']=$sDocUID = $oAppDocument->create($aFields); + if (!$index) { + $index = $_SESSION['INDEX']; + } + if (!$sUserLogged) { + $sUserLogged = $_SESSION['USER_LOGGED']; } - } - $sFilename = $aFields['APP_DOC_UID']. "_".$lastDocVersion; - $pathOutput = PATH_DOCUMENT . $sApplication . PATH_SEP . 'outdocs'. PATH_SEP ;//G::pr($sFilename);die; - G::mk_dir ( $pathOutput ); + G::LoadClass('case'); + $oCase = new Cases(); + $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'cases_List'); - $aProperties = array(); + //require_once 'classes/model/OutputDocument.php'; + $oOutputDocument = new OutputDocument(); + $aOD = $oOutputDocument->load($outputID); + $Fields = $oCase->loadCase( $sApplication ); + //The $_GET['UID'] variable is used when a process executes. + //$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; + //$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; + $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); + require_once 'classes/model/AppFolder.php'; + require_once 'classes/model/AppDocument.php'; - if(!isset($aOD['OUT_DOC_MEDIA'])) - $aOD['OUT_DOC_MEDIA'] = 'Letter'; - if(!isset($aOD['OUT_DOC_LEFT_MARGIN'])) - $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; - if(!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) - $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; - if(!isset($aOD['OUT_DOC_TOP_MARGIN'])) - $aOD['OUT_DOC_TOP_MARGIN'] = '15'; - if(!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) - $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; + //Get the Custom Folder ID (create if necessary) + $oFolder=new AppFolder(); + //$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT + // . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH']; + $folderId=$oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication); + //Tags + $fileTags=$oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication); - $aProperties['media']=$aOD['OUT_DOC_MEDIA']; - $aProperties['margins']=array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'],); - $oOutputDocument->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'] ); + //Get last Document Version and apply versioning if is enabled + $oAppDocument= new AppDocument(); + $lastDocVersion=$oAppDocument->getLastDocVersion($outputID, $sApplication); - //Plugin Hook PM_UPLOAD_DOCUMENT for upload document - //G::LoadClass('plugin'); - $oPluginRegistry =& PMPluginRegistry::getSingleton(); - if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) { - $triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); - $aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace; + $oCriteria = new Criteria('workflow'); + $oCriteria->add(AppDocumentPeer::APP_UID, $sApplication); + //$oCriteria->add(AppDocumentPeer::DEL_INDEX, $index); + $oCriteria->add(AppDocumentPeer::DOC_UID, $outputID); + $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion); + $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); + $oDataset = AppDocumentPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); - $oAppDocument1 = new AppDocument(); - $oAppDocument1->update($aFields); + if (($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)) { + //Create new Version of current output + $lastDocVersion++; + if ($aRow = $oDataset->getRow()) { + $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], + 'APP_UID' => $sApplication, + 'DEL_INDEX' => $index, + 'DOC_UID' => $outputID, + 'DOC_VERSION' => $lastDocVersion+1, + 'USR_UID' => $sUserLogged, + 'APP_DOC_TYPE' => 'OUTPUT', + 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), + 'APP_DOC_FILENAME' => $sFilename, + 'FOLDER_UID' => $folderId, + 'APP_DOC_TAGS' => $fileTags); + $oAppDocument = new AppDocument(); + $oAppDocument->create($aFields); + $sDocUID = $aRow['APP_DOC_UID']; + } + } else { + ////No versioning so Update a current Output or Create new if no exist + if ($aRow = $oDataset->getRow()) { + //Update + $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], + 'APP_UID' => $sApplication, + 'DEL_INDEX' => $index, + 'DOC_UID' => $outputID, + 'DOC_VERSION' => $lastDocVersion, + 'USR_UID' => $sUserLogged, + 'APP_DOC_TYPE' => 'OUTPUT', + 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), + 'APP_DOC_FILENAME' => $sFilename, + 'FOLDER_UID' => $folderId, + 'APP_DOC_TAGS' => $fileTags); + $oAppDocument = new AppDocument(); + $oAppDocument->update($aFields); + $sDocUID = $aRow['APP_DOC_UID']; + } else { + //we are creating the appdocument row + //create + if ($lastDocVersion==0) { + $lastDocVersion++; + } + $aFields = array('APP_UID' => $sApplication, + 'DEL_INDEX' => $index, + 'DOC_UID' => $outputID, + 'DOC_VERSION' => $lastDocVersion, + 'USR_UID' => $sUserLogged, + 'APP_DOC_TYPE' => 'OUTPUT', + 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), + 'APP_DOC_FILENAME' => $sFilename, + 'FOLDER_UID' => $folderId, + 'APP_DOC_TAGS' => $fileTags); + $oAppDocument = new AppDocument(); + $aFields['APP_DOC_UID']=$sDocUID = $oAppDocument->create($aFields); + } + } + $sFilename = $aFields['APP_DOC_UID']. "_".$lastDocVersion; - $sPathName = PATH_DOCUMENT . $sApplication . PATH_SEP; + $pathOutput = PATH_DOCUMENT . $sApplication . PATH_SEP . 'outdocs'. PATH_SEP ;//G::pr($sFilename);die; + G::mk_dir ( $pathOutput ); - $oData['APP_UID'] = $sApplication; - $oData['ATTACHMENT_FOLDER'] = true; - switch($aOD['OUT_DOC_GENERATE']){ - case "BOTH": - $documentData = new uploadDocumentData ( + $aProperties = array(); + + if (!isset($aOD['OUT_DOC_MEDIA'])) { + $aOD['OUT_DOC_MEDIA'] = 'Letter'; + } + if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) { + $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; + } + if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) { + $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; + } + if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { + $aOD['OUT_DOC_TOP_MARGIN'] = '15'; + } + if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) { + $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; + } + + + $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; + $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], + 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], + 'top' => $aOD['OUT_DOC_TOP_MARGIN'], + 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']); + $oOutputDocument->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], + (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'] ); + + //Plugin Hook PM_UPLOAD_DOCUMENT for upload document + //G::LoadClass('plugin'); + $oPluginRegistry =& PMPluginRegistry::getSingleton(); + if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) { + $triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); + $aFields['APP_DOC_PLUGIN']=$triggerDetail->sNamespace; + + $oAppDocument1 = new AppDocument(); + $oAppDocument1->update($aFields); + + $sPathName = PATH_DOCUMENT . $sApplication . PATH_SEP; + + $oData['APP_UID'] = $sApplication; + $oData['ATTACHMENT_FOLDER'] = true; + switch ($aOD['OUT_DOC_GENERATE']) { + case "BOTH": + $documentData = new uploadDocumentData ( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename. '.pdf', $sDocUID, $oAppDocument->getDocVersion() - ); + ); - $documentData->sFileType = "PDF"; - $documentData->bUseOutputFolder = true; - $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); - if($uploadReturn){//Only delete if the file was saved correctly - unlink ( $pathOutput . $sFilename. '.pdf' ); - } + $documentData->sFileType = "PDF"; + $documentData->bUseOutputFolder = true; + $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink ( $pathOutput . $sFilename. '.pdf' ); + } - $documentData = new uploadDocumentData ( + $documentData = new uploadDocumentData ( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename. '.doc', $sDocUID, $oAppDocument->getDocVersion() - ); + ); - $documentData->sFileType = "DOC"; - $documentData->bUseOutputFolder = true; - $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); - if($uploadReturn){//Only delete if the file was saved correctly - unlink ( $pathOutput . $sFilename. '.doc' ); - } + $documentData->sFileType = "DOC"; + $documentData->bUseOutputFolder = true; + $uploadReturn = $oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink ( $pathOutput . $sFilename. '.doc' ); + } - break; - case "PDF": - $documentData = new uploadDocumentData ( + break; + case "PDF": + $documentData = new uploadDocumentData ( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename. '.pdf', $sDocUID, $oAppDocument->getDocVersion() - ); + ); - $documentData->sFileType = "PDF"; - $documentData->bUseOutputFolder = true; - $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); - if($uploadReturn){//Only delete if the file was saved correctly - unlink ( $pathOutput . $sFilename. '.pdf' ); - } - break; - case "DOC": - $documentData = new uploadDocumentData ( + $documentData->sFileType = "PDF"; + $documentData->bUseOutputFolder = true; + $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink ( $pathOutput . $sFilename. '.pdf' ); + } + break; + case "DOC": + $documentData = new uploadDocumentData ( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename. '.doc', $sDocUID, $oAppDocument->getDocVersion() - ); + ); - $documentData->sFileType = "DOC"; - $documentData->bUseOutputFolder = true; - $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); - if($uploadReturn){//Only delete if the file was saved correctly - unlink ( $pathOutput . $sFilename. '.doc' ); - } - break; + $documentData->sFileType = "DOC"; + $documentData->bUseOutputFolder = true; + $uploadReturn=$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData ); + if ($uploadReturn) { + //Only delete if the file was saved correctly + unlink ( $pathOutput . $sFilename. '.doc' ); + } + break; + } } - } } /** * @method @@ -1371,17 +1423,17 @@ function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = nul */ function PMFGroupList() #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->groupList(); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->groupList(); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** @@ -1398,17 +1450,17 @@ function PMFGroupList() #its test was successfull */ function PMFRoleList() #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->roleList(); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->roleList(); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** * @method @@ -1425,17 +1477,17 @@ function PMFRoleList() #its test was successfull */ function PMFCaseList($userId) #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->caseList($userId); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->caseList($userId); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** * @method @@ -1451,17 +1503,17 @@ function PMFCaseList($userId) #its test was successfull */ function PMFProcessList() #its test was successfull { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->processList(); - $rows = Array(); - $i = 1; - if(isset ($result)) { - foreach ( $result as $item) { - $rows[$i++] = $item; + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->processList(); + $rows = Array(); + $i = 1; + if (isset ($result)) { + foreach ($result as $item) { + $rows[$i++] = $item; + } } - } - return $rows; + return $rows; } /** @@ -1478,16 +1530,17 @@ function PMFProcessList() #its test was successfull * @return int | $result | Result of send variables | Returns 1 if the variables were sent successfully to the case; otherwise, returns 0 if an error occurred. * */ -function PMFSendVariables($caseId, $variables) { - G::LoadClass('wsBase'); - $ws = new wsBase (); +function PMFSendVariables($caseId, $variables) +{ + G::LoadClass('wsBase'); + $ws = new wsBase (); - $result = $ws->sendVariables($caseId, $variables); - if($result->status_code == 0) { - return 1; - } else { - return 0; - } + $result = $ws->sendVariables($caseId, $variables); + if ($result->status_code == 0) { + return 1; + } else { + return 0; + } } /** * @method @@ -1505,24 +1558,24 @@ function PMFSendVariables($caseId, $variables) { * @return int | $result | Result of Derivate case | Returns 1 if new case was derivated (routed) successfully; otherwise, returns 0 if an error occurred. * */ -function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $sUserLogged = null) { - if(!$sUserLogged) { - $sUserLogged = $_SESSION['USER_LOGGED']; - } - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->derivateCase($sUserLogged, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment);//var_dump($result);die; - if (isset($result->status_code)) { - return $result->status_code; - } - else { - return 0; - } - if($result->status_code == 0) { - return 1; - } else { - return 0; - } +function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment=false, $sUserLogged=null) +{ + if (!$sUserLogged) { + $sUserLogged = $_SESSION['USER_LOGGED']; + } + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->derivateCase($sUserLogged, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment); + if (isset($result->status_code)) { + return $result->status_code; + } else { + return 0; + } + if ($result->status_code == 0) { + return 1; + } else { + return 0; + } } /** * @method @@ -1540,18 +1593,18 @@ function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = * @return int | $result | Result | Returns 1 if new case was created successfully; otherwise, returns 0 if an error occurred. * */ -function PMFNewCaseImpersonate($processId, $userId, $variables) { - G::LoadClass("wsBase"); - - $ws = new wsBase(); - $result = $ws->newCaseImpersonate($processId, $userId, $variables); +function PMFNewCaseImpersonate($processId, $userId, $variables) +{ + G::LoadClass("wsBase"); - if ($result->status_code == 0) { - return $result->caseId; - } - else { - return 0; - } + $ws = new wsBase(); + $result = $ws->newCaseImpersonate($processId, $userId, $variables); + + if ($result->status_code == 0) { + return $result->caseId; + } else { + return 0; + } } /** * @method @@ -1569,17 +1622,18 @@ function PMFNewCaseImpersonate($processId, $userId, $variables) { * @return string | $idNewCase | Case ID | If an error occured, it returns the integer zero. Otherwise, it returns a string with the case UID of the new case. * */ -function PMFNewCase($processId, $userId, $taskId, $variables) { - G::LoadClass('wsBase'); - $ws = new wsBase (); +function PMFNewCase($processId, $userId, $taskId, $variables) +{ + G::LoadClass('wsBase'); + $ws = new wsBase (); - $result = $ws->newCase($processId, $userId,$taskId, $variables); + $result = $ws->newCase($processId, $userId,$taskId, $variables); - if($result->status_code == 0) { - return $result->caseId; - } else { - return 0; - } + if ($result->status_code == 0) { + return $result->caseId; + } else { + return 0; + } } /** * @method @@ -1595,16 +1649,17 @@ function PMFNewCase($processId, $userId, $taskId, $variables) { * @return int | $result | Result of the assignment | Returns 1 if the user was successfully assigned to the group; otherwise, returns 0. * */ -function PMFAssignUserToGroup($userId, $groupId) { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->assignUserToGroup($userId, $groupId); +function PMFAssignUserToGroup($userId, $groupId) +{ + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->assignUserToGroup($userId, $groupId); - if($result->status_code == 0) { - return 1; - } else { - return 0; - } + if ($result->status_code == 0) { + return 1; + } else { + return 0; + } } /** * @method @@ -1624,16 +1679,17 @@ function PMFAssignUserToGroup($userId, $groupId) { * @return int | $result | Result of the creation | Returns 1 if the new user was created successfully; otherwise, returns 0 if an error occurred. * */ -function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role) { - G::LoadClass('wsBase'); - $ws = new wsBase (); - $result = $ws->createUser($userId, $firstname, $lastname, $email, $role, $password); +function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role) +{ + G::LoadClass('wsBase'); + $ws = new wsBase (); + $result = $ws->createUser($userId, $firstname, $lastname, $email, $role, $password); - if($result->status_code == 0) { - return 1; - } else { - return 0; - } + if ($result->status_code == 0) { + return 1; + } else { + return 0; + } } /** * @method @@ -1650,8 +1706,9 @@ function PMFCreateUser($userId, $password, $firstname, $lastname, $email, $role) * @return string | $generateString | Generated string | The generated string of random characters. * */ -function generateCode ( $iDigits = 4, $sType = 'NUMERIC' ) { - return G::generateCode ($iDigits, $sType ); +function generateCode($iDigits=4, $sType='NUMERIC') +{ + return G::generateCode ($iDigits, $sType ); } /** @@ -1669,22 +1726,22 @@ function generateCode ( $iDigits = 4, $sType = 'NUMERIC' ) { * @return int | $result | Result | If successful, returns zero, otherwise a non-zero error number. * */ -function setCaseTrackerCode($sApplicationUID, $sCode, $sPIN = '') { - if ($sCode != '') { - G::LoadClass('case'); - $oCase = new Cases(); - $aFields = $oCase->loadCase($sApplicationUID); - $aFields['APP_PROC_CODE'] = $sCode; - if ($sPIN != '') { - $aFields['APP_DATA']['PIN'] = $sPIN; - $aFields['APP_PIN'] = md5($sPIN); +function setCaseTrackerCode($sApplicationUID, $sCode, $sPIN='') +{ + if ($sCode != '') { + G::LoadClass('case'); + $oCase = new Cases(); + $aFields = $oCase->loadCase($sApplicationUID); + $aFields['APP_PROC_CODE'] = $sCode; + if ($sPIN != '') { + $aFields['APP_DATA']['PIN'] = $sPIN; + $aFields['APP_PIN'] = md5($sPIN); + } + $oCase->updateCase($sApplicationUID, $aFields); + return 1; + } else { + return 0; } - $oCase->updateCase($sApplicationUID, $aFields); - return 1; - } - else { - return 0; - } } /** * @method @@ -1700,15 +1757,17 @@ function setCaseTrackerCode($sApplicationUID, $sCode, $sPIN = '') { * @return none | $none | None | None * */ -function jumping ( $caseId, $delIndex ) { - try { - $x = PMFDerivateCase($caseId, $delIndex); - if($x==0) - G::SendTemporalMessage('ID_NOT_DERIVATED', 'error', 'labels'); - } catch (Exception $oException) { - G::SendTemporalMessage('ID_NOT_DERIVATED', 'error', 'labels'); - } - G::header('Location: cases_List'); +function jumping ($caseId, $delIndex) +{ + try { + $x = PMFDerivateCase($caseId, $delIndex); + if ($x == 0) { + G::SendTemporalMessage('ID_NOT_DERIVATED', 'error', 'labels'); + } + } catch (Exception $oException) { + G::SendTemporalMessage('ID_NOT_DERIVATED', 'error', 'labels'); + } + G::header('Location: cases_List'); } /** * @method @@ -1727,13 +1786,14 @@ function jumping ( $caseId, $delIndex ) { * @return string | $label | Label of the specified option | A string holding the label of the specified option or NULL if the specified option does not exist. * */ -function PMFgetLabelOption($PROCESS, $DYNAFORM_UID, $FIELD_NAME, $FIELD_SELECTED_ID) { - $G_FORM = new Form ("{$PROCESS}/{$DYNAFORM_UID}", PATH_DYNAFORM, SYS_LANG, false); - if( isset($G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID]) ) { - return $G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID]; - } else { - return null; - } +function PMFgetLabelOption($PROCESS, $DYNAFORM_UID, $FIELD_NAME, $FIELD_SELECTED_ID) +{ + $G_FORM = new Form ("{$PROCESS}/{$DYNAFORM_UID}", PATH_DYNAFORM, SYS_LANG, false); + if ( isset($G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID]) ) { + return $G_FORM->fields[$FIELD_NAME]->option[$FIELD_SELECTED_ID]; + } else { + return null; + } } /** * @method @@ -1753,60 +1813,62 @@ function PMFgetLabelOption($PROCESS, $DYNAFORM_UID, $FIELD_NAME, $FIELD_SELECTED * @return none | $none | None | None * */ -function PMFRedirectToStep($sApplicationUID, $iDelegation, $sStepType, $sStepUid) { - $iDelegation = intval($iDelegation); - require_once 'classes/model/AppDelegation.php'; - $oCriteria = new Criteria('workflow'); - $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID); - $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); - $oCriteria->add(AppDelegationPeer::DEL_INDEX, $iDelegation); - $oDataset = AppDelegationPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - global $oPMScript; - $aRow = $oDataset->getRow(); - if ($aRow) { - require_once 'classes/model/Step.php'; - $oStep = new Step(); - $oTheStep = $oStep->loadByType($aRow['TAS_UID'], $sStepType, $sStepUid); - $bContinue = true; - G::LoadClass('case'); - $oCase = new Cases(); - $aFields = $oCase->loadCase($sApplicationUID); - if ($oTheStep->getStepCondition() != '') { - G::LoadClass('pmScript'); - $pmScript = new PMScript(); - $pmScript->setFields($aFields['APP_DATA']); - $pmScript->setScript($oTheStep->getStepCondition()); - $bContinue = $pmScript->evaluate(); +function PMFRedirectToStep($sApplicationUID, $iDelegation, $sStepType, $sStepUid) +{ + $iDelegation = intval($iDelegation); + require_once 'classes/model/AppDelegation.php'; + $oCriteria = new Criteria('workflow'); + $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID); + $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); + $oCriteria->add(AppDelegationPeer::DEL_INDEX, $iDelegation); + $oDataset = AppDelegationPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset->next(); + global $oPMScript; + $aRow = $oDataset->getRow(); + if ($aRow) { + require_once 'classes/model/Step.php'; + $oStep = new Step(); + $oTheStep = $oStep->loadByType($aRow['TAS_UID'], $sStepType, $sStepUid); + $bContinue = true; + G::LoadClass('case'); + $oCase = new Cases(); + $aFields = $oCase->loadCase($sApplicationUID); + if ($oTheStep->getStepCondition() != '') { + G::LoadClass('pmScript'); + $pmScript = new PMScript(); + $pmScript->setFields($aFields['APP_DATA']); + $pmScript->setScript($oTheStep->getStepCondition()); + $bContinue = $pmScript->evaluate(); + } + if ($bContinue) { + switch ($oTheStep->getStepTypeObj()) { + case 'DYNAFORM': + $sAction = 'EDIT'; + break; + case 'OUTPUT_DOCUMENT': + $sAction = 'GENERATE'; + break; + case 'INPUT_DOCUMENT': + $sAction = 'ATTACH'; + break; + case 'EXTERNAL': + $sAction = 'EDIT'; + break; + case 'MESSAGE': + $sAction = ''; + break; + } + // save data + if (!is_null($oPMScript)) { + $aFields['APP_DATA'] = $oPMScript->aFields; + $oCase->updateCase($sApplicationUID,$aFields); + } + G::header('Location: ' . 'cases_Step?TYPE=' . $sStepType . '&UID=' . $sStepUid + . '&POSITION=' . $oTheStep->getStepPosition() . '&ACTION=' . $sAction); + die; + } } - if ($bContinue) { - switch ($oTheStep->getStepTypeObj()) { - case 'DYNAFORM': - $sAction = 'EDIT'; - break; - case 'OUTPUT_DOCUMENT': - $sAction = 'GENERATE'; - break; - case 'INPUT_DOCUMENT': - $sAction = 'ATTACH'; - break; - case 'EXTERNAL': - $sAction = 'EDIT'; - break; - case 'MESSAGE': - $sAction = ''; - break; - } - // save data - if (!is_null($oPMScript)) { - $aFields['APP_DATA'] = $oPMScript->aFields; - $oCase->updateCase($sApplicationUID,$aFields); - } - G::header('Location: ' . 'cases_Step?TYPE=' . $sStepType . '&UID=' . $sStepUid . '&POSITION=' . $oTheStep->getStepPosition() . '&ACTION=' . $sAction); - die; - } - } } /** @@ -1822,51 +1884,51 @@ function PMFRedirectToStep($sApplicationUID, $iDelegation, $sStepType, $sStepUid * @return array | $array | List of users | Return a list of users * */ -function PMFGetNextAssignedUser ($application, $task) { +function PMFGetNextAssignedUser ($application, $task) +{ - require_once 'classes/model/AppDelegation.php'; - require_once 'classes/model/Task.php'; - require_once 'classes/model/TaskUser.php'; - require_once 'classes/model/Users.php'; - require_once 'classes/model/Groupwf.php'; - require_once 'classes/model/GroupUser.php'; + require_once 'classes/model/AppDelegation.php'; + require_once 'classes/model/Task.php'; + require_once 'classes/model/TaskUser.php'; + require_once 'classes/model/Users.php'; + require_once 'classes/model/Groupwf.php'; + require_once 'classes/model/GroupUser.php'; - $oTask = new Task(); - $TaskFields = $oTask->load ($task); - $typeTask = $TaskFields ['TAS_ASSIGN_TYPE']; + $oTask = new Task(); + $TaskFields = $oTask->load ($task); + $typeTask = $TaskFields ['TAS_ASSIGN_TYPE']; - if($typeTask == 'BALANCED') - { + if ($typeTask == 'BALANCED') { - G::LoadClass('derivation'); - $oDerivation = new Derivation(); - $aDeriv = $oDerivation->prepareInformation( - array( 'USER_UID' => $_SESSION['USER_LOGGED'], - 'APP_UID' => $application, - 'DEL_INDEX' => $_SESSION['INDEX']) - ); + G::LoadClass('derivation'); + $oDerivation = new Derivation(); + $aDeriv = $oDerivation->prepareInformation( + array( 'USER_UID' => $_SESSION['USER_LOGGED'], + 'APP_UID' => $application, + 'DEL_INDEX' => $_SESSION['INDEX']) + ); - foreach($aDeriv as $derivation){ + foreach ($aDeriv as $derivation) { - $aUser = array( - 'USR_UID' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_UID'], - 'USR_USERNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'], - 'USR_FIRSTNAME'=> $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_FIRSTNAME'], - 'USR_LASTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_LASTNAME'], - 'USR_EMAIL' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_EMAIL'] - ); - $aUsers[] = $aUser; + $aUser = array( + 'USR_UID' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_UID'], + 'USR_USERNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'], + 'USR_FIRSTNAME'=> $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_FIRSTNAME'], + 'USR_LASTNAME' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_LASTNAME'], + 'USR_EMAIL' => $derivation['NEXT_TASK']['USER_ASSIGNED']['USR_EMAIL'] + ); + $aUsers[] = $aUser; + } + + if (count($aUsers) == 1) { + return $aUser; + } else { + return $aUsers; + } + + } else { + return false; } - - if(count($aUsers) == 1) - return $aUser; - else - return $aUsers; - - } else - { - return false; - } } /** @@ -1883,131 +1945,130 @@ function PMFGetNextAssignedUser ($application, $task) { * @return array | $aRecipient | Array of the Recipient | Return an Array of the Recipient * */ -function PMFGetUserEmailAddress($id, $APP_UID = null, $prefix='usr') +function PMFGetUserEmailAddress($id, $APP_UID=null, $prefix='usr') { - require_once 'classes/model/UsersPeer.php'; - require_once 'classes/model/AppDelegation.php'; - G::LoadClass('case'); + require_once 'classes/model/UsersPeer.php'; + require_once 'classes/model/AppDelegation.php'; + G::LoadClass('case'); - if( is_string($id) && trim($id) == "" ){ - return false; - } - if( is_array($id) && count($id) == 0 ){ - return false; - } - - - //recipient to store the email addresses - $aRecipient = Array(); - $aItems = Array(); - - /* - * First at all the $id user input can be by example erik@colosa.com - * 2. this $id param can be a array by example Array('000000000001', '000000000002') in this case $prefix is necessary - * 3. this same param can be a array by example Array('usr|000000000001', 'usr|-1', 'grp|2245141479413131441') - */ - - /* - * The second thing is that the return type will be configurated depend of the input type (using $retType) - */ - if( is_array($id) ){ - $aItems = $id; - $retType = 'array'; - } else { - $retType = 'string'; - if( strpos($id, ",") !== false ){ - $aItems = explode(',', $id); - } else { - array_push($aItems, $id); + if ( is_string($id) && trim($id) == "" ) { + return false; } - } - - foreach ($aItems as $sItem) { - //cleaning for blank spaces into each array item - $sItem = trim($sItem); - if( strpos($sItem, "|") !== false ){ - //explode the parameter because always will be compose with pipe separator to indicate the type (user or group) and the target mai - list($sType, $sID) = explode('|', $sItem); - $sType = trim($sType); - $sID = trim($sID); - } else { - $sType = $prefix; - $sID = $sItem; + if ( is_array($id) && count($id) == 0 ) { + return false; } - switch($sType) { - case 'ext': - if( G::emailAddress($sID) ) { - array_push($aRecipient, $sID); - } - break; - case 'usr': - if ($sID == '-1') { // -1: Cuurent user, load from user record - if( isset($APP_UID) ){ - $oAppDelegation = new AppDelegation; - $aAppDel = $oAppDelegation->getLastDeleration($APP_UID); - if(isset($aAppDel)){ - $oUserRow = UsersPeer::retrieveByPK($aAppDel['USR_UID']); - if( isset($oUserRow) ){ - $sID = $oUserRow->getUsrEmail(); - } else { - throw new Exception('User with ID '.$oAppDelegation->getUsrUid(). 'doesn\'t exist'); - } - if( G::emailAddress($sID) ) { - array_push($aRecipient, $sID); - } - } - } + //recipient to store the email addresses + $aRecipient = Array(); + $aItems = Array(); + + /* + * First at all the $id user input can be by example erik@colosa.com + * 2.this $id param can be a array by example Array('000000000001','000000000002') in this case $prefix is necessary + * 3.this same param can be a array by example Array('usr|000000000001', 'usr|-1', 'grp|2245141479413131441') + */ + + /* + * The second thing is that the return type will be configurated depend of the input type (using $retType) + */ + if ( is_array($id) ) { + $aItems = $id; + $retType = 'array'; + } else { + $retType = 'string'; + if ( strpos($id, ",") !== false ) { + $aItems = explode(',', $id); } else { - $oUserRow = UsersPeer::retrieveByPK($sID); - $sID = $oUserRow->getUsrEmail(); - if( G::emailAddress($sID) ) { - array_push($aRecipient, $sID); - } + array_push($aItems, $id); } - - break; - - case 'grp': - G::LoadClass('groups'); - $oGroups = new Groups(); - $oCriteria = $oGroups->getUsersGroupCriteria($sID); - $oDataset = GroupwfPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - while ($oDataset->next()) { - $aGroup = $oDataset->getRow(); - //to validate email address - if( G::emailAddress($aGroup['USR_EMAIL']) ) { - array_push($aRecipient, $aGroup['USR_EMAIL']); - } - } - - break; - - case 'dyn': - $oCase = new Cases(); - $aFields = $oCase->loadCase($APP_UID); - $aFields['APP_DATA'] = array_merge($aFields['APP_DATA'], G::getSystemConstants()); - - //to validate email address - if( isset($aFields['APP_DATA'][$sID]) && G::emailAddress($aFields['APP_DATA'][$sID]) ) { - array_push($aRecipient, $aFields['APP_DATA'][$sID]); - } - break; } - } - switch($retType){ - case 'array': - return $aRecipient; - - case 'string': - return implode(',', $aRecipient); + foreach ($aItems as $sItem) { + //cleaning for blank spaces into each array item + $sItem = trim($sItem); + if ( strpos($sItem, "|") !== false ) { + // explode the parameter because always will be compose with pipe separator to indicate + // the type (user or group) and the target mai + list($sType, $sID) = explode('|', $sItem); + $sType = trim($sType); + $sID = trim($sID); + } else { + $sType = $prefix; + $sID = $sItem; + } - default: - return $aRecipient; - } + switch ($sType) { + case 'ext': + if ( G::emailAddress($sID) ) { + array_push($aRecipient, $sID); + } + break; + case 'usr': + if ($sID == '-1') { + // -1: Curent user, load from user record + if ( isset($APP_UID) ) { + $oAppDelegation = new AppDelegation; + $aAppDel = $oAppDelegation->getLastDeleration($APP_UID); + if (isset($aAppDel)) { + $oUserRow = UsersPeer::retrieveByPK($aAppDel['USR_UID']); + if ( isset($oUserRow) ) { + $sID = $oUserRow->getUsrEmail(); + } else { + throw new Exception('User with ID '.$oAppDelegation->getUsrUid(). 'doesn\'t exist'); + } + if ( G::emailAddress($sID) ) { + array_push($aRecipient, $sID); + } + } + } + } else { + $oUserRow = UsersPeer::retrieveByPK($sID); + $sID = $oUserRow->getUsrEmail(); + if ( G::emailAddress($sID) ) { + array_push($aRecipient, $sID); + } + } + + break; + case 'grp': + G::LoadClass('groups'); + $oGroups = new Groups(); + $oCriteria = $oGroups->getUsersGroupCriteria($sID); + $oDataset = GroupwfPeer::doSelectRS($oCriteria); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + while ($oDataset->next()) { + $aGroup = $oDataset->getRow(); + //to validate email address + if ( G::emailAddress($aGroup['USR_EMAIL']) ) { + array_push($aRecipient, $aGroup['USR_EMAIL']); + } + } + + break; + case 'dyn': + $oCase = new Cases(); + $aFields = $oCase->loadCase($APP_UID); + $aFields['APP_DATA'] = array_merge($aFields['APP_DATA'], G::getSystemConstants()); + + //to validate email address + if ( isset($aFields['APP_DATA'][$sID]) && G::emailAddress($aFields['APP_DATA'][$sID]) ) { + array_push($aRecipient, $aFields['APP_DATA'][$sID]); + } + break; + } + } + + switch ($retType) { + case 'array': + return $aRecipient; + break; + case 'string': + return implode(',', $aRecipient); + break; + default: + return $aRecipient; + } } /** @@ -2024,9 +2085,10 @@ function PMFGetUserEmailAddress($id, $APP_UID = null, $prefix='usr') * @return array, object or string | $response | Array of the response | Return an Array or Object or String * */ -function PMFGetCaseNotes ($applicationID, $type = 'array', $userUid = '') +function PMFGetCaseNotes ($applicationID, $type='array', $userUid='') { - G::LoadClass('case'); - $response = Cases::getCaseNotes($applicationID, $type, $userUid); - return $response; + G::LoadClass('case'); + $response = Cases::getCaseNotes($applicationID, $type, $userUid); + return $response; } + \ No newline at end of file diff --git a/workflow/engine/templates/triggers/triggers_CreateWizard.php b/workflow/engine/templates/triggers/triggers_CreateWizard.php index edcc46751..3297bf38c 100755 --- a/workflow/engine/templates/triggers/triggers_CreateWizard.php +++ b/workflow/engine/templates/triggers/triggers_CreateWizard.php @@ -1,149 +1,164 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -try { - - G::LoadClass ( 'triggerLibrary' ); - $triggerLibrary = triggerLibrary::getSingleton (); - $libraryClassName = $_GET ['LIBRARY']; - $libraryMethod = $_GET ['NAME_FUN']; - $sProUid = $_GET ['PRO_UID']; - $libraryO = $triggerLibrary->getLibraryDefinition ( $libraryClassName ); - - $libraryName = $libraryO->info ['name']; - $libraryDescription = trim ( str_replace ( "*", "", implode ( " ", $libraryO->info ['description'] ) ) ); - $libraryIcon = isset ( $libraryO->info ['icon'] ) && ($libraryO->info ['icon'] != "") ? $libraryO->info ['icon'] : "/images/browse.gif"; - $aDataTrigger = $_GET; - - $sProUid = $aDataTrigger ['PRO_UID']; - $sNameFun = $aDataTrigger ['NAME_FUN']; - - $methodObject = $libraryO->methods [$sNameFun]; - - $methodName = $methodObject->info ['name']; - $methodLabel = $methodObject->info ['label']; - $methodDescription = trim ( str_replace ( "*", "", implode ( " ", $methodObject->info ['description'] ) ) ); - $methodReturn = $methodObject->info ['return']; - $methodParameters = array_keys ( $methodObject->params ); - $methodLink = isset ( $methodObject->info ['link'] ) && ($methodObject->info ['link'] != "") ? $methodObject->info ['link'] : ""; - $methodreturnA = explode ( "|", $methodReturn ); - - $bReturnValue = true; - $displayMode = 'display:block'; - $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ( 'ID_NONE')) )? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3]; - $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; - if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { - $methodReturnLabelRequired = (trim( $methodreturnA[1] ) != "" )? G::LoadTranslation ( "ID_REQUIRED_FIELD" ) : $methodreturnA[1]; - $methodReturnLabel .= "
" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]); - } - else { - $bReturnValue = false; - $displayMode = 'display:none'; - } - $aParametersFun = $methodParameters; - $triggerWizardTemplate = PATH_TPL . 'triggers' . PATH_SEP . 'triggers_CreateWizard.html'; - $template = new TemplatePower ( $triggerWizardTemplate ); - $template->prepare (); - - $tds = ''; - $nrows = 2; - - $template->assign ( 'LIBRARY_NAME', $libraryName ); - $template->assign ( 'LIBRARY_DESCRIPTION', $libraryDescription ); - $template->assign ( 'LIBRARY_ICON', $libraryIcon ); - $template->assign ( 'LIBRARY_CLASS', $libraryClassName ); - if ($methodLink != "") { - $template->newBlock ( 'methodLink' ); - $template->assign ( 'LIBRARY_METHOD_LINK', $methodLink ); - $template->assign ( 'MORE_INFO', G::LoadTranslation ( 'ID_MORE_INFO' ) ); - $template->gotoBlock ( '_ROOT' ); - } - - $template->assign ( 'PMFUNTION', $sNameFun ); - $template->assign ( 'PMFUNTION_LABEL', $methodLabel ); - $template->assign ( 'PMFUNTION_DESCRIPTION', $methodDescription ); - $template->assign ( 'TITLE', G::LoadTranslation ( 'ID_TITLE' ) ); - $template->assign ( 'DESCRIPTION', G::LoadTranslation ( 'ID_DESCRIPTION' ) ); - $template->assign ( 'DETAILS_LABEL', G::LoadTranslation ( 'ID_DETAILS' ) ); - $template->assign ( 'RETURN_TITLE', G::LoadTranslation ( 'ID_TRIGGER_RETURN_TITLE' ) ); - if ( $bReturnValue ) { - $template->assign ( 'RETURN_LABEL', G::LoadTranslation ( 'ID_TRIGGER_RETURN_LABEL' ) ); - } - $template->assign ( 'METHOD_LABEL', G::LoadTranslation ( 'ID_METHOD' ) ); - $template->assign ( 'ROWS', sizeof ( $aParametersFun ) + 3 ); - $template->assign ( 'TRIGGER_INFORMATION', 'Trigger Information' ); - $template->assign ( 'TRIGGER_ACTION', '../triggers/triggers_WizardSave' ); - $template->assign ( 'PRO_UID', $sProUid ); - $template->assign ( 'PAGED_TABLE_ID', $aDataTrigger ['PAGED_TABLE_ID'] ); - $template->assign ( 'RETURN_DESCRIPTION', $methodReturnLabel ); - $template->assign ( 'ID_SAVE', G::LoadTranslation ( 'ID_SAVE' ) ); - $template->assign ( 'ID_CANCEL', G::LoadTranslation ( 'ID_CANCEL' ) ); - $template->assign ( 'DISPLAY_MODE', $displayMode ); - - $sPMfunction = $sNameFun . " ("; - $methodParametersOnlyNames = array (); - if (count ( $aParametersFun ) > 0) { - $template->newBlock ( 'paremetersTriggersGroup' ); - $template->assign ( 'PARAMETERS_LABEL', G::LoadTranslation ( 'ID_PARAMETERS' ) ); - foreach ( $aParametersFun as $k => $v ) { - if ($v != '') { - $aParametersFunA = explode ( "|", $v ); - $paramType = $aParametersFunA [0]; - $paramDefinition = $aParametersFunA [1]; - $paramDefinitionA = explode ( "=", $paramDefinition ); - $paramName = $paramDefinitionA [0]; - $methodParametersOnlyNames [] = $paramName; - $paramDefaultValue = isset ( $paramDefinitionA [1] ) ? $paramDefinitionA [1] : ""; - $paramLabel = isset ( $aParametersFunA [2] ) ? $aParametersFunA [2] : $paramName; - $paramDescription = isset ( $aParametersFunA [3] ) ? $aParametersFunA [3] : ""; - $sPMfunction .= ($nrows != 2) ? ', "' . trim ( str_replace ( "$", "", $paramName ) ) . '"' : '"' . trim ( str_replace ( "$", "", $paramName ) . '"' ); - $template->newBlock ( 'paremetersTriggers' ); - $template->assign ( 'LABEL_PARAMETER', $paramLabel ); - $template->assign ( 'OPT_PARAMETER', trim ( str_replace ( "$", "", $paramName ) ) ); - $sNameTag = 'form.' . trim ( str_replace ( "$", "", $paramName ) ) . '.name'; - $sNameTag = trim ( $sNameTag ); - $template->assign ( 'SNAMETAG', $sNameTag ); - $tri_Button = ""; - $template->assign ( 'ADD_TRI_VARIABLE', $tri_Button ); - $template->assign ( 'ADD_TRI_VALUE', str_replace ( "'", "", str_replace ( '"', '', $paramDefaultValue ) ) ); - $fieldDescription = ($paramDescription!="")?$paramDescription . "
":""; - $fieldDescription .= $paramDefaultValue != "" ? $paramDefaultValue . " | " . $paramType : G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType; - $template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription ); - $nrows ++; - } - } - - } - $template->gotoBlock ( '_ROOT' ); - $template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) ); - $sPMfunction .= ");"; - $content = $template->getOutputContent (); - print $content; - -} catch ( Exception $oException ) { - die ( $oException->getMessage () ); -} -unset ( $_SESSION ['PROCESS'] ); -?> +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +try { + + G::LoadClass ( 'triggerLibrary' ); + $triggerLibrary = triggerLibrary::getSingleton (); + $libraryClassName = $_GET ['LIBRARY']; + $libraryMethod = $_GET ['NAME_FUN']; + $sProUid = $_GET ['PRO_UID']; + $libraryO = $triggerLibrary->getLibraryDefinition ( $libraryClassName ); + + $libraryName = $libraryO->info ['name']; + $libraryDescription = trim ( str_replace ( "*", "", implode ( " ", $libraryO->info ['description'] ) ) ); + $libraryIcon = isset ( $libraryO->info ['icon'] ) && ($libraryO->info ['icon'] != "") + ? $libraryO->info ['icon'] : "/images/browse.gif"; + $aDataTrigger = $_GET; + + $sProUid = $aDataTrigger ['PRO_UID']; + $sNameFun = $aDataTrigger ['NAME_FUN']; + + $methodObject = $libraryO->methods [$sNameFun]; + + $methodName = $methodObject->info ['name']; + $methodLabel = $methodObject->info ['label']; + $methodDescription = trim ( str_replace ( "*", "", implode ( " ", $methodObject->info ['description'] ) ) ); + $methodReturn = $methodObject->info ['return']; + $methodParameters = array_keys ( $methodObject->params ); + $methodLink = isset ( $methodObject->info ['link'] ) && ($methodObject->info ['link'] != "") + ? $methodObject->info ['link'] : ""; + + $methodreturnA = explode ( "|", $methodReturn ); + + $bReturnValue = true; + $displayMode = 'display:block'; + $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ( 'ID_NONE')) ) + ? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3]; + $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; + if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) + && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { + $methodReturnLabelRequired = (trim( $methodreturnA[1] ) != "" ) + ? G::LoadTranslation ( "ID_REQUIRED_FIELD" ) : $methodreturnA[1]; + $methodReturnLabel .= "
" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]); + } else { + $bReturnValue = false; + $displayMode = 'display:none'; + } + $aParametersFun = $methodParameters; + $triggerWizardTemplate = PATH_TPL . 'triggers' . PATH_SEP . 'triggers_CreateWizard.html'; + $template = new TemplatePower ( $triggerWizardTemplate ); + $template->prepare (); + + $tds = ''; + $nrows = 2; + + $template->assign ( 'LIBRARY_NAME', $libraryName ); + $template->assign ( 'LIBRARY_DESCRIPTION', $libraryDescription ); + $template->assign ( 'LIBRARY_ICON', $libraryIcon ); + $template->assign ( 'LIBRARY_CLASS', $libraryClassName ); + if ($methodLink != "") { + $template->newBlock ( 'methodLink' ); + $template->assign ( 'LIBRARY_METHOD_LINK', $methodLink ); + $template->assign ( 'MORE_INFO', G::LoadTranslation ( 'ID_MORE_INFO' ) ); + $template->gotoBlock ( '_ROOT' ); + } + + $template->assign ( 'PMFUNTION', $sNameFun ); + $template->assign ( 'PMFUNTION_LABEL', $methodLabel ); + $template->assign ( 'PMFUNTION_DESCRIPTION', $methodDescription ); + $template->assign ( 'TITLE', G::LoadTranslation ( 'ID_TITLE' ) ); + $template->assign ( 'DESCRIPTION', G::LoadTranslation ( 'ID_DESCRIPTION' ) ); + $template->assign ( 'DETAILS_LABEL', G::LoadTranslation ( 'ID_DETAILS' ) ); + $template->assign ( 'RETURN_TITLE', G::LoadTranslation ( 'ID_TRIGGER_RETURN_TITLE' ) ); + if ( $bReturnValue ) { + $template->assign ( 'RETURN_LABEL', G::LoadTranslation ( 'ID_TRIGGER_RETURN_LABEL' ) ); + } + $template->assign ( 'METHOD_LABEL', G::LoadTranslation ( 'ID_METHOD' ) ); + $template->assign ( 'ROWS', sizeof ( $aParametersFun ) + 3 ); + $template->assign ( 'TRIGGER_INFORMATION', 'Trigger Information' ); + $template->assign ( 'TRIGGER_ACTION', '../triggers/triggers_WizardSave' ); + $template->assign ( 'PRO_UID', $sProUid ); + $template->assign ( 'PAGED_TABLE_ID', $aDataTrigger ['PAGED_TABLE_ID'] ); + $template->assign ( 'RETURN_DESCRIPTION', $methodReturnLabel ); + $template->assign ( 'ID_SAVE', G::LoadTranslation ( 'ID_SAVE' ) ); + $template->assign ( 'ID_CANCEL', G::LoadTranslation ( 'ID_CANCEL' ) ); + $template->assign ( 'DISPLAY_MODE', $displayMode ); + + $sPMfunction = $sNameFun . " ("; + $methodParametersOnlyNames = array (); + if (count ( $aParametersFun ) > 0) { + $template->newBlock ( 'paremetersTriggersGroup' ); + $template->assign ( 'PARAMETERS_LABEL', G::LoadTranslation ( 'ID_PARAMETERS' ) ); + foreach ($aParametersFun as $k => $v) { + if ($v != '') { + $aParametersFunA = explode ( "|", $v ); + $paramType = $aParametersFunA [0]; + $paramDefinition = $aParametersFunA [1]; + $paramDefinitionA = explode ( "=", $paramDefinition ); + $paramName = $paramDefinitionA [0]; + $methodParametersOnlyNames [] = $paramName; + $paramDefaultValue = isset ( $paramDefinitionA [1] ) ? $paramDefinitionA [1] : ""; + $paramLabel = isset ( $aParametersFunA [2] ) ? $aParametersFunA [2] : $paramName; + $paramDescription = isset ( $aParametersFunA [3] ) ? $aParametersFunA [3] : ""; + $sPMfunction .= ($nrows != 2) + ? ', "' . trim ( str_replace ( "$", "", $paramName ) ) . '"' + : '"' . trim ( str_replace ( "$", "", $paramName ) . '"' ); + + $template->newBlock ( 'paremetersTriggers' ); + $template->assign ( 'LABEL_PARAMETER', $paramLabel ); + $template->assign ( 'OPT_PARAMETER', trim ( str_replace ( "$", "", $paramName ) ) ); + $sNameTag = 'form.' . trim ( str_replace ( "$", "", $paramName ) ) . '.name'; + $sNameTag = trim ( $sNameTag ); + $template->assign ( 'SNAMETAG', $sNameTag ); + $tri_Button = ""; + + $template->assign ( 'ADD_TRI_VARIABLE', $tri_Button ); + $template->assign ( 'ADD_TRI_VALUE', + str_replace ( "'", "", str_replace ( '"', '', $paramDefaultValue ) ) ); + + $fieldDescription = ($paramDescription!="")?$paramDescription . "
":""; + $fieldDescription .= $paramDefaultValue != "" + ? $paramDefaultValue . " | " . $paramType + : G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType; + $template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription ); + $nrows ++; + } + } + + } + $template->gotoBlock ( '_ROOT' ); + $template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) ); + $sPMfunction .= ");"; + $content = $template->getOutputContent (); + print $content; + +} catch ( Exception $oException ) { + die ( $oException->getMessage () ); +} +unset ($_SESSION ['PROCESS']); + \ No newline at end of file diff --git a/workflow/engine/templates/triggers/triggers_EditWizard.php b/workflow/engine/templates/triggers/triggers_EditWizard.php index 23e8976a9..7ccbadd4a 100755 --- a/workflow/engine/templates/triggers/triggers_EditWizard.php +++ b/workflow/engine/templates/triggers/triggers_EditWizard.php @@ -1,154 +1,168 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - -try { - G::LoadClass ( 'triggerLibrary' ); - $triggerLibrary = triggerLibrary::getSingleton (); - $libraryClassName = $_GET ['LIBRARY_CLASS']; - $libraryMethod = $_GET ['PMFUNTION_NAME']; - $sProUid = $_GET ['PRO_UID']; - $libraryO = $triggerLibrary->getLibraryDefinition ( $libraryClassName ); - - $libraryName = $libraryO->info ['name']; - $libraryDescription = trim ( str_replace ( "*", "", implode ( " ", $libraryO->info ['description'] ) ) ); - $libraryIcon = isset ( $libraryO->info ['icon'] ) && ($libraryO->info ['icon'] != "") ? $libraryO->info ['icon'] : "/images/browse.gif"; - $aDataTrigger = $_GET; - - $sProUid = $aDataTrigger ['PRO_UID']; - $sNameFun = $aDataTrigger ['PMFUNTION_NAME']; - - $methodObject = $libraryO->methods [$sNameFun]; - - $methodName = $methodObject->info ['name']; - $methodLabel = $methodObject->info ['label']; - $methodDescription = trim ( str_replace ( "*", "", implode ( " ", $methodObject->info ['description'] ) ) ); - $methodReturn = $methodObject->info ['return']; - $methodParameters = array_keys ( $methodObject->params ); - $methodLink = isset ( $methodObject->info ['link'] ) && ($methodObject->info ['link'] != "") ? $methodObject->info ['link'] : ""; - $methodreturnA = explode ( "|", $methodReturn ); - - $bReturnValue = true; - $displayMode = 'display:block'; - $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ( 'ID_NONE')) )? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3]; - $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; - if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { - $methodReturnLabelRequired = (trim( $methodreturnA[1] ) != "" )? G::LoadTranslation ( "ID_REQUIRED_FIELD" ) : $methodreturnA[1]; - $methodReturnLabel .= "
" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]); - } - else { - $bReturnValue = false; - $displayMode = 'display:none'; - } - $aParametersFun = $methodParameters; - $triggerWizardTemplate = PATH_TPL . 'triggers' . PATH_SEP . 'triggers_EditWizard.html'; - $template = new TemplatePower ( $triggerWizardTemplate ); - $template->prepare (); - - $tds = ''; - $nrows = 2; - - $template->assign ( 'LIBRARY_NAME', $libraryName ); - $template->assign ( 'LIBRARY_DESCRIPTION', $libraryDescription ); - $template->assign ( 'LIBRARY_ICON', $libraryIcon ); - $template->assign ( 'LIBRARY_CLASS', $libraryClassName ); - if ($methodLink != "") { - $template->newBlock ( 'methodLink' ); - $template->assign ( 'LIBRARY_METHOD_LINK', $methodLink ); - $template->gotoBlock ( '_ROOT' ); - } - - $template->assign ( 'PMFUNTION', $sNameFun ); - $template->assign ( 'PMFUNTION_LABEL', $methodLabel ); - $template->assign ( 'PMFUNTION_DESCRIPTION', $methodDescription ); - $template->assign ( 'TITLE', G::LoadTranslation ( 'ID_TITLE' ) ); - $template->assign ( 'TITLE_CONTENT', $_GET['TRI_TITLE'] ); - $template->assign ( 'TRI_UID', $_GET['TRI_UID'] ); - $template->assign ( 'SOURCE_LINK', G::LoadTranslation ( 'ID_TRIGGER_SOURCE_LINK' ) ); - $template->assign ( 'DESCRIPTION', G::LoadTranslation ( 'ID_DESCRIPTION' ) ); - $template->assign ( 'DESCRIPTION_CONTENT', $_GET['TRI_DESCRIPTION'] ); - $template->assign ( 'DETAILS_LABEL', G::LoadTranslation ( 'ID_DETAILS' ) ); - $template->assign ( 'RETURN_TITLE', G::LoadTranslation ( 'ID_TRIGGER_RETURN_TITLE' ) ); - if ( $bReturnValue ) { - $template->assign ( 'RETURN_LABEL', G::LoadTranslation ( 'ID_TRIGGER_RETURN_LABEL' ) ); - } - $template->assign ( 'RETURN_VALUE', $_GET['TRI_ANSWER'] ); - $template->assign ( 'METHOD_LABEL', G::LoadTranslation ( 'ID_METHOD' ) ); - $template->assign ( 'ROWS', sizeof ( $aParametersFun ) + 3 ); - $template->assign ( 'TRIGGER_INFORMATION', 'Triggers Edit Form' ); - $template->assign ( 'TRIGGER_ACTION', '../triggers/triggers_WizardUpdate' ); - $template->assign ( 'PRO_UID', $sProUid ); - $template->assign ( 'PAGED_TABLE_ID', $aDataTrigger ['PAGED_TABLE_ID'] ); - $template->assign ( 'RETURN_DESCRIPTION', $methodReturnLabel ); - $template->assign ( 'ID_SAVE', G::LoadTranslation ( 'ID_SAVE' ) ); - $template->assign ( 'ID_CANCEL', G::LoadTranslation ( 'ID_CANCEL' ) ); - $template->assign ( 'DISPLAY_MODE', $displayMode ); - - $sPMfunction = $sNameFun . " ("; - $methodParametersOnlyNames = array (); - if (count ( $aParametersFun ) > 0) { - $template->newBlock ( 'paremetersTriggersGroup' ); - $template->assign ( 'PARAMETERS_LABEL', G::LoadTranslation ( 'ID_PARAMETERS' ) ); - foreach ( $aParametersFun as $k => $v ) { - if ($v != '') { - $aParametersFunA = explode ( "|", $v ); - $paramType = $aParametersFunA [0]; - $paramDefinition = $aParametersFunA [1]; - $paramDefinitionA = explode ( "=", $paramDefinition ); - $paramName = $paramDefinitionA [0]; - $methodParametersOnlyNames [] = $paramName; - $paramDefaultValue = isset ( $paramDefinitionA [1] ) ? $paramDefinitionA [1] : ""; - $paramLabel = isset ( $aParametersFunA [2] ) ? $aParametersFunA [2] : $paramName; - $paramDescription = isset ( $aParametersFunA [3] ) ? $aParametersFunA [3] : ""; - $sPMfunction .= ($nrows != 2) ? ', "' . trim ( str_replace ( "$", "", $paramName ) ) . '"' : '"' . trim ( str_replace ( "$", "", $paramName ) . '"' ); - $template->newBlock ( 'paremetersTriggers' ); - $template->assign ( 'LABEL_PARAMETER', $paramLabel ); - $template->assign ( 'OPT_PARAMETER', trim ( str_replace ( "$", "", $paramName ) ) ); - $sNameTag = 'form.' . trim ( str_replace ( "$", "", $paramName ) ) . '.name'; - $sNameTag = trim ( $sNameTag ); - $template->assign ( 'SNAMETAG', $sNameTag ); - $tri_Button = ""; - $template->assign ( 'ADD_TRI_VARIABLE', $tri_Button ); -// $template->assign ( 'ADD_TRI_VALUE', str_replace ( "'", "", str_replace ( '"', '', $paramDefaultValue ) ) ); - $paramValue = $_GET[trim( str_replace( "$", "", $paramName ) )]; - $template->assign ( 'ADD_TRI_VALUE', str_replace("\'", "'", $paramValue) ); - $fieldDescription = ($paramDescription!="")?$paramDescription . "
":""; - $fieldDescription .= $paramDefaultValue != "" ? $paramDefaultValue . " | " . $paramType : G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType; - $template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription ); - $nrows ++; - } - } - - } - $template->gotoBlock ( '_ROOT' ); - $template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) ); - $sPMfunction .= ");"; - $content = $template->getOutputContent (); - print $content; - -} catch ( Exception $oException ) { - die ( $oException->getMessage () ); -} -unset ( $_SESSION ['PROCESS'] ); -?> \ No newline at end of file +. + * + * For more information, contact Colosa Inc, 2566 Le Jeune Rd., + * Coral Gables, FL, 33134, USA, or email info@colosa.com. + * + */ + +try { + G::LoadClass ( 'triggerLibrary' ); + $triggerLibrary = triggerLibrary::getSingleton (); + $libraryClassName = $_GET ['LIBRARY_CLASS']; + $libraryMethod = $_GET ['PMFUNTION_NAME']; + $sProUid = $_GET ['PRO_UID']; + $libraryO = $triggerLibrary->getLibraryDefinition ( $libraryClassName ); + + $libraryName = $libraryO->info ['name']; + $libraryDescription = trim ( str_replace ( "*", "", implode ( " ", $libraryO->info ['description'] ) ) ); + $libraryIcon = isset ( $libraryO->info ['icon'] ) && ($libraryO->info ['icon'] != "") + ? $libraryO->info ['icon'] : "/images/browse.gif"; + $aDataTrigger = $_GET; + + $sProUid = $aDataTrigger ['PRO_UID']; + $sNameFun = $aDataTrigger ['PMFUNTION_NAME']; + + $methodObject = $libraryO->methods [$sNameFun]; + + $methodName = $methodObject->info ['name']; + $methodLabel = $methodObject->info ['label']; + $methodDescription = trim ( str_replace ( "*", "", implode ( " ", $methodObject->info ['description'] ) ) ); + $methodReturn = $methodObject->info ['return']; + $methodParameters = array_keys ( $methodObject->params ); + $methodLink = isset ( $methodObject->info ['link'] ) && ($methodObject->info ['link'] != "") + ? $methodObject->info ['link'] : ""; + $methodreturnA = explode ( "|", $methodReturn ); + + $bReturnValue = true; + $displayMode = 'display:block'; + $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ( 'ID_NONE')) ) + ? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3]; + $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; + if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) + && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { + $methodReturnLabelRequired = (trim( $methodreturnA[1] ) != "" ) + ? G::LoadTranslation ( "ID_REQUIRED_FIELD" ) : $methodreturnA[1]; + $methodReturnLabel .= "
" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]); + } else { + $bReturnValue = false; + $displayMode = 'display:none'; + } + $aParametersFun = $methodParameters; + $triggerWizardTemplate = PATH_TPL . 'triggers' . PATH_SEP . 'triggers_EditWizard.html'; + $template = new TemplatePower ( $triggerWizardTemplate ); + $template->prepare (); + + $tds = ''; + $nrows = 2; + + $template->assign ( 'LIBRARY_NAME', $libraryName ); + $template->assign ( 'LIBRARY_DESCRIPTION', $libraryDescription ); + $template->assign ( 'LIBRARY_ICON', $libraryIcon ); + $template->assign ( 'LIBRARY_CLASS', $libraryClassName ); + if ($methodLink != "") { + $template->newBlock ( 'methodLink' ); + $template->assign ( 'LIBRARY_METHOD_LINK', $methodLink ); + $template->gotoBlock ( '_ROOT' ); + } + + $template->assign ( 'PMFUNTION', $sNameFun ); + $template->assign ( 'PMFUNTION_LABEL', $methodLabel ); + $template->assign ( 'PMFUNTION_DESCRIPTION', $methodDescription ); + $template->assign ( 'TITLE', G::LoadTranslation ( 'ID_TITLE' ) ); + $template->assign ( 'TITLE_CONTENT', $_GET['TRI_TITLE'] ); + $template->assign ( 'TRI_UID', $_GET['TRI_UID'] ); + $template->assign ( 'SOURCE_LINK', G::LoadTranslation ( 'ID_TRIGGER_SOURCE_LINK' ) ); + $template->assign ( 'DESCRIPTION', G::LoadTranslation ( 'ID_DESCRIPTION' ) ); + $template->assign ( 'DESCRIPTION_CONTENT', $_GET['TRI_DESCRIPTION'] ); + $template->assign ( 'DETAILS_LABEL', G::LoadTranslation ( 'ID_DETAILS' ) ); + $template->assign ( 'RETURN_TITLE', G::LoadTranslation ( 'ID_TRIGGER_RETURN_TITLE' ) ); + if ( $bReturnValue ) { + $template->assign ( 'RETURN_LABEL', G::LoadTranslation ( 'ID_TRIGGER_RETURN_LABEL' ) ); + } + $template->assign ( 'RETURN_VALUE', $_GET['TRI_ANSWER'] ); + $template->assign ( 'METHOD_LABEL', G::LoadTranslation ( 'ID_METHOD' ) ); + $template->assign ( 'ROWS', sizeof ( $aParametersFun ) + 3 ); + $template->assign ( 'TRIGGER_INFORMATION', 'Triggers Edit Form' ); + $template->assign ( 'TRIGGER_ACTION', '../triggers/triggers_WizardUpdate' ); + $template->assign ( 'PRO_UID', $sProUid ); + $template->assign ( 'PAGED_TABLE_ID', $aDataTrigger ['PAGED_TABLE_ID'] ); + $template->assign ( 'RETURN_DESCRIPTION', $methodReturnLabel ); + $template->assign ( 'ID_SAVE', G::LoadTranslation ( 'ID_SAVE' ) ); + $template->assign ( 'ID_CANCEL', G::LoadTranslation ( 'ID_CANCEL' ) ); + $template->assign ( 'DISPLAY_MODE', $displayMode ); + + $sPMfunction = $sNameFun . " ("; + $methodParametersOnlyNames = array (); + if (count ( $aParametersFun ) > 0) { + $template->newBlock ( 'paremetersTriggersGroup' ); + $template->assign ( 'PARAMETERS_LABEL', G::LoadTranslation ( 'ID_PARAMETERS' ) ); + foreach ($aParametersFun as $k => $v) { + if ($v != '') { + $aParametersFunA = explode ( "|", $v ); + $paramType = $aParametersFunA [0]; + $paramDefinition = $aParametersFunA [1]; + $paramDefinitionA = explode ( "=", $paramDefinition ); + $paramName = $paramDefinitionA [0]; + $methodParametersOnlyNames [] = $paramName; + $paramDefaultValue = isset ( $paramDefinitionA [1] ) ? $paramDefinitionA [1] : ""; + $paramLabel = isset ( $aParametersFunA [2] ) ? $aParametersFunA [2] : $paramName; + $paramDescription = isset ( $aParametersFunA [3] ) ? $aParametersFunA [3] : ""; + $sPMfunction .= ($nrows != 2) + ? ', "' . trim ( str_replace ( "$", "", $paramName ) ) . '"' + : '"' . trim ( str_replace ( "$", "", $paramName ) . '"' ); + + $template->newBlock ( 'paremetersTriggers' ); + $template->assign ( 'LABEL_PARAMETER', $paramLabel ); + $template->assign ( 'OPT_PARAMETER', trim ( str_replace ( "$", "", $paramName ) ) ); + $sNameTag = 'form.' . trim ( str_replace ( "$", "", $paramName ) ) . '.name'; + $sNameTag = trim ( $sNameTag ); + $template->assign ( 'SNAMETAG', $sNameTag ); + $tri_Button = ""; + + $template->assign ( 'ADD_TRI_VARIABLE', $tri_Button ); + // $template->assign ( 'ADD_TRI_VALUE', str_replace ( "'", "", + // str_replace ( '"', '', $paramDefaultValue ) ) ); + $paramValue = $_GET[trim( str_replace( "$", "", $paramName ) )]; + $template->assign ( 'ADD_TRI_VALUE', str_replace("\'", "'", $paramValue) ); + $fieldDescription = ($paramDescription!="")?$paramDescription . "
":""; + $fieldDescription .= $paramDefaultValue != "" + ? $paramDefaultValue . " | " . $paramType + : G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType; + + $template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription ); + $nrows ++; + } + } + + } + $template->gotoBlock ( '_ROOT' ); + $template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) ); + $sPMfunction .= ");"; + $content = $template->getOutputContent (); + print $content; + +} catch ( Exception $oException ) { + die ( $oException->getMessage () ); +} +unset ( $_SESSION ['PROCESS'] ); + \ No newline at end of file From 353621b3200b88b4a91bbb707300cf6085c6e854 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Wed, 4 Jul 2012 15:11:07 -0400 Subject: [PATCH 2/3] BUG 9246 Adjustment for standardization of code SOLVED - Adjustment workflow/engine/classes/class.pmTable.php, workflow/engine/classes/model/DbSource.php files. --- workflow/engine/classes/class.pmTable.php | 1497 ++++++++++---------- workflow/engine/classes/model/DbSource.php | 114 +- 2 files changed, 801 insertions(+), 810 deletions(-) diff --git a/workflow/engine/classes/class.pmTable.php b/workflow/engine/classes/class.pmTable.php index 9b076a60b..43a9c87c2 100755 --- a/workflow/engine/classes/class.pmTable.php +++ b/workflow/engine/classes/class.pmTable.php @@ -1,4 +1,5 @@ */ class PmTable { - private $dom = null; - private $schemaFile = ''; - private $tableName; - private $columns; + private $dom = null; + private $schemaFile = ''; + private $tableName; + private $columns; + private $baseDir = ''; + private $targetDir = ''; + private $configDir = ''; + private $dataDir = ''; + private $classesDir = ''; + private $className = ''; + private $dataSource = ''; + private $rootNode; + private $dbConfig; + private $db; + private $alterTable = true; - private $baseDir = ''; - private $targetDir = ''; - private $configDir = ''; - private $dataDir = ''; - private $classesDir = ''; - private $className = ''; - - private $dataSource = ''; - private $rootNode; - - private $dbConfig; - private $db; - - private $alterTable = true; - - function __construct($tableName = null) - { - if (isset($tableName)) { - $this->tableName = $tableName; - $this->className = $this->toCamelCase($tableName); - } - - $this->dbConfig = new StdClass(); - } - - - /** - * Set columns to pmTable - * @param array $columns contains a array of abjects - * array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...) - */ - function setColumns($columns) - { - $this->columns = $columns; - } - - /** - * Set a data source - * @param string $dbsUid DBS_UID to relate the pmTable to phisical table - */ - function setDataSource($dbsUid) - { - $this->dataSource = self::resolveDbSource($dbsUid); - - switch ($this->dataSource) { - case 'workflow': - $this->dbConfig->adapter= DB_ADAPTER; - $this->dbConfig->host = DB_HOST; - $this->dbConfig->name = DB_NAME; - $this->dbConfig->user = DB_USER; - $this->dbConfig->passwd = DB_PASS; - $this->dbConfig->port = 3306; //FIXME update this when port for workflow dsn will be available - break; - - case 'rp': - $this->dbConfig->adapter= DB_ADAPTER; - $this->dbConfig->host = DB_REPORT_HOST; - $this->dbConfig->name = DB_REPORT_NAME; - $this->dbConfig->user = DB_REPORT_USER; - $this->dbConfig->passwd = DB_REPORT_PASS; - $this->dbConfig->port = 3306; //FIXME update this when port for rp dsn will be available - break; - - default: - require_once 'classes/model/DbSource.php'; - $oDBSource = new DbSource(); - $proUid = $oDBSource->getValProUid($this->dataSource); - $dbSource = $oDBSource->load($this->dataSource, $proUid); - - if (is_object($dbSource)) { - $this->dbConfig->adapter= $dbSource->getDbsType(); - $this->dbConfig->host = $dbSource->getDbsServer(); - $this->dbConfig->name = $dbSource->getDbsDatabaseName(); - $this->dbConfig->user = $dbSource->getDbsUsername(); - $this->dbConfig->passwd = $dbSource->getDbsPassword(); - $this->dbConfig->port = $dbSource->getDbsPort(); + public function __construct($tableName=null) + { + if (isset($tableName)) { + $this->tableName = $tableName; + $this->className = $this->toCamelCase($tableName); } - if (is_array($dbSource)) { - $this->dbConfig->adapter= $dbSource['DBS_TYPE']; - $this->dbConfig->host = $dbSource['DBS_SERVER']; - $this->dbConfig->name = $dbSource['DBS_DATABASE_NAME']; - $this->dbConfig->user = $dbSource['DBS_USERNAME']; - $this->dbConfig->passwd = $dbSource['DBS_PASSWORD'] ; - $this->dbConfig->port = $dbSource['DBS_PORT']; - } - else { - throw new Exception("Db source with id $dbsUid does not exist!"); - } - } - } - /** - * Backward compatibility function - * Resolve a propel data source - * @param string $dbsUid corresponding to DBS_UID key - * @return string contains resolved DBS_UID - */ - public function resolveDbSource($dbsUid) - { - switch ($dbsUid) { - case 'workflow': case 'wf': case '0': case '': case null: - $dbsUid = 'workflow'; - break; - case 'rp': case 'report': - $dbsUid = 'rp'; - break; + $this->dbConfig = new StdClass(); } - return $dbsUid; - } - - public function getDataSource() - { - return $this->dataSource; - } - - /** - * get Data base config object - * @return object containing dbConfig var - */ - public function getDbConfig() - { - return $this->dbConfig; - } - - public function setAlterTable($value) - { - $this->alterTable = $value; - } - - /** - * Build the pmTable with all dependencies - */ - function build() - { - $this->prepare(); - $this->preparePropelIniFile(); - $this->buildSchema(); - - if ($this->alterTable) { - $this->phingbuildModel(); - $this->phingbuildSql(); - $this->upgradeDatabase(); - } - } - - function buildModelFor($dbsUid, $tablesList) - { - $this->setDataSource($dbsUid); - $loadSchema = false; - $this->prepare($loadSchema); - $this->phingbuildModel(); - $this->phingbuildSql(); - //$this->upgradeDatabaseFor($this->dataSource, $tablesList); - } - - /** - * Prepare the pmTable env - */ - function prepare($loadSchema = true) - { - //prevent execute prepare() twice or more - if (is_object($this->dom)) { - return true; - } - - $this->schemaFilename = 'schema.xml'; - $this->baseDir = PATH_DB . SYS_SYS . PATH_SEP; - $this->targetDir = $this->baseDir . 'pmt-propel' . PATH_SEP . $this->dataSource . PATH_SEP; - $this->configDir = $this->targetDir . 'config' . PATH_SEP; - $this->dataDir = $this->targetDir . 'data' . PATH_SEP; - $this->classesDir = $this->baseDir . 'classes' . PATH_SEP; - - // G::mk_dir create the requested dir and the parents directories if not exists - G::mk_dir($this->configDir); - G::mk_dir($this->dataDir); - - if ($loadSchema) { - $this->loadSchema(); - } - } - - function loadSchema() - { - $this->dom = new DOMDocument('1.0', 'utf-8'); - $this->dom->preserveWhiteSpace = false; - $this->dom->formatOutput = true; - - if (file_exists($this->configDir . $this->schemaFilename)) { - if (@$this->dom->load($this->configDir . $this->schemaFilename) !== true) { - throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!'); - } - $this->rootNode = $this->dom->firstChild; - } - else { - $this->rootNode = $this->dom->createElement('database'); - $this->rootNode->setAttribute('name', $this->dataSource); - $this->dom->appendChild($this->rootNode); - } - } - - /** - * Build the xml schema for propel - */ - function buildSchema() - { - $tableNode = $this->dom->createElement('table'); - $tableNode->setAttribute('name', $this->tableName); - - if ($this->hasAutoIncrementPKey()) { - $tableNode->setAttribute('idMethod', 'native'); - } - - // specifying collation - switch ($this->dbConfig->adapter) { - case 'mysql': - $vendorNode = $this->dom->createElement('vendor'); - $vendorNode->setAttribute('type', $this->dbConfig->adapter); - $parameterNode = $this->dom->createElement('parameter'); - $parameterNode->setAttribute('name', 'Collation'); - $parameterNode->setAttribute('value', 'utf8_general_ci'); - $vendorNode->appendChild($parameterNode); - $tableNode->appendChild($vendorNode); - break; - } - - - foreach ($this->columns as $column) { - - // create the column node - $columnNode = $this->dom->createElement('column'); - // setting column node attributes - $columnNode->setAttribute('name', $column->field_name); - $columnNode->setAttribute('type', $column->field_type); - - if ($column->field_size != '' && $column->field_size != 0) { - $columnNode->setAttribute('size', $column->field_size); - } - - $columnNode->setAttribute('required', ($column->field_null? 'false' : 'true')); - - // only define the primaryKey attribute if it is defined - if ($column->field_key) { - $columnNode->setAttribute('primaryKey', "true"); - } - - // only define the autoIncrement attribute if it is defined - if ($column->field_autoincrement) { - $columnNode->setAttribute('autoIncrement', "true"); - } - $tableNode->appendChild($columnNode); - } - - $xpath = new DOMXPath($this->dom); - $xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); - - if ($xtable->length == 0) { //the table definition does not exist, then just append the new node - $this->rootNode->appendChild($tableNode); - } - else { // the table definition already exist, then replace the node - $replacedNode = $xtable->item(0); - $this->rootNode->replaceChild($tableNode, $replacedNode); - } - - // saving the xml result file - $this->saveSchema(); - } - - /** - * Remove the pmTable and all related objects, files and others - */ - public function remove() - { - $this->prepare(); - $this->removeFromSchema(); - $this->removeModelFiles(); - $this->dropTable(); - } - - /** - * Remove the target pmTable from schema of propel - */ - public function removeFromSchema() - { - $xpath = new DOMXPath($this->dom); - // locate the node - $xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); - if ($xtable->length == 0) { - return false; - } - - $this->rootNode->removeChild($xtable->item(0)); - // saving the xml result file - $this->saveSchema(); - } - - /** - * Remove the model related classes files - */ - public function removeModelFiles() - { - @unlink($this->classesDir . $this->className . '.php'); - @unlink($this->classesDir . $this->className . 'Peer.php'); - @unlink($this->classesDir . 'map' . PATH_SEP . $this->className . 'MapBuilder.php'); - @unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . '.php'); - @unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . 'Peer.php'); - } - - /** - * Drop the phisical table of target pmTable or any specified as parameter - */ - public function dropTable($tableName = null) - { - $tableName = isset($tableName) ? $tableName : $this->tableName; - $con = Propel::getConnection($this->dataSource); - $stmt = $con->createStatement(); - - if (is_object($con)) { - try { - $stmt->executeQuery("DROP TABLE {$tableName}"); - } - catch (Exception $e) { - throw new Exception("Physical table '$tableName' does not exist!"); - } - } - } - - /** - * Save the xml schema for propel - */ - public function saveSchema() - { - $this->dom->save($this->configDir . $this->schemaFilename); - } - - - /** - * Prepare and create if not exists the propel ini file - */ - public function preparePropelIniFile() - { - $adapter = $this->dbConfig->adapter; - - if (file_exists($this->configDir . "propel.$adapter.ini")) { - return true; - } - - if (!file_exists(PATH_CORE. PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini")) { - throw new Exception("Invalid or not supported engine '$adapter'!"); - } - - @copy(PATH_CORE. PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini", $this->configDir . "propel.$adapter.ini"); - } - - /** - * Upgrade the phisical database for the target pmTable - * It executes the schema.sql autogenerated by propel, but just execute the correspondent sentenses - * for the related table - * - this function is not executing other sentenses like 'SET FOREIGN_KEY_CHECKS = 0;' for mysql, and others - */ - public function upgradeDatabase() - { - $con = Propel::getConnection($this->dataSource); - $stmt = $con->createStatement(); - $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); - $previous = NULL; - $queryStack = array(); - $aDNS = $con->getDSN(); - $dbEngine = $aDNS["phptype"]; - - foreach ($lines as $j => $line) { - switch($dbEngine) { - case 'mysql' : - $line = trim($line); // Remove comments from the script - - if (strpos($line, "--") === 0) { - $line = substr($line, 0, strpos($line, "--")); - } - - if (empty($line)) { - continue; - } - - if (strpos($line, "#") === 0) { - $line = substr($line, 0, strpos($line, "#")); - } - - if (empty($line)) { - continue; - } - - // Concatenate the previous line, if any, with the current - if ($previous) { - $line = $previous . " " . $line; - } - $previous = NULL; - - // If the current line doesnt end with ; then put this line together - // with the next one, thus supporting multi-line statements. - if (strrpos($line, ";") != strlen($line) - 1) { - $previous = $line; - continue; - } - - $line = substr($line, 0, strrpos($line, ";")); - // just execute the drop and create table for target table nad not for others - if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) { - $isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match); - if ($isCreateForCurrentTable) { - $queryStack['create'] = $line; - } - else { - $isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match); - if ($isDropForCurrentTable) { - $queryStack['drop'] = $line; - } - } - } - break; - case 'mssql' : - $line = trim($line); // Remove comments from the script - - if (strpos($line, "--") === 0) { - $line = substr($line, 0, strpos($line, "--")); - } - - if (empty($line)) { - continue; - } - - if (strpos($line, "#") === 0) { - $line = substr($line, 0, strpos($line, "#")); - } - - if (empty($line)) { - continue; - } - - // Concatenate the previous line, if any, with the current - if ($previous) { - $line = $previous . " " . $line; - } - $previous = NULL; - - // If the current line doesnt end with ; then put this line together - // with the next one, thus supporting multi-line statements. - if (strrpos($line, ";") != strlen($line) - 1) { - $previous = $line; - continue; - } - - $line = substr($line, 0, strrpos($line, ";")); - - if (strpos($line, $this->tableName) == false) { - continue; - } - - $auxCreate = explode('CREATE', $line); - $auxDrop = explode('IF EXISTS', $auxCreate['0']); - - $queryStack['drop'] = 'IF EXISTS' . $auxDrop['1']; - $queryStack['create'] = 'CREATE' . $auxCreate['1']; - - break; - case 'oracle' : - $line = trim($line); - if (empty($line)) { - continue; - } - switch(true) { - case preg_match("/^CREATE TABLE\s/i", $line): - if (strpos($line, $this->tableName) == true) { - $inCreate = true; - $lineCreate .= $line . ' '; - } - break; - case preg_match("/ALTER TABLE\s/i", $line): - if (strpos($line, $this->tableName) == true) { - $inAlter = true; - $lineAlter .= $line . ' '; - } - break; - case preg_match("/^DROP TABLE\s/i", $line): - if (strpos($line, $this->tableName) == true) { - $inDrop = true; - $lineDrop .= $line . ' '; - if (strrpos($line, ";") > 0) { - $queryStack['drop'] = $lineDrop; - $inDrop = false; - } - } - break; - default : - if ($inCreate) { - $lineCreate .= $line . ' '; - if (strrpos($line, ";") > 0) { - $queryStack['create'] = $lineCreate; - $inCreate = false; - } - } - if ($inAlter) { - $lineAlter .= $line . ' '; - if (strrpos($line, ";") > 0) { - $queryStack['alter'] = $lineAlter; - $inAlter = false; - } - } - if ($inDrop) { - $lineDrop .= $line . ' '; - if (strrpos($line, ";")>0) { - $queryStack['drop'] = $lineDrop; - $inDrop = false; - } - } - } - break; - } - - } - - if ($dbEngine == 'oracle') { - $queryStack['drop'] = substr($queryStack['drop'], 0, strrpos($queryStack['drop'], ";")); - $queryStack['create'] = substr($queryStack['create'], 0, strrpos($queryStack['create'], ";")); - $queryStack['alter'] = substr($queryStack['alter'], 0, strrpos($queryStack['alter'], ";")); - $queryIfExistTable = "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME = '" . $this->tableName . "'"; - - $rs = $stmt->executeQuery($queryIfExistTable); - if ($rs->next()) { - $stmt->executeQuery($queryStack['drop']); - } - $stmt->executeQuery($queryStack['create']); - $stmt->executeQuery($queryStack['alter']); - } - else { - if (isset($queryStack['create'])) { - // first at all we need to verify if we have a valid schema defined, - // so we verify that creating a dummy table - $swapQuery = str_replace($this->tableName, $this->tableName . '_TMP', $queryStack['create']); - - // if there is a problem with user defined table schema executeQuery() will throw a sql exception - $stmt->executeQuery($swapQuery); - - // if there was not problem above proceced deleting the dummy table and drop and create the target table - $stmt->executeQuery("DROP TABLE {$this->tableName}_TMP"); - if (!isset($queryStack['drop'])) { - $queryStack['drop'] = "DROP TABLE {$this->tableName}"; - } - if (!isset($queryStack['create'])) { - throw new Exception('A problem occurred resolving the schema to update for this table'); - } - $stmt->executeQuery($queryStack['drop']); - $stmt->executeQuery($queryStack['create']); - } - } - } - - public function upgradeDatabaseFor($dataSource, $tablesList = array()) - { - $con = Propel::getConnection($dataSource); - $stmt = $con->createStatement(); - $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); - $previous = NULL; - $errors = ''; - - foreach ($lines as $j => $line) { - $line = trim($line); // Remove comments from the script - - if (strpos($line, "--") === 0) { - $line = substr($line, 0, strpos($line, "--")); - } - - if (empty($line)) { - continue; - } - - if (strpos($line, "#") === 0) { - $line = substr($line, 0, strpos($line, "#")); - } - - if (empty($line)) { - continue; - } - - // Concatenate the previous line, if any, with the current - if ($previous) { - $line = $previous . " " . $line; - } - $previous = NULL; - - // If the current line doesnt end with ; then put this line together - // with the next one, thus supporting multi-line statements. - if (strrpos($line, ";") != strlen($line) - 1) { - $previous = $line; - continue; - } - - $line = substr($line, 0, strrpos($line, ";")); - - // execute - $isCreate = stripos($line, 'CREATE TABLE') !== false; - $isDrop = stripos($line, 'DROP TABLE') !== false; - - if ($isCreate || $isDrop) { - if (preg_match('/TABLE\s[\'\"\`]+(\w+)[\'\"\`]+/i', $line, $match)) { - if (in_array($match[1], $tablesList)) { - //error_log($line); - try { - $stmt->executeQuery($line); - } - catch(Exception $e) { - $errors .= $e->getMessage() . "\n"; - continue; - } - - } - } - } - } - - return $errors; - } - - /** - * verify if on the columns list was set a column as primary key - * @return boolean to affirm if was defined a column as pk. - */ - function hasAutoIncrementPKey() - { - foreach ($this->columns as $column) { - if ($column->field_autoincrement) { - return true; - } - } - - return false; - } - - /** - * - * @return array contains all supported columns types provided by propel - */ - function getPropelSupportedColumnTypes() - { /** - * http://www.propelorm.org/wiki/Documentation/1.2/Schema - * [type = "BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR}|LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"] + * Set columns to pmTable + * @param array $columns contains a array of abjects + * array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...) */ - $types = array(); - - $types['BOOLEAN'] = 'BOOLEAN'; - $types['TINYINT'] = 'TINYINT'; - $types['SMALLINT'] = 'SMALLINT'; - $types['INTEGER'] = 'INTEGER'; - $types['BIGINT'] = 'BIGINT'; - $types['DOUBLE'] = 'DOUBLE'; - $types['FLOAT'] = 'FLOAT'; - $types['REAL'] = 'REAL'; - $types['DECIMAL'] = 'DECIMAL'; - $types['CHAR'] = 'CHAR'; - $types['VARCHAR'] = 'VARCHAR'; - $types['LONGVARCHAR'] = 'LONGVARCHAR'; - $types['DATE'] = 'DATE'; - $types['TIME'] = 'TIME'; - $types['DATETIME'] = 'DATETIME'; - //$types['BLOB'] = 'BLOB'; <- disabled - //$types['CLOB'] = 'CLOB'; <- disabled - - return $types; - } - - /** - * @param string $name any string witha name separated by underscore - * @return string contains a camelcase expresion for $name - */ - public function toCamelCase($name) - { - $tmp = explode('_', trim($name)); - foreach ($tmp as $i => $part) { - $tmp[$i] = ucFirst(strtolower($part)); - } - return implode('', $tmp); - } - - /** - * Run om task for phing to build all mdoel classes - */ - public function phingbuildModel() - { - $this->_callPhing('om'); - } - - /** - * Run sql task for phing to generate the sql schema - */ - public function phingbuildSql() - { - $this->_callPhing('sql'); - } - - /** - * call phing to execute a determinated task - * @param string $taskName [om|sql] - */ - private function _callPhing($taskName) - { - $options = array( - 'project.dir' => $this->configDir, - 'build.properties' => "propel.{$this->dbConfig->adapter}.ini", - 'propel.targetPackage' => 'classes', - 'propel.output.dir' => $this->targetDir, - 'propel.php.dir' => $this->baseDir - ); - - self::callPhing(array($taskName), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false); - } - - /** - * @param string $target - task name to execute - * @param string $buildFile - build file path - * @param array $options - array options to override the options on .ini file - * @param bool $verbose - to show a verbose output - */ - public static function callPhing($target, $buildFile = '', $options = array(), $verbose = true) - { - G::loadClass('pmPhing'); - - $args = array(); - foreach ($options as $key => $value) { - $args[] = "-D$key=$value"; + public function setColumns($columns) + { + $this->columns = $columns; } - if ($buildFile) { - $args[] = '-f'; - $args[] = realpath($buildFile); + /** + * Set a data source + * @param string $dbsUid DBS_UID to relate the pmTable to phisical table + */ + public function setDataSource($dbsUid) + { + $this->dataSource = self::resolveDbSource($dbsUid); + + switch ($this->dataSource) { + case 'workflow': + $this->dbConfig->adapter = DB_ADAPTER; + $this->dbConfig->host = DB_HOST; + $this->dbConfig->name = DB_NAME; + $this->dbConfig->user = DB_USER; + $this->dbConfig->passwd = DB_PASS; + $this->dbConfig->port = 3306; //FIXME update this when port for workflow dsn will be available + break; + case 'rp': + $this->dbConfig->adapter = DB_ADAPTER; + $this->dbConfig->host = DB_REPORT_HOST; + $this->dbConfig->name = DB_REPORT_NAME; + $this->dbConfig->user = DB_REPORT_USER; + $this->dbConfig->passwd = DB_REPORT_PASS; + $this->dbConfig->port = 3306; //FIXME update this when port for rp dsn will be available + break; + default: + require_once 'classes/model/DbSource.php'; + $oDBSource = new DbSource(); + $proUid = $oDBSource->getValProUid($this->dataSource); + $dbSource = $oDBSource->load($this->dataSource, $proUid); + + if (is_object($dbSource)) { + $this->dbConfig->adapter = $dbSource->getDbsType(); + $this->dbConfig->host = $dbSource->getDbsServer(); + $this->dbConfig->name = $dbSource->getDbsDatabaseName(); + $this->dbConfig->user = $dbSource->getDbsUsername(); + $this->dbConfig->passwd = $dbSource->getDbsPassword(); + $this->dbConfig->port = $dbSource->getDbsPort(); + } + if (is_array($dbSource)) { + $this->dbConfig->adapter = $dbSource['DBS_TYPE']; + $this->dbConfig->host = $dbSource['DBS_SERVER']; + $this->dbConfig->name = $dbSource['DBS_DATABASE_NAME']; + $this->dbConfig->user = $dbSource['DBS_USERNAME']; + $this->dbConfig->passwd = $dbSource['DBS_PASSWORD']; + $this->dbConfig->port = $dbSource['DBS_PORT']; + } else { + throw new Exception("Db source with id $dbsUid does not exist!"); + } + } } - if (!$verbose) { - $args[] = '-q'; + /** + * Backward compatibility function + * Resolve a propel data source + * @param string $dbsUid corresponding to DBS_UID key + * @return string contains resolved DBS_UID + */ + public function resolveDbSource($dbsUid) + { + switch ($dbsUid) { + case 'workflow': + case 'wf': + case '0': + case '': + case null: + $dbsUid = 'workflow'; + break; + case 'rp': + case 'report': + $dbsUid = 'rp'; + break; + } + + return $dbsUid; } - if (is_array($target)) { - $args = array_merge($args, $target); + public function getDataSource() + { + return $this->dataSource; } - else { - $args[] = $target; - } - - if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) { - $args[] = '-logger'; - $args[] = 'phing.listener.AnsiColorLogger'; - } - - Phing::startup(); - Phing::setProperty('phing.home', getenv('PHING_HOME')); - $m = new pmPhing(); - $m->execute($args); - $m->runBuild(); - } + /** + * get Data base config object + * @return object containing dbConfig var + */ + public function getDbConfig() + { + return $this->dbConfig; + } + public function setAlterTable($value) + { + $this->alterTable = $value; + } + + /** + * Build the pmTable with all dependencies + */ + public function build() + { + $this->prepare(); + $this->preparePropelIniFile(); + $this->buildSchema(); + + if ($this->alterTable) { + $this->phingbuildModel(); + $this->phingbuildSql(); + $this->upgradeDatabase(); + } + } + + public function buildModelFor($dbsUid, $tablesList) + { + $this->setDataSource($dbsUid); + $loadSchema = false; + $this->prepare($loadSchema); + $this->phingbuildModel(); + $this->phingbuildSql(); + //$this->upgradeDatabaseFor($this->dataSource, $tablesList); + } + + /** + * Prepare the pmTable env + */ + public function prepare($loadSchema=true) + { + //prevent execute prepare() twice or more + if (is_object($this->dom)) { + return true; + } + + $this->schemaFilename = 'schema.xml'; + $this->baseDir = PATH_DB . SYS_SYS . PATH_SEP; + $this->targetDir = $this->baseDir . 'pmt-propel' . PATH_SEP . $this->dataSource . PATH_SEP; + $this->configDir = $this->targetDir . 'config' . PATH_SEP; + $this->dataDir = $this->targetDir . 'data' . PATH_SEP; + $this->classesDir = $this->baseDir . 'classes' . PATH_SEP; + + // G::mk_dir create the requested dir and the parents directories if not exists + G::mk_dir($this->configDir); + G::mk_dir($this->dataDir); + + if ($loadSchema) { + $this->loadSchema(); + } + } + + public function loadSchema() + { + $this->dom = new DOMDocument('1.0', 'utf-8'); + $this->dom->preserveWhiteSpace = false; + $this->dom->formatOutput = true; + + if (file_exists($this->configDir . $this->schemaFilename)) { + if (@$this->dom->load($this->configDir . $this->schemaFilename) !== true) { + throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!'); + } + $this->rootNode = $this->dom->firstChild; + } else { + $this->rootNode = $this->dom->createElement('database'); + $this->rootNode->setAttribute('name', $this->dataSource); + $this->dom->appendChild($this->rootNode); + } + } + + /** + * Build the xml schema for propel + */ + public function buildSchema() + { + $tableNode = $this->dom->createElement('table'); + $tableNode->setAttribute('name', $this->tableName); + + if ($this->hasAutoIncrementPKey()) { + $tableNode->setAttribute('idMethod', 'native'); + } + + // specifying collation + switch ($this->dbConfig->adapter) { + case 'mysql': + $vendorNode = $this->dom->createElement('vendor'); + $vendorNode->setAttribute('type', $this->dbConfig->adapter); + $parameterNode = $this->dom->createElement('parameter'); + $parameterNode->setAttribute('name', 'Collation'); + $parameterNode->setAttribute('value', 'utf8_general_ci'); + $vendorNode->appendChild($parameterNode); + $tableNode->appendChild($vendorNode); + break; + } + + + foreach ($this->columns as $column) { + + // create the column node + $columnNode = $this->dom->createElement('column'); + // setting column node attributes + $columnNode->setAttribute('name', $column->field_name); + $columnNode->setAttribute('type', $column->field_type); + + if ($column->field_size != '' && $column->field_size != 0) { + $columnNode->setAttribute('size', $column->field_size); + } + + $columnNode->setAttribute('required', ($column->field_null ? 'false' : 'true')); + + // only define the primaryKey attribute if it is defined + if ($column->field_key) { + $columnNode->setAttribute('primaryKey', "true"); + } + + // only define the autoIncrement attribute if it is defined + if ($column->field_autoincrement) { + $columnNode->setAttribute('autoIncrement', "true"); + } + $tableNode->appendChild($columnNode); + } + + $xpath = new DOMXPath($this->dom); + $xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); + + if ($xtable->length == 0) { + //the table definition does not exist, then just append the new node + $this->rootNode->appendChild($tableNode); + } else { + // the table definition already exist, then replace the node + $replacedNode = $xtable->item(0); + $this->rootNode->replaceChild($tableNode, $replacedNode); + } + + // saving the xml result file + $this->saveSchema(); + } + + /** + * Remove the pmTable and all related objects, files and others + */ + public function remove() + { + $this->prepare(); + $this->removeFromSchema(); + $this->removeModelFiles(); + $this->dropTable(); + } + + /** + * Remove the target pmTable from schema of propel + */ + public function removeFromSchema() + { + $xpath = new DOMXPath($this->dom); + // locate the node + $xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); + if ($xtable->length == 0) { + return false; + } + + $this->rootNode->removeChild($xtable->item(0)); + // saving the xml result file + $this->saveSchema(); + } + + /** + * Remove the model related classes files + */ + public function removeModelFiles() + { + @unlink($this->classesDir . $this->className . '.php'); + @unlink($this->classesDir . $this->className . 'Peer.php'); + @unlink($this->classesDir . 'map' . PATH_SEP . $this->className . 'MapBuilder.php'); + @unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . '.php'); + @unlink($this->classesDir . 'om' . PATH_SEP . 'Base' . $this->className . 'Peer.php'); + } + + /** + * Drop the phisical table of target pmTable or any specified as parameter + */ + public function dropTable($tableName=null) + { + $tableName = isset($tableName) ? $tableName : $this->tableName; + $con = Propel::getConnection($this->dataSource); + $stmt = $con->createStatement(); + + if (is_object($con)) { + try { + $stmt->executeQuery("DROP TABLE {$tableName}"); + } catch (Exception $e) { + throw new Exception("Physical table '$tableName' does not exist!"); + } + } + } + + /** + * Save the xml schema for propel + */ + public function saveSchema() + { + $this->dom->save($this->configDir . $this->schemaFilename); + } + + /** + * Prepare and create if not exists the propel ini file + */ + public function preparePropelIniFile() + { + $adapter = $this->dbConfig->adapter; + + if (file_exists($this->configDir . "propel.$adapter.ini")) { + return true; + } + + if (!file_exists(PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini")) { + throw new Exception("Invalid or not supported engine '$adapter'!"); + } + + @copy(PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini", + $this->configDir . "propel.$adapter.ini"); + } + + /** + * Upgrade the phisical database for the target pmTable + * It executes the schema.sql autogenerated by propel, but just execute the correspondent sentenses + * for the related table + * - this function is not executing other sentenses like 'SET FOREIGN_KEY_CHECKS = 0;' for mysql, and others + */ + public function upgradeDatabase() + { + $con = Propel::getConnection($this->dataSource); + $stmt = $con->createStatement(); + $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); + $previous = null; + $queryStack = array(); + $aDNS = $con->getDSN(); + $dbEngine = $aDNS["phptype"]; + + foreach ($lines as $j => $line) { + switch ($dbEngine) { + case 'mysql': + $line = trim($line); // Remove comments from the script + + if (strpos($line, "--") === 0) { + $line = substr($line, 0, strpos($line, "--")); + } + + if (empty($line)) { + continue; + } + + if (strpos($line, "#") === 0) { + $line = substr($line, 0, strpos($line, "#")); + } + + if (empty($line)) { + continue; + } + + // Concatenate the previous line, if any, with the current + if ($previous) { + $line = $previous . " " . $line; + } + $previous = null; + + // If the current line doesnt end with ; then put this line together + // with the next one, thus supporting multi-line statements. + if (strrpos($line, ";") != strlen($line) - 1) { + $previous = $line; + continue; + } + + $line = substr($line, 0, strrpos($line, ";")); + // just execute the drop and create table for target table nad not for others + if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) { + $isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName + . '[\]\'\"\`]{1}/i', $line, $match); + if ($isCreateForCurrentTable) { + $queryStack['create'] = $line; + } else { + $isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName + . '[\]\'\"\`]{1}/i', $line, $match); + if ($isDropForCurrentTable) { + $queryStack['drop'] = $line; + } + } + } + break; + case 'mssql': + $line = trim($line); // Remove comments from the script + + if (strpos($line, "--") === 0) { + $line = substr($line, 0, strpos($line, "--")); + } + + if (empty($line)) { + continue; + } + + if (strpos($line, "#") === 0) { + $line = substr($line, 0, strpos($line, "#")); + } + + if (empty($line)) { + continue; + } + + // Concatenate the previous line, if any, with the current + if ($previous) { + $line = $previous . " " . $line; + } + $previous = null; + + // If the current line doesnt end with ; then put this line together + // with the next one, thus supporting multi-line statements. + if (strrpos($line, ";") != strlen($line) - 1) { + $previous = $line; + continue; + } + + $line = substr($line, 0, strrpos($line, ";")); + + if (strpos($line, $this->tableName) == false) { + continue; + } + + $auxCreate = explode('CREATE', $line); + $auxDrop = explode('IF EXISTS', $auxCreate['0']); + + $queryStack['drop'] = 'IF EXISTS' . $auxDrop['1']; + $queryStack['create'] = 'CREATE' . $auxCreate['1']; + + break; + case 'oracle': + $line = trim($line); // Remove comments from the script + if (empty($line)) { + continue; + } + switch (true) { + case preg_match("/^CREATE TABLE\s/i", $line): + if (strpos($line, $this->tableName) == true) { + $inCreate = true; + $lineCreate .= $line . ' '; + } + break; + case preg_match("/ALTER TABLE\s/i", $line): + if (strpos($line, $this->tableName) == true) { + $inAlter = true; + $lineAlter .= $line . ' '; + } + break; + case preg_match("/^DROP TABLE\s/i", $line): + if (strpos($line, $this->tableName) == true) { + $inDrop = true; + $lineDrop .= $line . ' '; + if (strrpos($line, ";") > 0) { + $queryStack['drop'] = $lineDrop; + $inDrop = false; + } + } + break; + default: + if ($inCreate) { + $lineCreate .= $line . ' '; + if (strrpos($line, ";") > 0) { + $queryStack['create'] = $lineCreate; + $inCreate = false; + } + } + if ($inAlter) { + $lineAlter .= $line . ' '; + if (strrpos($line, ";") > 0) { + $queryStack['alter'] = $lineAlter; + $inAlter = false; + } + } + if ($inDrop) { + $lineDrop .= $line . ' '; + if (strrpos($line, ";") > 0) { + $queryStack['drop'] = $lineDrop; + $inDrop = false; + } + } + } + break; + } + } + + if ($dbEngine == 'oracle') { + $queryStack['drop'] = substr($queryStack['drop'], 0, strrpos($queryStack['drop'], ";")); + $queryStack['create'] = substr($queryStack['create'], 0, strrpos($queryStack['create'], ";")); + $queryStack['alter'] = substr($queryStack['alter'], 0, strrpos($queryStack['alter'], ";")); + $queryIfExistTable = "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME = '" . $this->tableName . "'"; + + $rs = $stmt->executeQuery($queryIfExistTable); + if ($rs->next()) { + $stmt->executeQuery($queryStack['drop']); + } + $stmt->executeQuery($queryStack['create']); + $stmt->executeQuery($queryStack['alter']); + } else { + if (isset($queryStack['create'])) { + // first at all we need to verify if we have a valid schema defined, + // so we verify that creating a dummy table + $swapQuery = str_replace($this->tableName, $this->tableName . '_TMP', $queryStack['create']); + + // if there is a problem with user defined table schema executeQuery() will throw a sql exception + $stmt->executeQuery($swapQuery); + + // if there was not problem above proceced deleting the dummy table and drop and create the target table + $stmt->executeQuery("DROP TABLE {$this->tableName}_TMP"); + if (!isset($queryStack['drop'])) { + $queryStack['drop'] = "DROP TABLE {$this->tableName}"; + } + if (!isset($queryStack['create'])) { + throw new Exception('A problem occurred resolving the schema to update for this table'); + } + $stmt->executeQuery($queryStack['drop']); + $stmt->executeQuery($queryStack['create']); + } + } + } + + public function upgradeDatabaseFor($dataSource, $tablesList=array()) + { + $con = Propel::getConnection($dataSource); + $stmt = $con->createStatement(); + $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); + $previous = null; + $errors = ''; + + foreach ($lines as $j => $line) { + $line = trim($line); // Remove comments from the script + + if (strpos($line, "--") === 0) { + $line = substr($line, 0, strpos($line, "--")); + } + + if (empty($line)) { + continue; + } + + if (strpos($line, "#") === 0) { + $line = substr($line, 0, strpos($line, "#")); + } + + if (empty($line)) { + continue; + } + + // Concatenate the previous line, if any, with the current + if ($previous) { + $line = $previous . " " . $line; + } + $previous = null; + + // If the current line doesnt end with ; then put this line together + // with the next one, thus supporting multi-line statements. + if (strrpos($line, ";") != strlen($line) - 1) { + $previous = $line; + continue; + } + + $line = substr($line, 0, strrpos($line, ";")); + + // execute + $isCreate = stripos($line, 'CREATE TABLE') !== false; + $isDrop = stripos($line, 'DROP TABLE') !== false; + + if ($isCreate || $isDrop) { + if (preg_match('/TABLE\s[\'\"\`]+(\w+)[\'\"\`]+/i', $line, $match)) { + if (in_array($match[1], $tablesList)) { + //error_log($line); + try { + $stmt->executeQuery($line); + } catch (Exception $e) { + $errors .= $e->getMessage() . "\n"; + continue; + } + } + } + } + } + + return $errors; + } + + /** + * verify if on the columns list was set a column as primary key + * @return boolean to affirm if was defined a column as pk. + */ + public function hasAutoIncrementPKey() + { + foreach ($this->columns as $column) { + if ($column->field_autoincrement) { + return true; + } + } + + return false; + } + + /** + * + * @return array contains all supported columns types provided by propel + */ + public function getPropelSupportedColumnTypes() + { + /** + * http://www.propelorm.org/wiki/Documentation/1.2/Schema + * [type = "BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR} + * |LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"] + */ + $types = array(); + + $types['BOOLEAN'] = 'BOOLEAN'; + $types['TINYINT'] = 'TINYINT'; + $types['SMALLINT'] = 'SMALLINT'; + $types['INTEGER'] = 'INTEGER'; + $types['BIGINT'] = 'BIGINT'; + $types['DOUBLE'] = 'DOUBLE'; + $types['FLOAT'] = 'FLOAT'; + $types['REAL'] = 'REAL'; + $types['DECIMAL'] = 'DECIMAL'; + $types['CHAR'] = 'CHAR'; + $types['VARCHAR'] = 'VARCHAR'; + $types['LONGVARCHAR'] = 'LONGVARCHAR'; + $types['DATE'] = 'DATE'; + $types['TIME'] = 'TIME'; + $types['DATETIME'] = 'DATETIME'; + //$types['BLOB'] = 'BLOB'; <- disabled + //$types['CLOB'] = 'CLOB'; <- disabled + + return $types; + } + + /** + * @param string $name any string witha name separated by underscore + * @return string contains a camelcase expresion for $name + */ + public function toCamelCase($name) + { + $tmp = explode('_', trim($name)); + foreach ($tmp as $i => $part) { + $tmp[$i] = ucFirst(strtolower($part)); + } + return implode('', $tmp); + } + + /** + * Run om task for phing to build all mdoel classes + */ + public function phingbuildModel() + { + $this->_callPhing('om'); + } + + /** + * Run sql task for phing to generate the sql schema + */ + public function phingbuildSql() + { + $this->_callPhing('sql'); + } + + /** + * call phing to execute a determinated task + * @param string $taskName [om|sql] + */ + private function _callPhing($taskName) + { + $options = array( + 'project.dir' => $this->configDir, + 'build.properties' => "propel.{$this->dbConfig->adapter}.ini", + 'propel.targetPackage' => 'classes', + 'propel.output.dir' => $this->targetDir, + 'propel.php.dir' => $this->baseDir + ); + + self::callPhing(array($taskName), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false); + } + + /** + * @param string $target - task name to execute + * @param string $buildFile - build file path + * @param array $options - array options to override the options on .ini file + * @param bool $verbose - to show a verbose output + */ + public static function callPhing($target, $buildFile='', $options=array(), $verbose=true) + { + G::loadClass('pmPhing'); + + $args = array(); + foreach ($options as $key => $value) { + $args[] = "-D$key=$value"; + } + + if ($buildFile) { + $args[] = '-f'; + $args[] = realpath($buildFile); + } + + if (!$verbose) { + $args[] = '-q'; + } + + if (is_array($target)) { + $args = array_merge($args, $target); + } else { + $args[] = $target; + } + + if (DIRECTORY_SEPARATOR != '\\' && (function_exists('posix_isatty') && @posix_isatty(STDOUT))) { + $args[] = '-logger'; + $args[] = 'phing.listener.AnsiColorLogger'; + } + + Phing::startup(); + Phing::setProperty('phing.home', getenv('PHING_HOME')); + + $m = new pmPhing(); + $m->execute($args); + $m->runBuild(); + } } + \ No newline at end of file diff --git a/workflow/engine/classes/model/DbSource.php b/workflow/engine/classes/model/DbSource.php index 89fe94080..02fed97d5 100755 --- a/workflow/engine/classes/model/DbSource.php +++ b/workflow/engine/classes/model/DbSource.php @@ -1,4 +1,5 @@ getDbsUid() == "" ) { - throw ( new Exception( "Error in getDBSourceDescription, the getDbsUid() can't be blank") ); - } - $lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en'; - $this->db_source_description = Content::load ( 'DBS_DESCRIPTION', '', $this->getDbsUid(), $lang ); - return $this->db_source_description; + public function getDBSourceDescription() + { + if ($this->getDbsUid() == "") { + throw ( new Exception("Error in getDBSourceDescription, the getDbsUid() can't be blank") ); + } + $lang = defined('SYS_LANG') ? SYS_LANG : 'en'; + $this->db_source_description = Content::load('DBS_DESCRIPTION', '', $this->getDbsUid(), $lang); + return $this->db_source_description; } - function getCriteriaDBSList($sProcessUID) + public function getCriteriaDBSList($sProcessUID) { $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); @@ -95,46 +95,44 @@ class DbSource extends BaseDbSource $this->setNew(false); return $aFields; } else { - throw(new Exception( "The row '$Uid'/'$ProUID' in table DbSource doesn't exist!" )); + throw(new Exception("The row '$Uid'/'$ProUID' in table DbSource doesn't exist!")); } - } - catch (exception $oError) { + } catch (exception $oError) { throw ($oError); } } - public function getValProUid($Uid) - { - $oCriteria = new Criteria('workflow'); - $oCriteria->clearSelectColumns(); - $oCriteria->addSelectColumn(DbSourcePeer::PRO_UID); - $oCriteria->add(DbSourcePeer::DBS_UID, $Uid); - $result = DbSourcePeer::doSelectRS($oCriteria); - $result->next(); - $aRow = $result->getRow(); - return $aRow[0]; - } + public function getValProUid($Uid) + { + $oCriteria = new Criteria('workflow'); + $oCriteria->clearSelectColumns(); + $oCriteria->addSelectColumn(DbSourcePeer::PRO_UID); + $oCriteria->add(DbSourcePeer::DBS_UID, $Uid); + $result = DbSourcePeer::doSelectRS($oCriteria); + $result->next(); + $aRow = $result->getRow(); + return $aRow[0]; + } - function Exists ( $Uid, $ProUID ) { - try { - $oPro = DbSourcePeer::retrieveByPk( $Uid, $ProUID ); - if (is_object($oPro) && get_class ($oPro) == 'DbSource' ) { - return true; - } - else { - return false; - } + public function Exists($Uid, $ProUID) + { + try { + $oPro = DbSourcePeer::retrieveByPk($Uid, $ProUID); + if (is_object($oPro) && get_class($oPro) == 'DbSource') { + return true; + } else { + return false; + } + } catch (Exception $oError) { + throw($oError); + } } - catch (Exception $oError) { - throw($oError); - } - } public function update($fields) { - if( $fields['DBS_ENCODE'] == '0'){ - unset($fields['DBS_ENCODE']); - } + if ($fields['DBS_ENCODE'] == '0') { + unset($fields['DBS_ENCODE']); + } $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); try { $con->begin(); @@ -148,14 +146,13 @@ class DbSource extends BaseDbSource $con->rollback(); throw (new Exception("Failed Validation in class " . get_class($this) . ".")); } - } - catch (exception $e) { + } catch (exception $e) { $con->rollback(); throw ($e); } } - function remove($DbsUid, $ProUID ) + public function remove($DbsUid, $ProUID) { $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); try { @@ -165,30 +162,31 @@ class DbSource extends BaseDbSource // note added by gustavo cruz gustavo-at-colosa-dot-com // we assure that the _delete attribute must be set to false // if a record exists in the database with that uid. - if ($this->Exists($DbsUid, $ProUID)){ + if ($this->Exists($DbsUid, $ProUID)) { $this->setDeleted(false); } $result = $this->delete(); $con->commit(); return $result; - } - catch (exception $e) { + } catch (exception $e) { $con->rollback(); throw ($e); } } - function create($aData) + public function create($aData) { - if( $aData['DBS_ENCODE'] == '0'){ - unset($aData['DBS_ENCODE']); - } + if ($aData['DBS_ENCODE'] == '0') { + unset($aData['DBS_ENCODE']); + } $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); try { - if ( isset ( $aData['DBS_UID'] ) && $aData['DBS_UID']== '' ) - unset ( $aData['DBS_UID'] ); - if ( !isset ( $aData['DBS_UID'] ) ) - $aData['DBS_UID'] = G::generateUniqueID(); + if (isset($aData['DBS_UID']) && $aData['DBS_UID'] == '') { + unset($aData['DBS_UID']); + } + if (!isset($aData['DBS_UID'])) { + $aData['DBS_UID'] = G::generateUniqueID(); + } $this->fromArray($aData, BasePeer::TYPE_FIELDNAME); if ($this->validate()) { $result = $this->save(); @@ -199,11 +197,11 @@ class DbSource extends BaseDbSource } $con->commit(); return $this->getDbsUid(); - } - catch (exception $e) { + } catch (exception $e) { $con->rollback(); throw ($e); } } - -} // DbSource +} +// DbSource + \ No newline at end of file From b6c177a32ee17a76394068195a385af50a7121a0 Mon Sep 17 00:00:00 2001 From: Hector Cortez Date: Wed, 4 Jul 2012 17:21:03 -0400 Subject: [PATCH 3/3] BUG 5359 Trigger wizard should indicate that the return value... SOLVED - The interface for the Trigger wizard should say that the return value variable is option (not required). - Adjustment index the third parameter that defined in return value. --- .../engine/templates/triggers/triggers_EditWizard.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/workflow/engine/templates/triggers/triggers_EditWizard.php b/workflow/engine/templates/triggers/triggers_EditWizard.php index 7ccbadd4a..6fb055219 100755 --- a/workflow/engine/templates/triggers/triggers_EditWizard.php +++ b/workflow/engine/templates/triggers/triggers_EditWizard.php @@ -53,8 +53,12 @@ try { $bReturnValue = true; $displayMode = 'display:block'; - $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ( 'ID_NONE')) ) - ? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3]; + $methodreturnDescription = ""; + if (isset($methodreturnA[3])) { + $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ('ID_NONE'))) + ? G::LoadTranslation ( 'ID_NOT_REQUIRED') + : $methodreturnA [3]; + } $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) {