function _menu_per_role_get_roles in Menu Per Role 6
Same name and namespace in other branches
- 7 menu_per_role.module \_menu_per_role_get_roles()
Gets all roles with access to the specified menu item No roles mean that access is granted by this module.
$show set to 0 for show to roles, 1 for hide from roles
2 calls to _menu_per_role_get_roles()
File
- ./
menu_per_role.module, line 168 - Allows restricting access to menu items per role
Code
function _menu_per_role_get_roles($mlid, $show) {
static $menu_per_role;
if (!isset($menu_per_role)) {
// read all the data ONCE, it is likely very small
$menu_per_role = array();
$result = db_query("SELECT * FROM {menu_per_role}");
while ($row = db_fetch_object($result)) {
if ($row->rids || $row->hrids) {
if ($row->rids) {
$menu_per_role[$row->mlid][0] = explode(',', $row->rids);
}
else {
$menu_per_role[$row->mlid][0] = array();
}
if ($row->hrids) {
$menu_per_role[$row->mlid][1] = explode(',', $row->hrids);
}
else {
$menu_per_role[$row->mlid][1] = array();
}
}
}
}
if (isset($menu_per_role[$mlid])) {
return $menu_per_role[$mlid][$show];
}
// not defined, everyone has the right to use it
return array();
}