function tft_og_get_og_nid in Taxonomy File Tree 7.2
Check if the current term is part of a OG term and return the OG nid.
Parameters
int $tid:
Return value
int|boolean The OG nid if found, else FALSE
5 calls to tft_og_get_og_nid()
- tft_og_archive_tft_term_access in modules/
tft_og_archive/ tft_og_archive.module - Implements hook_tft_term_access().
- tft_og_tft_folder_menu_links_alter in modules/
tft_og/ tft_og.module - Implements hook_tft_folder_menu_links_alter().
- tft_og_tft_get_add_content_links_alter in modules/
tft_og/ tft_og.module - Implements hook_tft_get_add_content_links_alter().
- tft_og_tft_term_access in modules/
tft_og/ tft_og.module - Implements hook_tft_term_access().
- tft_taxonomy_access_access in modules/
tft_taxonomy_access/ tft_taxonomy_access.module - Access callback: check if user has access to manage this term access.
File
- modules/
tft_og/ tft_og.module, line 297 - Hook implementations for TFT OG.
Code
function tft_og_get_og_nid($tid) {
static $cache = array();
if (is_array($tid)) {
$tid = $tid[0];
}
$tid = (int) $tid;
if (!$tid) {
return FALSE;
}
if (isset($cache[$tid])) {
return $cache[$tid];
}
$param_tid = $tid;
$depth = tft_get_depth($tid);
$og_nid = db_query("SELECT og_nid FROM {tft_tid_og_nid} WHERE tid = :tid", array(
':tid' => $tid,
))
->fetchField();
while ($depth && $tid && !$og_nid) {
$tid = db_query("SELECT parent FROM {taxonomy_term_hierarchy} WHERE tid = :tid", array(
':tid' => $tid,
))
->fetchField();
$depth--;
$og_nid = db_query("SELECT og_nid FROM {tft_tid_og_nid} WHERE tid = :tid", array(
':tid' => $tid,
))
->fetchField();
}
if ($og_nid) {
$cache[$param_tid] = (int) $og_nid;
}
else {
$cache[$param_tid] = FALSE;
}
return $cache[$param_tid];
}