This topic is locked

Handle more than one admission group to the same user

10/9/2007 4:59:34 AM
PHPRunner Tips and Tricks
Pfeiffer author

Problem :
I designed many admission groups like SELLER CUSTOMER ADVISOR .

Normally you can define ONE admission group to ONE user.
There is no way to give one user the rights of SELLER AND CUSTOMER at the same time.

Of course you can create an other permission group SEL_CUS (SELLER + CUSTOMER) but if you have a lot of

different permission groups it will get very complicate.
Solution :

So I changed the template commonfunctions.php in the function GetUserPermissions.
In the EDIT form of user i made the field for the admissiongroup as a multiline lookup field.

So afer edit for example the field has the value SELLER,CUSTOMER,ADVISOR
The changed function will now correctly grant the defined permissions of the different permission groups to the logged user.
Hope it helps..
best regards

Uwe Pfeiffer
function GetUserPermissions($table="")

{

global $strTableName;

$result = "";

if(!$table)

$table=$strTableName;

if @BUILDER.strAdminUserID##

if($_SESSION["AccessLevel"] == ACCESS_LEVEL_ADMIN)

$result.= "ADESP";

endif##



$sUserGroup="," . @$_SESSION["GroupID"] .",";

foreach @BUILDER.Tables as @t##

foreach @BUILDER.UserGroups as @u filter @u.strUserName!="<Default>"##

if($table=="##@t.strDataSourceTable s##" && instr($sUserGroup,",##@u.strUserName s##,"))

##if @u.strUserName=="<Guest>" && @t.nSecOptions==ADVSECURITY_VIEW_OWN##

$result.= ""; // guest sees nothing

##else##

$result.= "##@u.TablePermissions[strTableName=@t.strDataSourceTable].strPermissionMask

";

##endif##

endfor##

// default permissions

if($table=="##@t.strDataSourceTable s##")

if @BUILDER.UserGroups[strUserName=="<Default>"].len##

$result.= "##@BUILDER.UserGroups[strUserName=="<Default>"].TablePermissions[strTableName=@t.strDataSourceTable].strPermissionMask##";

elseif @BUILDER.UserGroups.len==0 || @BUILDER.UserGroups.len==1 && @BUILDER.UserGroups[strUserName=="<Guest>"].len==1##

$result.= "ADESP"; // grant all by default

else##

$result.= ""; // grant nothing by default

endif##

endfor##

return $result;

}

J
Jepsen 11/14/2007

I need this functionality, but I cannot get this modification to work.
Anyone tried this successfully ? Or is there an error in here?
Best regards

Morten