/** * Setup menus */ function menu_setup() { if (elgg_is_admin_logged_in()) { elgg_register_menu_item('page', array('name' => 'summary', 'href' => 'admin/roles/summary', 'text' => elgg_echo('admin:roles:summary'), 'context' => 'admin', 'section' => 'roles')); elgg_register_menu_item('page', array('name' => 'create', 'href' => 'admin/roles/create', 'text' => elgg_echo('admin:roles:create'), 'context' => 'admin', 'section' => 'roles')); elgg_register_menu_item('page', array('name' => 'permissions', 'href' => '#', 'text' => elgg_echo('admin:roles:permissions'), 'context' => 'admin', 'section' => 'roles')); $selectable_roles = roles_get_all_selectable_roles(); foreach ($selectable_roles as $role) { elgg_register_menu_item('page', array('name' => "roles:users:{$role->name}", 'href' => "admin/roles/users?role={$role->name}", 'text' => elgg_echo('admin:roles:users:role', array(elgg_echo($role->title))), 'context' => 'admin', 'parent_name' => 'users', 'section' => 'administer')); } $roles = roles_get_all_roles(); foreach ($roles as $role) { elgg_register_menu_item('page', array('name' => "roles:permissions:{$role->name}", 'href' => "admin/roles/permissions?role={$role->name}", 'text' => elgg_echo($role->title), 'context' => 'admin', 'parent_name' => 'permissions', 'section' => 'roles')); } } return; }
<?php if (!elgg_is_active_plugin('roles')) { return; } $context = elgg_extract('filter_context', $vars, 'default'); $roles = roles_get_all_roles(); foreach ($roles as $role) { if ($role->name == 'visitor') { continue; } elgg_register_menu_item('filter', ['name' => $role->name, 'text' => $role->getDisplayName(), 'href' => elgg_http_add_url_query_elements(current_page_url(), ['role' => $role->name]), 'selected' => $role->name == $context]); } echo elgg_view_menu('filter', ['sort_by' => 'priority', 'class' => 'elgg-tabs']);