function toolbar_patterns_export_all_roles in Patterns 7.2
Returns a PATTERNS_MODIFY action with the set of all the roles of the system groupped in 'addroles' or 'delroles' according to if they have permission to access or not the toolbar. The 'administrator' role is excluded.
Since this property depends on a specific permission, we cannot make user of an auxiliary function such as patterns_export_actions_from_form().
Parameters
string $args:
string $result:
Return value
array $actions
1 string reference to 'toolbar_patterns_export_all_roles'
- toolbar_patterns in patterns_components/
components/ toolbar.inc - hook_patterns()
File
- patterns_components/
components/ toolbar.inc, line 34
Code
function toolbar_patterns_export_all_roles($args = NULL, $result = NULL) {
switch ($args['type']) {
case PATTERNS_MODIFY:
//Prepare auxiliary variables
$actions = array(
PATTERNS_MODIFY => array(
'tag' => 'toolbarrole',
),
);
$roles_in = array();
$roles_out = array();
//Go through all the roles to classify them in the proper group excluding the admin
foreach (user_roles() as $role) {
if ($role != 'administrator') {
if (in_array($role, user_roles(FALSE, 'access toolbar'))) {
array_push($roles_in, $role);
}
else {
array_push($roles_out, $role);
}
}
}
//Both sections need to be added in any case (even if the array is empty)
$actions[PATTERNS_MODIFY]['addroles'] = $roles_in;
$actions[PATTERNS_MODIFY]['delroles'] = $roles_out;
$result = array(
$actions,
);
break;
}
return $result;
}