You are here

function tft_term_access in Taxonomy File Tree 7.2

Same name and namespace in other branches
  1. 7 tft.module \tft_term_access()

Check if the user has access to the term.

Will first check if the term is part of an OG term tree. If so, it will check if the user has access to the OG. If the term is not part of an OG term tree, it will check against the Tac Lite schemes.

Parameters

int $tid:

stdClass $account = NULL: The user account to check against. If no account is given, the current user will be used.

string $op = 'view':

Return value

boolean

Related topics

19 calls to tft_term_access()
tft in includes/tft.pages.inc
Page callback: file content list.
tft_add_term_form in includes/tft.pages.inc
Form: add a term.
tft_add_term_form_validate in includes/tft.pages.inc
Validation callback: for tft_add_term_form().
tft_ajax_get_folder in includes/tft.ajax.inc
Page callback: get folder content via AJAX.
tft_archive_access in modules/tft_archive/tft_archive.module
Access callback: custom access callback when checking if a user can archive files.

... See full list

2 string references to 'tft_term_access'
tft_archive_menu in modules/tft_archive/tft_archive.module
Implements hook_menu().
tft_menu in ./tft.module
Implementation of hook_menu().

File

./tft.module, line 289
Hook implementations and module logic for TFT.

Code

function tft_term_access($tid, $account = NULL, $op = 'view') {
  if (!$account) {
    global $user;
    $account = $user;
  }
  if ($account->uid == 1 || user_access(TFT_PERM__ADMIN, $account)) {
    return TRUE;
  }
  if (!isset($tid)) {
    if (!empty($_GET['tid'])) {
      $tid = $_GET['tid'];
    }
    elseif (!empty($_GET['parent'])) {
      $tid = $_GET['parent'];
    }
    else {
      $tid = 0;
    }
  }

  // Check if any other module has some saying in this matter.
  foreach (module_implements('tft_term_access') as $module) {
    $result = module_invoke($module, 'tft_term_access', $tid, $account, $op);
    if (isset($result)) {
      watchdog('returning access', '<pre>' . print_r($result, TRUE) . '</pre>');
      return $result;
    }
  }
  if ($op == 'view' && user_access(TFT_PERM__ACCESS_FULL_TREE, $account)) {
    return TRUE;
  }
  elseif (($op == 'edit' || $op == 'add-folder') && user_access(TFT_PERM__ADD_TERMS, $account)) {
    return TRUE;
  }
  elseif ($op == 'delete' && user_access(TFT_PERM__DELETE_TERMS, $account)) {
    return TRUE;
  }
  elseif ($op == 'add-file' && user_access(TFT_PERM__ADD_FILE, $account)) {
    return TRUE;
  }
  elseif ($op == 'add-folder' && user_access(TFT_PERM__ADD_TERMS, $account)) {
    return TRUE;
  }
  elseif ($op == 'reorder' && user_access(TFT_PERM__REORDER_ITEMS, $account)) {
    return TRUE;
  }
  else {
    watchdog('returning false at end', '<pre>' . print_r($account, TRUE) . '</pre>');
    return FALSE;
  }
}