Skip to content

Commit a33553e

Browse files
committed
N°9723 - IsActionAllowed should work with non instantiated users objects
1 parent 918f110 commit a33553e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

addons/userrights/userrightsprofile.class.inc.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ public function IsPortalUser($oUser)
582582
*/
583583
public function ListProfiles($oUser)
584584
{
585-
if (count($oUser->ListChanges()) === 0) { // backward compatibility
585+
if (!array_key_exists('profile_list', $oUser->ListChanges())) {
586+
// Profiles list is not modified on the $oUser object, we can use DBObjectSearch with `all data` capabilities
587+
// Note: This is the default behavior
586588
$aRet = [];
587589
$oSearch = new DBObjectSearch('URP_UserProfile');
588590
$oSearch->AllowAllData();
@@ -595,6 +597,8 @@ public function ListProfiles($oUser)
595597

596598
return $aRet;
597599
} else {
600+
// Profiles list must be computed with memory changes.
601+
// Note: this is a bit tricky because the user object may have been modified in memory (e.g. a profile added or removed) and we need to take that into account
598602
$aRet = [];
599603
$oProfilesSet = $oUser->Get('profile_list');
600604
foreach ($oProfilesSet as $oUserProfile) {

0 commit comments

Comments
 (0)