public function getVars($bWhitSystemVars = true) { $aFields = array(); if ($bWhitSystemVars) { $aAux = G::getSystemConstants(); foreach ($aAux as $sName => $sValue) { $aFields[] = array("sName" => $sName, "sType" => "system"); } } foreach ($this->fields as $k => $v) { if ($v->type != "title" && $v->type != "subtitle" && $v->type != "file" && $v->type != "button" && $v->type != "reset" && $v->type != "submit" && $v->type != "listbox" && $v->type != "checkgroup" && $v->type != "grid" && $v->type != "javascript") { $aFields[] = array('sName' => trim($k), 'sType' => trim($v->type)); } } return $aFields; }
/** * Get data of Cases InputDocument * * @param string $applicationUid * @param string $taskUid * @param string $appDocComment * @param string $inputDocumentUid * @param string $userUid * * return array Return an array with data of an InputDocument */ public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid) { try { if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) { $code = $_FILES['form']['error']; switch ($code) { case UPLOAD_ERR_INI_SIZE: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' ); break; case UPLOAD_ERR_FORM_SIZE: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_FORM_SIZE' ); break; case UPLOAD_ERR_PARTIAL: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' ); break; case UPLOAD_ERR_NO_FILE: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_FILE' ); break; case UPLOAD_ERR_NO_TMP_DIR: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_TMP_DIR' ); break; case UPLOAD_ERR_CANT_WRITE: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' ); break; case UPLOAD_ERR_EXTENSION: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' ); break; default: $message = \G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' ); break; } \G::SendMessageText( $message, "ERROR" ); $backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] ); \G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] ); die(); } \G::LoadClass("case"); $appDocUid = \G::generateUniqueID(); $docVersion = ''; $appDocType = 'INPUT'; $case = new \Cases(); $delIndex = \AppDelegation::getCurrentIndex($applicationUid); $case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, "REDIRECT", "casesListExtJs"); //Load the fields $arrayField = $case->loadCase($applicationUid); $arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants()); //Triggers $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document if (empty($_FILES)) { throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_FILENAME_DOES_NOT_EXIST")); } if (!$_FILES["form"]["error"]) { $_FILES["form"]["error"] = 0; } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { $appDocUid = $case->addInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType, $appDocComment, '', $applicationUid, $delIndex, $taskUid, $userUid, "xmlform", $_FILES["form"]["name"], $_FILES["form"]["error"], $_FILES["form"]["tmp_name"]); } //Trigger - Execute after - Start $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER", $arrayField["APP_DATA"]); //Trigger - Execute after - End //Save data $arrayData = array(); $arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"]; //$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"]; $arrayData["APP_DATA"] = $arrayField["APP_DATA"]; $arrayData["DEL_INDEX"] = $delIndex; $arrayData["TAS_UID"] = $taskUid; $case->updateCase($applicationUid, $arrayData); return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid)); } catch (\Exception $e) { throw $e; } }
/** * derivate Case moves the case to the next task in the process according to the routing rules * * @param string $userId * @param string $caseId * @param string $delIndex * @param array $tasks * @param bool $bExecuteTriggersBeforeAssignment * @return $result will return an object */ public function derivateCase ($userId, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $tasks = array()) { $g = new G(); try { $g->sessionVarSave(); $_SESSION["APPLICATION"] = $caseId; $_SESSION["INDEX"] = $delIndex; $_SESSION["USER_LOGGED"] = $userId; $sStatus = 'TO_DO'; $varResponse = ''; $varTriggers = "\n"; if ($delIndex == '') { $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX ); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); if (AppDelegationPeer::doCount( $oCriteria ) > 1) { $result = new wsResponse( 20, G::loadTranslation( 'ID_SPECIFY_DELEGATION_INDEX' ) ); return $result; } $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); $delIndex = $aRow['DEL_INDEX']; } $oAppDel = new AppDelegation(); $appdel = $oAppDel->Load( $caseId, $delIndex ); if ($userId != $appdel['USR_UID']) { $result = new wsResponse( 17, G::loadTranslation( 'ID_CASE_ASSIGNED_ANOTHER_USER' ) ); return $result; } if ($appdel['DEL_FINISH_DATE'] != null) { $result = new wsResponse( 18, G::loadTranslation( 'ID_CASE_DELEGATION_ALREADY_CLOSED' ) ); return $result; } $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelayPeer::APP_UID ); $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX ); $oCriteria->add( AppDelayPeer::APP_TYPE, '' ); $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'PAUSE' )->addOr( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'CANCEL' ) ) ); $oCriteria->addAscendingOrderByColumn( AppDelayPeer::APP_ENABLE_ACTION_DATE ); $oDataset = AppDelayPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (is_array( $aRow )) { if (isset( $aRow['APP_DISABLE_ACTION_USER'] ) && $aRow['APP_DISABLE_ACTION_USER'] != 0 && isset( $aRow['APP_DISABLE_ACTION_DATE'] ) && $aRow['APP_DISABLE_ACTION_DATE'] != '') { $result = new wsResponse( 19, G::loadTranslation( 'ID_CASE_IN_STATUS' ) . " " . $aRow['APP_TYPE'] ); return $result; } } $aData = array(); $aData['APP_UID'] = $caseId; $aData['DEL_INDEX'] = $delIndex; $aData['USER_UID'] = $userId; //Load data $oCase = new Cases(); $appFields = $oCase->loadCase( $caseId, $delIndex ); if (is_null( $appFields["DEL_INIT_DATE"] )) { $oCase->setDelInitDate( $caseId, $delIndex ); $appFields = $oCase->loadCase( $caseId, $delIndex ); } $appFields["APP_DATA"]["APPLICATION"] = $caseId; if (! isset( $_SESSION["PROCESS"] )) { $_SESSION["PROCESS"] = $appFields["PRO_UID"]; } if ($bExecuteTriggersBeforeAssignment) { //Execute triggers before assignment $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 1, 'BEFORE' ); if (count( $aTriggers ) > 0) { $varTriggers = $varTriggers . "<br /><b>-= Before Assignment =-</b><br />"; $oPMScript = new PMScript(); foreach ($aTriggers as $aTrigger) { //$appFields = $oCase->loadCase( $caseId ); //$appFields['APP_DATA']['APPLICATION'] = $caseId; //Set variables $params = new stdClass(); $params->appData = $appFields["APP_DATA"]; if ($this->stored_system_variables) { $params->option = "STORED SESSION"; $params->SID = $this->wsSessionId; } $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); //PMScript $oPMScript->setFields( $appFields['APP_DATA'] ); $bExecute = true; if ($aTrigger['ST_CONDITION'] !== '') { $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); $bExecute = $oPMScript->evaluate(); } if ($bExecute) { $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); $oPMScript->execute(); $trigger = TriggersPeer::retrieveByPk($aTrigger["TRI_UID"]); $varTriggers = $varTriggers . " - " . nl2br(htmlentities($trigger->getTriTitle(), ENT_QUOTES)) . "<br />"; //$appFields = $oCase->loadCase( $caseId ); $appFields['APP_DATA'] = $oPMScript->aFields; unset($appFields['APP_STATUS']); unset($appFields['APP_PROC_STATUS']); unset($appFields['APP_PROC_CODE']); unset($appFields['APP_PIN']); $oCase->updateCase( $caseId, $appFields ); } } } } //Execute triggers before derivation BEFORE_ROUTING $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'BEFORE' ); if (count( $aTriggers ) > 0) { $varTriggers .= "<b>-= Before Derivation =-</b><br/>"; $oPMScript = new PMScript(); foreach ($aTriggers as $aTrigger) { //$appFields = $oCase->loadCase( $caseId ); //$appFields['APP_DATA']['APPLICATION'] = $caseId; //Set variables $params = new stdClass(); $params->appData = $appFields["APP_DATA"]; if ($this->stored_system_variables) { $params->option = "STORED SESSION"; $params->SID = $this->wsSessionId; } $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); //PMScript $oPMScript->setFields( $appFields['APP_DATA'] ); $bExecute = true; if ($aTrigger['ST_CONDITION'] !== '') { $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); $bExecute = $oPMScript->evaluate(); } if ($bExecute) { $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); $oPMScript->execute(); $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "<br/>"; //$appFields = $oCase->loadCase( $caseId ); $appFields['APP_DATA'] = $oPMScript->aFields; unset($appFields['APP_STATUS']); unset($appFields['APP_PROC_STATUS']); unset($appFields['APP_PROC_CODE']); unset($appFields['APP_PIN']); //$appFields['APP_DATA']['APPLICATION'] = $caseId; $oCase->updateCase( $caseId, $appFields ); } } } $oDerivation = new Derivation(); if (!empty($tasks)) { $nextDelegations = $tasks; } else { $derive = $oDerivation->prepareInformation($aData); if (isset($derive[1])) { if ($derive[1]['ROU_TYPE'] == 'SELECT') { $result = new wsResponse(21, G::loadTranslation('ID_CAN_NOT_ROUTE_CASE_USING_WEBSERVICES')); return $result; } } else { $result = new wsResponse(22, G::loadTranslation('ID_TASK_DOES_NOT_HAVE_ROUTING_RULE')); return $result; } foreach ($derive as $key => $val) { if ($val['NEXT_TASK']['TAS_ASSIGN_TYPE'] == 'MANUAL') { $result = new wsResponse(15, G::loadTranslation('ID_TASK_DEFINED_MANUAL_ASSIGNMENT')); return $result; } //Routed to the next task, if end process then not exist user $nodeNext = array(); $usrasgdUid = null; $usrasgdUserName = null; if (isset($val['NEXT_TASK']['USER_ASSIGNED'])) { $usrasgdUid = $val['NEXT_TASK']['USER_ASSIGNED']['USR_UID']; $usrasgdUserName = '******' . $val['NEXT_TASK']['USER_ASSIGNED']['USR_USERNAME'] . ')'; } $nodeNext['TAS_UID'] = $val['NEXT_TASK']['TAS_UID']; $nodeNext['USR_UID'] = $usrasgdUid; $nodeNext['TAS_ASSIGN_TYPE'] = $val['NEXT_TASK']['TAS_ASSIGN_TYPE']; $nodeNext['TAS_DEF_PROC_CODE'] = $val['NEXT_TASK']['TAS_DEF_PROC_CODE']; $nodeNext['DEL_PRIORITY'] = $appdel['DEL_PRIORITY']; $nodeNext['TAS_PARENT'] = $val['NEXT_TASK']['TAS_PARENT']; $nextDelegations[] = $nodeNext; $varResponse = $varResponse . (($varResponse != '') ? ',' : '') . $val['NEXT_TASK']['TAS_TITLE'] . $usrasgdUserName; } } $appFields['DEL_INDEX'] = $delIndex; if (isset( $derive['TAS_UID'] )) { $appFields['TAS_UID'] = $derive['TAS_UID']; } //Save data - Start //$appFields = $oCase->loadCase( $caseId ); //$oCase->updateCase ( $caseId, $appFields ); //Save data - End $row = array (); $oCriteria = new Criteria( 'workflow' ); $del = DBAdapter::getStringDelimiter(); $oCriteria->addSelectColumn( RoutePeer::ROU_TYPE ); $oCriteria->addSelectColumn( RoutePeer::ROU_NEXT_TASK ); $oCriteria->add( RoutePeer::TAS_UID, $appdel['TAS_UID'] ); $oDataset = TaskPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $row[] = array ('ROU_TYPE' => $aRow['ROU_TYPE'],'ROU_NEXT_TASK' => $aRow['ROU_NEXT_TASK'] ); $oDataset->next(); } //derivate case $aCurrentDerivation = array ('APP_UID' => $caseId,'DEL_INDEX' => $delIndex,'APP_STATUS' => $sStatus,'TAS_UID' => $appdel['TAS_UID'],'ROU_TYPE' => $row[0]['ROU_TYPE'] ); $oDerivation->derivate( $aCurrentDerivation, $nextDelegations ); $appFields = $oCase->loadCase( $caseId ); //Execute triggers after derivation $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'AFTER' ); if (count( $aTriggers ) > 0) { //$appFields['APP_DATA']['APPLICATION'] = $caseId; //Set variables $params = new stdClass(); $params->appData = $appFields["APP_DATA"]; if ($this->stored_system_variables) { $params->option = "STORED SESSION"; $params->SID = $this->wsSessionId; } $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); //PMScript $oPMScript = new PMScript(); $oPMScript->setFields( $appFields['APP_DATA'] ); $varTriggers .= "<b>-= After Derivation =-</b><br/>"; foreach ($aTriggers as $aTrigger) { $bExecute = true; if ($aTrigger['ST_CONDITION'] !== '') { $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); $bExecute = $oPMScript->evaluate(); } if ($bExecute) { $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); $oPMScript->execute(); $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "<br/>"; //$appFields = $oCase->loadCase($caseId); $appFields['APP_DATA'] = $oPMScript->aFields; //$appFields['APP_DATA']['APPLICATION'] = $caseId; //$appFields = $oCase->loadCase($caseId); unset($aFields['APP_STATUS']); unset($aFields['APP_PROC_STATUS']); unset($aFields['APP_PROC_CODE']); unset($aFields['APP_PIN']); $oCase->updateCase( $caseId, $appFields ); } } } $sFromName = ""; if ($userId != "") { $user = new Users(); $arrayUserData = $user->load($userId); if (trim($arrayUserData["USR_EMAIL"]) == "") { $arrayUserData["USR_EMAIL"] = "info@" . $_SERVER["HTTP_HOST"]; } $sFromName = "\"" . $arrayUserData["USR_FIRSTNAME"] . " " . $arrayUserData["USR_LASTNAME"] . "\" <" . $arrayUserData["USR_EMAIL"] . ">"; } $oCase->sendNotifications( $appdel['TAS_UID'], $nextDelegations, $appFields['APP_DATA'], $caseId, $delIndex, $sFromName ); // Send notifications Mobile - Start try { $oLight = new \ProcessMaker\BusinessModel\Light(); $nextIndex = $oLight->getInformationDerivatedCase($appFields['APP_UID'], $delIndex); $notificationMobile = new \ProcessMaker\BusinessModel\Light\NotificationDevice(); $notificationMobile->routeCaseNotification($userId, $_SESSION["PROCESS"], $appdel['TAS_UID'], $appFields, $nextDelegations, $nextIndex); } catch (Exception $e) { \G::log(G::loadTranslation( 'ID_NOTIFICATION_ERROR' ) . '|' . $e->getMessage() , PATH_DATA, "mobile.log"); } // Send notifications Mobile - End //Save data - Start //$appFields = $oCase->loadCase($caseId); //$oCase->updateCase($caseId, $appFields); //Save data - End $oProcess = new Process(); $oProcessFieds = $oProcess->Load( $appFields['PRO_UID'] ); //here dubug mode in web entry if (isset( $oProcessFieds['PRO_DEBUG'] ) && $oProcessFieds['PRO_DEBUG']) { $result = new wsResponse( 0, $varResponse . " <br><br><table width='100%' cellpadding='0' cellspacing='0'><tr><td class='FormTitle'> " . G::LoadTranslation( 'ID_DEBUG_MESSAGE' ) . "</td></tr></table>" . $varTriggers ); } else { $result = new wsResponse( 0, $varResponse . " --- " . $oProcessFieds['PRO_DEBUG'] ); } $res = $result->getPayloadArray(); //now fill the array of AppDelegationPeer $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_INDEX ); $oCriteria->addSelectColumn( AppDelegationPeer::USR_UID ); $oCriteria->addSelectColumn( AppDelegationPeer::TAS_UID ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_THREAD ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_THREAD_STATUS ); $oCriteria->addSelectColumn( AppDelegationPeer::DEL_FINISH_DATE ); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::DEL_PREVIOUS, $delIndex ); $oCriteria->addAscendingOrderByColumn( AppDelegationPeer::DEL_INDEX ); $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $aCurrentUsers = array (); while ($oDataset->next()) { $aAppDel = $oDataset->getRow(); $oUser = new Users(); try { $oUser->load( $aAppDel['USR_UID'] ); $uFields = $oUser->toArray( BasePeer::TYPE_FIELDNAME ); $currentUserName = $oUser->getUsrFirstname() . ' ' . $oUser->getUsrLastname(); } catch (Exception $e) { $currentUserName = ''; } $oTask = new Task(); try { $uFields = $oTask->load( $aAppDel['TAS_UID'] ); $taskName = $uFields['TAS_TITLE']; } catch (Exception $e) { $taskName = ''; } // execute events $eventPro = $_SESSION["PROCESS"]; $eventApp = $caseId; $eventInd = $aAppDel['DEL_INDEX']; $eventTas = $aAppDel['TAS_UID']; $oEvent = new Event(); $oEvent->createAppEvents( $eventPro, $eventApp, $eventInd, $eventTas ); // end events $currentUser = new stdClass(); $currentUser->userId = $aAppDel['USR_UID']; $currentUser->userName = $currentUserName; $currentUser->taskId = $aAppDel['TAS_UID']; $currentUser->taskName = $taskName; $currentUser->delIndex = $aAppDel['DEL_INDEX']; $currentUser->delThread = $aAppDel['DEL_THREAD']; $currentUser->delThreadStatus = $aAppDel['DEL_THREAD_STATUS']; $aCurrentUsers[] = $currentUser; } $res['routing'] = $aCurrentUsers; $g->sessionVarRestore(); return $res; } catch (Exception $e) { $result = new wsResponse( 100, $e->getMessage() ); $g->sessionVarRestore(); return $result; } }
/** * Function that return the valid fields to replace * * @author Julio Cesar Laura Avendao?=o <*****@*****.**> * @access public * @param boolean $bWhitSystemVars * @return array */ public function getVars($bWhitSystemVars = true) { $aFields = array(); if ($bWhitSystemVars) { $aAux = G::getSystemConstants(); foreach ($aAux as $sName => $sValue) { $aFields[] = array('sName' => $sName, 'sType' => 'system'); } } foreach ($this->fields as $k => $v) { if ($v->type != 'title' && $v->type != 'subtitle' && $v->type != 'link' && $v->type != 'file' && $v->type != 'button' && $v->type != 'reset' && $v->type != 'submit' && $v->type != 'listbox' && $v->type != 'checkgroup' && $v->type != 'grid' && $v->type != 'javascript') { $aFields[] = array('sName' => trim($k), 'sType' => trim($v->type)); } } return $aFields; }
G::header("location: " . "/sys" . SYS_SYS . $backUrlObj[1]); die; } G::LoadClass("case"); $inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"] $appDocUid = $_POST["form"]["APP_DOC_UID"]; $docVersion = intval($_POST["form"]["docVersion"]); $appDocType = $_POST["form"]["APP_DOC_TYPE"]; $appDocComment = isset($_POST["form"]["APP_DOC_COMMENT"]) ? $_POST["form"]["APP_DOC_COMMENT"] : ""; $actionType = $_POST["form"]["actionType"]; $case = new Cases(); $case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs"); //Load the fields $arrayField = $case->loadCase($_SESSION["APPLICATION"]); $arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants()); //Triggers $arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Trigger debug routines //Cleaning debug variables $_SESSION["TRIGGER_DEBUG"]["ERRORS"] = array(); $_SESSION["TRIGGER_DEBUG"]["DATA"] = array(); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = array(); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = array(); $_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] = count($arrayTrigger); $_SESSION["TRIGGER_DEBUG"]["TIME"] = "AFTER"; if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = $case->getTriggerNames($arrayTrigger); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger; } //Add Input Document
public function executeTriggersAfterExternal($sProcess, $sTask, $sApplication, $iIndex, $iStepPosition, $aNewData = array()) { //load the variables $Fields = $this->loadCase($sApplication); $Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants()); $Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], $aNewData); //execute triggers $oCase = new Cases(); $aNextStep = $this->getNextStep($sProcess, $sApplication, $iIndex, $iStepPosition - 1); $Fields['APP_DATA'] = $this->ExecuteTriggers( $sTask, 'EXTERNAL', $aNextStep['UID'], 'AFTER', $Fields['APP_DATA'] ); //save data $aData = array(); $aData['APP_NUMBER'] = $Fields['APP_NUMBER']; //$aData['APP_PROC_STATUS'] = $Fields['APP_PROC_STATUS']; $aData['APP_DATA'] = $Fields['APP_DATA']; $aData['DEL_INDEX'] = $iIndex; $aData['TAS_UID'] = $sTask; $this->updateCase($sApplication, $aData); }
/** * consolidatedUpdate * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia */ function consolidatedUpdate($dynaformUid, $dataUpdate, $usr_uid) { G::LoadClass("case"); G::LoadClass("pmFunctions"); $delIndex = 1; $oCase = new \Cases(); $array = array(); $array["form"] = $dataUpdate; $appUid = $array["form"]["APP_UID"]; $fields = $oCase->loadCase($appUid); if (!isset($fields["DEL_INIT_DATE"])) { $oCase->setDelInitDate($appUid, $delIndex); //$aFields = $oCase->loadCase($appUid, $delIndex); $fields = $oCase->loadCase($appUid, $delIndex); } $auxAppDataApplication = $fields["APP_DATA"]["APPLICATION"]; $auxAppDataProcess = $fields["APP_DATA"]["PROCESS"]; $auxAppDataTask = $fields["APP_DATA"]["TASK"]; $auxAppDataIndex = $fields["APP_DATA"]["INDEX"]; foreach ($array["form"] as $key => $value) { $array["form"][$key] = (string)$array["form"][$key]; if (isset($fields["APP_DATA"][$key.'_label'])) { $array["form"][$key.'_label'] = (string)$array["form"][$key]; } } /* $_POST['form'] = $array["form"]; if (!class_exists('Smarty')) { require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php'); } $oForm = new \Form( $auxAppDataProcess . "/" . $dynaformUid , PATH_DYNAFORM ); $oForm->validatePost(); $array["form"] = $_POST['form']; */ $fields["APP_DATA"] = array_merge($fields["APP_DATA"], G::getSystemConstants()); $fields["APP_DATA"] = array_merge($fields["APP_DATA"], $array["form"]); $fields["APP_DATA"]["APPLICATION"] = $auxAppDataApplication; $fields["APP_DATA"]["PROCESS"] = $auxAppDataProcess; $fields["APP_DATA"]["TASK"] = $auxAppDataTask; $fields["APP_DATA"]["INDEX"] = $auxAppDataIndex; $aData = array(); $aData["APP_NUMBER"] = $fields["APP_NUMBER"]; $aData["APP_PROC_STATUS"] = $fields["APP_PROC_STATUS"]; $aData["APP_DATA"] = $fields["APP_DATA"]; $aData["DEL_INDEX"] = $delIndex; $aData["TAS_UID"] = $fields["APP_DATA"]["TASK"]; $aData["CURRENT_DYNAFORM"] = $dynaformUid; $aData["USER_UID"] = $usr_uid; $aData["APP_STATUS"] = $fields["APP_STATUS"]; $aData["PRO_UID"] = $fields["APP_DATA"]["PROCESS"]; $oCase->updateCase($appUid, $aData); }
/** * Function getDynaformsVars * * @access public * @param eter string $sProcessUID * @param eter boolean $bSystemVars * @return array */ function getDynaformsVars ($sProcessUID, $typeVars = 'all', $bIncMulSelFields = 0) { $aFields = array (); $aFieldsNames = array (); if ($typeVars == 'system' || $typeVars == 'all') { $aAux = G::getSystemConstants(); foreach ($aAux as $sName => $sValue) { $aFields[] = array ('sName' => $sName,'sType' => 'system','sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLES')); } //we're adding the ping variable to the system list $aFields[] = array ('sName' => 'PIN','sType' => 'system','sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLES')); } $aInvalidTypes = array("title", "subtitle", "file", "button", "reset", "submit", "javascript", "pmconnection"); $aMultipleSelectionFields = array("listbox", "checkgroup"); if ($bIncMulSelFields != 0) { $aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields ); } // getting bpmn projects $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(BpmnProjectPeer::PRJ_UID); $oCriteria->add(BpmnProjectPeer::PRJ_UID, $sProcessUID); $oDataset = ProcessPeer::doSelectRS($oCriteria, Propel::getDbConnection('workflow_ro')); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $row = $oDataset->getRow(); if (isset($row["PRJ_UID"])) { if($typeVars == 'process' || $typeVars == 'all') { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_UID); $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_NAME); $oCriteria->addSelectColumn(ProcessVariablesPeer::VAR_FIELD_TYPE); $oCriteria->add(ProcessVariablesPeer::PRJ_UID, $sProcessUID); $oDataset = DynaformPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($oDataset->next()) { $row = $oDataset->getRow(); array_push($aFields, array( "sName" => $row["VAR_NAME"], "sType" => $row["VAR_FIELD_TYPE"], "sLabel" => $row["VAR_FIELD_TYPE"] )); } } if($typeVars == 'grid' || $typeVars == 'all') { $oC = new Criteria( 'workflow' ); $oC->addSelectColumn( DynaformPeer::DYN_CONTENT ); $oC->add( DynaformPeer::PRO_UID, $sProcessUID ); $oC->add( DynaformPeer::DYN_TYPE, 'xmlform' ); $oData = DynaformPeer::doSelectRS( $oC ); $oData->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oData->next(); while ($aRowd = $oData->getRow()) { $dynaform = G::json_decode($aRowd['DYN_CONTENT'],true); if(is_array($dynaform) && sizeof($dynaform)) { $items = $dynaform['items'][0]['items']; foreach($items as $key => $val){ if($val[0]['type'] == 'grid'){ if(sizeof($val[0]['columns'])) { $columns = $val[0]['columns']; foreach($columns as $column) { array_push($aFields, array( "sName" => $column['name'], "sType" => $column['type'], "sLabel" => $column['type'] )); } } } } } $oData->next(); } } } else { require_once 'classes/model/Dynaform.php'; $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( DynaformPeer::DYN_FILENAME ); $oCriteria->add( DynaformPeer::PRO_UID, $sProcessUID ); $oCriteria->add( DynaformPeer::DYN_TYPE, 'xmlform' ); $oDataset = DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if (file_exists( PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml' )) { $G_FORM = new Form( $aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG ); if (($G_FORM->type == 'xmlform') || ($G_FORM->type == '')) { foreach ($G_FORM->fields as $k => $v) { if (! in_array( $v->type, $aInvalidTypes )) { if (! in_array( $k, $aFieldsNames )) { $aFields[] = array ('sName' => $k,'sType' => $v->type,'sLabel' => ($v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation( 'ID_GRID' ) . ' ]') ); $aFieldsNames[] = $k; } } } } } $oDataset->next(); } } return $aFields; }
/** * @covers G::getSystemConstants * @todo Implement testGetSystemConstants(). */ public function testGetSystemConstants() { $response = G::getSystemConstants(); $this->assertTrue(is_array($response)); }
/** * @method * * Returns a list or user. * * @name PMFGetUserEmailAddress * @label PMF Get User Email Address * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFGetUserEmailAddress.28.29 * * @param string(32) or Array | $id | Case ID | Id of the case. * @param string(32) | $APP_UID = null | Application ID | Id of the Application. * @param string(32) | $prefix = "usr" | prefix | Id of the task. * @return array | $aRecipient | Array of the Recipient | Return an Array of the Recipient. * */ function PMFGetUserEmailAddress($id, $APP_UID = null, $prefix = 'usr') { 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); } } 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; } 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); if ($oUserRow != null) { $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; } }
$oApp = new Cases(); $aFields = $oApp->loadCase($_SESSION['APPLICATION']); $aVars = array(); for ($i = 0; $i < count($_SESSION['TRIGGER_DEBUG']['DATA']); $i++) { $aVars[$_SESSION['TRIGGER_DEBUG']['DATA'][$i]['key']] = $_SESSION['TRIGGER_DEBUG']['DATA'][$i]['value']; } $aVars = array_merge($aFields['APP_DATA'], $aVars); if (isset($_POST['filter']) && $_POST['filter'] == 'dyn') { $sysVars = array_keys(G::getSystemConstants()); $varNames = array_keys($aVars); foreach ($varNames as $var) { if (in_array($var, $sysVars)) { unset($aVars[$var]); } } } if (isset($_POST['filter']) && $_POST['filter'] == 'sys') { $aVars = G::getSystemConstants(); } ksort($aVars); $return_object = new StdClass(); $return_object->totalCount = 1; foreach ($aVars as $i => $var) { if (is_array($var) || is_object($var)) { $aVars[$i] = print_r($var, true); } } $return_object->data[0] = $aVars; echo G::json_encode($return_object); break; }
/** * Return Informaction User for derivate * assignment Users * * return array Return an array with Task Case */ public function GetPrepareInformation($usr_uid, $tas_uid, $app_uid, $del_index = null) { try { $oCase = new \Cases(); $Fields = $oCase->loadCase($app_uid); $_SESSION["APPLICATION"] = $app_uid; $_SESSION["PROCESS"] = $Fields['PRO_UID']; $_SESSION["TASK"] = $tas_uid; $_SESSION["INDEX"] = $del_index; $_SESSION["USER_LOGGED"] = $usr_uid; $_SESSION["USR_USERNAME"] = isset($Fields['APP_DATA']['USR_USERNAME']) ? $Fields['APP_DATA']['USR_USERNAME'] : ''; $triggers = $oCase->loadTriggers($tas_uid, 'ASSIGN_TASK', '-1', 'BEFORE'); if (isset($triggers)) { $Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants()); $Fields['APP_DATA'] = $oCase->ExecuteTriggers($tas_uid, 'DYNAFORM', '-1', 'BEFORE', $Fields['APP_DATA']); $oCase->updateCase($app_uid, $Fields); } $oDerivation = new \Derivation(); $aData = array(); $aData['APP_UID'] = $app_uid; $aData['DEL_INDEX'] = $del_index; $aData['USER_UID'] = $usr_uid; $derive = $oDerivation->prepareInformation($aData); $response = array(); foreach ($derive as $sKey => &$aValues) { $sPriority = ''; //set priority value if ($derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'] != '') { //TO DO: review this type of assignment if (isset($aData['APP_DATA'][str_replace('@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])])) { $sPriority = $aData['APP_DATA'][str_replace('@@', '', $derive[$sKey]['NEXT_TASK']['TAS_PRIORITY_VARIABLE'])]; } } //set priority value $taskType = isset($aValues["NEXT_TASK"]["TAS_TYPE"]) ? $aValues["NEXT_TASK"]["TAS_TYPE"] : false; $taskMessage = ""; switch ($taskType) { case "SCRIPT-TASK": $taskMessage = G::LoadTranslation("ID_ROUTE_TO_TASK_SCRIPT_TASK"); break; case "INTERMEDIATE-CATCH-TIMER-EVENT": $taskMessage = G::LoadTranslation("ID_ROUTE_TO_TASK_INTERMEDIATE_CATCH_TIMER_EVENT"); break; } switch ($aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']) { case 'EVALUATE': case 'REPORT_TO': case 'BALANCED': case 'SELF_SERVICE': $taskAss = array(); $taskAss['taskId'] = $aValues['NEXT_TASK']['TAS_UID']; $taskAss['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE']; $taskAss['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']; $taskAss['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE']; $taskAss['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY']) ? $aValues['NEXT_TASK']['DEL_PRIORITY'] : ""; $taskAss['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT']; $taskAss['taskMessage'] = $taskType ? $taskMessage : ""; $users = array(); $users['userId'] = $derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_UID']; $users['userFullName'] = strip_tags($derive[$sKey]['NEXT_TASK']['USER_ASSIGNED']['USR_FULLNAME']); $taskAss['users'][] = $users; $response[] = $taskAss; break; case 'MANUAL': case "MULTIPLE_INSTANCE": case "MULTIPLE_INSTANCE_VALUE_BASED": $manual = array(); $manual['taskId'] = $aValues['NEXT_TASK']['TAS_UID']; $manual['taskName'] = $aValues['NEXT_TASK']['TAS_TITLE']; $manual['taskAssignType'] = $aValues['NEXT_TASK']['TAS_ASSIGN_TYPE']; $manual['taskDefProcCode'] = $aValues['NEXT_TASK']['TAS_DEF_PROC_CODE']; $manual['delPriority'] = isset($aValues['NEXT_TASK']['DEL_PRIORITY']) ? $aValues['NEXT_TASK']['DEL_PRIORITY'] : ""; $manual['taskParent'] = $aValues['NEXT_TASK']['TAS_PARENT']; $manual['taskMessage'] = $taskType ? $taskMessage : ""; $Aux = array(); foreach ($aValues['NEXT_TASK']['USER_ASSIGNED'] as $aUser) { $Aux[$aUser['USR_UID']] = $aUser['USR_FULLNAME']; } asort($Aux); $users = array(); foreach ($Aux as $id => $fullname) { $user['userId'] = $id; $user['userFullName'] = $fullname; $users[] = $user; } $manual['users'] = $users; $response[] = $manual; break; case '': //when this task is the Finish process //when this task is the Finish process case 'nobody': $userFields = $oDerivation->getUsersFullNameFromArray($derive[$sKey]['USER_UID']); $taskAss = array(); $taskAss['routeFinishFlag'] = true; $user['userId'] = $derive[$sKey]['USER_UID']; $user['userFullName'] = $userFields['USR_FULLNAME']; $taskAss['users'][] = $user; $response[] = $taskAss; break; } } if (empty($response)) { throw new \Exception(G::LoadTranslation("ID_NO_DERIVATION_RULE")); } } catch (\Exception $e) { throw $e; } return $response; }
/** * Function getDynaformsVars * * @access public * @param eter string $sProcessUID * @param eter boolean $bSystemVars * @return array */ public static function getDynaformsVars ($sProcessUID, $bSystemVars = true, $bIncMulSelFields = 0) { $aFields = array (); $aFieldsNames = array (); if ($bSystemVars) { $aAux = G::getSystemConstants(); foreach ($aAux as $sName => $sValue) { $aFields[] = array ('sName' => $sName,'sType' => 'system','sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLE'), 'sUid' => ''); } //we're adding the ping variable to the system list $aFields[] = array ('sName' => 'PIN','sType' => 'system','sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLE'), 'sUid' => ''); } $aInvalidTypes = array("title", "subtitle", "file", "button", "reset", "submit", "javascript"); $aMultipleSelectionFields = array("listbox", "checkgroup", "grid"); if ($bIncMulSelFields != 0) { $aInvalidTypes = array_merge( $aInvalidTypes, $aMultipleSelectionFields ); } $oCriteria = new Criteria( 'workflow' ); $oCriteria->addSelectColumn( \DynaformPeer::DYN_FILENAME ); $oCriteria->addSelectColumn( \DynaformPeer::DYN_UID ); $oCriteria->add( \DynaformPeer::PRO_UID, $sProcessUID ); $oCriteria->add( \DynaformPeer::DYN_TYPE, 'xmlform' ); $oDataset = \DynaformPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if (is_file(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml")) { $dyn = new \dynaFormHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml"); if ($dyn->getHeaderAttribute("type") !== "xmlform" && $dyn->getHeaderAttribute("type") !== "") { // skip it, if that is not a xmlform $oDataset->next(); continue; } $fields = $dyn->getFields(); foreach ($fields as $field) { $label = ""; if ($field->hasChildNodes()) { $child = $field->getElementsByTagName(SYS_LANG)->length ? $field->getElementsByTagName(SYS_LANG): $field->getElementsByTagName("en"); $label = $child->item(0) ? $child->item(0)->textContent : ""; } if (! in_array($field->getAttribute("type"), $aInvalidTypes) && ! in_array($field->tagName, $aFieldsNames)) { $aFieldsNames[] = $field->tagName; $aFields[] = array ( 'sName' => $field->tagName, 'sType' => $field->getAttribute("type"), 'sLabel' => ($field->getAttribute("type") != 'grid' ? $label : '[ ' . G::LoadTranslation('ID_GRID') . ' ]'), 'sUid' => $aRow['DYN_UID']); } } } $oDataset->next(); } return $aFields; }
public function replaceDataField($sqlString, $result, $DBEngine = 'mysql') { if (!is_array($result)) { $result = array(); } $result = $result + G::getSystemConstants(); $__textoEval = ""; $u = 0; //$count=preg_match_all('/\@(?:([\@\%\#\!Qq])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))/',$sqlString,$match,PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); $count = preg_match_all('/\\@(?:([\\@\\%\\#\\=\\!Qq])([a-zA-Z\\_]\\w*)|([a-zA-Z\\_][\\w\\-\\>\\:]*)\\(((?:[^\\\\\\)]*?)*)\\))/', $sqlString, $match, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE); if ($count) { for ($r = 0; $r < $count; $r++) { if (!isset($result[$match[2][$r][0]])) { $result[$match[2][$r][0]] = ''; } if (!is_array($result[$match[2][$r][0]])) { $__textoEval .= substr($sqlString, $u, $match[0][$r][1] - $u); $u = $match[0][$r][1] + strlen($match[0][$r][0]); //Mysql quotes scape if ($match[1][$r][0] == '@' && isset($result[$match[2][$r][0]])) { $__textoEval .= "\"" . G::sqlEscape($result[$match[2][$r][0]], $DBEngine) . "\""; continue; } //URL encode if ($match[1][$r][0] == '%' && isset($result[$match[2][$r][0]])) { $__textoEval .= urlencode($result[$match[2][$r][0]]); continue; } //Double quoted parameter if ($match[1][$r][0] == 'Q' && isset($result[$match[2][$r][0]])) { $__textoEval .= '"' . addcslashes($result[$match[2][$r][0]], '\\"') . '"'; continue; } //Single quoted parameter if ($match[1][$r][0] == 'q' && isset($result[$match[2][$r][0]])) { $__textoEval .= "'" . addcslashes($result[$match[2][$r][0]], '\\\'') . "'"; continue; } //Substring (Sub replaceDataField) if ($match[1][$r][0] == '!' && isset($result[$match[2][$r][0]])) { $__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result); continue; } //Call function if ($match[1][$r][0] === '' && $match[2][$r][0] === '' && $match[3][$r][0] !== '') { eval('$strAux = ' . $match[3][$r][0] . '(\'' . addcslashes(G::replaceDataField(stripslashes($match[4][$r][0]), $result), '\\\'') . '\');'); if ($match[3][$r][0] == "G::LoadTranslation") { $arraySearch = array("'"); $arrayReplace = array("\\'"); $strAux = str_replace($arraySearch, $arrayReplace, $strAux); } $__textoEval .= $strAux; continue; } //Non-quoted if ($match[1][$r][0] == '#' && isset($result[$match[2][$r][0]])) { $__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result); continue; } //Non-quoted = if ($match[1][$r][0] == '=' && isset($result[$match[2][$r][0]])) { $__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result); continue; } } } } $__textoEval .= substr($sqlString, $u); return $__textoEval; }
/** * Function getDynaformsVars * * @access public * @param eter string $sProcessUID * @param eter boolean $bSystemVars * @return array */ function getDynaformsVars($sProcessUID, $bSystemVars = true, $bIncMulSelFields = 0) { $aFields = array(); $aFieldsNames = array(); if ($bSystemVars) { $aAux = G::getSystemConstants(); foreach ($aAux as $sName => $sValue) { $aFields[] = array('sName' => $sName, 'sType' => 'system', 'sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLES')); } //we're adding the ping variable to the system list $aFields[] = array('sName' => 'PIN', 'sType' => 'system', 'sLabel' => G::LoadTranslation('ID_TINY_SYSTEM_VARIABLES')); } $aInvalidTypes = array("title", "subtitle", "file", "button", "reset", "submit", "javascript", "pmconnection"); $aMultipleSelectionFields = array("listbox", "checkgroup"); if ($bIncMulSelFields != 0) { $aInvalidTypes = array_merge($aInvalidTypes, $aMultipleSelectionFields); } require_once 'classes/model/Dynaform.php'; $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME); $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID); $oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform'); $oDataset = DynaformPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if (file_exists(PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml')) { $G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG); if ($G_FORM->type == 'xmlform' || $G_FORM->type == '') { foreach ($G_FORM->fields as $k => $v) { if (!in_array($v->type, $aInvalidTypes)) { if (!in_array($k, $aFieldsNames)) { $aFields[] = array('sName' => $k, 'sType' => $v->type, 'sLabel' => $v->type != 'grid' ? $v->label : '[ ' . G::LoadTranslation('ID_GRID') . ' ]'); $aFieldsNames[] = $k; } } } } } $oDataset->next(); } return $aFields; }
$oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptCode(' var Cse = {}; Cse.panels = {}; var leimnud = new maborak(); leimnud.make(); leimnud.Package.Load("rpc,drag,drop,panel,app,validator,fx,dom,abbr",{Instance:leimnud,Type:"module"}); leimnud.exec(leimnud.fix.memoryLeak); leimnud.event.add(window,"load",function(){ ' . (isset($_SESSION['showCasesWindow']) ? 'try{' . $_SESSION['showCasesWindow'] . '}catch(e){}' : '') . ' }); '); $G_PUBLISH->AddContent('template', '', '', '', $oTemplatePower); $oCase = new Cases(); $Fields = $oCase->loadCase($_SESSION['APPLICATION']); $Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants()); $sStatus = $Fields['APP_STATUS']; $APP_NUMBER = $Fields['APP_NUMBER']; $APP_TITLE = $Fields['TITLE']; $oProcess = new Process(); $oProcessFieds = $oProcess->Load($_SESSION['PROCESS']); #trigger debug routines... if (isset($oProcessFieds['PRO_DEBUG']) && $oProcessFieds['PRO_DEBUG']) { #here we must verify if is a debugg session $_SESSION['TRIGGER_DEBUG']['ISSET'] = 1; $_SESSION['PMDEBUGGER'] = true; } else { $_SESSION['TRIGGER_DEBUG']['ISSET'] = 0; $_SESSION['PMDEBUGGER'] = false; } //cleaning debug variables
/** * Execute Trigger case * */ public function doExecuteTriggerCase($usr_uid, $prj_uid, $act_uid, $cas_uid, $step_uid, $type) { $userData = $this->getUserData($usr_uid); $c = new \Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(\StepPeer::STEP_UID); $c->addSelectColumn(\StepPeer::STEP_UID_OBJ); $c->add(\StepPeer::TAS_UID, $act_uid); $c->add(\StepPeer::STEP_TYPE_OBJ, 'DYNAFORM'); $c->add(\StepPeer::STEP_UID, $step_uid); $rs = \StepPeer::doSelectRS($c); $rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $step_uid_obj = $row['STEP_UID_OBJ']; $oCase = new \Cases(); $Fields = $oCase->loadCase( $cas_uid ); $_SESSION["APPLICATION"] = $cas_uid; $_SESSION["PROCESS"] = $prj_uid; $_SESSION["TASK"] = $act_uid; $_SESSION["USER_LOGGED"] = $usr_uid; $_SESSION["USR_USERNAME"] = $userData['firstName']; $_SESSION["INDEX"] = $Fields["DEL_INDEX"] = \AppDelegation::getCurrentIndex($cas_uid); $Fields['APP_DATA'] = array_merge( $Fields['APP_DATA'], G::getSystemConstants() ); $triggers = $oCase->loadTriggers( $act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type) ); if($triggers){ $Fields['APP_DATA'] = $oCase->ExecuteTriggers( $act_uid, 'DYNAFORM', $step_uid_obj, strtoupper($type), $Fields['APP_DATA'] ); } $Fields['TAS_UID'] = $act_uid; $Fields['CURRENT_DYNAFORM'] = $step_uid_obj; $Fields['USER_UID'] = $usr_uid; $Fields['PRO_UID'] = $prj_uid; $oCase->updateCase( $cas_uid, $Fields ); $response = array('status' => 'ok'); return $response; }