Ejemplo n.º 1
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $triUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($triUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(TriggersPeer::TRI_UID);
             $criteria->addSelectColumn(TriggersPeer::PRO_UID);
             $criteria->addSelectColumn(TriggersPeer::TRI_TYPE);
             $criteria->addSelectColumn(TriggersPeer::TRI_WEBBOT);
             $criteria->addSelectColumn(TriggersPeer::TRI_PARAM);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = TriggersPeer::retrieveByPK($triUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table Triggers ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Ejemplo n.º 2
0
 function create($aData)
 {
     if (!isset($aData['EVN_UID']) || $aData['EVN_UID'] == '') {
         $aData['EVN_UID'] = G::generateUniqueID();
     }
     $oConnection = Propel::getConnection(EventPeer::DATABASE_NAME);
     try {
         $oEvent = new Event();
         $oEvent->setEvnUid($aData['EVN_UID']);
         $oEvent->setProUid($aData['PRO_UID']);
         if (isset($aData['EVN_RELATED_TO'])) {
             $oEvent->setEvnRelatedTo($aData['EVN_RELATED_TO']);
             if ($aData['EVN_RELATED_TO'] == 'SINGLE') {
                 if (isset($aData['TAS_UID'])) {
                     $oEvent->setTasUid($aData['TAS_UID']);
                 }
                 $oEvent->setEvnTasUidTo('');
                 $oEvent->setEvnTasUidFrom('');
             } else {
                 $oEvent->setTasUid('');
                 if (isset($aData['EVN_TAS_UID_TO'])) {
                     $oEvent->setEvnTasUidTo($aData['EVN_TAS_UID_TO']);
                 }
                 if (isset($aData['EVN_TAS_UID_FROM'])) {
                     $oEvent->setEvnTasUidFrom($aData['EVN_TAS_UID_FROM']);
                 }
             }
         }
         if (isset($aData['EVN_POSX'])) {
             $oEvent->setEvnPosx($aData['EVN_POSX']);
         }
         if (isset($aData['EVN_POSY'])) {
             $oEvent->setEvnPosy($aData['EVN_POSY']);
         }
         if (isset($aData['EVN_TYPE'])) {
             $oEvent->setEvnType($aData['EVN_TYPE']);
         }
         if (isset($aData['EVN_TAS_ESTIMATED_DURATION'])) {
             $oEvent->setEvnTasEstimatedDuration($aData['EVN_TAS_ESTIMATED_DURATION']);
         }
         if (isset($aData['EVN_WHEN_OCCURS'])) {
             $oEvent->setEvnWhenOccurs($aData['EVN_WHEN_OCCURS']);
         }
         if (isset($aData['EVN_ACTION'])) {
             $oEvent->setEvnAction($aData['EVN_ACTION']);
         }
         if (isset($aData['EVN_CONDITIONS'])) {
             $oEvent->setEvnConditions($aData['EVN_CONDITIONS']);
         }
         if (isset($aData['EVN_STATUS'])) {
             $oEvent->setEvnStatus($aData['EVN_STATUS']);
         }
         if (isset($aData['EVN_WHEN'])) {
             $oEvent->setEvnWhen($aData['EVN_WHEN']);
         }
         $oEvent->setEvnMaxAttempts(3);
         //start the transaction
         $oConnection->begin();
         if (isset($aData['EVN_TYPE'])) {
             if ($aData['EVN_TYPE'] === 'bpmnEventEmptyEnd') {
                 unset($aData['TRI_UID']);
             }
         }
         if (isset($aData['TRI_UID'])) {
             $oTrigger = new Triggers();
             if (trim($aData['TRI_UID']) === "" || !$oTrigger->TriggerExists($aData['TRI_UID'])) {
                 //create an empty trigger
                 $aTrigger = array();
                 $aTrigger['PRO_UID'] = $aData['PRO_UID'];
                 $aTrigger['TRI_TITLE'] = 'For event: ' . $aData['EVN_DESCRIPTION'];
                 $aTrigger['TRI_DESCRIPTION'] = 'Autogenerated ' . $aTrigger['TRI_TITLE'];
                 $aTrigger['TRI_WEBBOT'] = '// ' . $aTrigger['TRI_DESCRIPTION'];
                 $oTrigger->create($aTrigger);
             } else {
                 $oTrigger = TriggersPeer::retrieveByPk($aData['TRI_UID']);
             }
             $oEvent->setTriUid($oTrigger->getTriUid());
             $parameters = new StdClass();
             $parameters->hash = md5($oTrigger->getTriWebbot());
             if (isset($aData['EVN_ACTION_PARAMETERS']->SUBJECT)) {
                 $parameters->SUBJECT = $aData['EVN_ACTION_PARAMETERS']->SUBJECT;
                 $parameters->TO = $aData['EVN_ACTION_PARAMETERS']->TO;
                 $parameters->CC = $aData['EVN_ACTION_PARAMETERS']->CC;
                 $parameters->BCC = $aData['EVN_ACTION_PARAMETERS']->BCC;
                 $parameters->TEMPLATE = $aData['EVN_ACTION_PARAMETERS']->TEMPLATE;
             }
             $oEvent->setEvnActionParameters(serialize($parameters));
         }
         if ($oEvent->validate()) {
             $iResult = $oEvent->save();
             if (isset($aData['EVN_DESCRIPTION'])) {
                 $oEvent->setEvnDescription($aData['EVN_DESCRIPTION']);
             }
             $oConnection->commit();
             return $aData['EVN_UID'];
         } else {
             $sMessage = '';
             $aValidationFailures = $oEvent->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The row Event cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
Ejemplo n.º 3
0
 public function getExtTriggersList($start, $limit, $sProcessUID = '')
 {
     $sDelimiter = DBAdapter::getStringDelimiter();
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(TriggersPeer::TRI_UID);
     $oCriteria->addSelectColumn(TriggersPeer::PRO_UID);
     $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
     $this->tmpCriteria = clone $oCriteria;
     $oCriteria->addAsColumn('TRI_TITLE', 'C1.CON_VALUE');
     $oCriteria->addAsColumn('TRI_DESCRIPTION', 'C2.CON_VALUE');
     $oCriteria->addAlias('C1', 'CONTENT');
     $oCriteria->addAlias('C2', 'CONTENT');
     $aConditions = array();
     $aConditions[] = array(TriggersPeer::TRI_UID, 'C1.CON_ID');
     $aConditions[] = array('C1.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
     $aConditions[] = array('C1.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
     $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
     $aConditions = array();
     $aConditions[] = array(TriggersPeer::TRI_UID, 'C2.CON_ID');
     $aConditions[] = array('C2.CON_CATEGORY', $sDelimiter . 'TRI_TITLE' . $sDelimiter);
     $aConditions[] = array('C2.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter);
     $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
     $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
     $oCriteria->addAscendingOrderByColumn('TRI_TITLE');
     if ($start != '') {
         $oCriteria->setOffset($start);
     }
     if ($limit != '') {
         $oCriteria->setLimit($limit);
     }
     $oDataset = TriggersPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $triggersArray = "";
     $triggersArray[] = array('TRI_UID' => 'char', 'PRO_UID' => 'char', 'TRI_TITLE' => 'char', 'TRI_DESCRIPTION' => 'char');
     while ($aRow = $oDataset->getRow()) {
         if ($aRow['TRI_TITLE'] == null || $aRow['TRI_TITLE'] == "") {
             // There is no translation for this Trigger name, try to get/regenerate the label
             $triggerO = new Triggers();
             $triggerObj = $triggerO->load($aRow['TRI_UID']);
             $aRow['TRI_TITLE'] = $triggerObj['TRI_TITLE'];
             $aRow['TRI_DESCRIPTION'] = $triggerObj['TRI_DESCRIPTION'];
         }
         $triggersArray[] = $aRow;
         $oDataset->next();
     }
     return $triggersArray;
 }
Ejemplo n.º 4
0
$sDirectory = PATH_DATA_MAILTEMPLATES . $aFields['PRO_UID'] . PATH_SEP;
G::verifyPath($sDirectory, true);
if (!file_exists($sDirectory . 'alert_message.html')) {
    @copy(PATH_TPL . 'mails' . PATH_SEP . 'alert_message.html', $sDirectory . 'alert_message.html');
}
$oDirectory = dir($sDirectory);
while ($sObject = $oDirectory->read()) {
    if ($sObject !== '.' && $sObject !== '..' && $sObject !== 'alert_message.html') {
        $aTemplates[] = array('TEMPLATE1' => $sObject, 'TEMPLATE2' => $sObject);
    }
}
$_DBArray['templates'] = $aTemplates;
$aTriggers[] = array('TRI_UID' => 'char', 'TRI_TITLE' => 'char');
G::LoadClass('processMap');
$oProcessMap = new ProcessMap();
$oDataset = TriggersPeer::doSelectRS($oProcessMap->getTriggersCriteria($aFields['PRO_UID']));
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
    $aTriggers[] = array('TRI_UID' => $aRow['TRI_UID'], 'TRI_TITLE' => $aRow['TRI_TITLE']);
    $oDataset->next();
}
$_DBArray['triggers'] = $aTriggers;
$_SESSION['_DBArray'] = $_DBArray;
$aFields = array_merge($aFields, setLabels());
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'events/eventsEditAction', '', $aFields, '../events/eventsSave');
//$G_PUBLISH->AddContent('xmlform', 'xmlform', 'events/eventsEditAction', '', $aFields, '../events/eventsSave');
G::RenderPage('publish', 'raw');
function replaceQuotes($aData)
{
Ejemplo n.º 5
0
 public function deleteProcess($sProcessUID, $flagRemoveCases = true)
 {
     try {
         //G::LoadClass('case');
         //G::LoadClass('reportTables');
         //Instance all classes necesaries
         $oProcess = new \Process();
         $oDynaform = new \Dynaform();
         $oInputDocument = new \InputDocument();
         $oOutputDocument = new \OutputDocument();
         $oTrigger = new \Triggers();
         $oRoute = new \Route();
         $oGateway = new \Gateway();
         $oEvent = new \Event();
         $oSwimlaneElement = new \SwimlanesElements();
         $oConfiguration = new \Configuration();
         $oDbSource = new \DbSource();
         $oReportTable = new \ReportTables();
         $oCaseTracker = new \CaseTracker();
         $oCaseTrackerObject = new \CaseTrackerObject();
         //Update PROCESS_FILES_CHECKED
         $configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", "");
         if (!is_null($configuration)) {
             $arrayProjectUid = unserialize($configuration->getCfgValue());
             unset($arrayProjectUid[$sProcessUID]);
             $conf = new \Configuration();
             $result = $conf->update(array("CFG_UID" => "PROCESS_FILES_CHECKED", "OBJ_UID" => "", "CFG_VALUE" => serialize($arrayProjectUid), "PRO_UID" => "", "USR_UID" => "", "APP_UID" => ""));
         }
         //Delete the applications of process
         if ($flagRemoveCases) {
             $case = new \Cases();
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\ApplicationPeer::APP_UID);
             $criteria->add(\ApplicationPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
             $rsCriteria = \ApplicationPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 $row = $rsCriteria->getRow();
                 $result = $case->removeCase($row["APP_UID"]);
             }
         }
         //Delete the tasks of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
         $oDataset = \TaskPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             //$this->deleteTask($aRow['TAS_UID']);
             $oTasks = new \Tasks();
             $oTasks->deleteTask($aRow['TAS_UID']);
             $oDataset->next();
         }
         //Delete the dynaforms of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\DynaformPeer::PRO_UID, $sProcessUID);
         $oDataset = \DynaformPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oDynaform->remove($aRow['DYN_UID']);
             $oDataset->next();
         }
         //Delete the input documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\InputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = \InputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oInputDocument->remove($aRow['INP_DOC_UID']);
             $oDataset->next();
         }
         //Delete the output documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oOutputDocument->remove($aRow['OUT_DOC_UID']);
             $oDataset->next();
         }
         //Delete the triggers of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\TriggersPeer::PRO_UID, $sProcessUID);
         $oDataset = \TriggersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oTrigger->remove($aRow['TRI_UID']);
             $oDataset->next();
         }
         //Delete the routes of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\RoutePeer::PRO_UID, $sProcessUID);
         $oDataset = \RoutePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oRoute->remove($aRow['ROU_UID']);
             $oDataset->next();
         }
         //Delete the gateways of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\GatewayPeer::PRO_UID, $sProcessUID);
         $oDataset = \GatewayPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oGateway->remove($aRow['GAT_UID']);
             $oDataset->next();
         }
         //Delete the Event of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\EventPeer::PRO_UID, $sProcessUID);
         $oDataset = \EventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oEvent->remove($aRow['EVN_UID']);
             $oDataset->next();
         }
         //Delete the swimlanes elements of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\SwimlanesElementsPeer::PRO_UID, $sProcessUID);
         $oDataset = \SwimlanesElementsPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oSwimlaneElement->remove($aRow['SWI_UID']);
             $oDataset->next();
         }
         //Delete the configurations of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ConfigurationPeer::PRO_UID, $sProcessUID);
         $oDataset = \ConfigurationPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
             $oDataset->next();
         }
         //Delete the DB sources of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\DbSourcePeer::PRO_UID, $sProcessUID);
         $oDataset = \DbSourcePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             /**
              * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
              * in order to solve the bug 0004389, we use the validation function Exists
              * inside the remove function in order to verify if the DbSource record
              * exists in the Database, however there is a strange behavior within the
              * propel engine, when the first record is erased somehow the "_deleted"
              * attribute of the next row is set to true, so when propel tries to erase
              * it, obviously it can't and trows an error. With the "Exist" function
              * we ensure that if there is the record in the database, the _delete attribute must be false.
              *
              * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
              * I have just identified the source of the issue, when is created a $oDbSource DbSource object
              * it's used whenever a record is erased or removed in the db, however the problem
              * it's that the same object is used every time, and the delete method invoked
              * sets the _deleted attribute to true when its called, of course as we use
              * the same object, the first time works fine but trowns an error with the
              * next record, cos it's the same object and the delete method checks if the _deleted
              * attribute it's true or false, the attrib _deleted is setted to true the
              * first time and later is never changed, the issue seems to be part of
              * every remove function in the model classes, not only DbSource
              * i recommend that a more general solution must be achieved to resolve
              * this issue in every model class, to prevent future problems.
              */
             $oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
             $oDataset->next();
         }
         //Delete the supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
         \ProcessUserPeer::doDelete($oCriteria);
         //Delete the object permissions
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ObjectPermissionPeer::PRO_UID, $sProcessUID);
         \ObjectPermissionPeer::doDelete($oCriteria);
         //Delete the step supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\StepSupervisorPeer::PRO_UID, $sProcessUID);
         \StepSupervisorPeer::doDelete($oCriteria);
         //Delete the report tables
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ReportTablePeer::PRO_UID, $sProcessUID);
         $oDataset = \ReportTablePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
             $oDataset->next();
         }
         //Delete case tracker configuration
         $oCaseTracker->remove($sProcessUID);
         //Delete case tracker objects
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
         \ProcessUserPeer::doDelete($oCriteria);
         //Delete SubProcess
         $criteria = new \Criteria("workflow");
         $criteria->add(\SubProcessPeer::PRO_PARENT, $sProcessUID, \Criteria::EQUAL);
         $result = \SubProcessPeer::doDelete($criteria);
         //Delete WebEntries
         $webEntry = new \ProcessMaker\BusinessModel\WebEntry();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\WebEntryPeer::WE_UID);
         $criteria->add(\WebEntryPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \WebEntryPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $webEntry->delete($row["WE_UID"]);
         }
         //Delete WebEntry-Events
         $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\WebEntryEventPeer::WEE_UID);
         $criteria->add(\WebEntryEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \WebEntryEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $webEntryEvent->delete($row["WEE_UID"]);
         }
         //Delete MessageTypes
         $messageType = new \ProcessMaker\BusinessModel\MessageType();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\MessageTypePeer::MSGT_UID);
         $criteria->add(\MessageTypePeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \MessageTypePeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $messageType->delete($row["MSGT_UID"]);
         }
         //Delete Message-Event-Relation
         $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
         $messageEventRelation->deleteWhere(array(\MessageEventRelationPeer::PRJ_UID => $sProcessUID));
         //Delete Message-Event-Task-Relation
         $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
         $elementTaskRelation->deleteWhere(array(\ElementTaskRelationPeer::PRJ_UID => $sProcessUID));
         //Delete Message-Event-Definition
         $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_UID);
         $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $messageEventDefinition->delete($row["MSGED_UID"]);
         }
         //Delete Script-Task
         $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();
         $scriptTask->deleteWhere(array(\ScriptTaskPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL)));
         //Delete Timer-Event
         $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
         $timerEvent->deleteWhere(array(\TimerEventPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL)));
         //Delete Email-Event
         $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_UID);
         $criteria->add(\EmailEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \EmailEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $emailEvent->delete($sProcessUID, $row["EMAIL_EVENT_UID"], false);
         }
         //Delete files Manager
         $filesManager = new \ProcessMaker\BusinessModel\FilesManager();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID);
         $criteria->add(\ProcessFilesPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $filesManager->deleteProcessFilesManager($sProcessUID, $row["PRF_UID"]);
         }
         //Delete the actions by email
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\AbeConfigurationPeer::PRO_UID, $sProcessUID);
         \AbeConfigurationPeer::doDelete($oCriteria);
         //Delete the process
         try {
             $oProcess->remove($sProcessUID);
         } catch (\Exception $oError) {
             throw $oError;
         }
         return true;
     } catch (\Exception $oError) {
         throw $oError;
     }
 }
