Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Security API > Methods

Security API: setPermissions

Scroll Prev Next More

 

Sets permissions for a certain table for the current user. Permissions need to be set only once per user session, i.e., in the After Successful Login event.

 

Permissions should be passed in the form of an array where the keys are specific permission letters:

 

A - add,

D - delete,

E - edit,

S - search/list,

P - print/export,

I - import,

M - admin permission. When advanced permissions are in effect (e.g., Users can see/edit their own records only), this permissions grants access to all records.

Syntax

Security::setPermissions($table, $rights)

Arguments

$table

the name of the table.

$rights

an array where the keys are specific permission letters.

Return value

No return value.

Example 1

Enable the Add and disable Delete functionality for the "Cars" table for the current user:

 

$rights = Security::getPermissions("Cars");
$rights["A"] = true;
$rights["D"] = false;
Security::setPermissions("Cars", $rights);

Example 2

Check if the current user has Add permissions for the "Cars" table:

 

$rights = Security::getPermissions("Cars");
if($rights["A"])
echo "add permission available";

See also:

Security API: getPermissions

Event: GetTablePermissions

User group permissions

About Security API

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software