diff --git a/workflow/engine/classes/class.wsBase.php b/workflow/engine/classes/class.wsBase.php index afb70d7f7..f3f7732db 100755 --- a/workflow/engine/classes/class.wsBase.php +++ b/workflow/engine/classes/class.wsBase.php @@ -2221,7 +2221,7 @@ class wsBase } } - //Execute triggers before derivation + //Execute triggers before derivation BEFORE_ROUTING $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 2, 'BEFORE' ); if (count( $aTriggers ) > 0) { @@ -2272,6 +2272,51 @@ class wsBase } } + //Execute triggers before derivation BEFORE_ASSIGNMENT + $aTriggers = $oCase->loadTriggers( $appdel['TAS_UID'], 'ASSIGN_TASK', - 1, 'BEFORE' ); + + if (count( $aTriggers ) > 0) { + $varTriggers .= "-= Before Derivation =-
"; + + $oPMScript = new PMScript(); + + foreach ($aTriggers as $aTrigger) { + //Set variables + $params = new stdClass(); + $params->appData = $appFields["APP_DATA"]; + + if ($this->stored_system_variables) { + $params->option = "STORED SESSION"; + $params->SID = $this->wsSessionId; + } + + $appFields["APP_DATA"] = array_merge( $appFields["APP_DATA"], G::getSystemConstants( $params ) ); + + //PMScript + $oPMScript->setFields( $appFields['APP_DATA'] ); + $bExecute = true; + + if ($aTrigger['ST_CONDITION'] !== '') { + $oPMScript->setScript( $aTrigger['ST_CONDITION'] ); + $bExecute = $oPMScript->evaluate(); + } + + if ($bExecute) { + $oPMScript->setScript( $aTrigger['TRI_WEBBOT'] ); + $oPMScript->execute(); + + $oTrigger = TriggersPeer::retrieveByPk( $aTrigger['TRI_UID'] ); + $varTriggers .= " - " . nl2br( htmlentities( $oTrigger->getTriTitle(), ENT_QUOTES ) ) . "
"; + $appFields['APP_DATA'] = $oPMScript->aFields; + unset($appFields['APP_STATUS']); + unset($appFields['APP_PROC_STATUS']); + unset($appFields['APP_PROC_CODE']); + unset($appFields['APP_PIN']); + $oCase->updateCase( $caseId, $appFields ); + } + } + } + $oDerivation = new Derivation(); $derive = $oDerivation->prepareInformation( $aData ); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php b/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php index 6c76422be..f8e126d10 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/CaseScheduler.php @@ -70,7 +70,7 @@ class CaseScheduler try { $oCaseSchedulerTest = \CaseSchedulerPeer::retrieveByPK( $sCaseSchedulerUID ); if (is_null($oCaseSchedulerTest)) { - throw (new \Exception( 'This id: '. $sCaseSchedulerUID .' does not correspond to a registered case scheduler')); + throw new \Exception(\G::LoadTranslation("ID_CASE_SCHEDULER_DOES_NOT_EXIST", array($sCaseSchedulerUID))); } $oCriteria = new \Criteria( 'workflow' ); $oCriteria->clearSelectColumns(); @@ -217,7 +217,7 @@ class CaseScheduler $oCriteria->add( \UsersPeer::USR_USERNAME, $sWS_USER ); $userIsAssigned = \GroupUserPeer::doCount( $oCriteria ); if (! ($userIsAssigned >= 1)) { - throw (new \Exception( "The User " . $sWS_USER . " doesn't have the activity " . $sTASKS . " assigned")); + throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_HAVE_ACTIVITY", array($sWS_USER, $sTASKS))); } } $oDataset = \TaskUserPeer::doSelectRS($oCriteria); @@ -251,17 +251,17 @@ class CaseScheduler $caseSchedulerData = array_change_key_case($caseSchedulerData, CASE_UPPER); $sOption = $caseSchedulerData['SCH_OPTION']; if (empty($caseSchedulerData)) { - die( 'the information sended is empty!' ); + die( \G::LoadTranslation("ID_INFORMATION_EMPTY") ); } $arrayTaskUid = $this->getTaskUid($caseSchedulerData['TAS_UID']); if (empty($arrayTaskUid)) { - throw (new \Exception( 'Task not found for id: '. $caseSchedulerData['TAS_UID'])); + throw (new \Exception( \G::LoadTranslation("ID_TASK_NOT_FOUND", array($caseSchedulerData['TAS_UID'])))); } if ($caseSchedulerData['SCH_NAME']=='') { - throw (new \Exception( 'sch_name can not be empty')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", array ('sch_name'))); } if ($this->existsName($sProcessUID, $caseSchedulerData['SCH_NAME'])) { - throw (new \Exception( 'Duplicate Case Scheduler name')); + throw new \Exception(\G::LoadTranslation("ID_CASE_SCHEDULER_DUPLICATE")); } $mUser = $this->getUser($caseSchedulerData['SCH_DEL_USER_NAME'], $caseSchedulerData['TAS_UID']); $oUser = \UsersPeer::retrieveByPK( $mUser ); @@ -273,19 +273,19 @@ class CaseScheduler if ($sOption != '5') { $pattern="/^([0-1][0-9]|[2][0-3])[\:]([0-5][0-9])$/"; if (!preg_match($pattern, $caseSchedulerData['SCH_START_TIME'])) { - throw (new \Exception( 'Invalid value specified for sch_start_time. Expecting time in HH:MM format (The time can not be increased to 23:59)')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_TIME")); } } $patternDate="/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/"; if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if (!preg_match($patternDate, $caseSchedulerData['SCH_START_DATE'])) { - throw (new \Exception( 'Invalid value specified for sch_start_date. Expecting date in YYYY-MM-DD format, such as 2014-01-01')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_DATE")); } if (!preg_match($patternDate, $caseSchedulerData['SCH_END_DATE'])) { - throw (new \Exception( 'Invalid value specified for sch_end_date. Expecting date in YYYY-MM-DD format, such as 2014-01-01')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_END_DATE")); } if ($caseSchedulerData['SCH_START_DATE'] == "") { - throw (new \Exception( 'sch_start_date can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_date'))); } } if ($sOption == '2') { @@ -331,7 +331,7 @@ class CaseScheduler break; case '2': // If the option is zero, set by default 1 if ($caseSchedulerData['SCH_WEEK_DAYS'] == "") { - throw (new \Exception( 'sch_week_days can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_week_days'))); } else { $weeks = $caseSchedulerData['SCH_WEEK_DAYS']; $weeks = explode("|", $weeks); @@ -339,7 +339,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7") { $caseSchedulerData['SCH_WEEK_DAYS'] = $caseSchedulerData['SCH_WEEK_DAYS']; } else { - throw (new \Exception( 'Invalid value specified for sch_week_days')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_week_days'))); } } } @@ -359,49 +359,49 @@ class CaseScheduler case '3': $nStartDay = $caseSchedulerData['SCH_START_DAY']; if ($nStartDay == "") { - throw (new \Exception( 'sch_start_day can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day'))); } if ($nStartDay == 1) { if ($caseSchedulerData['SCH_START_DAY_OPT_1'] == "") { - throw (new \Exception( 'sch_start_day_opt_1 can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day_opt_1'))); } $temp = $caseSchedulerData['SCH_START_DAY_OPT_1']; $temp = (int)$temp; if ($temp >= 1 && $temp <= 31) { $caseSchedulerData['SCH_START_DAY_OPT_1'] = $caseSchedulerData['SCH_START_DAY_OPT_1']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_1. Must be between 1 and 31')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_DAY_1")); } $caseSchedulerData['SCH_START_DAY'] = $nStartDay . '|' . $caseSchedulerData['SCH_START_DAY_OPT_1']; } else { if ($caseSchedulerData['SCH_START_DAY_OPT_2'] == "") { - throw (new \Exception( 'sch_start_day_opt_2 can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day_opt_2'))); } $caseSchedulerData['SCH_START_DAY'] = $nStartDay . '|' . $caseSchedulerData['SCH_START_DAY_OPT_2']; $optionTwo = $caseSchedulerData['SCH_START_DAY_OPT_2']{0}; if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") { $caseSchedulerData['SCH_START_DAY_OPT_2'] = $caseSchedulerData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_2')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_start_day_opt_2'))); } $pipelineTwo = $caseSchedulerData['SCH_START_DAY_OPT_2']{1}; if ($pipelineTwo == "|") { $caseSchedulerData['SCH_START_DAY_OPT_2'] = $caseSchedulerData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_2')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_start_day_opt_2'))); } $dayTwo = $caseSchedulerData['SCH_START_DAY_OPT_2']{2}; if ($dayTwo == "1" || $dayTwo == "2" || $dayTwo == "3" || $dayTwo == "4" || $dayTwo == "5" || $dayTwo == "6" || $dayTwo == "7") { $caseSchedulerData['SCH_START_DAY_OPT_2'] = $caseSchedulerData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_2')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_start_day_opt_2'))); } } if ($nStartDay == "") { - throw (new \Exception( 'sch_start_day can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day'))); } if ($caseSchedulerData['SCH_MONTHS'] == "") { - throw (new \Exception( 'sch_months can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_months'))); } if (! empty( $caseSchedulerData['SCH_MONTHS'] )) { $aMonths = $caseSchedulerData['SCH_MONTHS']; @@ -410,7 +410,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7"|| $row == "8" || $row == "9" || $row == "10"|| $row == "11" || $row == "12") { $caseSchedulerData['SCH_MONTHS'] = $caseSchedulerData['SCH_MONTHS']; } else { - throw (new \Exception( 'Invalid value specified for sch_months')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_months'))); } } } @@ -469,11 +469,11 @@ class CaseScheduler $caseSchedulerData['SCH_START_TIME'] = time(); $caseSchedulerData['SCH_START_DATE'] = $caseSchedulerData['SCH_START_TIME']; if ($caseSchedulerData['SCH_REPEAT_EVERY'] == "") { - throw (new \Exception( 'sch_repeat_every can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_repeat_every'))); } $patternHour="/^([0-1][0-9]|[2][0-3])[\.]([0-5][0-9])$/"; if (!preg_match($patternHour, $caseSchedulerData['SCH_REPEAT_EVERY'])) { - throw (new \Exception( 'Invalid value specified for sch_repeat_every. Expecting time in HH.MM format')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_REPEAT")); } $nextRun = $caseSchedulerData['SCH_REPEAT_EVERY'] * 60 * 60; $caseSchedulerData['SCH_REPEAT_EVERY'] = $caseSchedulerData['SCH_REPEAT_EVERY']; @@ -525,7 +525,7 @@ class CaseScheduler require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php"); $caseSchedulerData = array_change_key_case($caseSchedulerData, CASE_UPPER); if (empty( $caseSchedulerData )) { - die( 'The information sended is empty!' ); + die( \G::LoadTranslation("ID_INFORMATION_EMPTY") ); } $oCaseScheduler = new \CaseScheduler(); $aFields = $oCaseScheduler->Load($sSchUID); @@ -538,18 +538,15 @@ class CaseScheduler $caseSchedulerData['sch_repeat_stop_if_running'] = '0'; $caseSchedulerData['case_sh_plugin_uid'] = null; $caseSchedulerData = array_change_key_case($caseSchedulerData, CASE_UPPER); - if (empty($caseSchedulerData)) { - die( 'the information sended is empty!' ); - } $arrayTaskUid = $this->getTaskUid($caseSchedulerData['TAS_UID']); if (empty($arrayTaskUid)) { - throw (new \Exception( 'Task not found for id: '. $caseSchedulerData['TAS_UID'])); + throw new \Exception(\G::LoadTranslation("ID_TASK_NOT_FOUND", array($caseSchedulerData['TAS_UID']))); } if ($caseSchedulerData['SCH_NAME']=='') { - throw (new \Exception( 'sch_name can not be empty')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_EMPTY", array ('sch_name'))); } if ($this->existsNameUpdate($sSchUID, $caseSchedulerData['SCH_NAME'])) { - throw (new \Exception( 'Duplicate Case Scheduler name')); + throw new \Exception(\G::LoadTranslation("ID_CASE_SCHEDULER_DUPLICATE")); } $mUser = $this->getUser($caseSchedulerData['SCH_DEL_USER_NAME'], $caseSchedulerData['TAS_UID']); $oUser = \UsersPeer::retrieveByPK( $mUser ); @@ -561,19 +558,19 @@ class CaseScheduler if ($sOption != '5') { $pattern="/^([0-1][0-9]|[2][0-3])[\:]([0-5][0-9])$/"; if (!preg_match($pattern, $caseSchedulerData['SCH_START_TIME'])) { - throw (new \Exception( 'Invalid value specified for sch_start_time. Expecting time in HH:MM format (The time can not be increased to 23:59)')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_TIME")); } } $patternDate="/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/"; if ($sOption == '1' || $sOption == '2' || $sOption == '3') { if (!preg_match($patternDate, $caseSchedulerData['SCH_START_DATE'])) { - throw (new \Exception( 'Invalid value specified for sch_start_date. Expecting date in YYYY-MM-DD format, such as 2014-01-01')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_DATE")); } if (!preg_match($patternDate, $caseSchedulerData['SCH_END_DATE'])) { - throw (new \Exception( 'Invalid value specified for sch_end_date. Expecting date in YYYY-MM-DD format, such as 2014-01-01')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_END_DATE")); } if ($caseSchedulerData['SCH_START_DATE'] == "") { - throw (new \Exception( 'sch_start_date can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_date'))); } } if ($sOption == '2') { @@ -626,7 +623,7 @@ class CaseScheduler break; case '2': // If the option is zero, set by default 1 if ($caseSchedulerData['SCH_WEEK_DAYS'] == "") { - throw (new \Exception( 'sch_week_days can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_week_days'))); } else { $weeks = $caseSchedulerData['SCH_WEEK_DAYS']; $weeks = explode("|", $weeks); @@ -634,7 +631,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7") { $caseSchedulerData['SCH_WEEK_DAYS'] = $caseSchedulerData['SCH_WEEK_DAYS']; } else { - throw (new \Exception( 'Invalid value specified for sch_week_days')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_week_days'))); } } } @@ -654,49 +651,49 @@ class CaseScheduler case '3': $nStartDay = $caseSchedulerData['SCH_START_DAY']; if ($nStartDay == "") { - throw (new \Exception( 'sch_start_day can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day'))); } if ($nStartDay == 1) { if ($caseSchedulerData['SCH_START_DAY_OPT_1'] == "") { - throw (new \Exception( 'sch_start_day_opt_1 can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day_opt_1'))); } $temp = $caseSchedulerData['SCH_START_DAY_OPT_1']; $temp = (int)$temp; if ($temp >= 1 && $temp <= 31) { $caseSchedulerData['SCH_START_DAY_OPT_1'] = $caseSchedulerData['SCH_START_DAY_OPT_1']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_1. Must be between 1 and 31')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_DAY_1")); } $caseSchedulerData['SCH_START_DAY'] = $nStartDay . '|' . $caseSchedulerData['SCH_START_DAY_OPT_1']; } else { if ($caseSchedulerData['SCH_START_DAY_OPT_2'] == "") { - throw (new \Exception( 'sch_start_day_opt_2 can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day_opt_2'))); } $caseSchedulerData['SCH_START_DAY'] = $nStartDay . '|' . $caseSchedulerData['SCH_START_DAY_OPT_2']; $optionTwo = $caseSchedulerData['SCH_START_DAY_OPT_2']{0}; if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") { $caseSchedulerData['SCH_START_DAY_OPT_2'] = $caseSchedulerData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_2')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_start_day_opt_2'))); } $pipelineTwo = $caseSchedulerData['SCH_START_DAY_OPT_2']{1}; if ($pipelineTwo == "|") { $caseSchedulerData['SCH_START_DAY_OPT_2'] = $caseSchedulerData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_2')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_start_day_opt_2'))); } $dayTwo = $caseSchedulerData['SCH_START_DAY_OPT_2']{2}; if ($dayTwo == "1" || $dayTwo == "2" || $dayTwo == "3" || $dayTwo == "4" || $dayTwo == "5" || $dayTwo == "6" || $dayTwo == "7") { $caseSchedulerData['SCH_START_DAY_OPT_2'] = $caseSchedulerData['SCH_START_DAY_OPT_2']; } else { - throw (new \Exception( 'Invalid value specified for sch_start_day_opt_2')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_start_day_opt_2'))); } } if ($nStartDay == "") { - throw (new \Exception( 'sch_start_day can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_day'))); } if ($caseSchedulerData['SCH_MONTHS'] == "") { - throw (new \Exception( 'sch_months can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_months'))); } if (! empty( $caseSchedulerData['SCH_MONTHS'] )) { $aMonths = $caseSchedulerData['SCH_MONTHS']; @@ -705,7 +702,7 @@ class CaseScheduler if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7"|| $row == "8" || $row == "9" || $row == "10"|| $row == "11" || $row == "12") { $caseSchedulerData['SCH_MONTHS'] = $caseSchedulerData['SCH_MONTHS']; } else { - throw (new \Exception( 'Invalid value specified for sch_months')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('sch_months'))); } } } @@ -765,11 +762,11 @@ class CaseScheduler $caseSchedulerData['SCH_START_TIME'] = time(); $caseSchedulerData['SCH_START_DATE'] = $caseSchedulerData['SCH_START_TIME']; if ($caseSchedulerData['SCH_REPEAT_EVERY'] == "") { - throw (new \Exception( 'sch_repeat_every can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_repeat_every'))); } $patternHour="/^([0-1][0-9]|[2][0-3])[\.]([0-5][0-9])$/"; if (!preg_match($patternHour, $caseSchedulerData['SCH_REPEAT_EVERY'])) { - throw (new \Exception( 'Invalid value specified for sch_repeat_every. Expecting time in HH.MM format')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_REPEAT")); } $nextRun = $caseSchedulerData['SCH_REPEAT_EVERY'] * 60 * 60; $caseSchedulerData['SCH_REPEAT_EVERY'] = $caseSchedulerData['SCH_REPEAT_EVERY']; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 93b18a1a9..c9ae92176 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -501,7 +501,7 @@ class Cases } //Return if (empty($result)) { - throw (new \Exception('Incorrect or unavailable information about this case: ' .$applicationUid)); + throw new \Exception(\G::LoadTranslation("ID_CASES_INCORRECT_INFORMATION", array($applicationUid))); } else { return $result; } @@ -528,13 +528,10 @@ class Cases if ($variables) { $variables = array_shift($variables); } - $oProcesses = new \Processes(); - if (! $oProcesses->processExists($processUid)) { - throw (new \Exception( 'Invalid value specified for \'pro_uid\'')); - } + Validator::proUid($processUid, '$pro_uid'); $oTask = new \Task(); if (! $oTask->taskExists($taskUid)) { - throw (new \Exception( 'Invalid value specified for \'tas_uid\'')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('tas_uid'))); } $fields = $ws->newCase($processUid, $userUid, $taskUid, $variables); $array = json_decode(json_encode($fields), true); @@ -577,21 +574,18 @@ class Cases } elseif ($variables == null) { $variables = array(array()); } - $oProcesses = new \Processes(); - if (! $oProcesses->processExists($processUid)) { - throw (new \Exception( 'Invalid value specified for \'pro_uid\'')); - } + Validator::proUid($processUid, '$pro_uid'); $user = new \Users(); if (! $user->userExists( $userUid )) { - throw (new \Exception( 'Invalid value specified for \'usr_uid\'')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_uid'))); } $fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid); $array = json_decode(json_encode($fields), true); if ($array ["status_code"] != 0) { if ($array ["status_code"] == 12) { - throw (new \Exception( G::loadTranslation( 'ID_NO_STARTING_TASK' ) . '. \'tas_uid\'.')); + throw (new \Exception(\G::loadTranslation('ID_NO_STARTING_TASK') . '. tas_uid.')); } elseif ($array ["status_code"] == 13) { - throw (new \Exception( G::loadTranslation( 'ID_MULTIPLE_STARTING_TASKS' ) . '. \'tas_uid\'.')); + throw (new \Exception(\G::loadTranslation('ID_MULTIPLE_STARTING_TASKS') . '. tas_uid.')); } throw (new \Exception($array ["message"])); } else { @@ -641,7 +635,7 @@ class Cases unset($array['timestamp']); } } else { - throw (new \Exception('The Application with app_uid: '.$applicationUid.' doesn\'t exist')); + throw new \Exception(\G::LoadTranslation("ID_CASES_INCORRECT_INFORMATION", array($applicationUid))); } } catch (\Exception $e) { throw $e; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index ecf9dddaa..7d52176ac 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -84,7 +84,7 @@ class InputDocument if ($docrow['app_doc_uid'] == $inputDocumentUid) { $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, $row['DOC_VERSION'] ); if (is_null( $oAppDocument )) { - throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!')); + throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid))); } $result = $docrow; } @@ -109,7 +109,7 @@ class InputDocument try { $oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 ); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!')); + throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid))); } \G::LoadClass('wsBase'); $ws = new \wsBase(); @@ -180,7 +180,7 @@ class InputDocument $arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Add Input Document if (empty($_FILES)) { - throw (new \Exception('This document filename doesn\'t exist!')); + throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_FILENAME_DOES_NOT_EXIST")); } if (!$_FILES["form"]["error"]) { $_FILES["form"]["error"] = 0; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index 5225298dc..4b9e3b71a 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -82,7 +82,7 @@ class OutputDocument if ($docrow['app_doc_uid'] == $applicationDocumentUid) { $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $row['DOC_VERSION'] ); if (is_null( $oAppDocument )) { - throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); + throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid))); } $result = $docrow; } @@ -108,7 +108,7 @@ class OutputDocument $lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid); $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion); if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { - throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); + throw new \Exception(\G::LoadTranslation("ID_CASES_OUTPUT_DOES_NOT_EXIST", array($applicationDocumentUid))); } $aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED'); $oAppDocument->update( $aFields ); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php b/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php index 01df38d5a..3a818f024 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/FilesManager.php @@ -62,7 +62,7 @@ class FilesManager $sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $sSubDirectory; break; default: - throw (new \Exception( 'Invalid value specified for path. Expecting templates or public')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('path'))); break; } \G::verifyPath($sDirectory, true); @@ -147,7 +147,7 @@ class FilesManager try { $aData['prf_path'] = rtrim($aData['prf_path'], '/') . '/'; if (!$aData['prf_filename']) { - throw (new \Exception( 'Invalid value specified for prf_filename.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_filename'))); } $extention = strstr($aData['prf_filename'], '.'); if (!$extention) { @@ -162,7 +162,7 @@ class FilesManager } $sMainDirectory = current(explode("/", $aData['prf_path'])); if ($sMainDirectory != 'public' && $sMainDirectory != 'templates') { - throw (new \Exception( 'Invalid value specified for prf_path. Expecting templates/ or public/')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_PRF_PATH")); } if (strstr($aData['prf_path'],'/')) { $sSubDirectory = substr($aData['prf_path'], strpos($aData['prf_path'], "/")+1) ; @@ -186,7 +186,8 @@ class FilesManager $content = $aData['prf_content']; if (is_string($content)) { if (file_exists(PATH_SEP.$sDirectory)) { - throw (new \Exception( 'The file: '.$sMainDirectory. PATH_SEP . $sSubDirectory . $aData['prf_filename'] . ' already exists.')); + $directory = $sMainDirectory. PATH_SEP . $sSubDirectory . $aData['prf_filename']; + throw new \Exception(\G::LoadTranslation("ID_EXISTS_FILE", array($directory))); } } if (!file_exists($sCheckDirectory)) { @@ -329,7 +330,7 @@ class FilesManager $rsCriteria->next(); } if ($path == '') { - throw new \Exception('Invalid value specified for prf_uid.'); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid'))); } $sFile = end(explode("/",$path)); $sPath = str_replace($sFile,'',$path); @@ -348,7 +349,7 @@ class FilesManager $sEditable = false; } if ($sEditable == false) { - throw (new \Exception( 'Unable to edit. Make sure your file has an editable extension.')); + throw new \Exception(\G::LoadTranslation("ID_UNABLE_TO_EDIT")); } $oProcessFiles = \ProcessFilesPeer::retrieveByPK($prfUid); $sDate = date('Y-m-d H:i:s'); @@ -398,7 +399,7 @@ class FilesManager $rsCriteria->next(); } if ($path == '') { - throw new \Exception('Invalid value specified for prf_uid.'); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid'))); } $sFile = end(explode("/",$path)); $sPath = str_replace($sFile,'',$path); @@ -440,7 +441,7 @@ class FilesManager $rsCriteria->next(); } if ($path == '') { - throw new \Exception('Invalid value specified for prf_uid.'); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('prf_uid'))); } $sFile = end(explode("/",$path)); $sPath = str_replace($sFile,'',$path); @@ -492,7 +493,7 @@ class FilesManager if (file_exists($sDirectory.$sDirToDelete)) { \G::rm_dir($sDirectory.$sDirToDelete); } else { - throw (new \Exception( 'Invalid value specified for path.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('path'))); } $criteria = new \Criteria("workflow"); $criteria->addSelectColumn(\ProcessFilesPeer::PRF_PATH); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php index fe8b10e4a..af330057a 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/OutputDocument.php @@ -235,7 +235,7 @@ class OutputDocument if ($row == "print" || $row == "modify" || $row == "copy" || $row == "forms" || $row == "") { $outputDocumentData['out_doc_pdf_security_permissions'] = $outputDocumentData['out_doc_pdf_security_permissions']; } else { - throw (new \Exception( 'Invalid value specified for out_doc_pdf_security_permissions')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('out_doc_pdf_security_permissions'))); } } try { @@ -245,7 +245,7 @@ class OutputDocument //Verify data Validator::proUid($sProcessUID, '$pro_uid'); if ($outputDocumentData["OUT_DOC_TITLE"]=="") { - throw (new \Exception( 'Invalid value specified for out_doc_title, can not be null')); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('out_doc_title'))); } if (isset($outputDocumentData["OUT_DOC_TITLE"]) && $this->existsTitle($sProcessUID, $outputDocumentData["OUT_DOC_TITLE"])) { throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE"))); @@ -303,7 +303,7 @@ class OutputDocument if ($row == "print" || $row == "modify" || $row == "copy" || $row == "forms" || $row == "") { $outputDocumentData['out_doc_pdf_security_permissions'] = $outputDocumentData['out_doc_pdf_security_permissions']; } else { - throw (new \Exception( 'Invalid value specified for out_doc_pdf_security_permissions')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('out_doc_pdf_security_permissions'))); } } try { @@ -339,10 +339,10 @@ class OutputDocument foreach ($aValidationFailures as $oValidationFailure) { $sMessage .= $oValidationFailure->getMessage(); } - throw (new \Exception('The registry cannot be updated!' . $sMessage)); + throw (new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . $sMessage)); } } else { - throw (new \Exception('This row does not exist!')); + throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } } catch (\Exception $e) { throw $e; diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php index 86f215cfb..052b1357d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessSupervisor.php @@ -90,7 +90,7 @@ class ProcessSupervisor $aResp = array(); $oProcess = \ProcessUserPeer::retrieveByPK( $sPuUID ); if (is_null($oProcess)) { - throw (new \Exception( 'This id for pu_uid: '. $sPuUID .' does not correspond to a valid relation')); + throw new \Exception(\G::LoadTranslation("ID_NOT_VALID_RELATION", array($sPuUID))); } // Groups $oCriteria = new \Criteria('workflow'); @@ -321,7 +321,7 @@ class ProcessSupervisor $aResp = array(); $oDynaformSupervisor = \StepSupervisorPeer::retrieveByPK( $sPudUID ); if (is_null( $oDynaformSupervisor ) ) { - throw (new \Exception( 'This id: '. $sPudUID .' does not correspond to a registered process supervisor ')); + throw new \Exception(\G::LoadTranslation("ID_NOT_REGISTERED_PROCESS_SUPERVISOR", array($sPudUID))); } $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -473,7 +473,7 @@ class ProcessSupervisor $aResp = array(); $oInputDocumentSupervisor = \StepSupervisorPeer::retrieveByPK( $sPuiUID ); if (is_null( $oInputDocumentSupervisor ) ) { - throw (new \Exception( 'This id: '. $sPuiUID .' does not correspond to a registered process supervisor ')); + throw new \Exception(\G::LoadTranslation("ID_NOT_REGISTERED_PROCESS_SUPERVISOR", array($sPuiUID))); } $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -575,16 +575,16 @@ class ProcessSupervisor $oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sUsrUID ); $oTypeAssigneeU = \UsersPeer::retrieveByPK( $sUsrUID ); if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { - throw (new \Exception( 'This id: '. $sUsrUID .' does not correspond to a registered ' .$sTypeUID )); + throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID))); } if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) { if ( "SUPERVISOR"!= $sTypeUID ) { - throw (new \Exception( 'This id: '. $sUsrUID .' does not correspond to a registered ' .$sTypeUID )); + throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID))); } } if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { if ( "GROUP_SUPERVISOR" != $sTypeUID ) { - throw (new \Exception( 'This id: '. $sUsrUID .' does not correspond to a registered ' .$sTypeUID )); + throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID))); } } // validate Groups @@ -632,7 +632,7 @@ class ProcessSupervisor $oCriteria = $this->getProcessSupervisor($sProcessUID, $sPuUID); return $oCriteria; } else { - throw (new \Exception('This relation already exist!')); + throw new \Exception(\G::LoadTranslation("ID_RELATION_EXIST")); } } @@ -648,7 +648,7 @@ class ProcessSupervisor { $oTypeDynaform = \DynaformPeer::retrieveByPK($sDynUID); if (is_null( $oTypeDynaform )) { - throw (new \Exception( 'This id for dyn_uid: '. $sDynUID .' does not correspond to a registered Dynaform')); + throw new \Exception(\G::LoadTranslation("ID_DOES NOT_DYNAFORM", array($sDynUID))); } $aResp = array(); $sPuUIDT = array(); @@ -717,7 +717,7 @@ class ProcessSupervisor } return $aResp; } else { - throw (new \Exception('This relation already exist!')); + throw new \Exception(\G::LoadTranslation("ID_RELATION_EXIST")); } } @@ -734,7 +734,7 @@ class ProcessSupervisor { $oTypeInputDocument= \InputDocumentPeer::retrieveByPK($sInputDocumentUID); if (is_null( $oTypeInputDocument )) { - throw (new \Exception( 'This id for inp_doc_uid: '. $sInputDocumentUID .' does not correspond to a registered InputDocument')); + throw new \Exception(\G::LoadTranslation("ID_DOES NOT_INPUT_DOCUMENT", array($sInputDocumentUID))); } $aResp = array(); $sPuUIDT = array(); @@ -804,7 +804,7 @@ class ProcessSupervisor } return $aResp; } else { - throw (new \Exception('This relation already exist!')); + throw new \Exception(\G::LoadTranslation("ID_RELATION_EXIST")); } } @@ -826,7 +826,7 @@ class ProcessSupervisor $oConnection->commit(); return $iResult; } else { - throw (new \Exception('This row does not exist!')); + throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } } catch (\Exception $e) { $oConnection->rollback(); @@ -849,7 +849,7 @@ class ProcessSupervisor $oProcessMap = new \processMap(new \DBConnection()); $oProcessMap->removeSupervisorStep( $oDynaformSupervidor->getStepUid(), $sProcessUID, 'DYNAFORM', $oDynaformSupervidor->getStepUidObj(), $oDynaformSupervidor->getStepPosition() ); } else { - throw (new \Exception('This row does not exist!')); + throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } } catch (Exception $oError) { throw ($oError); @@ -871,7 +871,7 @@ class ProcessSupervisor $oProcessMap = new \processMap(new \DBConnection()); $oProcessMap->removeSupervisorStep( $oInputDocumentSupervidor->getStepUid(), $sProcessUID, 'INPUT_DOCUMENT', $oInputDocumentSupervidor->getStepUidObj(), $oInputDocumentSupervidor->getStepPosition() ); } else { - throw (new \Exception('This row does not exist!')); + throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } } catch (Exception $oError) { throw ($oError); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php index f57feff9a..72b3575d9 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProjectUser.php @@ -17,10 +17,7 @@ class ProjectUser public function getProjectUsers($sProcessUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } + Validator::proUid($sProcessUID, '$prj_uid'); $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -103,10 +100,7 @@ class ProjectUser public function getProjectStartingTasks($sProcessUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } + Validator::proUid($sProcessUID, '$prj_uid'); $aUsers = array(); $usersIds = array(); @@ -183,14 +177,8 @@ class ProjectUser public function getProjectStartingTaskUsers($sProcessUID, $sUserUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oUser = \UsersPeer::retrieveByPK($sUserUID); - if (is_null($oUser)) { - throw (new \Exception( 'This id for usr_uid: '. $sUserUID .' does not correspond to a registered user')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + Validator::usrUid($sUserUID, '$usr_uid'); $aUsers = array(); \G::LoadClass( 'case' ); $oCase = new \Cases(); @@ -207,7 +195,7 @@ class ProjectUser } } if (sizeof($aUsers) < 1) { - throw (new \Exception( 'This user usr_uid: '. $sUserUID .' does not have initial activities assigned in this project.')); + throw new \Exception(\G::LoadTranslation("ID_USER_NOT_INITIAL ACTIVITIES", array($sUserUID))); } return $aUsers; } catch (Exception $e) { @@ -229,10 +217,7 @@ class ProjectUser public function projectWsUserCanStartTask($sProcessUID, $sActivityUID, $oData) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } + Validator::proUid($sProcessUID, '$prj_uid'); /** * process_webEntryValidate * validates if the username and password are valid data and if the user assigned @@ -309,9 +294,9 @@ class ProjectUser $userIsAssigned = \GroupUserPeer::doCount( $oCriteria ); if (! ($userIsAssigned >= 1)) { if ($sTASKS) { - throw (new \Exception( "The usr_uid: " . $sWS_USER . " doesn't have the activity act_uid: " . $sTASKS . " assigned")); + throw new \Exception(\G::LoadTranslation("ID_USER_NOT_ID_ACTIVITY", array($sWS_USER, $sTASKS))); } else { - throw (new \Exception( "The usr_uid: " . $sWS_USER . " doesn't have an activity assigned")); + throw new \Exception(\G::LoadTranslation("ID_USER_NOT_ACTIVITY", array($sWS_USER))); } } } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php index 7a47256ac..c6cac2c64 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Task.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Task.php @@ -728,14 +728,8 @@ class Task require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RbacUsers.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "GroupUser.php"); - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -878,14 +872,8 @@ class Task require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RbacUsers.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "GroupUser.php"); - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 1; $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType); @@ -973,14 +961,14 @@ class Task } if ($start) { if ($start < 0) { - throw (new \Exception( 'Invalid value specified for start.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } } else { $start = 0; } if (isset($limit)) { if ($limit < 0) { - throw (new \Exception( 'Invalid value specified for limit.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return array(); @@ -1010,14 +998,8 @@ class Task public function getTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 1; $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); @@ -1110,7 +1092,7 @@ class Task $oDataset->next(); } if (empty($aUsers)) { - throw (new \Exception( 'Record not found for id: '. $sAssigneeUID)); + throw new \Exception(\G::LoadTranslation("ID_RECORD_NOT_FOUND", array($sAssigneeUID))); } else { return $aUsers; } @@ -1134,14 +1116,8 @@ class Task public function addTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID, $assType) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 1; $iRelation = ''; $oCriteria = new \Criteria('workflow'); @@ -1157,23 +1133,23 @@ class Task } $oTaskUser = \TaskUserPeer::retrieveByPK( $sTaskUID, $sAssigneeUID, $iType, $iRelation ); if (! is_null( $oTaskUser )) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' is already assigned to task: ' . $sTaskUID )); + throw new \Exception(\G::LoadTranslation("ID_ALREADY_ASSIGNED", array($sAssigneeUID, $sTaskUID))); } else { $oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sAssigneeUID ); $oTypeAssigneeU = \UsersPeer::retrieveByPK( $sAssigneeUID ); if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' does not correspond to a registered ' .$assType )); + throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType))); } if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) { $type = "user"; if ( $type != $assType ) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' does not correspond to a registered ' .$assType )); + throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType))); } } if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { $type = "group"; if ( $type != $assType ) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' does not correspond to a registered ' .$assType )); + throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType))); } } $oTaskUser = new \TaskUser(); @@ -1206,14 +1182,8 @@ class Task public function removeTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 1; $iRelation = ''; $oCriteria = new \Criteria('workflow'); @@ -1231,7 +1201,7 @@ class Task if (! is_null( $oTaskUser )) { \TaskUserPeer::doDelete($oCriteria); } else { - throw (new \Exception( 'This row does not exist!' )); + throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } } catch (\Exception $e) { throw $e; @@ -1258,14 +1228,8 @@ class Task require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RbacUsers.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "GroupUser.php"); - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); $oCriteria = new \Criteria('workflow'); @@ -1365,14 +1329,14 @@ class Task } if ($start) { if ($start < 0) { - throw (new \Exception( 'Invalid value specified for start.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } } else { $start = 0; } if (isset($limit)) { if ($limit < 0) { - throw (new \Exception( 'Invalid value specified for limit.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return array(); @@ -1408,14 +1372,8 @@ class Task require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RbacUsers.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "GroupUser.php"); - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 2; $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType); @@ -1503,14 +1461,14 @@ class Task } if ($start) { if ($start < 0) { - throw (new \Exception( 'Invalid value specified for start.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } } else { $start = 0; } if (isset($limit)) { if ($limit < 0) { - throw (new \Exception( 'Invalid value specified for limit.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return array(); @@ -1540,14 +1498,8 @@ class Task public function getTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 2; $aUsers = array(); $sDelimiter = \DBAdapter::getStringDelimiter(); @@ -1640,7 +1592,7 @@ class Task $oDataset->next(); } if (empty($aUsers)) { - throw (new \Exception( 'Record not found for id: '. $sAssigneeUID)); + throw new \Exception(\G::LoadTranslation("ID_RECORD_NOT_FOUND", array($sAssigneeUID))); } else { return $aUsers; } @@ -1664,14 +1616,8 @@ class Task public function addTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID, $assType) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 2; $iRelation = ''; $oCriteria = new \Criteria('workflow'); @@ -1687,23 +1633,23 @@ class Task } $oTaskUser = \TaskUserPeer::retrieveByPK( $sTaskUID, $sAssigneeUID, $iType, $iRelation ); if (! is_null( $oTaskUser )) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' is already assigned to task: ' . $sTaskUID )); + throw new \Exception(\G::LoadTranslation("ID_ALREADY_ASSIGNED", array($sAssigneeUID, $sTaskUID))); } else { $oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sAssigneeUID ); $oTypeAssigneeU = \UsersPeer::retrieveByPK( $sAssigneeUID ); if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' does not correspond to a registered ' .$assType )); + throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType))); } if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) { $type = "user"; if ( $type != $assType ) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' does not correspond to a registered ' .$assType )); + throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType))); } } if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { $type = "group"; if ( $type != $assType ) { - throw (new \Exception( 'This id: '. $sAssigneeUID .' does not correspond to a registered ' .$assType )); + throw new \Exception(\G::LoadTranslation("ID_DOES_NOT_CORRESPOND", array($sAssigneeUID, $assType))); } } $oTaskUser = new \TaskUser(); @@ -1736,14 +1682,8 @@ class Task public function removeTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $iType = 2; $iRelation = ''; $oCriteria = new \Criteria('workflow'); @@ -1761,7 +1701,7 @@ class Task if (! is_null( $oTaskUser )) { \TaskUserPeer::doDelete($oCriteria); } else { - throw (new \Exception( 'This row does not exist!' )); + throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST")); } } catch (\Exception $e) { throw $e; @@ -1863,14 +1803,8 @@ class Task public function getTaskAssigneesAll($sProcessUID, $sTaskUID, $filter, $start, $limit, $type) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $aUsers = array(); $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, 1); @@ -1947,14 +1881,14 @@ class Task } if ($start) { if ($start < 0) { - throw (new \Exception( 'Invalid value specified for start.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } } else { $start = 0; } if (isset($limit)) { if ($limit < 0) { - throw (new \Exception( 'Invalid value specified for limit.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return array(); @@ -1987,14 +1921,8 @@ class Task public function getTaskAdhocAssigneesAll($sProcessUID, $sTaskUID, $filter, $start, $limit, $type) { try { - $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); - if (is_null($oProcess)) { - throw (new \Exception( 'This id for prj_uid: '. $sProcessUID .' does not correspond to a registered process')); - } - $oActivity = \TaskPeer::retrieveByPK( $sTaskUID ); - if (is_null($oActivity)) { - throw (new \Exception( 'This id for act_uid: '. $sTaskUID .' does not correspond to a registered activity')); - } + Validator::proUid($sProcessUID, '$prj_uid'); + $this->validateActUid($sTaskUID); $aUsers = array(); $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, 2); @@ -2071,14 +1999,14 @@ class Task } if ($start) { if ($start < 0) { - throw (new \Exception( 'Invalid value specified for start.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } } else { $start = 0; } if (isset($limit)) { if ($limit < 0) { - throw (new \Exception( 'Invalid value specified for limit.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return array(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/User.php b/workflow/engine/src/ProcessMaker/BusinessModel/User.php index aab4759cf..63a8058bc 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/User.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/User.php @@ -223,7 +223,7 @@ class User if ($form['USR_COUNTRY'] != '') { $oCountry = \IsoCountryPeer::retrieveByPK($form['USR_COUNTRY']); if (is_null($oCountry)) { - throw new \Exception('Invalid value for usr_country: '.$form['USR_COUNTRY']); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array($form['USR_COUNTRY']))); } } } @@ -231,7 +231,7 @@ class User if ($form['USR_CITY'] != '') { $oCity = \IsoSubdivisionPeer::retrieveByPK($form['USR_COUNTRY'], $form['USR_CITY']); if (is_null($oCity)) { - throw new \Exception('Invalid value for usr_city: '.$form['USR_CITY']); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array($form['USR_CITY']))); } } } @@ -239,7 +239,7 @@ class User if ($form['USR_LOCATION'] != '') { $oLocation = \IsoLocationPeer::retrieveByPK($form['USR_COUNTRY'], $form['USR_LOCATION']); if (is_null($oLocation)) { - throw new \Exception('Invalid value for usr_location: '.$form['USR_LOCATION']); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array($form['USR_LOCATION']))); } } } @@ -298,7 +298,7 @@ class User $userData['USR_LASTNAME'] = $form['USR_LASTNAME']; } if ($form['USR_EMAIL'] == '') { - throw new \Exception('Invalid value specified for usr_email, can not be null.'); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('usr_email'))); } else { if (!filter_var($form['USR_EMAIL'], FILTER_VALIDATE_EMAIL)) { throw new \Exception('usr_email. '.\G::LoadTranslation('ID_INCORRECT_EMAIL')); @@ -326,16 +326,16 @@ class User $userData['USR_AUTH_USER_DN'] = $form['USR_AUTH_USER_DN']; $statusWF = $form['USR_STATUS']; if ($form['USR_STATUS'] == '') { - throw new \Exception('Invalid value specified for usr_status, can not be null'); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('usr_status'))); } else { if ($form['USR_STATUS'] == 'ACTIVE' || $form['USR_STATUS'] == 'INACTIVE' || $form['USR_STATUS'] == 'VACATION') { $userData['USR_STATUS'] = $form['USR_STATUS']; } else { - throw new \Exception('usr_status. Invalid value for status field.'); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_status'))); } } if ($form['USR_ROLE'] == '') { - throw new \Exception('Invalid value specified for usr_role, can not be null'); + throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('usr_role'))); } else { require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Roles.php"); $oCriteria = new \Criteria('rbac'); @@ -346,7 +346,7 @@ class User if ($oDataset->getRow()) { $userData['USR_ROLE'] = $form['USR_ROLE']; } else { - throw new \Exception('usr_role. Invalid value for role field.'); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_role'))); } } try { @@ -411,7 +411,7 @@ class User } } if ($countPermission != 1) { - throw new \Exception('This user: '.$usrLoggedUid. ', can not update the data.'); + throw new \Exception(\G::LoadTranslation("ID_USER_CAN_NOT_UPDATE", array($usrLoggedUid))); } if (isset($arrayUserData['USR_USERNAME'])) { $criteria = new \Criteria(); @@ -566,7 +566,7 @@ class User if ($oDataset->getRow()) { $userData['USR_ROLE'] = $form['USR_ROLE']; } else { - throw new \Exception('usr_role. Invalid value for field.'); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('usr_role'))); } $this->updateUser($userData, $form['USR_ROLE']); } else { @@ -581,7 +581,7 @@ class User if ($form['USR_COUNTRY'] != '') { $oReplacedBy = \IsoCountryPeer::retrieveByPK($form['USR_COUNTRY']); if (is_null($oReplacedBy)) { - throw new \Exception('Invalid value for usr_country: '.$form['USR_COUNTRY']); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array($form['USR_COUNTRY']))); } else { $userData['USR_COUNTRY'] = $form['USR_COUNTRY']; $userData['USR_CITY'] = ''; @@ -593,7 +593,7 @@ class User if ($form['USR_CITY'] != '') { $oCity = \IsoSubdivisionPeer::retrieveByPK($form['USR_COUNTRY'], $form['USR_CITY']); if (is_null($oCity)) { - throw new \Exception('Invalid value for usr_city: '.$form['USR_CITY']); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array($form['USR_CITY']))); } else { $userData['USR_CITY'] = $form['USR_CITY']; } @@ -603,7 +603,7 @@ class User if ($form['USR_LOCATION'] != '') { $oLocation = \IsoLocationPeer::retrieveByPK($form['USR_COUNTRY'], $form['USR_LOCATION']); if (is_null($oLocation)) { - throw new \Exception('Invalid value for usr_location: '.$form['USR_LOCATION']); + throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array($form['USR_LOCATION']))); } else { $userData['USR_LOCATION'] = $form['USR_LOCATION']; } @@ -695,7 +695,7 @@ class User $c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID); $history += \ApplicationPeer::doCount($c); if ($total > 0) { - throw (new \Exception( 'The user with usr_uid: '. $USR_UID .', cannot be deleted while it has cases assigned.')); + throw new \Exception(\G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", array($USR_UID))); } else { $UID = $usrUid; \G::LoadClass('tasks'); @@ -745,14 +745,14 @@ class User } if ($start) { if ($start < 0) { - throw (new \Exception( 'Invalid value specified for start.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } else { $oCriteria->setOffset($start); } } if ($limit != '') { if ($limit < 0) { - throw (new \Exception( 'Invalid value specified for limit.')); + throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return $aUserInfo; @@ -788,10 +788,7 @@ class User try { $filter = ''; $aUserInfo = array(); - $oUser = \UsersPeer::retrieveByPK($userUid); - if (is_null($oUser)) { - throw (new \Exception( 'This id for usr_uid: '. $userUid .' does not correspond to a registered user')); - } + Validator::usrUid($userUid, '$usr_uid'); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php"); $oCriteria = new \Criteria(); if ($filter != '') {