N°5324 - disable repairment with backoffice and a customized portal

This commit is contained in:
odain
2023-06-21 21:42:40 +02:00
parent c6b203fc4e
commit cd3f7d7ead
2 changed files with 27 additions and 6 deletions

View File

@@ -89,10 +89,17 @@ class UserProfilesEventListener implements iEventServiceSetup
$sRepairmentProfile = \utils::GetConfig()->GetModuleSetting('itop-profiles-itil', 'poweruserportal-repair-profile', null); $sRepairmentProfile = \utils::GetConfig()->GetModuleSetting('itop-profiles-itil', 'poweruserportal-repair-profile', null);
if (is_null($sRepairmentProfile) && sizeof($aPortalDispatcherData) > 2){ if (is_null($sRepairmentProfile) && count($aPortalDispatcherData) > 2){
//when there are further portals we dont want to force a specific portal by repairing the associated profiles to a user //when there are further portals we dont want to force a specific portal by repairing the associated profiles to a user
$this->bIsRepairmentEnabled = false; $this->bIsRepairmentEnabled = false;
return; return;
} else{
$aPortalNames = array_keys($aPortalDispatcherData);
sort($aPortalNames);
if ($aPortalNames !== ['backoffice', 'itop-portal']){
$this->bIsRepairmentEnabled = false;
return;
}
} }
if (is_null($sRepairmentProfile)){ if (is_null($sRepairmentProfile)){

View File

@@ -377,13 +377,27 @@ class UserProfilesEventListenerTest extends ItopDataTestCase
$this->assertTrue($oUserProfilesEventListener->IsRepairmentEnabled()); $this->assertTrue($oUserProfilesEventListener->IsRepairmentEnabled());
} }
public function testUserProfilesEventListenerInit_furtherportals_norepairmentconfigured(){ public function CustomizedPortalsProvider(){
$aPortalDispatcherData = [ return [
'console + customized portal' => [
'aPortalDispatcherData' => [
'customer-portal',
'backoffice'
]],
'console + itop portal + customized portal' => [
'aPortalDispatcherData' => [
'itop-portal', 'itop-portal',
'customer-portal', 'customer-portal',
'backoffice' 'backoffice'
]
],
]; ];
}
/**
* @dataProvider CustomizedPortalsProvider
*/
public function testUserProfilesEventListenerInit_furtherportals_norepairmentconfigured($aPortalDispatcherData){
$oUserProfilesEventListener = new UserProfilesEventListener(); $oUserProfilesEventListener = new UserProfilesEventListener();
$oUserProfilesEventListener->Init($aPortalDispatcherData); $oUserProfilesEventListener->Init($aPortalDispatcherData);