Merged in 3.1 (pull request #4761)
Updating branch HOR-1500 with last changes (2016-08-13)
This commit is contained in:
@@ -19,8 +19,8 @@ class Calendar
|
||||
|
||||
private $arrayWorkHourFieldDefinition = array(
|
||||
"DAY" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(0, 1, 2, 3, 4, 5, 6, 7), "fieldNameAux" => "day"),
|
||||
"HOUR_START" => array("type" => "hour", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "hourStart"),
|
||||
"HOUR_END" => array("type" => "hour", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "hourEnd")
|
||||
'HOUR_START' => array('type' => 'hour', 'required' => true, 'empty' => false, 'defaultValues' => array(), 'fieldNameAux' => 'hourStart', 'regexp' => '/^(?:[0-1]\d|2[0-3])\:[0-5]\d$/'),
|
||||
'HOUR_END' => array('type' => 'hour', 'required' => true, 'empty' => false, 'defaultValues' => array(), 'fieldNameAux' => 'hourEnd', 'regexp' => '/^(?:[0-1]\d|2[0-3])\:[0-5]\d$/')
|
||||
);
|
||||
|
||||
private $arrayHolidayFieldDefinition = array(
|
||||
@@ -751,4 +751,3 @@ class Calendar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2887,6 +2887,53 @@ class Cases
|
||||
|
||||
$dataResponse = $data;
|
||||
|
||||
//Verify data
|
||||
$arrayCasesToReassign = $data['cases'];
|
||||
|
||||
$arrayMsg = [];
|
||||
|
||||
foreach($arrayCasesToReassign as $key => $value) {
|
||||
$appDelegation = \AppDelegationPeer::retrieveByPK($value['APP_UID'], $value['DEL_INDEX']);
|
||||
|
||||
if (is_null($appDelegation)) {
|
||||
$arrayMsg[] = [
|
||||
'app_uid' => $value['APP_UID'],
|
||||
'del_index' => $value['DEL_INDEX'],
|
||||
'result' => 0,
|
||||
'status' => 'DELEGATION_NOT_EXISTS'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arrayMsg)) {
|
||||
return ['cases' => $arrayMsg];
|
||||
}
|
||||
|
||||
$task = new \ProcessMaker\BusinessModel\Task();
|
||||
$userUid = $data['usr_uid_target'];
|
||||
|
||||
foreach($arrayCasesToReassign as $value) {
|
||||
$appDelegation = \AppDelegationPeer::retrieveByPK($value['APP_UID'], $value['DEL_INDEX']);
|
||||
|
||||
//Verify data
|
||||
$taskUid = $appDelegation->getTasUid();
|
||||
|
||||
$flagBoolean = $task->checkUserOrGroupAssignedTask($taskUid, $userUid);
|
||||
|
||||
if (!$flagBoolean) {
|
||||
$arrayMsg[] = [
|
||||
'app_uid' => $value['APP_UID'],
|
||||
'del_index' => $value['DEL_INDEX'],
|
||||
'result' => 0,
|
||||
'status' => 'USER_NOT_ASSIGNED_TO_TASK'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arrayMsg)) {
|
||||
return ['cases' => $arrayMsg];
|
||||
}
|
||||
|
||||
G::LoadClass( 'case' );
|
||||
$oCases = new \Cases();
|
||||
$appDelegation = new \AppDelegation();
|
||||
@@ -2904,15 +2951,60 @@ class Cases
|
||||
$fields = $appDelegation->load($val['APP_UID'], $val['DEL_INDEX']);
|
||||
$usrUid = $fields['USR_UID'];
|
||||
}
|
||||
//Will be not able reassign a case when is paused
|
||||
$flagReassign = true;
|
||||
if (!\AppDelay::isPaused($val['APP_UID'], $val['INDEX'])) {
|
||||
$dataResponse['cases'][$key]['result'] = 0;
|
||||
$dataResponse['cases'][$key]['status'] = \G::LoadTranslation('ID_REASSIGNMENT_PAUSED_ERROR');
|
||||
$flagReassign = false;
|
||||
}
|
||||
|
||||
$reassigned = $oCases->reassignCase($val['APP_UID'], $val['DEL_INDEX'], $usrUid, $data['usr_uid_target']);
|
||||
$result = $reassigned ? 1 : 0 ;
|
||||
//Current users of OPEN DEL_INDEX thread
|
||||
$aCurUser = $oAppDel->getCurrentUsers($val['APP_UID'], $val['INDEX']);
|
||||
if(!empty($aCurUser)){
|
||||
foreach ($aCurUser as $key => $value) {
|
||||
if($value === $data['usr_uid_target']){
|
||||
$flagReassign = false;
|
||||
$result = 1;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//DEL_INDEX is CLOSED
|
||||
$dataResponse['cases'][$key]['result'] = 0;
|
||||
$dataResponse['cases'][$key]['status'] = \G::LoadTranslation('ID_REASSIGNMENT_ERROR');
|
||||
}
|
||||
|
||||
if($flagReassign) {
|
||||
$reassigned = $oCases->reassignCase($val['APP_UID'], $val['DEL_INDEX'], $usrUid, $data['usr_uid_target']);
|
||||
$result = $reassigned ? 1 : 0 ;
|
||||
}
|
||||
$dataResponse['cases'][$key]['result'] = $result;
|
||||
$dataResponse['cases'][$key]['status'] = 'SUCCESS';
|
||||
}
|
||||
}
|
||||
unset($dataResponse['usr_uid_target']);
|
||||
|
||||
return G::json_encode($dataResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* if case already routed
|
||||
*
|
||||
* @param type $app_uid
|
||||
* @param type $del_index
|
||||
* @param type $usr_uid
|
||||
* @throws type
|
||||
*/
|
||||
public function caseAlreadyRouted($app_uid, $del_index, $usr_uid = '')
|
||||
{
|
||||
$c = new \Criteria('workflow');
|
||||
$c->add(\AppDelegationPeer::APP_UID, $app_uid);
|
||||
$c->add(\AppDelegationPeer::DEL_INDEX, $del_index);
|
||||
if (!empty($usr_uid)) {
|
||||
$c->add(\AppDelegationPeer::USR_UID, $usr_uid);
|
||||
}
|
||||
$c->add(\AppDelegationPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL);
|
||||
return !(boolean) \AppDelegationPeer::doCount($c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,13 @@ class Process
|
||||
}
|
||||
break;
|
||||
case "hour":
|
||||
if (!preg_match('/^' . $regexpTime . '$/', $fieldValue)) {
|
||||
$regexpTime = '/^' . $regexpTime . '$/';
|
||||
|
||||
if (array_key_exists('regexp', $arrayFieldDefinition[$fieldName])) {
|
||||
$regexpTime = $arrayFieldDefinition[$fieldName]['regexp'];
|
||||
}
|
||||
|
||||
if (!preg_match($regexpTime, $fieldValue)) {
|
||||
throw new \Exception(\G::LoadTranslation('ID_INVALID_VALUE', [$fieldNameAux]));
|
||||
}
|
||||
break;
|
||||
@@ -532,16 +538,16 @@ class Process
|
||||
$trigger = new \ProcessMaker\BusinessModel\Trigger();
|
||||
|
||||
/**
|
||||
* Try catch block is added to escape the exception and continue editing
|
||||
* the properties of the process, otherwise there is no way to edit
|
||||
* the properties that the exception is thrown: trigger nonexistent.
|
||||
* Try catch block is added to escape the exception and continue editing
|
||||
* the properties of the process, otherwise there is no way to edit
|
||||
* the properties that the exception is thrown: trigger nonexistent.
|
||||
* The same goes for the similar blocks.
|
||||
*/
|
||||
if (isset($arrayData["PRO_TRI_DELETED"]) && $arrayData["PRO_TRI_DELETED"] . "" != "") {
|
||||
try {
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_DELETED"], $processUid, $this->arrayFieldNameForException["processTriDeleted"]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,7 +555,7 @@ class Process
|
||||
try {
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_CANCELED"], $processUid, $this->arrayFieldNameForException["processTriCanceled"]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,7 +563,7 @@ class Process
|
||||
try {
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_PAUSED"], $processUid, $this->arrayFieldNameForException["processTriPaused"]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,7 +571,7 @@ class Process
|
||||
try {
|
||||
$trigger->throwExceptionIfNotExistsTrigger($arrayData["PRO_TRI_REASSIGNED"], $processUid, $this->arrayFieldNameForException["processTriReassigned"]);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1834,4 +1840,3 @@ class Process
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1972,4 +1972,52 @@ class Task
|
||||
);
|
||||
return $aTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check user to group assigned Task (Normal and/or Ad-Hoc Users)
|
||||
*
|
||||
* @param string $taskUid Unique uid of Task
|
||||
* @param string $userUid Unique uid of User
|
||||
*
|
||||
* return bool
|
||||
*/
|
||||
public function checkUserOrGroupAssignedTask($taskUid, $usrUid)
|
||||
{
|
||||
$criteriaUser = new \Criteria('workflow');
|
||||
|
||||
$criteriaUser->add(\TaskUserPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||
$criteriaUser->add(\TaskUserPeer::USR_UID, $usrUid, \Criteria::EQUAL);
|
||||
$criteriaUser->add(\TaskUserPeer::TU_RELATION, 1, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \TaskUserPeer::doSelectRS($criteriaUser);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$criteriaGroup = new \Criteria('workflow');
|
||||
|
||||
$criteriaGroup->addSelectColumn(\TaskUserPeer::USR_UID);
|
||||
|
||||
$criteriaGroup->add(\TaskUserPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||
$criteriaGroup->add(\TaskUserPeer::TU_RELATION, 2, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteriaGroup = \TaskUserPeer::doSelectRS($criteriaGroup);
|
||||
$rsCriteriaGroup->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
while ($rsCriteriaGroup->next()) {
|
||||
$row = $rsCriteriaGroup->getRow();
|
||||
$groupUid = $row['USR_UID'];
|
||||
|
||||
$obj = \GroupUserPeer::retrieveByPK($groupUid, $usrUid);
|
||||
|
||||
if (!is_null($obj)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//Return
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user