Beispiel #1
0
     }
 } else {
     if (!isset($_POST['form'])) {
         $aData = urldecode_values($_POST);
     } else {
         $aData = urldecode_values($_POST['form']);
     }
 }
 switch ($aData['action']) {
     case 'showTriggers':
         G::LoadClass('processMap');
         $oProcessMap = new ProcessMap();
         global $G_PUBLISH;
         $G_PUBLISH = new Publisher();
         $oStepTrigger = new StepTrigger();
         $oStepTrigger->orderPosition($aData['sStep'], $_SESSION['TASK'], $aData['sType']);
         if ($aData['sType'] == 'BEFORE') {
             $G_PUBLISH->AddContent('propeltable', 'steps/paged-table', 'steps/triggersBefore_List', $oProcessMap->getStepTriggersCriteria($aData['sStep'], $_SESSION['TASK'], $aData['sType']), array('STEP' => $aData['sStep']));
         } else {
             $G_PUBLISH->AddContent('propeltable', 'steps/paged-table', 'steps/triggersAfter_List', $oProcessMap->getStepTriggersCriteria($aData['sStep'], $_SESSION['TASK'], $aData['sType']), array('STEP' => $aData['sStep']));
         }
         G::RenderPage('publish-twocolumns', 'raw');
         break;
     case 'availableTriggers':
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn('TRI_UID');
         $oCriteria->add(StepTriggerPeer::TAS_UID, $_SESSION['TASK']);
         $oCriteria->add(StepTriggerPeer::STEP_UID, $aData['sStep']);
         $oCriteria->add(StepTriggerPeer::ST_TYPE, $aData['sType']);
         $oDataset = StepTriggerPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
Beispiel #2
0
    /**
     * Get all Triggers of a Step
     *
     * @param string $stepUid Unique id of Step
     * @param string $taskUid Unique id of Task
     *
     * return array Return an array with all Triggers of a Step
     */
    public function getTriggers($stepUid, $taskUid = "")
    {
        try {
            $arrayTrigger = array();

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

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

            //Get data
            $bmTrigger = new \ProcessMaker\BusinessModel\Trigger();
            $bmStepTrigger = new \ProcessMaker\BusinessModel\Step\Trigger();

            $stepTrigger = new \StepTrigger();

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

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

                $taskUid = $arrayStepData["TAS_UID"];
            }

            $arrayTriggerType1 = array(
                "BEFORE" => "BEFORE",
                "AFTER"  => "AFTER"
            );

            $arrayTriggerType2 = array(
                "BEFORE_ASSIGNMENT" => "BEFORE",
                "BEFORE_ROUTING"    => "BEFORE",
                "AFTER_ROUTING"     => "AFTER"
            );

            $arrayTriggerType = ($stepUid != "")? $arrayTriggerType1 : $arrayTriggerType2;

            foreach ($arrayTriggerType as $index => $value) {
                $triggerType = $index;
                $type = $value;

                $flagStepAssignTask = 0;

                switch ($triggerType) {
                    case "BEFORE_ASSIGNMENT":
                        $stepUid = "-1";
                        $flagStepAssignTask = 1;
                        break;
                    case "BEFORE_ROUTING":
                        $stepUid = "-2";
                        $flagStepAssignTask = 1;
                        break;
                    case "AFTER_ROUTING":
                        $stepUid = "-2";
                        $flagStepAssignTask = 1;
                        break;
                }

                $stepTrigger->orderPosition($stepUid, $taskUid, $type);

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

                $criteria->addSelectColumn(\StepTriggerPeer::ST_TYPE);
                $criteria->addSelectColumn(\StepTriggerPeer::ST_CONDITION);
                $criteria->addSelectColumn(\StepTriggerPeer::ST_POSITION);
                $criteria->addJoin(\StepTriggerPeer::TRI_UID, \TriggersPeer::TRI_UID, \Criteria::LEFT_JOIN);
                $criteria->add(\StepTriggerPeer::STEP_UID, $stepUid, \Criteria::EQUAL);
                $criteria->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
                $criteria->add(\StepTriggerPeer::ST_TYPE, $type, \Criteria::EQUAL);
                $criteria->addAscendingOrderByColumn(\StepTriggerPeer::ST_POSITION);

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

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

                    if ($flagStepAssignTask == 1) {
                        $row["ST_TYPE"] = $triggerType;
                    }

                    $arrayTrigger[] = $bmStepTrigger->getTriggerDataFromRecord($row);
                }
            }

            return $arrayTrigger;
        } catch (\Exception $e) {
            throw $e;
        }
    }