function om_maximenu_link_visible in OM Maximenu 8
Same name and namespace in other branches
- 6 inc/om_maximenu.utils.inc \om_maximenu_link_visible()
- 7 inc/om_maximenu.utils.inc \om_maximenu_link_visible()
Link visibility per user role
7 calls to om_maximenu_link_visible()
- om-maximenu-modal-content.tpl.php in tpl/
om-maximenu-modal-content.tpl.php - om_maximenu_modal_content.tpl.php Default theme implementation of om maximenu contents with modal blocks
- om-maximenu-tabbed-content.tpl.php in tpl/
om-maximenu-tabbed-content.tpl.php - om_maximenu_tabbed_content.tpl.php Default theme implementation of om maximenu contents with tabbed blocks
- template_preprocess_om_maximenu_accordion_links in inc/
om_maximenu.render.inc - Process variables for om_maximenu_accordion_links.tpl.php
- template_preprocess_om_maximenu_modal_links in inc/
om_maximenu.render.inc - Process variables for om_maximenu_modal_links.tpl.php
- template_preprocess_om_maximenu_roundabout_links in inc/
om_maximenu.render.inc - Process variables for om_maximenu_roundabout_links.tpl.php
File
- inc/
om_maximenu.utils.inc, line 260 - OM Maximenu Admin Utilities
Code
function om_maximenu_link_visible($roles = array()) {
global $user;
// user roles
$user_id = $user->uid;
$user_roles = $user->roles;
// user permission to view the link
// roles
// 1 - anonymous
// 2 - authenticated
$permission = array();
$anyone = 0;
foreach ($roles as $role => $value) {
// check roles
if ($value != 0 && isset($user_roles[$role])) {
$permission[$role] = $user_roles[$role];
}
// for all roles are unchecked
if ($value != 0) {
$anyone++;
}
}
// the link will be visible if the user has permission
if (!empty($permission)) {
return $permission;
}
elseif ($anyone == 0) {
// the links is for everybody
return 1;
}
else {
return 0;
}
}