function toolbar_patterns_prepare in Patterns 7.2
Same name and namespace in other branches
- 7 patterns_components/components/toolbar.inc \toolbar_patterns_prepare()
hook_patterns_prepare()
File
- patterns_components/
components/ toolbar.inc, line 68
Code
function toolbar_patterns_prepare($action, $tag, &$data) {
module_load_include('module', 'user', 'user');
$data['role_names'] = user_roles();
$data['role_permissions'] = user_role_permissions($data['role_names']);
//get all the module's name which inplement the hook_permission function.
$module_info = system_get_info('module');
$modules = array();
foreach (module_implements('permission') as $module) {
$modules[$module] = $module_info[$module]['name'];
}
asort($modules);
//three foreach,every module implementing the hook_permission,every permission from module's hook_permission,every role for every permission.
//$data['status'] get every rid's permission. asort by module's name.
foreach ($modules as $module => $display_name) {
if ($permissions = module_invoke($module, 'permission')) {
foreach ($permissions as $perm => $perm_item) {
foreach ($data['role_names'] as $rid => $name) {
// Builds arrays for checked boxes for each role
if (isset($data['role_permissions'][$rid][$perm])) {
$data['status'][$rid][] = $perm;
}
}
}
}
}
return patterns_results();
}