/** * Update properties of an Task * @var string $prj_uid. Uid for Process * @var string $act_uid. Uid for Activity * @var array $arrayProperty. Data for properties of Activity * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * return object */ public function updateProperties($prj_uid, $act_uid, $arrayProperty) { //Copy of processmaker/workflow/engine/methods/tasks/tasks_Ajax.php //case "saveTaskData": try { if (isset($arrayProperty['properties'])) { $arrayProperty = array_change_key_case($arrayProperty['properties'], CASE_UPPER); } $prj_uid = $this->validateProUid($prj_uid); $act_uid = $this->validateActUid($act_uid); $arrayProperty["TAS_UID"] = $act_uid; $arrayProperty["PRO_UID"] = $prj_uid; $task = new \Task(); $aTaskInfo = $task->load($arrayProperty["TAS_UID"]); $bpmnActivity = \BpmnActivityPeer::retrieveByPK($act_uid); $arrayResult = array(); if ($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == "1") { if (!is_numeric($arrayProperty["TAS_SELFSERVICE_TIME"]) || $arrayProperty["TAS_SELFSERVICE_TIME"] == '') { throw new \Exception("Invalid value specified for 'tas_selfservice_time'"); } } foreach ($arrayProperty as $k => $v) { $arrayProperty[$k] = str_replace("@amp@", "&", $v); } if (isset($arrayProperty["TAS_SEND_LAST_EMAIL"])) { $arrayProperty["TAS_SEND_LAST_EMAIL"] = $arrayProperty["TAS_SEND_LAST_EMAIL"] == "TRUE" ? "TRUE" : "FALSE"; } else { if (isset($arrayProperty["SEND_EMAIL"])) { $arrayProperty["TAS_SEND_LAST_EMAIL"] = $arrayProperty["SEND_EMAIL"] == "TRUE" ? "TRUE" : "FALSE"; } else { $arrayProperty["TAS_SEND_LAST_EMAIL"] = is_null($aTaskInfo["TAS_SEND_LAST_EMAIL"]) ? "FALSE" : $aTaskInfo["TAS_SEND_LAST_EMAIL"]; } } //Validating TAS_ASSIGN_VARIABLE value if (!isset($arrayProperty["TAS_ASSIGN_TYPE"])) { $derivateType = $task->kgetassigType($arrayProperty["PRO_UID"], $arrayProperty["TAS_UID"]); if (is_null($derivateType)) { $arrayProperty["TAS_ASSIGN_TYPE"] = "BALANCED"; } else { $arrayProperty["TAS_ASSIGN_TYPE"] = $derivateType["TAS_ASSIGN_TYPE"]; } } $flagTaskIsMultipleInstance = $bpmnActivity->getActType() == "TASK" && preg_match("/^(?:EMPTY|USERTASK|MANUALTASK)\$/", $bpmnActivity->getActTaskType()) && $bpmnActivity->getActLoopType() == "PARALLEL"; $flagTaskAssignTypeIsMultipleInstance = preg_match("/^(?:MULTIPLE_INSTANCE|MULTIPLE_INSTANCE_VALUE_BASED)\$/", $arrayProperty["TAS_ASSIGN_TYPE"]); if ($flagTaskIsMultipleInstance && !$flagTaskAssignTypeIsMultipleInstance) { $arrayProperty["TAS_ASSIGN_TYPE"] = "MULTIPLE_INSTANCE"; $flagTaskAssignTypeIsMultipleInstance = true; } if ($flagTaskIsMultipleInstance && !$flagTaskAssignTypeIsMultipleInstance) { throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_INVALID_ASSIGNMENT_METHOD_FOR_MULTIPLE_INSTANCE_ACTIVITY", array(strtolower("ACT_UID"), $act_uid))); } if (!$flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance) { $arrayProperty["TAS_ASSIGN_TYPE"] = "BALANCED"; $flagTaskAssignTypeIsMultipleInstance = false; } if (!$flagTaskIsMultipleInstance && $flagTaskAssignTypeIsMultipleInstance) { throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_INVALID_ASSIGNMENT_METHOD_FOR_ACTIVITY", array(strtolower("ACT_UID"), $act_uid))); } switch ($arrayProperty["TAS_ASSIGN_TYPE"]) { case 'BALANCED': case 'MANUAL': case 'REPORT_TO': $this->unsetVar($arrayProperty, "TAS_ASSIGN_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_GROUP_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIMEOUT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_EXECUTION"); break; case 'EVALUATE': if (empty($arrayProperty["TAS_ASSIGN_VARIABLE"])) { throw new \Exception("Invalid value specified for 'tas_assign_variable'"); } $this->unsetVar($arrayProperty, "TAS_GROUP_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIMEOUT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_EXECUTION"); break; case 'SELF_SERVICE': case 'SELF_SERVICE_EVALUATE': if ($arrayProperty["TAS_ASSIGN_TYPE"] == "SELF_SERVICE_EVALUATE") { if (empty($arrayProperty["TAS_GROUP_VARIABLE"])) { throw new \Exception("Invalid value specified for 'tas_group_variable'"); } } else { $arrayProperty["TAS_GROUP_VARIABLE"] = ''; } $arrayProperty["TAS_ASSIGN_TYPE"] = "SELF_SERVICE"; if (!($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == 0 || $arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == 1)) { throw new \Exception("Invalid value specified for 'tas_selfservice_timeout'"); } if ($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == "1") { if (empty($arrayProperty["TAS_SELFSERVICE_TIME"])) { throw new \Exception("Invalid value specified for 'tas_assign_variable'"); } if (empty($arrayProperty["TAS_SELFSERVICE_TIME_UNIT"])) { throw new \Exception("Invalid value specified for 'tas_selfservice_time_unit'"); } if (empty($arrayProperty["TAS_SELFSERVICE_TRIGGER_UID"])) { throw new \Exception("Invalid value specified for 'tas_selfservice_trigger_uid'"); } if (empty($arrayProperty["TAS_SELFSERVICE_EXECUTION"])) { throw new \Exception("Invalid value specified for 'tas_selfservice_execution'"); } } else { $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_EXECUTION"); } break; case "MULTIPLE_INSTANCE_VALUE_BASED": if (trim($arrayProperty["TAS_ASSIGN_VARIABLE"]) == "") { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array(strtolower("TAS_ASSIGN_VARIABLE")))); } break; } //Validating TAS_TRANSFER_FLY value if ($arrayProperty["TAS_TRANSFER_FLY"] == "FALSE") { if (!isset($arrayProperty["TAS_DURATION"])) { throw new \Exception("Invalid value specified for 'tas_duration'"); } $valuesTimeUnit = array('DAYS', 'HOURS', 'MINUTES'); if (!isset($arrayProperty["TAS_TIMEUNIT"]) || !in_array($arrayProperty["TAS_TIMEUNIT"], $valuesTimeUnit)) { throw new \Exception("Invalid value specified for 'tas_timeunit'"); } $valuesTypeDay = array('1', '2', ''); if (!isset($arrayProperty["TAS_TYPE_DAY"]) || !in_array($arrayProperty["TAS_TYPE_DAY"], $valuesTypeDay)) { throw new \Exception("Invalid value specified for 'tas_type_day'"); } if (!isset($arrayProperty["TAS_CALENDAR"])) { throw new \Exception("Invalid value specified for 'tas_calendar'"); } } else { $this->unsetVar($arrayProperty, "TAS_DURATION"); $this->unsetVar($arrayProperty, "TAS_TIMEUNIT"); $this->unsetVar($arrayProperty, "TAS_TYPE_DAY"); $this->unsetVar($arrayProperty, "TAS_CALENDAR"); } if ($arrayProperty["TAS_SEND_LAST_EMAIL"] == "TRUE") { if (empty($arrayProperty["TAS_DEF_SUBJECT_MESSAGE"])) { throw new \Exception("Invalid value specified for 'tas_def_subject_message'"); } $valuesDefMessageType = array('template', 'text'); if (!isset($arrayProperty["TAS_DEF_MESSAGE_TYPE"]) || !in_array($arrayProperty["TAS_DEF_MESSAGE_TYPE"], $valuesDefMessageType)) { throw new \Exception("Invalid value specified for 'tas_def_message_type'"); } if ($arrayProperty["TAS_DEF_MESSAGE_TYPE"] == 'template') { if (empty($arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"])) { throw new \Exception("Invalid value specified for 'tas_def_message_template'"); } $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE"); } else { if (empty($arrayProperty["TAS_DEF_MESSAGE"])) { throw new \Exception("Invalid value specified for 'tas_def_message'"); } $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TEMPLATE"); } //Additional configuration if (isset($arrayProperty["TAS_DEF_MESSAGE_TYPE"])) { \G::LoadClass("configuration"); $oConf = new \Configurations(); if (!isset($arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"])) { $arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"] = "alert_message.html"; } $oConf->aConfig = array("TAS_DEF_MESSAGE_TYPE" => $arrayProperty["TAS_DEF_MESSAGE_TYPE"], "TAS_DEF_MESSAGE_TEMPLATE" => $arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"]); $oConf->saveConfig("TAS_EXTRA_PROPERTIES", $arrayProperty["TAS_UID"], "", ""); } } else { $this->unsetVar($arrayProperty, "TAS_DEF_SUBJECT_MESSAGE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TYPE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TEMPLATE"); } $result = $task->update($arrayProperty); if (!empty($arrayProperty['CONSOLIDATE_DATA'])) { if (!empty($arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'])) { G::LoadClass("consolidatedCases"); $consolidated = new \ConsolidatedCases(); $dataConso = array('con_status' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_enable'], 'tas_uid' => $arrayProperty['TAS_UID'], 'dyn_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'], 'pro_uid' => $arrayProperty['PRO_UID'], 'rep_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_report_table'], 'table_name' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_table'], 'title' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_title']); $consolidated->saveConsolidated($dataConso); } } $arrayResult["status"] = "OK"; if ($result == 3) { $arrayResult["status"] = "CRONCL"; } return $arrayResult; } catch (Exception $e) { throw $e; } }
/** * Update properties of an Task * @var string $prj_uid. Uid for Process * @var string $act_uid. Uid for Activity * @var array $arrayProperty. Data for properties of Activity * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * return object */ public function updateProperties($prj_uid, $act_uid, $arrayProperty) { //Copy of processmaker/workflow/engine/methods/tasks/tasks_Ajax.php //case "saveTaskData": try { if (isset($arrayProperty['properties'])) { $arrayProperty = array_change_key_case($arrayProperty['properties'], CASE_UPPER); } $prj_uid = $this->validateProUid($prj_uid); $act_uid = $this->validateActUid($act_uid); $arrayProperty["TAS_UID"] = $act_uid; $arrayProperty["PRO_UID"] = $prj_uid; $task = new \Task(); $aTaskInfo = $task->load($arrayProperty["TAS_UID"]); $arrayResult = array(); if ($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == "1") { if (!is_numeric($arrayProperty["TAS_SELFSERVICE_TIME"]) || $arrayProperty["TAS_SELFSERVICE_TIME"]=='') { throw (new \Exception("Invalid value specified for 'tas_selfservice_time'")); } } foreach ($arrayProperty as $k => $v) { $arrayProperty[$k] = str_replace("@amp@", "&", $v); } if (isset($arrayProperty["TAS_SEND_LAST_EMAIL"])) { $arrayProperty["TAS_SEND_LAST_EMAIL"] = ($arrayProperty["TAS_SEND_LAST_EMAIL"] == "TRUE")? "TRUE" : "FALSE"; } else { if (isset($arrayProperty["SEND_EMAIL"])) { $arrayProperty["TAS_SEND_LAST_EMAIL"] = ($arrayProperty["SEND_EMAIL"] == "TRUE")? "TRUE" : "FALSE"; } else { $arrayProperty["TAS_SEND_LAST_EMAIL"] = (is_null($aTaskInfo["TAS_SEND_LAST_EMAIL"]))? "FALSE" : $aTaskInfo["TAS_SEND_LAST_EMAIL"]; } } //Validating TAS_ASSIGN_VARIABLE value if (!isset($arrayProperty["TAS_ASSIGN_TYPE"])) { $derivateType = $task->kgetassigType($arrayProperty["PRO_UID"], $arrayProperty["TAS_UID"]); if (is_null($derivateType)) { $arrayProperty["TAS_ASSIGN_TYPE"] = "BALANCED"; } else { $arrayProperty["TAS_ASSIGN_TYPE"] = $derivateType["TAS_ASSIGN_TYPE"]; } } switch ($arrayProperty["TAS_ASSIGN_TYPE"]) { case 'BALANCED': case 'MANUAL': case 'REPORT_TO': $this->unsetVar($arrayProperty, "TAS_ASSIGN_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_GROUP_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIMEOUT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); break; case 'EVALUATE': if (empty($arrayProperty["TAS_ASSIGN_VARIABLE"])) { throw (new \Exception("Invalid value specified for 'tas_assign_variable'")); } $this->unsetVar($arrayProperty, "TAS_GROUP_VARIABLE"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIMEOUT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); break; case 'SELF_SERVICE': case 'SELF_SERVICE_EVALUATE': if ($arrayProperty["TAS_ASSIGN_TYPE"] == "SELF_SERVICE_EVALUATE") { if (empty($arrayProperty["TAS_GROUP_VARIABLE"])) { throw (new \Exception("Invalid value specified for 'tas_group_variable'")); } } else { $arrayProperty["TAS_GROUP_VARIABLE"] = ''; } $arrayProperty["TAS_ASSIGN_TYPE"] = "SELF_SERVICE"; if (!($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == 0 || $arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == 1)) { throw (new \Exception("Invalid value specified for 'tas_selfservice_timeout'")); } if ($arrayProperty["TAS_SELFSERVICE_TIMEOUT"] == "1") { if (empty($arrayProperty["TAS_SELFSERVICE_TIME"])) { throw (new \Exception("Invalid value specified for 'tas_assign_variable'")); } if (empty($arrayProperty["TAS_SELFSERVICE_TIME_UNIT"])) { throw (new \Exception("Invalid value specified for 'tas_selfservice_time_unit'")); } if (empty($arrayProperty["TAS_SELFSERVICE_TRIGGER_UID"])) { throw (new \Exception("Invalid value specified for 'tas_selfservice_trigger_uid'")); } } else { $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TIME_UNIT"); $this->unsetVar($arrayProperty, "TAS_SELFSERVICE_TRIGGER_UID"); } break; } //Validating TAS_TRANSFER_FLY value if ($arrayProperty["TAS_TRANSFER_FLY"] == "FALSE") { if (!isset($arrayProperty["TAS_DURATION"])) { throw (new \Exception("Invalid value specified for 'tas_duration'")); } $valuesTimeUnit = array('DAYS','HOURS'); if ((!isset($arrayProperty["TAS_TIMEUNIT"])) || (!in_array($arrayProperty["TAS_TIMEUNIT"], $valuesTimeUnit))) { throw (new \Exception("Invalid value specified for 'tas_timeunit'")); } $valuesTypeDay = array('1','2',''); if ((!isset($arrayProperty["TAS_TYPE_DAY"])) || (!in_array($arrayProperty["TAS_TYPE_DAY"], $valuesTypeDay))) { throw (new \Exception("Invalid value specified for 'tas_type_day'")); } if (!isset($arrayProperty["TAS_CALENDAR"])) { throw (new \Exception("Invalid value specified for 'tas_calendar'")); } } else { $this->unsetVar($arrayProperty, "TAS_DURATION"); $this->unsetVar($arrayProperty, "TAS_TIMEUNIT"); $this->unsetVar($arrayProperty, "TAS_TYPE_DAY"); $this->unsetVar($arrayProperty, "TAS_CALENDAR"); } if ($arrayProperty["TAS_SEND_LAST_EMAIL"] == "TRUE") { if (empty($arrayProperty["TAS_DEF_SUBJECT_MESSAGE"])) { throw (new \Exception("Invalid value specified for 'tas_def_subject_message'")); } $valuesDefMessageType = array('template','text'); if ((!isset($arrayProperty["TAS_DEF_MESSAGE_TYPE"])) || (!in_array($arrayProperty["TAS_DEF_MESSAGE_TYPE"], $valuesDefMessageType))) { throw (new \Exception("Invalid value specified for 'tas_def_message_type'")); } if ($arrayProperty["TAS_DEF_MESSAGE_TYPE"] == 'template') { if (empty($arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"])) { throw (new \Exception("Invalid value specified for 'tas_def_message_template'")); } $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE"); } else { if (empty($arrayProperty["TAS_DEF_MESSAGE"])) { throw (new \Exception("Invalid value specified for 'tas_def_message'")); } $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TEMPLATE"); } //Additional configuration if (isset($arrayProperty["TAS_DEF_MESSAGE_TYPE"])) { \G::LoadClass("configuration"); $oConf = new \Configurations(); if (!isset($arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"])) { $arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"] = "alert_message.html"; } $oConf->aConfig = array("TAS_DEF_MESSAGE_TYPE" => $arrayProperty["TAS_DEF_MESSAGE_TYPE"], "TAS_DEF_MESSAGE_TEMPLATE" => $arrayProperty["TAS_DEF_MESSAGE_TEMPLATE"]); $oConf->saveConfig("TAS_EXTRA_PROPERTIES", $arrayProperty["TAS_UID"], "", ""); } } else { $this->unsetVar($arrayProperty, "TAS_DEF_SUBJECT_MESSAGE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TYPE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE"); $this->unsetVar($arrayProperty, "TAS_DEF_MESSAGE_TEMPLATE"); } $result = $task->update($arrayProperty); if (!empty($arrayProperty['CONSOLIDATE_DATA'])) { if (!empty($arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'])) { G::LoadClass("consolidatedCases"); $consolidated = new \ConsolidatedCases(); $dataConso = array( 'con_status' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_enable'], 'tas_uid' => $arrayProperty['TAS_UID'], 'dyn_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_dynaform'], 'pro_uid' => $arrayProperty['PRO_UID'], 'rep_uid' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_report_table'], 'table_name' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_table'], 'title' => $arrayProperty['CONSOLIDATE_DATA']['consolidated_title'] ); $consolidated->saveConsolidated($dataConso); } } $arrayResult["status"] = "OK"; if ($result == 3) { $arrayResult["status"] = "CRONCL"; } return $arrayResult; } catch (Exception $e) { throw $e; } }