N°4036 - User edition controls : a user cannot delete himself

This commit is contained in:
Eric
2021-07-27 10:59:13 +02:00
parent c450f1d02f
commit 71a7e060e4

View File

@@ -413,14 +413,22 @@ abstract class User extends cmdbAbstractObject
}
}
public function DoCheckToDelete(&$oDeletionPlan)
{
parent::DoCheckToDelete($oDeletionPlan);
// A user cannot suppress himself
if (UserRights::GetUserId() == $this->GetKey()) {
$this->m_bSecurityIssue = true;
$this->m_aDeleteIssues[] = Dict::S('UI:Delete:NotAllowedToDelete');
}
}
function GetGrantAsHtml($sClass, $iAction)
{
if (UserRights::IsActionAllowed($sClass, $iAction, null, $this))
{
if (UserRights::IsActionAllowed($sClass, $iAction, null, $this)) {
return '<span style="background-color: #ddffdd;">'.Dict::S('UI:UserManagement:ActionAllowed:Yes').'</span>';
}
else
{
} else {
return '<span style="background-color: #ffdddd;">'.Dict::S('UI:UserManagement:ActionAllowed:No').'</span>';
}
}