function user_patterns_export_all_roles in Patterns 7.2
Same name and namespace in other branches
- 7 patterns_components/components/user.inc \user_patterns_export_all_roles()
Returns a set of PATTERNS_CREATE or PATTERNS_MODIFY actions with the whole set of roles currently stored in the system.
Parameters
array $args Set of arguments received from the form.:
string $result Current set of actions for the whole process.:
Return value
array $result Set of actions after performing the changes.
1 string reference to 'user_patterns_export_all_roles'
- user_patterns in patterns_components/
components/ user.inc - Implements hook_patterns() for the user module.
File
- patterns_components/
components/ user.inc, line 63
Code
function user_patterns_export_all_roles($args = NULL, &$result = NULL) {
$roles = user_roles(TRUE);
$result = array();
//Got through all the roles and prepare set of actions according to the type of export process
switch ($args['type']) {
case PATTERNS_CREATE:
foreach ($roles as $rid => $role) {
//Create operations just require the name
$data = array(
'tag' => 'role',
);
$data['name'] = $role;
$action = array(
PATTERNS_CREATE => $data,
);
array_push($result, $action);
}
break;
case PATTERNS_MODIFY:
foreach ($roles as $rid => $role) {
//Modify operations require the name and the rid
$data = array(
'tag' => 'role',
);
$data['name'] = $role;
$data['rid'] = $rid;
$action = array(
PATTERNS_MODIFY => $data,
);
array_push($result, $action);
}
break;
}
return $result;
}