PMCORE-3693
This commit is contained in:
@@ -2150,4 +2150,16 @@ class RBAC
|
|||||||
{
|
{
|
||||||
return self::GUEST_USER_UID === $usrUid;
|
return self::GUEST_USER_UID === $usrUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true in case the parameter corresponds to the admin user,
|
||||||
|
* otherwise it returns false.
|
||||||
|
*
|
||||||
|
* @param string $usrUid
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static function isAdminUserUid($usrUid)
|
||||||
|
{
|
||||||
|
return self::ADMIN_USER_UID === $usrUid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ class User
|
|||||||
|
|
||||||
$this->throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $this->arrayFieldNameForException["userUid"]);
|
$this->throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $this->arrayFieldNameForException["userUid"]);
|
||||||
|
|
||||||
if ($userUid == "00000000000000000000000000000001") {
|
if (RBAC::isAdminUserUid($userUid)) {
|
||||||
throw new Exception(G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
throw new Exception(G::LoadTranslation("ID_ADMINISTRATOR_ROLE_CANT_CHANGED"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1287,27 +1287,29 @@ class User
|
|||||||
try {
|
try {
|
||||||
//Verify data
|
//Verify data
|
||||||
$this->throwExceptionIfNotExistsUser($usrUid, $this->arrayFieldNameForException["usrUid"]);
|
$this->throwExceptionIfNotExistsUser($usrUid, $this->arrayFieldNameForException["usrUid"]);
|
||||||
|
// Check user admin
|
||||||
|
if (RBAC::isAdminUserUid($usrUid)) {
|
||||||
|
throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", [$usrUid]));
|
||||||
|
}
|
||||||
|
// Check user guest
|
||||||
|
if (RBAC::isGuestUserUid($usrUid)) {
|
||||||
|
throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", [$usrUid]));
|
||||||
|
}
|
||||||
|
// Check if the user has cases
|
||||||
$oProcessMap = new ClassesCases();
|
$oProcessMap = new ClassesCases();
|
||||||
$USR_UID = $usrUid;
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$history = 0;
|
$history = 0;
|
||||||
$c = $oProcessMap->getCriteriaUsersCases('TO_DO', $USR_UID);
|
$c = $oProcessMap->getCriteriaUsersCases('TO_DO', $usrUid);
|
||||||
$total += ApplicationPeer::doCount($c);
|
$total += ApplicationPeer::doCount($c);
|
||||||
$c = $oProcessMap->getCriteriaUsersCases('DRAFT', $USR_UID);
|
$c = $oProcessMap->getCriteriaUsersCases('DRAFT', $usrUid);
|
||||||
$total += ApplicationPeer::doCount($c);
|
$total += ApplicationPeer::doCount($c);
|
||||||
$c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $USR_UID);
|
$c = $oProcessMap->getCriteriaUsersCases('COMPLETED', $usrUid);
|
||||||
$history += ApplicationPeer::doCount($c);
|
$history += ApplicationPeer::doCount($c);
|
||||||
$c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $USR_UID);
|
$c = $oProcessMap->getCriteriaUsersCases('CANCELLED', $usrUid);
|
||||||
$history += ApplicationPeer::doCount($c);
|
$history += ApplicationPeer::doCount($c);
|
||||||
|
|
||||||
//check user guest
|
|
||||||
if (RBAC::isGuestUserUid($usrUid)) {
|
|
||||||
throw new Exception(G::LoadTranslation("ID_MSG_CANNOT_DELETE_USER", array($USR_UID)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($total > 0) {
|
if ($total > 0) {
|
||||||
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", array($USR_UID)));
|
throw new Exception(G::LoadTranslation("ID_USER_CAN_NOT_BE_DELETED", [$usrUid]));
|
||||||
} else {
|
} else {
|
||||||
$UID = $usrUid;
|
$UID = $usrUid;
|
||||||
$oTasks = new Tasks();
|
$oTasks = new Tasks();
|
||||||
@@ -1316,20 +1318,20 @@ class User
|
|||||||
$oGroups->removeUserOfAllGroups($UID);
|
$oGroups->removeUserOfAllGroups($UID);
|
||||||
$this->changeUserStatus($UID, 'CLOSED');
|
$this->changeUserStatus($UID, 'CLOSED');
|
||||||
$_GET['USR_USERNAME'] = '';
|
$_GET['USR_USERNAME'] = '';
|
||||||
$this->updateUser(array('USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']), '');
|
$this->updateUser(['USR_UID' => $UID, 'USR_USERNAME' => $_GET['USR_USERNAME']], '');
|
||||||
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
|
||||||
$oUser = new Users();
|
$oUser = new Users();
|
||||||
$aFields = $oUser->load($UID);
|
$aFields = $oUser->load($UID);
|
||||||
$aFields['USR_STATUS'] = 'CLOSED';
|
$aFields['USR_STATUS'] = 'CLOSED';
|
||||||
$aFields['USR_USERNAME'] = '';
|
$aFields['USR_USERNAME'] = '';
|
||||||
$oUser->update($aFields);
|
$oUser->update($aFields);
|
||||||
//Delete Dashboard
|
// Delete Dashboard
|
||||||
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashletInstance.php");
|
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "DashletInstance.php");
|
||||||
$criteria = new Criteria('workflow');
|
$criteria = new Criteria('workflow');
|
||||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $UID);
|
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $UID);
|
||||||
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'USER');
|
$criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'USER');
|
||||||
DashletInstancePeer::doDelete($criteria);
|
DashletInstancePeer::doDelete($criteria);
|
||||||
//Destroy session after delete user
|
// Destroy session after delete user
|
||||||
RBAC::destroySessionUser($usrUid);
|
RBAC::destroySessionUser($usrUid);
|
||||||
(new OauthClients())->removeByUser($usrUid);
|
(new OauthClients())->removeByUser($usrUid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user