Ejemplo n.º 6
0
    /**
     * Get available Triggers of a Step
     *
     * @param string $stepUid Unique id of Step
     * @param string $type    Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
     * @param string $taskUid Unique id of Task
     *
     * return array Return an array with the Triggers available of a Step
     */
    public function getAvailableTriggers($stepUid, $type, $taskUid = "")
    {
        try {
            $arrayAvailableTrigger = array();

            //Verify data
            if ($stepUid != "") {
                $this->throwExceptionIfNotExistsStep($stepUid);
            }

            if ($stepUid == "") {
                $this->throwExceptionIfNotExistsTask($taskUid);
            }

            //Get data
            $trigger = new \ProcessMaker\BusinessModel\Trigger();

            $flagStepAssignTask = 0;

            if ($stepUid != "") {
                //Load Step
                $step = new \Step();

                $arrayStepData = $step->load($stepUid);

                $processUid = $arrayStepData["PRO_UID"];
            } else {
                //Load Task
                $task = new \Task();

                $arrayTaskData = $task->load($taskUid);

                $processUid = $arrayTaskData["PRO_UID"];

                //Set variables
                $flagStepAssignTask = 1;

                switch ($type) {
                    case "BEFORE_ASSIGNMENT":
                        $stepUid = "-1";
                        $type = "BEFORE";
                        break;
                    case "BEFORE_ROUTING":
                        $stepUid = "-2";
                        $type = "BEFORE";
                        break;
                    case "AFTER_ROUTING":
                        $stepUid = "-2";
                        $type = "AFTER";
                        break;
                }
            }

            //Get data
            //Get Uids
            $arrayUid = array();

            $criteria = new \Criteria("workflow");

            $criteria->addSelectColumn(\StepTriggerPeer::TRI_UID);
            $criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL);

            if ($flagStepAssignTask == 1) {
                $criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
            }

            $criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);

            $rsCriteria = \StepTriggerPeer::doSelectRS($criteria);
            $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

            while ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                $arrayUid[] = $row["TRI_UID"];
            }

            //Criteria
            $criteria = $trigger->getTriggerCriteria();

            $criteria->add(\TriggersPeer::TRI_UID, $arrayUid, \Criteria::NOT_IN);
            $criteria->add(\TriggersPeer::PRO_UID, $processUid, \Criteria::EQUAL);
            $criteria->addAscendingOrderByColumn("TRI_TITLE");

            $rsCriteria = \TriggersPeer::doSelectRS($criteria);
            $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

            while ($rsCriteria->next()) {
                $row = $rsCriteria->getRow();

                $arrayAvailableTrigger[] = array(
                    $this->getFieldNameByFormatFieldName("TRI_UID")         => $row["TRI_UID"],
                    $this->getFieldNameByFormatFieldName("TRI_TITLE")       => $row["TRI_TITLE"],
                    $this->getFieldNameByFormatFieldName("TRI_DESCRIPTION") => $row["TRI_DESCRIPTION"],
                    $this->getFieldNameByFormatFieldName("TRI_TYPE")        => $row["TRI_TYPE"],
                    $this->getFieldNameByFormatFieldName("TRI_WEBBOT")      => $row["TRI_WEBBOT"],
                    $this->getFieldNameByFormatFieldName("TRI_PARAM")       => $row["TRI_PARAM"]
                );
            }

            //Return
            return $arrayAvailableTrigger;
        } catch (\Exception $e) {
            throw $e;
        }
    }
