You are here

function tft_get_og_nid in Taxonomy File Tree 7

Same name and namespace in other branches
  1. 7.2 tft.module \tft_get_og_nid()

Check if the current term is part of a OG term and return the OG nid. If no nid is found, return FALSE.

Parameters

int $tid: The tid (and its ancestor tree) to check against

Return value

int|boolean The OG nid if found, else FALSE

10 calls to tft_get_og_nid()
tft_add_content_links in ./tft.module
Render the add file and add folder links.
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_file_form_submit in ./tft.admin.inc
Submission callback
tft_archive_term_form_submit in ./tft.admin.inc
Submission callback
tft_form_alter in ./tft.module
Implementation of hook_form_alter()

... See full list

File

./tft.module, line 1256
Module hooks.

Code

function tft_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];
}