function tft_term_access in Taxonomy File Tree 7
Same name and namespace in other branches
- 7.2 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: The term tid
stdClass $account = NULL: The user account to check against. If no account is given, the current user will be used.
Return value
boolean TRUE if the user has access to this term. FALSE otherwise.
14 calls to tft_term_access()
- tft in ./
tft.pages.inc - Menu callback function the file explorer
- tft_add_term_form in ./
tft.admin.inc - Add a term form.
- tft_add_term_form_validate in ./
tft.admin.inc - Validation callback.
- tft_ajax_get_folder in ./
tft.ajax.inc - Menu function callback for getting the forlder content via AJAX. Returns a JSON object with a 'data' key for the HTML table and a 'parent' key for the parent taxonomy term tid. A 'ops_links' key stores the folder menu.
- tft_archive_term_form in ./
tft.admin.inc - Archive a term form
File
- ./
tft.module, line 548 - Module hooks.
Code
function tft_term_access($tid, $account = NULL) {
if (!$tid && $tid != 0) {
return FALSE;
}
if (!$account) {
global $user;
$account = $user;
}
if ($account->uid == 1 || user_access(TFT_ACCESS_FULL_TREE, $account) || user_access(TFT_ADMIN, $account) || user_access('administer taxonomy', $account)) {
return TRUE;
}
// Is this part of an OG term tree ?
if ($og_nid = tft_get_og_nid($tid)) {
// Check against OG
return node_access('view', node_load($og_nid), $account);
}
else {
// Check against Tac Lite
for ($i = 1, $schemes = variable_get('tac_lite_schemes', 1); $i <= $schemes; $i++) {
$array_scheme = variable_get("tac_lite_grants_scheme_{$i}", array());
foreach ($array_scheme as $rid => $vids) {
if ($array_scheme[$rid][variable_get('tft_vocabulary_vid', 0)][$tid]) {
return TRUE;
}
}
}
}
return FALSE;
}