diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 9f3f10af2..bcd3c6163 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -289,45 +289,52 @@ abstract class User extends cmdbAbstractObject $oSet = $this->Get('profile_list'); if ($oSet->Count() == 0) { - $this->m_aCheckIssues[] = Dict::Format('Class:User/Error:AtLeastOneProfileIsNeeded'); + $this->m_aCheckIssues[] = Dict::S('Class:User/Error:AtLeastOneProfileIsNeeded'); } } // Only administrators can manage administrators if (UserRights::IsAdministrator($this) && !UserRights::IsAdministrator()) { - $this->m_aCheckIssues[] = Dict::Format('UI:Login:Error:AccessRestricted'); + $this->m_aCheckIssues[] = Dict::S('UI:Login:Error:AccessRestricted'); } if (!UserRights::IsAdministrator()) { - $oUser = UserRights::GetUserObject(); - $oAddon = UserRights::GetModuleInstance(); - if (!is_null($oUser) && method_exists($oAddon, 'GetUserOrgs')) + if (empty($this->GetOriginal('org_id')) || empty($this->Get('org_id'))) { - $aOrgs = $oAddon->GetUserOrgs($oUser, ''); - if (count($aOrgs) > 0) + $this->m_aCheckIssues[] = Dict::S('Class:User/Error:PersonIsMandatory'); + } + else + { + $oUser = UserRights::GetUserObject(); + $oAddon = UserRights::GetModuleInstance(); + if (!is_null($oUser) && method_exists($oAddon, 'GetUserOrgs')) { - // Check that the modified User belongs to one of our organization - if (!in_array($this->GetOriginal('org_id'), $aOrgs) && !in_array($this->Get('org_id'), $aOrgs)) + $aOrgs = $oAddon->GetUserOrgs($oUser, ''); + if (count($aOrgs) > 0) { - $this->m_aCheckIssues[] = Dict::Format('Class:User/Error:UserOrganizationNotAllowed'); - } - // Check users with restricted organizations when allowed organizations have changed - if ($this->IsNew() || array_key_exists('allowed_org_list', $aChanges)) - { - $oSet = $this->get('allowed_org_list'); - if ($oSet->Count() == 0) + // Check that the modified User belongs to one of our organization + if (!in_array($this->GetOriginal('org_id'), $aOrgs) && !in_array($this->Get('org_id'), $aOrgs)) { - $this->m_aCheckIssues[] = Dict::Format('Class:User/Error:AtLeastOneOrganizationIsNeeded'); + $this->m_aCheckIssues[] = Dict::S('Class:User/Error:UserOrganizationNotAllowed'); } - else + // Check users with restricted organizations when allowed organizations have changed + if ($this->IsNew() || array_key_exists('allowed_org_list', $aChanges)) { - $aModifiedLinks = $oSet->ListModifiedLinks(); - foreach($aModifiedLinks as $oLink) + $oSet = $this->get('allowed_org_list'); + if ($oSet->Count() == 0) { - if (!in_array($oLink->Get('allowed_org_id'), $aOrgs)) + $this->m_aCheckIssues[] = Dict::S('Class:User/Error:AtLeastOneOrganizationIsNeeded'); + } + else + { + $aModifiedLinks = $oSet->ListModifiedLinks(); + foreach ($aModifiedLinks as $oLink) { - $this->m_aCheckIssues[] = Dict::Format('Class:User/Error:OrganizationNotAllowed'); + if (!in_array($oLink->Get('allowed_org_id'), $aOrgs)) + { + $this->m_aCheckIssues[] = Dict::S('Class:User/Error:OrganizationNotAllowed'); + } } } } diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index a30716005..f7ed54807 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -141,6 +141,7 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:User/Error:AtLeastOneOrganizationIsNeeded' => 'At least one organization must be assigned to this user.', '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:UserInternal' => 'User Internal', 'Class:UserInternal+' => 'User defined within iTop', )); diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index 90536c108..e11daa171 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -121,6 +121,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'Class:User/Error:AtLeastOneOrganizationIsNeeded' => 'L\'utilisateur doit avoir au moins une organisation.', '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:UserInternal' => 'Utilisateur interne', 'Class:UserInternal+' => 'Utilisateur défini dans iTop', )); diff --git a/webservices/rest.php b/webservices/rest.php index aab2958c6..0b5843efd 100644 --- a/webservices/rest.php +++ b/webservices/rest.php @@ -165,7 +165,7 @@ try if ($sJsonString == null) { - throw new Exception("Missing parameter 'json_data", RestResult::MISSING_JSON); + throw new Exception("Missing parameter 'json_data'", RestResult::MISSING_JSON); } $aJsonData = @json_decode($sJsonString); if ($aJsonData == null)