Ejemplo n.º 7
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(TriggersPeer::TRI_UID, $pks, Criteria::IN);
         $objs = TriggersPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 8
0
    /**

     * this function remove all Process except the PROCESS ROW

     *

     * @param string $sProUid

     * @return boolean

     */

    public function removeProcessRows ($sProUid)

    {

        try {

            //Instance all classes necesaries

            $oProcess = new Process();

            $oDynaform = new Dynaform();

            $oInputDocument = new InputDocument();

            $oOutputDocument = new OutputDocument();

            $oTrigger = new Triggers();

            $oStepTrigger = new StepTrigger();

            $oRoute = new Route();

            $oStep = new Step();

            $oSubProcess = new SubProcess();

            $oCaseTracker = new CaseTracker();

            $oCaseTrackerObject = new CaseTrackerObject();

            $oObjectPermission = new ObjectPermission();

            $oSwimlaneElement = new SwimlanesElements();

            $oConnection = new DbSource();

            $oStage = new Stage();

            $oEvent = new Event();

            $oCaseScheduler = new CaseScheduler();

            $oConfig = new Configuration();



            //Delete the tasks of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( TaskPeer::PRO_UID, $sProUid );

            $oDataset = TaskPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            $oTask = new Task();

            while ($aRow = $oDataset->getRow()) {

                $oCriteria = new Criteria( 'workflow' );

                $oCriteria->add( StepTriggerPeer::TAS_UID, $aRow['TAS_UID'] );

                StepTriggerPeer::doDelete( $oCriteria );

                if ($oTask->taskExists( $aRow['TAS_UID'] )) {

                    $oTask->remove( $aRow['TAS_UID'] );

                }

                $oDataset->next();

            }



            //Delete the dynaforms of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( DynaformPeer::PRO_UID, $sProUid );

            $oDataset = DynaformPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '_tmp*';

                foreach (glob( $sWildcard ) as $fn) {

                    @unlink( $fn );

                }

                $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '.*';

                foreach (glob( $sWildcard ) as $fn) {

                    @unlink( $fn );

                }

                if ($oDynaform->dynaformExists( $aRow['DYN_UID'] )) {

                    $oDynaform->remove( $aRow['DYN_UID'] );

                }

                $oDataset->next();

            }



            //Delete the input documents of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( InputDocumentPeer::PRO_UID, $sProUid );

            $oDataset = InputDocumentPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oInputDocument->InputExists( $aRow['INP_DOC_UID'] )) {

                    $oInputDocument->remove( $aRow['INP_DOC_UID'] );

                }

                $oDataset->next();

            }



            //Delete the output documents of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( OutputDocumentPeer::PRO_UID, $sProUid );

            $oDataset = OutputDocumentPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oOutputDocument->OutputExists( $aRow['OUT_DOC_UID'] )) {

                    $oOutputDocument->remove( $aRow['OUT_DOC_UID'] );

                }

                $oDataset->next();

            }



            //Delete the steps

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( StepPeer::PRO_UID, $sProUid );

            $oDataset = StepPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                //Delete the steptrigger of process

                /*$oCriteria = new Criteria('workflow');

                  $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow['STEP_UID']);

                  $oDataseti = StepTriggerPeer::doSelectRS($oCriteria);

                  $oDataseti->setFetchmode(ResultSet::FETCHMODE_ASSOC);

                  $oDataseti->next();

                  while ($aRowi = $oDataseti->getRow()) {

                  if ($oStepTrigger->stepTriggerExists($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']))

                  $oStepTrigger->remove($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']);

                  $oDataseti->next();

                  }*/

                $oStep->remove( $aRow['STEP_UID'] );

                $oDataset->next();

            }



            //Delete the StepSupervisor

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid );

            $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oStep->StepExists( $aRow['STEP_UID'] )) {

                    $oStep->remove( $aRow['STEP_UID'] );

                }

                $oDataset->next();

            }



            //Delete the triggers of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( TriggersPeer::PRO_UID, $sProUid );

            $oDataset = TriggersPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oTrigger->TriggerExists( $aRow['TRI_UID'] )) {

                    $oTrigger->remove( $aRow['TRI_UID'] );

                }

                $oDataset->next();

            }

            //Delete the routes of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( RoutePeer::PRO_UID, $sProUid );

            $oDataset = RoutePeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oRoute->routeExists( $aRow['ROU_UID'] )) {

                    $oRoute->remove( $aRow['ROU_UID'] );

                }

                $oDataset->next();

            }

            //Delete the swimlanes elements of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid );

            $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oSwimlaneElement->swimlanesElementsExists( $aRow['SWI_UID'] )) {

                    $oSwimlaneElement->remove( $aRow['SWI_UID'] );

                }

                $oDataset->next();

            }



            //Delete the DB connections of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid );

            $oDataset = DbSourcePeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) {

                    $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] );

                }

                $oDataset->next();

            }



            //Delete the sub process of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid );

            $oDataset = SubProcessPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oSubProcess->subProcessExists( $aRow['SP_UID'] )) {

                    $oSubProcess->remove( $aRow['SP_UID'] );

                }

                $oDataset->next();

            }



            //Delete the caseTracker of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid );

            $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oCaseTracker->caseTrackerExists( $aRow['PRO_UID'] )) {

                    $oCaseTracker->remove( $aRow['PRO_UID'] );

                }

                $oDataset->next();

            }



            //Delete the caseTrackerObject of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid );

            $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oCaseTrackerObject->caseTrackerObjectExists( $aRow['CTO_UID'] )) {

                    $oCaseTrackerObject->remove( $aRow['CTO_UID'] );

                }

                $oDataset->next();

            }



            //Delete the ObjectPermission of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid );

            $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oObjectPermission->Exists( $aRow['OP_UID'] )) {

                    $oObjectPermission->remove( $aRow['OP_UID'] );

                }

                $oDataset->next();

            }



            //Delete the Stage of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( StagePeer::PRO_UID, $sProUid );

            $oDataset = StagePeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oStage->Exists( $aRow['STG_UID'] )) {

                    $oStage->remove( $aRow['STG_UID'] );

                }

                $oDataset->next();

            }



            //Delete the Event of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( EventPeer::PRO_UID, $sProUid );

            $oDataset = EventPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oEvent->Exists( $aRow['EVN_UID'] )) {

                    $oEvent->remove( $aRow['EVN_UID'] );

                }

                $oDataset->next();

                if ($oEvent->existsByTaskUidFrom( $aRow['TAS_UID'] )) {

                    $aRowEvent = $oEvent->getRowByTaskUidFrom( $aRow['TAS_UID'] );

                    $oEvent->remove( $aRowEvent['EVN_UID'] );

                }

                $oDataset->next();

            }



            //Delete the CaseScheduler of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid );

            $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oCaseScheduler->Exists( $aRow['SCH_UID'] )) {

                    $oCaseScheduler->remove( $aRow['SCH_UID'] );

                }

                $oDataset->next();

            }



            //Delete the TaskExtraProperties of the process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->addSelectColumn( ConfigurationPeer::CFG_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::OBJ_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE );

            $oCriteria->addSelectColumn( TaskPeer::PRO_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::USR_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::APP_UID );

            $oCriteria->add( TaskPeer::PRO_UID, $sProUid );

            $oCriteria->add( ConfigurationPeer::CFG_UID, 'TAS_EXTRA_PROPERTIES' );

            $oCriteria->addJoin( ConfigurationPeer::OBJ_UID, TaskPeer::TAS_UID );

            $oDataset = ConfigurationPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oConfig->exists($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID'])) {

                    $oConfig->remove( $aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID'] );

                }

                $oDataset->next();

            }



            return true;

        } catch (Exception $oError) {

            throw ($oError);

        }

    }
