Merged in bugfix/HOR-3332 (pull request #5708)

HOR-3332

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Jonathan Quispe
2017-06-02 14:57:16 +00:00
committed by Julio Cesar Laura Avendaño
2 changed files with 65 additions and 3 deletions

View File

@@ -605,17 +605,41 @@ 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':
//Check if is Self Service Value Based Assignment
if (!empty($nextAssignedTask['TAS_GROUP_VARIABLE'])) {
$appFields = $this->case->loadCase($tasInfo['APP_UID']);
$variable = str_replace('@@', '', $nextAssignedTask['TAS_GROUP_VARIABLE']);
//If the variable exists will be validate the UID's
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'] = '<b>' . G::LoadTranslation( 'ID_UNASSIGNED' ) . '</b>';
$userFields['USR_USERNAME'] = '<b>' . G::LoadTranslation( 'ID_UNASSIGNED' ) . '</b>';
$userFields['USR_FULLNAME'] = '<b>' . G::LoadTranslation('ID_UNASSIGNED') . '</b>';
$userFields['USR_USERNAME'] = '<b>' . G::LoadTranslation('ID_UNASSIGNED') . '</b>';
$userFields['USR_FIRSTNAME'] = '';
$userFields['USR_LASTNAME'] = '';
$userFields['USR_EMAIL'] = '';

View File

@@ -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;
}
}