mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°4036 - User edition controls : a user cannot add to himself a profile denying the backoffice
This commit is contained in:
@@ -355,11 +355,22 @@ abstract class User extends cmdbAbstractObject
|
||||
// Check that this user has at least one profile assigned when profiles have changed
|
||||
if (array_key_exists('profile_list', $aChanges))
|
||||
{
|
||||
/** @var \DBObjectSet $oSet */
|
||||
$oSet = $this->Get('profile_list');
|
||||
if ($oSet->Count() == 0)
|
||||
{
|
||||
if ($oSet->Count() == 0) {
|
||||
$this->m_aCheckIssues[] = Dict::S('Class:User/Error:AtLeastOneProfileIsNeeded');
|
||||
}
|
||||
// A user cannot add a profile denying the access to the backoffice
|
||||
$aForbiddenProfiles = PortalDispatcherData::GetData('backoffice')['deny'];
|
||||
if (UserRights::GetUserId() == $this->GetKey()) {
|
||||
$oSet->Rewind();
|
||||
while ($oUserProfile = $oSet->Fetch()) {
|
||||
$sProfile = $oUserProfile->Get('profile');
|
||||
if (in_array($sProfile, $aForbiddenProfiles)) {
|
||||
$this->m_aCheckIssues[] = Dict::Format('Class:User/Error:ProfileNotAllowed', $sProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Only administrators can manage administrators
|
||||
if (UserRights::IsAdministrator($this) && !UserRights::IsAdministrator())
|
||||
|
||||
Reference in New Issue
Block a user