function checkPidFile($pidfile = null) { if ($pidfile == null) { if ($this->_pidfile) { $pidfile = $this->_pidfile; } else { $pidfile = $this->getName() . '.pid'; } } logger::debug('Checking pidfile: %s', $pidfile); // Check if the process exist if (file_exists($pidfile)) { $pid = file_get_contents($pidfile); $p = new Process($pid); logger::debug(' - Inspecting pid %d', $pid); if ($p->exists()) { // Already running return self::PROCESS_RUNNING; } unlink($pidfile); $retval = self::PROCESS_STALE; } else { $retval = self::PROCESS_CLEAR; } $tp = new Process(); file_put_contents($pidfile, $tp->getPid()); $this->_pidfile = $pidfile; return $retval; }
G::LoadClass('dynaformEditor'); G::LoadClass('toolBar'); G::LoadClass('dynaFormField'); //G::LoadClass('configuration'); $G_MAIN_MENU = 'processmaker'; $G_SUB_MENU = 'processes'; $G_ID_MENU_SELECTED = 'PROCESSES'; $G_ID_SUB_MENU_SELECTED = 'FIELDS'; $PRO_UID = isset($_GET['PRO_UID']) ? $_GET['PRO_UID'] : '0'; $DYN_UID = isset($_GET['DYN_UID']) ? urldecode($_GET['DYN_UID']) : '0'; $_SESSION['PROCESS'] = $_GET['PRO_UID']; if ($PRO_UID === '0') { return; } $process = new Process(); if ($process->exists($PRO_UID)) { $process->load($PRO_UID); } else { //TODO print "{$PRO_UID} doesn't exist, continue? yes"; } $dynaform = new dynaform(); if ($dynaform->exists($DYN_UID)) { $dynaform->load($DYN_UID); $_SESSION['CURRENT_DYN_UID'] = $DYN_UID; } else { /* New Dynaform * */ $dynaform->create(array('PRO_UID' => $PRO_UID)); }
/** * Verify if doesn't exist the Process in table PROCESS * * @param string $processUid Unique id of Process * * return void Throw exception if doesn't exist the Process in table PROCESS */ public function throwExceptionIfNotExistsProcess($processUid) { $process = new \Process(); if (!$process->exists($processUid)) { throw new \Exception(\G::LoadTranslation("ID_PROJECT_DOES_NOT_EXIST", array($this->arrayParamException["processUid"], $processUid))); } }
public function load($sProcessUID, $bView = false, $sApplicationUID = '', $iDelegation = 0, $sTask = '', $bCT = false) { try { $oProcess = new Process(); $aRow = $oProcess->load($sProcessUID); $oPM->title->label = strip_tags($aRow['PRO_TITLE']); $oPM->title->position->x = $aRow['PRO_TITLE_X']; $oPM->title->position->y = $aRow['PRO_TITLE_Y']; $oPM->task = array(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(TaskPeer::PRO_UID); $oCriteria->addSelectColumn(TaskPeer::TAS_UID); $oCriteria->addSelectColumn(ContentPeer::CON_VALUE); $oCriteria->addSelectColumn(TaskPeer::TAS_START); $oCriteria->addSelectColumn(TaskPeer::TAS_POSX); $oCriteria->addSelectColumn(TaskPeer::TAS_POSY); $oCriteria->addSelectColumn(TaskPeer::TAS_COLOR); $oCriteria->addSelectColumn(TaskPeer::TAS_TYPE); $aConditions = array(); $aConditions[] = array(0 => TaskPeer::TAS_UID, 1 => ContentPeer::CON_ID); $aConditions[] = array(0 => ContentPeer::CON_CATEGORY, 1 => DBAdapter::getStringDelimiter() . 'TAS_TITLE' . DBAdapter::getStringDelimiter()); $aConditions[] = array(0 => ContentPeer::CON_LANG, 1 => DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter()); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID); $oDataset = TaskPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow1 = $oDataset->getRow()) { $oTask = null; $oTask->uid = $aRow1['TAS_UID']; $oTask->task_type = $aRow1['TAS_TYPE']; if ($aRow1['TAS_TYPE'] == 'NORMAL') { if ($aRow1['CON_VALUE'] == "") { //There is no Label in Current SYS_LANG language so try to find in English - by default $oTask1 = new Task(); $aFields1 = $oTask1->load($oTask->uid); $aRow1['CON_VALUE'] = $oTask1->getTasTitle(); } $oTask->label = strip_tags($aRow1['CON_VALUE']); } else { $oCriteria = new Criteria('workflow'); $del = DBAdapter::getStringDelimiter(); $oCriteria->add(SubProcessPeer::PRO_PARENT, $aRow1['PRO_UID']); $oCriteria->add(SubProcessPeer::TAS_PARENT, $aRow1['TAS_UID']); $oCriteria->addAsColumn('TAS_TITLE', 'C1.CON_VALUE'); $oCriteria->addAlias("C1", 'CONTENT'); $tasTitleConds = array(); $tasTitleConds[] = array(SubProcessPeer::TAS_PARENT, 'C1.CON_ID'); $tasTitleConds[] = array('C1.CON_CATEGORY', $del . 'TAS_TITLE' . $del); $tasTitleConds[] = array('C1.CON_LANG', $del . SYS_LANG . $del); $oCriteria->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN); $oDatasetX = SubProcessPeer::doSelectRS($oCriteria); $oDatasetX->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDatasetX->next(); $aRowx = $oDatasetX->getRow(); if ($oProcess->exists($aRowx['PRO_UID'])) { //$aRowy = $oProcess->load($aRowx['PRO_UID']); //$oTask->label = $aRowy['PRO_TITLE']; $oTask->label = $aRowx['TAS_TITLE']; } else { $oTask->label = strip_tags($aRow1['CON_VALUE']); } } $oTask->taskINI = strtolower($aRow1['TAS_START']) == 'true' ? true : false; $oTask->position->x = (int) $aRow1['TAS_POSX']; $oTask->position->y = (int) $aRow1['TAS_POSY']; $oTask->derivation = null; $oTask->derivation->to = array(); $oCriteria = new Criteria('workflow'); $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID); $oCriteria->add(RoutePeer::TAS_UID, $aRow1['TAS_UID']); $oDataset2 = RoutePeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); while ($aRow2 = $oDataset2->getRow()) { switch ($aRow2['ROU_TYPE']) { case 'SEQUENTIAL': $aRow2['ROU_TYPE'] = 0; break; case 'SELECT': $aRow2['ROU_TYPE'] = 1; break; case 'EVALUATE': $aRow2['ROU_TYPE'] = 2; break; case 'PARALLEL': $aRow2['ROU_TYPE'] = 3; break; case 'PARALLEL-BY-EVALUATION': $aRow2['ROU_TYPE'] = 4; break; case 'SEC-JOIN': $aRow2['ROU_TYPE'] = 5; break; case 'DISCRIMINATOR': $aRow2['ROU_TYPE'] = 8; break; } $oTo = null; $oTo->task = $aRow2['ROU_NEXT_TASK']; $oTo->condition = $aRow2['ROU_CONDITION']; $oTo->executant = $aRow2['ROU_TO_LAST_USER']; $oTo->optional = $aRow2['ROU_OPTIONAL']; $oTask->derivation->type = $aRow2['ROU_TYPE']; $oTask->derivation->to[] = $oTo; $oDataset2->next(); } if ($bCT) { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS CANT'); $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('DEL_FINISH_DATE'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow3 = $oDataset2->getRow(); if ($aRow3) { $aRow2['FINISH'] = ''; } /* if (($aRow2['FINISH'] == null) && ($aRow1['TAS_UID'] == $sTask)) { $oTask->color = '#FF0000'; } else { if ($aRow2['CANT'] != 0) { if ($aRow2['FINISH'] == null) { //$oTask->color = '#FF9900'; $oTask->color = '#FF0000'; } else { $oTask->color = '#006633'; } } else { $oTask->color = "#939598"; } } */ if (empty($aRow2["FINISH"]) && $aRow1["TAS_UID"] == $sTask) { $oTask->color = "#FF0000"; //Red } else { if (!empty($aRow2["FINISH"])) { $oTask->color = "#006633"; //Green } else { if ($aRow2["CANT"] == 0 || $oTask->derivation->type != 5) { $oTask->color = "#939598"; //Gray } else { //$oTask->color = "#FF9900"; //Yellow $oTask->color = "#FF0000"; //Red } } } } else { if ($bView && $sApplicationUID != '' && $iDelegation > 0 && $sTask != '') { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS CANT'); $oCriteria->addSelectColumn('MIN(DEL_FINISH_DATE) AS FINISH'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('DEL_FINISH_DATE'); $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDelegationPeer::TAS_UID, $aRow1['TAS_UID']); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow3 = $oDataset2->getRow(); if ($aRow3) { $aRow2['FINISH'] = ''; } /* if (($aRow2['FINISH'] == null) && ($aRow1['TAS_UID'] == $sTask)) { $oTask->color = '#FF0000'; } else { if ($aRow2['CANT'] != 0) { if ($aRow2['FINISH'] == null) { $oTask->color = '#FF9900'; } else { $oTask->color = '#006633'; } } else { $oTask->color = '#939598'; } } */ if (empty($aRow2["FINISH"]) && $aRow1["TAS_UID"] == $sTask) { $oTask->color = "#FF0000"; //Red } else { if (!empty($aRow2["FINISH"])) { $oTask->color = "#006633"; //Green } else { if ($aRow2["CANT"] == 0 || $oTask->derivation->type != 5) { $oTask->color = "#939598"; //Gray } else { $oTask->color = "#FF9900"; //Yellow } } } } } $msg = array(); G::LoadClass('derivation'); $Derivation = new Derivation(); $users = $Derivation->getAllUsersFromAnyTask($aRow1['TAS_UID']); $sw_error = false; if (count($users) == 0) { $sw_error = true; $msg[] = G::LoadTranslation('ID_NO_USERS'); } G::LoadClass('ArrayPeer'); $stepsCriteria = $this->getStepsCriteria($aRow1['TAS_UID']); $oDatasetSteps = ArrayBasePeer::doSelectRS($stepsCriteria); $oDatasetSteps->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDatasetSteps->next(); $countDynaform = 0; $countOutput = 0; $countInput = 0; $countExternal = 0; while ($aRowSteps = $oDatasetSteps->getRow()) { switch ($aRowSteps['STEP_TYPE_OBJ']) { case 'DYNAFORM': $countDynaform++; break; case 'INPUT_DOCUMENT': $countInput++; break; case 'OUTPUT_DOCUMENT': $countOutput++; break; case 'EXTERNAL': $countExternal++; break; } $oDatasetSteps->next(); } $totalSteps = $countDynaform + $countInput + $countOutput + $countExternal; if ($totalSteps == 0) { $sw_error = true; $msg[] = G::LoadTranslation('ID_TASK_NO_STEPS'); } if ($sw_error) { $oTask->statusIcons[] = array('label' => implode(",", $msg), 'icon' => '/images/alert.gif', 'message' => implode(", ", $msg), 'url' => ''); } $oPM->task[] = $oTask; $oDataset->next(); } $oPM->executant[] = G::LoadTranslation('ID_RULES_AND_USER_GROUPS'); $oPM->executant[] = G::LoadTranslation('ID_ADD_USER_OF_TASK'); $oPM->tasExtra[0]->label = '-- ' . G::LoadTranslation('ID_END_OF_PROCESS') . ' --'; $oPM->tasExtra[0]->uid = 'end'; $oPM->tasExtra[1]->label = '-- ' . G::LoadTranslation('ID_TAREA_COLGANTE') . ' --'; $oPM->tasExtra[1]->uid = 'leaf'; $oPM->guide = array(); $oPM->text = array(); $oPM->statusIcons = array(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_UID); // $oCriteria->addSelectColumn ( ContentPeer::CON_VALUE ); $oCriteria->addAsColumn("CON_VALUE", "CASE WHEN CONTENT.CON_VALUE IS NULL THEN (SELECT DISTINCT MAX(A.CON_VALUE) FROM CONTENT A WHERE SWIMLANES_ELEMENTS.SWI_UID=A.CON_ID ) ELSE CONTENT.CON_VALUE END "); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_TYPE); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_X); $oCriteria->addSelectColumn(SwimlanesElementsPeer::SWI_Y); $aConditions = array(); $aConditions[] = array(0 => SwimlanesElementsPeer::SWI_UID, 1 => ContentPeer::CON_ID); $aConditions[] = array(0 => ContentPeer::CON_CATEGORY, 1 => DBAdapter::getStringDelimiter() . 'SWI_TEXT' . DBAdapter::getStringDelimiter()); $aConditions[] = array(0 => ContentPeer::CON_LANG, 1 => DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter()); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID); $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { switch (strtolower($aRow['SWI_TYPE'])) { case 'line': $oGuide = null; $oGuide->uid = $aRow['SWI_UID']; $oGuide->position = $aRow['SWI_X'] > 0 ? $aRow['SWI_X'] : $aRow['SWI_Y']; $oGuide->direction = $aRow['SWI_X'] > 0 ? 'vertical' : 'horizontal'; $oPM->guide[] = $oGuide; break; case 'text': $oText = null; $oText->uid = $aRow['SWI_UID']; $oText->label = strip_tags($aRow['CON_VALUE'] != '' ? str_replace(chr(92), '\', str_replace('<', '<', $aRow['CON_VALUE'])) : '-'); // $oText->label = '->' . $aRow ['CON_VALUE'] . '<-' ; $oText->position->x = $aRow['SWI_X']; $oText->position->y = $aRow['SWI_Y']; $oPM->text[] = $oText; break; } $oDataset->next(); } $oPM->derivation = array('Sequential', 'Evaluate (manual)', 'Evaluate (auto)', 'Parallel (fork)', 'Parallel by evaluation (fork)', 'Parallel (sequential join)', 'Parallel (sequential main join)'); //Load extended task properties from plugin. By JHL Jan 18, 2011 $oPluginRegistry =& PMPluginRegistry::getSingleton(); $activePluginsForTaskProperties = $oPluginRegistry->getTaskExtendedProperties(); $oPM->taskOptions = array(); foreach ($activePluginsForTaskProperties as $key => $taskPropertiesInfo) { $taskOption['title'] = $taskPropertiesInfo->sName; $taskOption['id'] = $taskPropertiesInfo->sNamespace . "--" . $taskPropertiesInfo->sName; $oPM->taskOptions[] = $taskOption; } //$oJSON = new Services_JSON(); return Bootstrap::json_encode($oPM); //$oJSON->encode( $oPM ); } catch (Exception $oError) { throw $oError; } }
/** * Validate pro_uid * * @param string $pro_uid, Uid for process * @param string $nameField . Name of field for message * * @access public * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @return string */ public static function proUid($pro_uid, $nameField = 'pro_uid') { $pro_uid = trim($pro_uid); if ($pro_uid == '') { throw new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, ''))); } $oProcess = new \Process(); if (!$oProcess->exists($pro_uid)) { throw new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array($nameField, $pro_uid))); } return $pro_uid; }