diff --git a/workflow/engine/classes/class.derivation.php b/workflow/engine/classes/class.derivation.php
index 716954179..9b8a9b5ed 100644
--- a/workflow/engine/classes/class.derivation.php
+++ b/workflow/engine/classes/class.derivation.php
@@ -605,17 +605,36 @@ class Derivation
if (isset( $useruid ) && $useruid != '') {
$userFields = $this->getUsersFullNameFromArray( $useruid );
}
-
// if there is no report_to user info, throw an exception indicating this
if (! isset( $userFields ) || $userFields['USR_UID'] == '') {
throw (new Exception( G::LoadTranslation( 'ID_MSJ_REPORSTO' ) )); // "The current user does not have a valid Reports To user. Please contact administrator.") ) ;
}
break;
case 'SELF_SERVICE':
+ $AppFields = $this->case->loadCase($tasInfo['APP_UID']);
+ $variable = str_replace('@@', '', $nextAssignedTask['TAS_GROUP_VARIABLE']);
+
+ if (isset($AppFields['APP_DATA'][$variable])) {
+ $arrVar = $AppFields['APP_DATA'][$variable];
+ if (is_array($arrVar)) {
+ $statusToCheck = $arrVar;
+ } else {
+ $statusToCheck = array($arrVar);
+ }
+ $toValidate = array('ACTIVE', 'VACATION');
+ $gpr = new GroupUser();
+ if (!$gpr->groupsUsersAvailable($statusToCheck, $toValidate)) {
+ if (!($gpr->groupsUsersAvailable($statusToCheck, $toValidate, "groups"))) {
+ throw (new Exception("Task doesn't have a valid user in variable $variable or this variable doesn't exist."));
+ }
+ }
+ } else {
+ throw (new Exception("Task doesn't have a valid user in variable $variable or this variable doesn't exist."));
+ }
//look for USR_REPORTS_TO to this user
$userFields['USR_UID'] = '';
- $userFields['USR_FULLNAME'] = '' . G::LoadTranslation( 'ID_UNASSIGNED' ) . '';
- $userFields['USR_USERNAME'] = '' . G::LoadTranslation( 'ID_UNASSIGNED' ) . '';
+ $userFields['USR_FULLNAME'] = '' . G::LoadTranslation('ID_UNASSIGNED') . '';
+ $userFields['USR_USERNAME'] = '' . G::LoadTranslation('ID_UNASSIGNED') . '';
$userFields['USR_FIRSTNAME'] = '';
$userFields['USR_LASTNAME'] = '';
$userFields['USR_EMAIL'] = '';
diff --git a/workflow/engine/classes/model/GroupUser.php b/workflow/engine/classes/model/GroupUser.php
index 639d09b54..bf082de4f 100644
--- a/workflow/engine/classes/model/GroupUser.php
+++ b/workflow/engine/classes/model/GroupUser.php
@@ -179,5 +179,43 @@ class GroupUser extends BaseGroupUser
return $rows;
}
+
+ /**
+ * This function check if the array have at least one UID valid
+ * Ex. we need to check the data for self service value based assignment
+ *
+ * @param array $toValidate , this array contains uid of user or uid of groups
+ * @param array $statusToCheck , this array must be have a valid status for users or groups, ACTIVE INACTIVE VACATION
+ * @param string $tableReview , if you need to check uid for users or groups
+ * @return boolean $rows
+ */
+ public function groupsUsersAvailable($toValidate, $statusToCheck = array('ACTIVE'), $tableReview = 'users')
+ {
+ //Define the batching value for the MySQL error related to max_allowed_packet
+ $batching = 25000;
+ $array = array_chunk($toValidate, $batching);
+ foreach ($array as $key => $uidValues) {
+ $oCriteria = new Criteria('workflow');
+ switch ($tableReview) {
+ case 'groups':
+ $oCriteria->add(GroupwfPeer::GRP_UID, $uidValues, Criteria::IN);
+ $oCriteria->add(GroupwfPeer::GRP_STATUS, $statusToCheck, Criteria::IN);
+ $oCriteria->setLimit(1);
+ $rsCriteria = GroupwfPeer::doSelectRS($oCriteria);
+ break;
+ default:
+ $oCriteria->add(UsersPeer::USR_UID, $uidValues, Criteria::IN);
+ $oCriteria->add(UsersPeer::USR_STATUS, $statusToCheck, Criteria::IN);
+ $oCriteria->setLimit(1);
+ $rsCriteria = UsersPeer::doSelectRS($oCriteria);
+ break;
+ }
+ $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
+ if ($rsCriteria->next()) {
+ return true;
+ }
+ }
+ return false;
+ }
}