You are here

function tft_menu_access in Taxonomy File Tree 7

Custom access callback to check for multiple permissions.

Parameters

string ...: Multiple permissions. Each is passed through user_access() If the last parameter is numeric, it will be treated as a gid.

Return value

boolean TRUE if at least one of the passed permissions is allowed. FALSE otherwise.

1 call to tft_menu_access()
tft_operation_links in ./tft.module
Format the operation links and check user access.
1 string reference to 'tft_menu_access'
tft_menu in ./tft.module
Implementation of hook_menu().

File

./tft.module, line 501
Module hooks.

Code

function tft_menu_access() {
  global $user;
  $args = func_get_args();
  if (count($args) == 1 && is_array($args[0])) {
    $args = $args[0];
  }
  foreach ($args as $permission) {
    if ($permission && user_access((string) $permission)) {
      return TRUE;
    }
  }
  $gid = array_pop($args);
  if (!is_numeric($gid)) {
    $groups = array(
      $gid => $gid,
    );
  }
  else {
    $groups = og_get_groups_by_user($user, 'node');
  }
  foreach ($groups as $gid) {
    foreach ($args as $permission) {
      if ($permission && og_user_access('node', $gid, $permission)) {
        return TRUE;
      }
    }
  }
  return FALSE;
}