Ejemplo n.º 9
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = TriggersPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setTriUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setProUid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setTriType($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setTriWebbot($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setTriParam($arr[$keys[4]]);
     }
 }
Ejemplo n.º 10
0
 /**
  * Verify if doesn't exists the Trigger in table TRIGGERS
  *
  * @param string $triggerUid            Unique id of Trigger
  * @param string $processUid            Unique id of Process
  * @param string $fieldNameForException Field name for the exception
  *
  * return void Throw exception if doesn't exists the Trigger in table TRIGGERS
  */
 public function throwExceptionIfNotExistsTrigger($triggerUid, $processUid, $fieldNameForException)
 {
     try {
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\TriggersPeer::TRI_UID);
         if ($processUid != "") {
             $criteria->add(\TriggersPeer::PRO_UID, $processUid, \Criteria::EQUAL);
         }
         $criteria->add(\TriggersPeer::TRI_UID, $triggerUid, \Criteria::EQUAL);
         $rsCriteria = \TriggersPeer::doSelectRS($criteria);
         if (!$rsCriteria->next()) {
             throw new \Exception(\G::LoadTranslation("ID_TRIGGER_DOES_NOT_EXIST", array($fieldNameForException, $triggerUid)));
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 11
0
 /**
  * verify if a dbconnection is assigned in some dynaforms or triggers
  *
  * @param      string $sproUid   the uid of the process
  * @param      string $sdbsUid   the uid of the db connection
  */
 function loadInfoAssigConnecctionDB($sproUid, $sdbsUid)
 {
     require_once "classes/model/DynaformPeer.php";
     G::LoadSystem('dynaformhandler');
     $swDynaform = true;
     $swTriggers = true;
     //we are looking for triggers if there is at least one db connection
     $oC = new Criteria('workflow');
     $oC->add(TriggersPeer::PRO_UID, $sproUid);
     $oDataset = TriggersPeer::doSelectRS($oC);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     //print $sproUid;
     while ($aRowT = $oDataset->getRow()) {
         $uidConnection = preg_quote($sdbsUid);
         if (strrpos($uidConnection, $aRowT['TRI_WEBBOT'])) {
             $swTriggers = false;
         }
         $oDataset->next();
     }
     //we are looking for dynaforms if there is at least one db connection
     $oC = new Criteria('workflow');
     $oC->add(DynaformPeer::PRO_UID, $sproUid);
     $oDataset = DynaformPeer::doSelectRS($oC);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         if ($aRow['DYN_TYPE'] == 'xmlform') {
             $dynHandler = new dynaFormHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME'] . ".xml");
             $dynFields = $dynHandler->getFields();
             $sxmlgrid = '';
             $sType = '';
             $check = 0;
             foreach ($dynFields as $field) {
                 $ssqlConnection = $this->getAttribute($field, 'sqlconnection');
                 if ($ssqlConnection == $sdbsUid) {
                     $swDynaform = false;
                 }
             }
             //end foreach
         }
         //end if
         $oDataset->next();
     }
     //end while
     //is there a connecction?
     if ($swDynaform && $swTriggers) {
         //there is no db connection, you can delete this connection
         return true;
     } else {
         //there is a db connection, you can not delete this connection
         return false;
     }
     die;
 }
Ejemplo n.º 12
0
 /**
  * Execute Script
  *
  * @param string $activityUid          Unique id of Event
  * @param array  $arrayApplicationData Case data
  *
  * return array
  */
 public function execScriptByActivityUid($activityUid, array $arrayApplicationData)
 {
     try {
         $task = \TaskPeer::retrieveByPK($activityUid);
         if (!is_null($task) && $task->getTasType() == "SCRIPT-TASK") {
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\ScriptTaskPeer::SCRTAS_OBJ_UID);
             $criteria->add(\ScriptTaskPeer::ACT_UID, $activityUid, \Criteria::EQUAL);
             $rsCriteria = \ScriptTaskPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             if ($rsCriteria->next()) {
                 $row = $rsCriteria->getRow();
                 $scriptTasObjUid = $row["SCRTAS_OBJ_UID"];
                 $trigger = \TriggersPeer::retrieveByPK($scriptTasObjUid);
                 if (!is_null($trigger)) {
                     $pmScript = new \PMScript();
                     $pmScript->setFields($arrayApplicationData["APP_DATA"]);
                     $pmScript->setScript($trigger->getTriWebbot());
                     $result = $pmScript->execute();
                     if (isset($pmScript->aFields["__ERROR__"])) {
                         \G::log("Case Uid: " . $arrayApplicationData["APP_UID"] . ", Error: " . $pmScript->aFields["__ERROR__"], PATH_DATA . "log/ScriptTask.log");
                     }
                     $arrayApplicationData["APP_DATA"] = $pmScript->aFields;
                     $case = new \Cases();
                     $result = $case->updateCase($arrayApplicationData["APP_UID"], $arrayApplicationData);
                 }
             }
         }
         //Return
         return $arrayApplicationData["APP_DATA"];
     } catch (\Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 13
0
 public function executeEvents($sNow, $debug = false, &$log = array(), $cron = 0)
 {
     require_once 'classes/model/Configuration.php';
     require_once 'classes/model/Triggers.php';
     G::LoadClass('case');
     $debug = 1;
     $oCase = new Cases();
     try {
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(AppEventPeer::APP_UID);
         $oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
         $oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
         $oCriteria->addSelectColumn(EventPeer::PRO_UID);
         $oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
         $oCriteria->addSelectColumn(EventPeer::TRI_UID);
         $oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
         $oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
         $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
         $oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
         $oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::JOIN);
         $aConditions = array();
         array_push($aConditions, array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID));
         array_push($aConditions, array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX));
         $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
         $oCriteria->addJoin(ApplicationPeer::APP_UID, AppEventPeer::APP_UID);
         $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
         //by me
         $oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
         $oCriteria->add(AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL);
         $oDataset = AppEventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $c = 0;
         while ($oDataset->next()) {
             if ($cron == 1) {
                 $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
                 $arrayCron["processcTimeStart"] = time();
                 @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
             }
             $c++;
             $aRow = $oDataset->getRow();
             $oTrigger = new Triggers();
             $aFields = $oCase->loadCase($aRow['APP_UID']);
             $oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
             //g::pr($aRow); //die;
             if ($debug) {
                 require_once 'classes/model/Application.php';
                 $oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
                 $oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
                 $log[] = 'Event ' . $oEv->getEvnDescription() . ' with ID ' . $aRow['EVN_UID'];
                 println("\nOK+ event \"" . $oEv->getEvnDescription() . "\" with ID {} was found");
                 println(" - PROCESS................" . $aRow['PRO_UID']);
                 println(" - APPLICATION............" . $aRow['APP_UID'] . " CASE #" . $oApp->getAppNumber());
                 println(" - ACTION DATE............" . $aRow['APP_EVN_ACTION_DATE']);
                 println(" - ATTEMPTS..............." . $aRow['APP_EVN_ATTEMPTS']);
                 println(" - INTERVAL WITH TASKS...." . $aRow['EVN_RELATED_TO']);
             }
             if ($aRow['TRI_UID'] == '') {
                 //a rare case when the tri_uid is not set.
                 $log[] = " (!) Any trigger was set................................SKIPPED and will be CLOSED";
                 if ($debug) {
                     println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
                 }
                 $oAppEvent->setAppEvnStatus('CLOSE');
                 $oAppEvent->save();
                 continue;
             }
             $oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
             if (!is_object($oTrigger)) {
                 //the trigger record doesn't exist..
                 $log[] = ' (!) The trigger ' . $aRow['TRI_UID'] . ' ' . $oTrigger->getTriTitle() . " doesn't exist.......SKIPPED and will be CLOSED";
                 if ($debug) {
                     println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
                 }
                 $oAppEvent->setAppEvnStatus('CLOSE');
                 $oAppEvent->save();
                 continue;
             }
             global $oPMScript;
             $oPMScript = new PMScript();
             $task = new Task();
             $taskFields = $task->Load($aRow['TAS_UID']);
             $aFields['APP_DATA']['APP_NUMBER'] = $aFields['APP_NUMBER'];
             $aFields['APP_DATA']['TAS_TITLE'] = $taskFields['TAS_TITLE'];
             $aFields['APP_DATA']['DEL_TASK_DUE_DATE'] = $aRow['DEL_TASK_DUE_DATE'];
             $oPMScript->setFields($aFields['APP_DATA']);
             $oPMScript->setScript($oTrigger->getTriWebbot());
             $oPMScript->execute();
             $oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
             if (sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0) {
                 $log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
                 if ($debug) {
                     println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
                     //g::pr($aFields);
                 }
                 $aFields['APP_DATA'] = $oPMScript->aFields;
                 $oCase->updateCase($aRow['APP_UID'], $aFields);
                 $oAppEvent->setAppEvnStatus('CLOSE');
             } else {
                 if ($debug) {
                     $log[] = ' - The trigger ' . $aRow['TRI_UID'] . ' throw some errors!';
                     println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
                     print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
                 }
                 if ($oAppEvent->getAppEvnAttempts() > 0) {
                     $oAppEvent->setAppEvnAttempts($oAppEvent->getAppEvnAttempts() - 1);
                 } else {
                     $oAppEvent->setAppEvnStatus('CLOSE');
                 }
             }
             $oAppEvent->save();
         }
         return $c;
     } catch (Exception $oError) {
         $log[] = ' Error execute event : ' . $oError->getMessage();
         die($oError->getMessage());
         return $oError->getMessage();
     }
 }
