You are here

function _vppr_access_term in Vocabulary Permissions Per Role 6

VPPR's access callback for term ID's (edit and delete terms).

1 string reference to '_vppr_access_term'
vppr_menu_alter in ./vppr.module
Implementation of hook_menu_alter().

File

./vppr.module, line 69
Vocabulary Permissions Per Role

Code

function _vppr_access_term($tid) {
  if (user_access('administer taxonomy')) {
    return TRUE;
  }
  $term = taxonomy_get_term($tid);

  // Speed up things if there is no such term.
  if (!$term) {
    return FALSE;
  }
  global $user;
  $perms = variable_get('vppr_perms', array(
    array(),
  ));
  foreach ($user->roles as $rid => $role) {
    if (isset($perms[$term->vid]) && isset($perms[$term->vid][$rid]) && $perms[$term->vid][$rid]) {
      return TRUE;
    }
  }
  return FALSE;
}