-
Notifications
You must be signed in to change notification settings - Fork 1
Permissions
When using the default Auth_Basic authentication type, you get a bunch of basic user account infrastructure mechanisms.
res/Permissions.php - Permission definitions can be defined here without labels and descriptions.
Add your group of rights to the $namespace_keys array and then add a public class variable with the "myNamespace_keys" nomenclature. e.g. if you wanted to add a "newperm" set of rights with the specific rights of "modify", "create", "delete", "play", and "loop":
public $namespace_keys = array('auth','config','accounts','home', 'newperm',);
` public $newperm_keys = array('modify','create','delete','play','loop',);
res/i18n/en/Permissions.php - Permission definitions with their labels and descriptions in the language for the folder they reside in. Change the "en" to your 2-char language identifier for languages other than English. Regions within a given language can also be used as well, such as res/i18n/en/US/Permissions.php. In this class, you would modify the $namespace variable as well as create a new variable for your $newperm. e.g. using the same example from res/Permissions.php:
public $namespace = array( 'auth' => array('label'=>'Authorization', 'desc'=>'Authorization Rights', ),
'config' => array('label'=>'Settings', 'desc'=>'Settings/Configuration/Preferences', ), 'accounts' => array('label'=>'Accounts', 'desc'=>'Membership Account Rights', ),
'newperm' => array('label'=>'My New Permissions', 'desc'=>'Long description for my new permissions.', ), );
public $newperm = array(
'modify' => array('label'=>'Modify A Widget', 'desc'=>'Change widget properties.', ), 'create' => array('label'=>'Create A Widget', 'desc'=>'Define new widgets.', ),
'delete' => array('label'=>'Delete A Widget', 'desc'=>'Remove existing widgets.', ), 'play' => array('label'=>'Run A Widget', 'desc'=>'Activate a widget.', ),
'loop' => array('label'=>'Run A Widget Continuously', 'desc'=>'Loop a widget forever.', ), );
Note that these two classes and their respective array variables will be merged together; what this means is that if you define new rights only in the "res/i18n/en/Permissions.php" file, they will still be considered "defined rights" such that the website will operate on them normally. It is considered best practice, though, to define them in both places so that language dependency is not an issue.