Ejemplo n.º 14
0
    /**
     * Delete Process
     *
     * @param string $processUid
     * @param bool   $checkCases
     *
     * return bool   Return true, if is succesfully
     *
     * @access public

    DEPRECATED
    public function deleteProcess($processUid, $checkCases = true)
    {
        if ($checkCases) {
            $process = new \Process();

            $arrayCases = $process->getCasesCountInAllProcesses($processUid);

            $sum = 0;

            if (isset($arrayCases[$processUid]) && count($arrayCases[$processUid]) > 0) {
                foreach ($arrayCases[$processUid] as $value) {
                    $sum = $sum + $value;
                }
            }

            if ($sum > 0) {
                throw (new \Exception("You can't delete the process, because it has $sum cases"));
            }
        }

        $processMap = new \processMap();

        return $processMap->deleteProcess($processUid);

    }*/

    public function deleteProcess($sProcessUID)
    {
        try {
            G::LoadClass('case');
            G::LoadClass('reportTables');
            //Instance all classes necesaries
            $oProcess = new Process();
            $oDynaform = new Dynaform();
            $oInputDocument = new InputDocument();
            $oOutputDocument = new OutputDocument();
            $oTrigger = new Triggers();
            $oRoute = new Route();
            $oGateway = new Gateway();
            $oEvent = new Event();
            $oSwimlaneElement = new SwimlanesElements();
            $oConfiguration = new Configuration();
            $oDbSource = new DbSource();
            $oReportTable = new ReportTables();
            $oCaseTracker = new CaseTracker();
            $oCaseTrackerObject = new CaseTrackerObject();
            //Delete the applications of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID);
            $oDataset = ApplicationPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            $oCase = new Cases();
            while ($aRow = $oDataset->getRow()) {
                $oCase->removeCase($aRow['APP_UID']);
                $oDataset->next();
            }
            //Delete the tasks of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
            $oDataset = TaskPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $this->deleteTask($aRow['TAS_UID']);
                $oDataset->next();
            }
            //Delete the dynaforms of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
            $oDataset = DynaformPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oDynaform->remove($aRow['DYN_UID']);
                $oDataset->next();
            }
            //Delete the input documents of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
            $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oInputDocument->remove($aRow['INP_DOC_UID']);
                $oDataset->next();
            }
            //Delete the output documents of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
            $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oOutputDocument->remove($aRow['OUT_DOC_UID']);
                $oDataset->next();
            }

            //Delete the triggers of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
            $oDataset = TriggersPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oTrigger->remove($aRow['TRI_UID']);
                $oDataset->next();
            }

            //Delete the routes of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
            $oDataset = RoutePeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oRoute->remove($aRow['ROU_UID']);
                $oDataset->next();
            }

            //Delete the gateways of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
            $oDataset = GatewayPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oGateway->remove($aRow['GAT_UID']);
                $oDataset->next();
            }

            //Delete the Event of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(EventPeer::PRO_UID, $sProcessUID);
            $oDataset = EventPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oEvent->remove($aRow['EVN_UID']);
                $oDataset->next();
            }

            //Delete the swimlanes elements of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
            $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oSwimlaneElement->remove($aRow['SWI_UID']);
                $oDataset->next();
            }
            //Delete the configurations of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID);
            $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
                $oDataset->next();
            }
            //Delete the DB sources of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
            $oDataset = DbSourcePeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {

                /**
                 * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
                 * in order to solve the bug 0004389, we use the validation function Exists
                 * inside the remove function in order to verify if the DbSource record
                 * exists in the Database, however there is a strange behavior within the
                 * propel engine, when the first record is erased somehow the "_deleted"
                 * attribute of the next row is set to true, so when propel tries to erase
                 * it, obviously it can't and trows an error. With the "Exist" function
                 * we ensure that if there is the record in the database, the _delete attribute must be false.
                 *
                 * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
                 * I have just identified the source of the issue, when is created a $oDbSource DbSource object
                 * it's used whenever a record is erased or removed in the db, however the problem
                 * it's that the same object is used every time, and the delete method invoked
                 * sets the _deleted attribute to true when its called, of course as we use
                 * the same object, the first time works fine but trowns an error with the
                 * next record, cos it's the same object and the delete method checks if the _deleted
                 * attribute it's true or false, the attrib _deleted is setted to true the
                 * first time and later is never changed, the issue seems to be part of
                 * every remove function in the model classes, not only DbSource
                 * i recommend that a more general solution must be achieved to resolve
                 * this issue in every model class, to prevent future problems.
                 */
                $oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
                $oDataset->next();
            }
            //Delete the supervisors
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
            ProcessUserPeer::doDelete($oCriteria);
            //Delete the object permissions
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
            ObjectPermissionPeer::doDelete($oCriteria);
            //Delete the step supervisors
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
            StepSupervisorPeer::doDelete($oCriteria);
            //Delete the report tables
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
            $oDataset = ReportTablePeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
                $oDataset->next();
            }
            //Delete case tracker configuration
            $oCaseTracker->remove($sProcessUID);
            //Delete case tracker objects
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
            ProcessUserPeer::doDelete($oCriteria);
            //Delete the process
            try {
                $oProcess->remove($sProcessUID);
            } catch (Exception $oError) {
                throw ($oError);
            }
            return true;
        } catch (Exception $oError) {
            throw ($oError);
        }
    }
