Ejemplo n.º 1
0
 /**
  * Update Trigger 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
  * @param string $triggerUid Unique id of Trigger
  * @param array  $arrayData  Data
  *
  * return array Data updated of the Trigger assigned to a Step
  */
 public function updateAll($stepUid, $type, $taskUid, $triggerUid, $arrayData)
 {
     try {
         $flagStepAssignTask = 0;
         if ($stepUid == "" || $stepUid == "-1" || $stepUid == "-2") {
             $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;
             }
         }
         //Verify data
         if ($flagStepAssignTask == 0) {
             $step = new \Step();
             if (!$step->StepExists($stepUid)) {
                 throw new \Exception(\G::LoadTranslation("ID_STEP_DOES_NOT_EXIST", array("step_uid", $stepUid)));
             }
         }
         $trigger = new \Triggers();
         if (!$trigger->TriggerExists($triggerUid)) {
             throw new \Exception(\G::LoadTranslation("ID_TRIGGER_DOES_NOT_EXIST", array("tri_uid", $triggerUid)));
         }
         //Update
         $stepTrigger = new \StepTrigger();
         $arrayUpdateData = array();
         $arrayUpdateData["STEP_UID"] = $stepUid;
         $arrayUpdateData["TAS_UID"] = $taskUid;
         $arrayUpdateData["TRI_UID"] = $triggerUid;
         $arrayUpdateData["ST_TYPE"] = $type;
         if (isset($arrayData["st_condition"])) {
             $arrayUpdateData["ST_CONDITION"] = $arrayData["st_condition"];
         }
         $stepTrigger->update($arrayUpdateData);
         return array_change_key_case($arrayUpdateData, CASE_LOWER);
     } catch (\Exception $e) {
         throw $e;
     }
 }