Page 1 of 1

Is there a way to have more permission for userlevels?

Posted: Fri Feb 09, 2024 4:20 am
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 ?


Re: Is there a way to have more permission for userlevels ?

Posted: Fri Feb 09, 2024 10:23 am
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


Re: Is there a way to have more permission for userlevels ?

Posted: Sat Feb 10, 2024 2:30 am
by ASHKAR

but how to make permission for userlevel..!!


Re: Is there a way to have more permission for userlevels ?

Posted: Sat Feb 10, 2024 10:17 am
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.)


Re: Is there a way to have more permission for userlevels?

Posted: Wed Feb 21, 2024 9:53 am
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){

}