Ejemplo n.º 15
0
    public function getTriggerNames($triggers)

    {

        $triggers_info = Array();

        $aTriggers = array();

        foreach ($triggers as $key => $val) {

            $aTriggers[] = $val['TRI_UID'];

        }

        $lang = defined('SYS_LANG') ? SYS_LANG : 'en';

        $c = new Criteria();

        $c->clearSelectColumns();

        $c->addSelectColumn(ContentPeer::CON_ID);

        $c->addSelectColumn(ContentPeer::CON_VALUE);

        $c->add(ContentPeer::CON_ID, $aTriggers, Criteria::IN);

        $c->add(ContentPeer::CON_CATEGORY, 'TRI_TITLE');

        $c->add(ContentPeer::CON_LANG, $lang);

        $rs = TriggersPeer::doSelectRS($c);

        $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        $rs->next();

        $row = $rs->getRow();

        while (is_array($row)) {

            $info[$row['CON_ID']] = ($row['CON_VALUE'] != '' ? $row['CON_VALUE'] : '-');

            $rs->next();

            $row = $rs->getRow();

        }

        foreach ($triggers as $key => $val) {

            if (isset($info[$val['TRI_UID']])) {

                $triggers_info[] = $info[$val['TRI_UID']];

            } else {

                $triggers_info[] = Content::load('TRI_TITLE', '', $val['TRI_UID'], $lang);

            }

        }

        return $triggers_info;

    }
