N°7425 - Add Warning when a user has no contact or no allow org

This commit is contained in:
vdumas
2024-06-06 12:07:15 +02:00
parent bbebca7951
commit 3fd6f47f8b
3 changed files with 14 additions and 1 deletions

View File

@@ -455,8 +455,12 @@ abstract class User extends cmdbAbstractObject
&& empty($this->Get('contactid'))) {
$this->m_aCheckIssues[] = Dict::S('Class:User/Error:PersonIsMandatory');
}
// Warning if the user has no associated contact
elseif (empty($this->Get('contactid'))) {
$this->AddCheckWarning(Dict::S('Class:User/Warning:NoContactHasImpact'));
}
// Allowed orgs must contains the user org (if any)
// Allowed orgs must contain the user org (if any)
if (!empty($this->Get('org_id')) && !UserRights::IsAdministrator($this)) {
// Get the user org and all its parent orgs
$aUserOrgs = [$this->Get('org_id')];
@@ -485,6 +489,11 @@ abstract class User extends cmdbAbstractObject
}
}
// Modified User is not administrator and has no allowed orgs, warn about the consequences
if (!UserRights::IsAdministrator($this) && ($this->get('allowed_org_list')->Count() == 0)) {
$this->AddCheckWarning(Dict::S('Class:User/Warning:NoOrganizationMeansFullAccess'));
}
if (!UserRights::IsAdministrator()) {
$oUser = UserRights::GetUserObject();
if (!is_null($oUser) && method_exists($oAddon, 'GetUserOrgs')) {

View File

@@ -187,6 +187,8 @@ Dict::Add('EN US', 'English', 'English', array(
'Class:User/Error:OrganizationNotAllowed' => 'Organization not allowed.',
'Class:User/Error:UserOrganizationNotAllowed' => 'The user account does not belong to your allowed organizations.',
'Class:User/Error:PersonIsMandatory' => 'The Contact is mandatory.',
'Class:User/Warning:NoOrganizationMeansFullAccess' => 'No "Allowed Organizations" defined for this user, this means they have access to all organizations',
'Class:User/Warning:NoContactHasImpact' => 'Cautious: there is no Person defined on this User, this prevents access to portals, news notifications and other side effects in back-office',
'Class:UserInternal' => 'User Internal',
'Class:UserInternal+' => 'User defined within '.ITOP_APPLICATION_SHORT,
));

View File

@@ -171,6 +171,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:User/Error:OrganizationNotAllowed' => 'Organisation non autorisée.',
'Class:User/Error:UserOrganizationNotAllowed' => 'L\'utilisateur n\'appartient pas à vos organisations.',
'Class:User/Error:PersonIsMandatory' => 'Le Contact est obligatoire.',
'Class:User/Warning:NoOrganizationMeansFullAccess' => 'Aucune "Organisations permises" définie pour cet utilisateur, il aura accès à toutes les organisations sans restriction',
'Class:User/Warning:NoContactHasImpact' => 'Attention: il n\'y a pas de Personne liée à cet utilisateur, il ne pourra pas se connecter à un portail, ni recevoir de News, ni changer sa langue.',
'Class:UserInternal' => 'Utilisateur interne',
'Class:UserInternal+' => 'Utilisateur défini dans '.ITOP_APPLICATION_SHORT,
));