HOR-4404
This commit is contained in:
@@ -27,6 +27,7 @@ use Exception;
|
||||
use EntitySolrRequestData;
|
||||
use G;
|
||||
use Groups;
|
||||
use GroupUserPeer;
|
||||
use InvalidIndexSearchTextException;
|
||||
use ListParticipatedLast;
|
||||
use PmDynaform;
|
||||
@@ -36,6 +37,7 @@ use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Services\OAuth2\Server;
|
||||
use ProcessUser;
|
||||
use ProcessUserPeer;
|
||||
use ProcessPeer;
|
||||
use RBAC;
|
||||
@@ -876,9 +878,8 @@ class Cases
|
||||
throw (new Exception(G::LoadTranslation("ID_CASE_ALREADY_CANCELED", array($app_uid))));
|
||||
}
|
||||
|
||||
$appCacheView = new AppCacheView();
|
||||
|
||||
$arrayProcess = $appCacheView->getProUidSupervisor($usr_uid);
|
||||
$processUser = new ProcessUser();
|
||||
$arrayProcess = $processUser->getProUidSupervisor($usr_uid);
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
@@ -937,9 +938,8 @@ class Cases
|
||||
throw (new Exception(G::LoadTranslation("ID_CASE_PAUSED", array($app_uid))));
|
||||
}
|
||||
|
||||
$appCacheView = new AppCacheView();
|
||||
|
||||
$arrayProcess = $appCacheView->getProUidSupervisor($usr_uid);
|
||||
$processUser = new ProcessUser();
|
||||
$arrayProcess = $processUser->getProUidSupervisor($usr_uid);
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
|
||||
@@ -996,9 +996,8 @@ class Cases
|
||||
throw (new Exception(G::LoadTranslation("ID_CASE_NOT_PAUSED", array($app_uid))));
|
||||
}
|
||||
|
||||
$appCacheView = new AppCacheView();
|
||||
|
||||
$arrayProcess = $appCacheView->getProUidSupervisor($usr_uid);
|
||||
$processUser = new ProcessUser();
|
||||
$arrayProcess = $processUser->getProUidSupervisor($usr_uid);
|
||||
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
@@ -1844,15 +1843,15 @@ class Cases
|
||||
throw new Exception(G::LoadTranslation("ID_CASE_IS_COMPLETED", array($app_uid)));
|
||||
}
|
||||
|
||||
$appCacheView = new AppCacheView();
|
||||
$isProcessSupervisor = $appCacheView->getProUidSupervisor($usr_uid);
|
||||
$processUser = new ProcessUser();
|
||||
$listProcess = $processUser->getProUidSupervisor($usr_uid);
|
||||
$criteria = new Criteria("workflow");
|
||||
$criteria->addSelectColumn(AppDelegationPeer::APP_UID);
|
||||
$criteria->add(AppDelegationPeer::APP_UID, $app_uid, Criteria::EQUAL);
|
||||
$criteria->add(AppDelegationPeer::USR_UID, $usr_uid, Criteria::EQUAL);
|
||||
$criteria->add(
|
||||
$criteria->getNewCriterion(AppDelegationPeer::USR_UID, $usr_uid, Criteria::EQUAL)->addOr(
|
||||
$criteria->getNewCriterion(AppDelegationPeer::PRO_UID, $isProcessSupervisor, Criteria::IN))
|
||||
$criteria->getNewCriterion(AppDelegationPeer::PRO_UID, $listProcess, Criteria::IN))
|
||||
);
|
||||
$rsCriteria = AppDelegationPeer::doSelectRS($criteria);
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use G;
|
||||
use Criteria;
|
||||
use DynaformPeer;
|
||||
use Exception;
|
||||
use G;
|
||||
use GroupUserPeer;
|
||||
use ProcessUserPeer;
|
||||
use ResultSet;
|
||||
use StepSupervisorPeer;
|
||||
use Exception;
|
||||
|
||||
class ProcessSupervisor
|
||||
{
|
||||
|
||||
@@ -22,9 +22,11 @@ use IsoLocationPeer;
|
||||
use IsoSubdivisionPeer;
|
||||
use ListParticipatedLast;
|
||||
use PMmemcached;
|
||||
use ProcessMaker\BusinessModel\ProcessSupervisor as BmProcessSupervisor;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Util\DateTime;
|
||||
use ProcessMaker\Util\System;
|
||||
use ProcessUser;
|
||||
use Propel;
|
||||
use RBAC;
|
||||
use RbacUsers;
|
||||
@@ -1713,4 +1715,53 @@ class User
|
||||
|
||||
return $dataUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function get the list of process that the user can reassign
|
||||
* If the user has the permission PM_REASSIGNCASE can reassign any process
|
||||
* If the user has the permission PM_REASSIGNCASE_SUPERVISOR can reassign only their processes
|
||||
*
|
||||
* @param array $listPermissions
|
||||
*
|
||||
* @return mixed array|null where:
|
||||
* Array empty if he can reassign any process
|
||||
* List of processes that he can reassign
|
||||
* Will be return null if can not reassign
|
||||
*/
|
||||
public function getProcessToReassign($listPermissions = [])
|
||||
{
|
||||
global $RBAC;
|
||||
$processes = [];
|
||||
if (in_array('PM_REASSIGNCASE', $listPermissions) && $RBAC->userCanAccess('PM_REASSIGNCASE') === 1){
|
||||
//The user can reassign any process
|
||||
return $processes;
|
||||
} elseif (in_array('PM_REASSIGNCASE_SUPERVISOR', $listPermissions) && $RBAC->userCanAccess('PM_REASSIGNCASE_SUPERVISOR') === 1){
|
||||
$userLogged = $RBAC->aUserInfo['USER_INFO']['USR_UID'];
|
||||
$processUser = new ProcessUser();
|
||||
$processes = $processUser->getProUidSupervisor($userLogged);
|
||||
//The user can reassign only their processes
|
||||
return $processes;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function review if the user can reassign cases
|
||||
*
|
||||
* @param string $usrUid
|
||||
* @param string $proUid
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function userCanReassign($usrUid, $proUid)
|
||||
{
|
||||
if ($this->checkPermission($usrUid, 'PM_REASSIGNCASE')) {
|
||||
return true;
|
||||
} elseif ($this->checkPermission($usrUid, 'PM_REASSIGNCASE_SUPERVISOR')) {
|
||||
$processSupervisor = new BmProcessSupervisor();
|
||||
$isSupervisor = $processSupervisor->isUserProcessSupervisor($proUid, $usrUid);
|
||||
return $isSupervisor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,22 +92,15 @@ class Cases extends Api
|
||||
//Check if the user is supervisor process
|
||||
$case = new BmCases();
|
||||
$user = new BmUser();
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($arrayParameters as $value) {
|
||||
$arrayApplicationData = $case->getApplicationRecordByPk($value['APP_UID'], [], false);
|
||||
|
||||
if (!empty($arrayApplicationData)) {
|
||||
if (!$user->checkPermission($usrUid, 'PM_REASSIGNCASE')) {
|
||||
if ($user->checkPermission($usrUid, 'PM_REASSIGNCASE_SUPERVISOR')) {
|
||||
$supervisor = new BmProcessSupervisor();
|
||||
$flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $usrUid);
|
||||
if (!$flagps) {
|
||||
$count = $count + 1;
|
||||
}
|
||||
|
||||
}
|
||||
$canReassign = $user->userCanReassign($usrUid, $arrayApplicationData['PRO_UID']);
|
||||
if (!$canReassign) {
|
||||
//We count when the user is not supervisor to the process
|
||||
$count = $count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,6 +109,15 @@ class Cases extends Api
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 'doPutReassignCase':
|
||||
$appUid = $this->parameters[$arrayArgs['app_uid']];
|
||||
$usrUid = $this->getUserId();
|
||||
$case = new BmCases();
|
||||
$user = new BmUser();
|
||||
$arrayApplicationData = $case->getApplicationRecordByPk($appUid, [], false);
|
||||
|
||||
return $user->userCanReassign($usrUid, $arrayApplicationData['PRO_UID']);
|
||||
break;
|
||||
case "doGetCaseInfo" :
|
||||
$appUid = $this->parameters[$arrayArgs['app_uid']];
|
||||
$usrUid = $this->getUserId();
|
||||
@@ -838,7 +840,7 @@ class Cases extends Api
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_REASSIGNCASE,PM_REASSIGNCASE_SUPERVISOR}
|
||||
* @class AccessControl {@className \ProcessMaker\Services\Api\Cases}
|
||||
*/
|
||||
public function doPutReassignCase($app_uid, $usr_uid_source, $usr_uid_target, $del_index = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user