Ejemplo n.º 16
0
 $oCriteria->add(StepTriggerPeer::ST_TYPE, $aData['sType']);
 $oDataset = StepTriggerPeer::doSelectRS($oCriteria);
 $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
 $oDataset->next();
 $sUIDs = "'0'";
 $aUIDs = array();
 while ($aRow = $oDataset->getRow()) {
     $sUIDs .= ",'" . $aRow['TRI_UID'] . "'";
     $aUIDs[] = $aRow['TRI_UID'];
     $oDataset->next();
 }
 $oCriteria = new Criteria('workflow');
 $oCriteria->addSelectColumn('COUNT(TRI_UID) AS CANTITY');
 $oCriteria->add(TriggersPeer::TRI_UID, $aUIDs, Criteria::NOT_IN);
 $oCriteria->add(TriggersPeer::PRO_UID, $aData['sProcess']);
 $oDataset = TriggersPeer::doSelectRS($oCriteria);
 $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
 $oDataset->next();
 $aRow = $oDataset->getRow();
 if ((int) $aRow['CANTITY'] > 0) {
     $aFields['LANG'] = SYS_LANG;
     $aFields['UIDS'] = $sUIDs;
     $aFields['PROCESS'] = $aData['sProcess'];
     $aFields['action'] = 'assignTrigger';
     $aFields['STEP_UID'] = $aData['sStep'];
     $aFields['ST_TYPE'] = $aData['sType'];
     global $G_PUBLISH;
     G::LoadClass('xmlfield_InputPM');
     $G_PUBLISH = new Publisher();
     $G_PUBLISH->AddContent('xmlform', 'xmlform', 'steps/triggers_Assign', '', $aFields, '../steps/steps_Ajax');
     G::RenderPage('publish', 'raw');
Ejemplo n.º 17
0
function executeCaseSelfService()
{
    try {
        global $sFilter;
        if ($sFilter != "" && strpos($sFilter, "unassigned-case") === false) {
            return false;
        }
        $criteria = new Criteria("workflow");
        //SELECT
        $criteria->addSelectColumn(AppCacheViewPeer::APP_UID);
        $criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX);
        $criteria->addSelectColumn(AppCacheViewPeer::DEL_DELEGATE_DATE);
        $criteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER);
        $criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
        $criteria->addSelectColumn(TaskPeer::TAS_UID);
        $criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TIME);
        $criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TIME_UNIT);
        $criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TRIGGER_UID);
        //FROM
        $condition = array();
        $condition[] = array(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID);
        $condition[] = array(TaskPeer::TAS_SELFSERVICE_TIMEOUT, 1);
        $criteria->addJoinMC($condition, Criteria::LEFT_JOIN);
        //WHERE
        $criteria->add(AppCacheViewPeer::USR_UID, "");
        $criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
        //QUERY
        $rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        setExecutionMessage("Unassigned case");
        saveLog("unassignedCase", "action", "Unassigned case", "c");
        $date = new dates();
        while ($rsCriteria->next()) {
            $row = $rsCriteria->getRow();
            $appcacheAppUid = $row["APP_UID"];
            $appcacheDelIndex = $row["DEL_INDEX"];
            $appcacheDelDelegateDate = $row["DEL_DELEGATE_DATE"];
            $appcacheAppNumber = $row["APP_NUMBER"];
            $appcacheProUid = $row["PRO_UID"];
            $taskUid = $row["TAS_UID"];
            $taskSelfServiceTime = intval($row["TAS_SELFSERVICE_TIME"]);
            $taskSelfServiceTimeUnit = $row["TAS_SELFSERVICE_TIME_UNIT"];
            $taskSelfServiceTriggerUid = $row["TAS_SELFSERVICE_TRIGGER_UID"];
            $dueDate = $date->calculateDate($appcacheDelDelegateDate, $taskSelfServiceTime, $taskSelfServiceTimeUnit, 1);
            if (time() > $dueDate["DUE_DATE_SECONDS"]) {
                $sessProcess = null;
                $sessProcessSw = 0;
                //Load data
                $case = new Cases();
                $appFields = $case->loadCase($appcacheAppUid);
                $appFields["APP_DATA"]["APPLICATION"] = $appcacheAppUid;
                if (isset($_SESSION["PROCESS"])) {
                    $sessProcess = $_SESSION["PROCESS"];
                    $sessProcessSw = 1;
                }
                $_SESSION["PROCESS"] = $appFields["PRO_UID"];
                //Execute trigger
                $criteriaTgr = new Criteria();
                $criteriaTgr->add(TriggersPeer::TRI_UID, $taskSelfServiceTriggerUid);
                $rsCriteriaTgr = TriggersPeer::doSelectRS($criteriaTgr);
                $rsCriteriaTgr->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                if ($rsCriteriaTgr->next()) {
                    $row = $rsCriteriaTgr->getRow();
                    if (is_array($row) && $row["TRI_TYPE"] == "SCRIPT") {
                        $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
                        $arrayCron["processcTimeProcess"] = 60;
                        //Minutes
                        $arrayCron["processcTimeStart"] = time();
                        @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
                        //Trigger
                        global $oPMScript;
                        $oPMScript = new PMScript();
                        $oPMScript->setFields($appFields["APP_DATA"]);
                        $oPMScript->setScript($row["TRI_WEBBOT"]);
                        $oPMScript->execute();
                        $appFields["APP_DATA"] = array_merge($appFields["APP_DATA"], $oPMScript->aFields);
                        $case->updateCase($appFields["APP_UID"], $appFields);
                        saveLog("unassignedCase", "action", "OK Executed tigger to the case {$appcacheAppNumber}");
                    }
                }
                unset($_SESSION["PROCESS"]);
                if ($sessProcessSw == 1) {
                    $_SESSION["PROCESS"] = $sessProcess;
                }
            }
        }
        setExecutionResultMessage("DONE");
    } catch (Exception $e) {
        setExecutionResultMessage("WITH ERRORS", "error");
        eprintln("  '-" . $e->getMessage(), "red");
        saveLog("unassignedCase", "error", "Error in unassigned case: " . $e->getMessage());
    }
}
Ejemplo n.º 18
0
    /**

     * execute Trigger, executes a ProcessMaker trigger.

     * Note that triggers which are tied to case derivation

     * will executing automatically.

     *

     * @param string $userId

     * @param string $caseId

     * @param string $delIndex

     * @return $result will return an object

     */

    public function executeTrigger ($userId, $caseId, $triggerIndex, $delIndex)

    {

        $g = new G();



        try {

            $g->sessionVarSave();



            $_SESSION["APPLICATION"] = $caseId;

            $_SESSION["INDEX"] = $delIndex;

            $_SESSION["USER_LOGGED"] = $userId;



            $oAppDel = new AppDelegation();

            $appdel = $oAppDel->Load( $caseId, $delIndex );



            if ($userId != $appdel['USR_UID']) {

                $result = new wsResponse( 17, G::loadTranslation( 'ID_CASE_ASSIGNED_ANOTHER_USER' ) );



                $g->sessionVarRestore();



                return $result;

            }



            if ($appdel['DEL_FINISH_DATE'] != null) {

                $result = new wsResponse( 18, G::loadTranslation( 'ID_CASE_DELEGATION_ALREADY_CLOSED' ) );



                $g->sessionVarRestore();



                return $result;

            }



            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->addSelectColumn( AppDelayPeer::APP_UID );

            $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX );

            $oCriteria->addSelectColumn( AppDelayPeer::APP_DISABLE_ACTION_USER );

            $oCriteria->addSelectColumn( AppDelayPeer::APP_DISABLE_ACTION_DATE );

            $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 ($aRow['APP_DISABLE_ACTION_USER'] != 0 && $aRow['APP_DISABLE_ACTION_DATE'] != '') {

                    $result = new wsResponse( 19, G::loadTranslation( 'ID_CASE_IN_STATUS' ) . " " . $aRow['APP_TYPE'] );



                    $g->sessionVarRestore();



                    return $result;

                }

            }



            //Load data

            $oCase = new Cases();

            $appFields = $oCase->loadCase( $caseId );



            $appFields["APP_DATA"]["APPLICATION"] = $caseId;



            if (! isset( $_SESSION["PROCESS"] )) {

                $_SESSION["PROCESS"] = $appFields["PRO_UID"];

            }



            //executeTrigger

            $aTriggers = array ();

            $c = new Criteria();

            $c->add( TriggersPeer::TRI_UID, $triggerIndex );

            $rs = TriggersPeer::doSelectRS( $c );

            $rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $rs->next();

            $row = $rs->getRow();



            if (is_array( $row ) && $row['TRI_TYPE'] == 'SCRIPT') {

                $aTriggers[] = $row;



                $oPMScript = new PMScript();

                $oPMScript->setFields( $appFields['APP_DATA'] );

                $oPMScript->setScript( $row['TRI_WEBBOT'] );

                $oPMScript->execute();



                if (isset($oPMScript->aFields["__ERROR__"]) && trim($oPMScript->aFields["__ERROR__"]) != "" && $oPMScript->aFields["__ERROR__"] != "none") {

                    throw new Exception($oPMScript->aFields["__ERROR__"]);

                }



                //Save data - Start

                $appFields['APP_DATA'] = $oPMScript->aFields;

                unset($appFields['APP_STATUS']);

                unset($appFields['APP_PROC_STATUS']);

                unset($appFields['APP_PROC_CODE']);

                unset($appFields['APP_PIN']);

                //$appFields = $oCase->loadCase($caseId);

                $oCase->updateCase( $caseId, $appFields );

                //Save data - End

            } else {

                $data['TRIGGER_INDEX'] = $triggerIndex;

                $result = new wsResponse( 100, G::loadTranslation( 'ID_INVALID_TRIGGER', SYS_LANG, $data ) );



                $g->sessionVarRestore();



                return $result;

            }



            $result = new wsResponse( 0, G::loadTranslation( 'ID_EXECUTED' ) . ": " . trim( $row['TRI_WEBBOT'] ) );

            //$result = new wsResponse(0, 'executed: ' . print_r($oPMScript, 1));



            $g->sessionVarRestore();



            return $result;

        } catch (Exception $e) {

            $result = new wsResponse( 100, $e->getMessage() );



            $g->sessionVarRestore();



            return $result;

        }

    }
