Is there a way to have more permission for userlevels?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
ASHKAR
User
Posts: 26

Is there a way to have more permission for userlevels?

Post by ASHKAR »

Hi everyone :)

if I have table ( driver ) contain columns :
id
name
age
mobile
allow_to_drive (default is 1 => it means allow )
driver_area

note: allow_to_drive will be a dropdown menu ( allow = 1 & disallow = 0 )

if I have ( userlevel A,B,C,D,E,F ) and ALL USERLEVELS HAVE PERMISSION TO EDIT THIS TABLE

,But if i want (userlevel A & E) only to take permission to change allow_to_drive to be allow or disallow and other (userlevel B,C,D,F) can NOT change it but can edit all data except allow_to_drive and (( can't edit driver_area ))

and (userlevel B & C) only can edit (( driver_area ))

is there any way ?


arbei
User
Posts: 9384

Post by arbei »

Note that user level permissions are table level, not field level. You should use Row_Rendered server event to set the Disabled property of the field object


ASHKAR
User
Posts: 26

Post by ASHKAR »

but how to make permission for userlevel..!!


arbei
User
Posts: 9384

Post by arbei »

arbei wrote:

You should use Row_Rendered server event to set the Disabled property of the field object

You should check user level in the server event before setting field properties.

(You can only customize the template or generated scripts to add more permissions. It is better to use server events and your code can still be used in future versions.)


yinsw
User
Posts: 148
Location: Penang, Malaysia

Post by yinsw »

I have a suggestion. Why not add this permission in USERS table instead? For example, add a new field called "edit_allow_to_drive" in USERS table.

Then in User_Validated event, you can add the following:

function User_Validated($rs)
{
    // Example:
    //$_SESSION['UserEmail'] = $rs['Email'];
    Profile()->set("edit_allow_to_drive", $rs["edit_allow_to_drive"])->saveToSession();   // Set additional data to the profile object
}

Then in your module edit page event, you can retrieve the Current User Level and this permission to do your checking to enable/disable whatever fields you want.

if (Profile()->loadFromSession()->get("edit_allow_to_drive")==1){

}

Post Reply