N°5324 -rename and move conf parameter to security.single-profile-completion + display warningmessage

This commit is contained in:
odain
2023-06-28 14:41:20 +02:00
parent 97f4818076
commit 07eadb3ea7
4 changed files with 115 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1">
<itop_design version="3.1">
<classes/>
<user_rights>
<groups>
@@ -544,5 +544,23 @@
<groups/>
</profile>
</profiles>
<dictionaries>
<dictionary id="EN US" _alteration="added">
<english_description>English</english_description>
<localized_description>English</localized_description>
<entries>
<entry id="Class:User/NonStandaloneProfileWarning" _alteration="added">User profile %1$s cannot be standalone. You should add
other prrofiles otherwise you may encounter access issue with this user.</entry>
</entries>
</dictionary>
<dictionary id="FR FR" _alteration="added">
<english_description>French</english_description>
<localized_description>Français</localized_description>
<entries>
<entry id="Core:DeletedObjectLabel" _alteration="added">Le profil %1$s ne peut être seul. Sans rajout d'autres profiles,
l'utilisateur peut rencontrer des problèmes dans iTop.</entry>
</entries>
</dictionary>
</dictionaries>
</user_rights>
</itop_design>

View File

@@ -24,7 +24,7 @@ define('POWER_USER_PORTAL_PROFILE_NAME', 'Portal power user');
*/
class UserProfilesEventListener implements iEventServiceSetup
{
const USERPROFILE_REPAIR_ITOP_PARAM_NAME = 'poweruserportal-repair-profile';
const USERPROFILE_REPAIR_ITOP_PARAM_NAME = 'security.single-profile-completion';
private $bIsRepairmentEnabled = false;
//map: non standalone profile name => repairing profile id
@@ -90,7 +90,7 @@ class UserProfilesEventListener implements iEventServiceSetup
$aPortalDispatcherData = \PortalDispatcherData::GetData();
}
$aNonStandaloneProfiles = \utils::GetConfig()->GetModuleSetting('itop-profiles-itil', self::USERPROFILE_REPAIR_ITOP_PARAM_NAME, null);
$aNonStandaloneProfiles = \utils::GetConfig()->Get(self::USERPROFILE_REPAIR_ITOP_PARAM_NAME, null);
//When there are several customized portals on an itop, choosing a specific profile means choosing which portal user will access
//In that case, itop administrator has to specify it via itop configuration. we dont use default profiles repairment otherwise
@@ -190,6 +190,8 @@ class UserProfilesEventListener implements iEventServiceSetup
if (is_null($sRepairingProfileId)){
//Notify current user via session messages that there will be an issue
//Without preventing from commiting
$sMessage = \Dict::Format("Class:User/NonStandaloneProfileWarning", $sSingleProfileName);
$oUser::SetSessionMessage(get_class($oUser), $oUser->GetKey(), 1, $sMessage, 'WARNING', 1);
} else {
//Completing profiles profiles by adding repairing one : by default portal user to a power portal user
$oUserProfile = new \URP_UserProfile();