Ejemplo n.º 19
0
 public function verifyDependecies($TRI_UID)
 {
     require_once "classes/model/Event.php";
     require_once "classes/model/StepTrigger.php";
     $oResult = new stdClass();
     $oResult->dependencies = array();
     $oCriteria = new Criteria();
     $oCriteria->addSelectColumn(EventPeer::EVN_UID);
     $oCriteria->addSelectColumn(EventPeer::TRI_UID);
     $oCriteria->add(EventPeer::EVN_ACTION, '', Criteria::NOT_EQUAL);
     $oCriteria->add(EventPeer::TRI_UID, $TRI_UID);
     $oDataset = EventPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aRows = array();
     while ($oDataset->next()) {
         array_push($aRows, $oDataset->getRow());
     }
     $oResult->dependencies['Events'] = array();
     if (count($aRows) == 0) {
         $oResult->code = 0;
     } else {
         $oResult->code = 1;
         foreach ($aRows as $row) {
             $oTrigger = TriggersPeer::retrieveByPK($row['TRI_UID']);
             array_push($oResult->dependencies['Events'], array('UID' => $oTrigger->getTriUid(), 'DESCRIPTION' => $oTrigger->getTriTitle()));
         }
     }
     //for tasks dependencies
     $oCriteria = new Criteria();
     $oCriteria->addSelectColumn(StepTriggerPeer::TAS_UID);
     $oCriteria->addSelectColumn(StepTriggerPeer::TRI_UID);
     $oCriteria->add(StepTriggerPeer::TRI_UID, $TRI_UID);
     $oDataset = StepTriggerPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aRows = array();
     while ($oDataset->next()) {
         array_push($aRows, $oDataset->getRow());
     }
     $oResult->dependencies['Tasks'] = array();
     if ($oResult->code == 0 && count($aRows) == 0) {
         $oResult->code = 0;
     } elseif (count($aRows) > 0) {
         $oResult->code = 1;
         foreach ($aRows as $row) {
             $oTask = TaskPeer::retrieveByPK($row['TAS_UID']);
             array_push($oResult->dependencies['Tasks'], array('UID' => $oTask->getTasUid(), 'DESCRIPTION' => $oTask->getTasTitle()));
         }
     }
     //Tasks, assignment rules dependencies
     $criteria = new Criteria();
     $criteria->addSelectColumn(TaskPeer::TAS_UID);
     $criteria->add(TaskPeer::TAS_SELFSERVICE_TIMEOUT, 1);
     $criteria->add(TaskPeer::TAS_SELFSERVICE_TRIGGER_UID, $TRI_UID);
     $rsCriteria = TaskPeer::doSelectRS($criteria);
     $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arrayRow = array();
     while ($rsCriteria->next()) {
         array_push($arrayRow, $rsCriteria->getRow());
     }
     $oResult->dependencies["Assignment rules"] = array();
     if ($oResult->code == 0 && count($arrayRow) == 0) {
         $oResult->code = 0;
     } else {
         if (count($arrayRow) > 0) {
             foreach ($arrayRow as $row) {
                 $task = TaskPeer::retrieveByPK($row["TAS_UID"]);
                 array_push($oResult->dependencies["Assignment rules"], array("UID" => $task->getTasUid(), "DESCRIPTION" => $task->getTasTitle()));
             }
             $oResult->code = 1;
         }
     }
     return $oResult;
 }