1 views_handler_field_user_permissions.inc | views_handler_field_user_permissions::pre_render(&$values) |
Run before any fields are rendered.
This gives the handlers some time to set up before any handler has been rendered.
Parameters
$values: An array of all objects returned from the query.
Overrides views_handler_field::pre_render
File
- core/
modules/ user/ views/ views_handler_field_user_permissions.inc, line 23 - Definition of views_handler_field_user_permissions.
Class
- views_handler_field_user_permissions
- Field handler to provide a list of permissions.
Code
function pre_render(&$values) {
$uids = array();
$this->items = array();
// Assemble authenticated permissions which are available for all accounts.
$permissions = module_invoke_all('permission');
$all_roles = user_roles(FALSE, NULL, TRUE);
$authenticated_permissions = array();
foreach ($all_roles[BACKDROP_AUTHENTICATED_ROLE]->permissions as $permission) {
$authenticated_permissions[$permission]['permissions'] = $permissions[$permission]['title'];
}
foreach ($values as $result) {
$uid = $this->get_value($result, NULL, TRUE);
$this->items[$uid] = $authenticated_permissions;
$uids[] = $uid;
}
if ($uids) {
$result = db_query("SELECT u.uid, u.role FROM {users_roles} u WHERE u.uid IN (:uids)", array(':uids' => $uids));
foreach ($result as $user) {
foreach ($all_roles as $user_role) {
foreach ($user_role->permissions as $permission) {
if (isset($permissions[$permission])) {
$this->items[$user->uid][$permission]['permissions'] = $permissions[$permission]['title'];
}
}
}
}
}
}