Umil.permission set
From phpBB Development Wiki
umil::permission_set –– Set permissions to "Yes" or "Never" for a certain group/role using the Umil Library.
To set permissions to "No" see Umil.permission_unset.
Please note that forum (local) permissions can not be set for groups using this method.
Contents |
Description
string umil::permission_set ( mixed $name [, mixed $auth_option [, string $type [, boolean $has_permission ]]] )
Parameters
| Parameter | Required/Default | Usage |
|---|---|---|
| name | Required | The name of the role/group |
| auth_option | default array() | The (string) auth_option or array of auth_options you would like to set |
| type | default 'role' | The type of permissions you would like to set - 'role' or 'group' |
| has_permission | default true | True if you want to set the permission to "Yes" False if you want to set the permission to "Never" |
Return Values
Returns result or umil_end data
Examples
Example #1
Add the 'a_test_mod' permission to the 'ROLE_ADMIN_FULL' role and set it to "Yes"
$umil->permission_set('ROLE_ADMIN_FULL', 'a_test_mod');
Example #2
Add the 'a_test_mod' permission to the 'ROLE_ADMIN_FULL' role and set it to "Never"
$umil->permission_set('ROLE_ADMIN_FULL', 'a_test_mod', 'role', false);
Example #3
Add the 'f_test_mod' permission to the 'ROLE_FORUM_FULL' role and set it to "Yes"
$umil->permission_set('ROLE_FORUM_FULL', 'f_test_mod');
Example #4
Add the 'u_test_mod' permission to the 'REGISTERED' group and set it to "Yes" The option to set group permissions was initially designed so it would be possible to set permissions for guests (since they do not have a default role). If you would like to set permissions for a group and it has a default role set to it with phpBB3 it is recommended that you set the permission to the role and not the group.
$umil->permission_set('REGISTERED', 'u_test_mod', 'group');
Example #5
Set multiple permissions for the same role
$umil->permission_set('ROLE_USER_FULL', array('u_test_mod', 'u_test_mod2', 'u_test_mod3'));
Example #6
Set multiple permissions for multiple groups and/or roles in one function call
$umil->permission_set(array(
array('ROLE_ADMIN_FULL', 'a_test_mod', 'role', false),
array('ROLE_FORUM_FULL', 'f_test_mod'),
array('REGISTERED', 'u_test_mod', 'group'),
array('ROLE_USER_FULL', array('u_test_mod', 'u_test_mod2', 'u_test_mod3')),
));
See Also

