You are here

function og_menu_access in Organic Groups Menu (OG Menu) 6

Same name and namespace in other branches
  1. 6.2 og_menu.module \og_menu_access()
  2. 7.3 og_menu.module \og_menu_access()
  3. 7.2 og_menu.module \og_menu_access()

Access function.

Parameters

node: The group node for which the menu is edited.

menu: The edited menu.

1 string reference to 'og_menu_access'
og_menu_menu in ./og_menu.module
Implementation of hook_menu().

File

./og_menu.module, line 507
Integrates Menu with Organic Groups. Lots of menu forms duplication in OG context.

Code

function og_menu_access($node, $menu = NULL) {
  if (!og_is_group_type($node->type)) {
    return FALSE;
  }
  else {
    if (user_access('administer menu')) {
      return TRUE;
    }
    else {
      if (user_access('administer og menu')) {
        if ($node && og_is_group_member($node)) {
          return TRUE;
        }
        else {
          if ($menu) {
            $gids = array();
            $result = db_query("SELECT gid FROM {og_menu} WHERE menu_name = '%s'", $menu['menu_name']);
            while ($group = db_fetch_object($result)) {
              if ($group->gid && og_is_group_member($group->gid)) {
                return TRUE;
              }
            }
          }
        }
      }
    }
  }
  return FALSE;
}