View source
<?php
function tft($tid = 'all', $gid = NULL) {
tft_check_vocabulary_setting();
if ($tid == 'all' || !(int) $tid) {
if (user_access(TFT_ACCESS_FULL_TREE)) {
$tid = 0;
}
else {
drupal_access_denied();
return;
}
}
if (!tft_term_access($tid)) {
drupal_access_denied();
return;
}
if ($tid) {
$name = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid = :tid", array(
':tid' => $tid,
))
->fetchField();
}
else {
$name = t("Root");
}
$_SESSION['tft']['q'] = $_GET['q'];
$_SESSION['tft']['root_tid'] = $tid;
$path = drupal_get_path('module', 'tft');
drupal_add_js(array(
'tftDirectory' => drupal_get_path('module', 'tft'),
'cleanUrl' => variable_get('clean_url', 0),
), 'setting');
drupal_add_js($path . '/js/jquery.tablesorter.min.js');
drupal_add_js($path . '/js/tft.js');
drupal_add_css($path . '/css/tft.css');
$html = '';
$html .= theme('tft_folder_menu', array(
'name' => $name,
'path' => $path,
'ops_links' => tft_get_folder_operation_links($tid),
));
$html .= '<div id="folder-content-container">' . tft_content_table($tid, $gid) . '</div>';
return $html;
}
function tft_og($nid) {
tft_check_vocabulary_setting();
if (!node_access('view', node_load($nid))) {
drupal_access_denied();
return;
}
$tid = db_query("SELECT tid FROM {tft_tid_og_nid} WHERE og_nid = :nid", array(
':nid' => $nid,
))
->fetchField();
$breadcrumb = drupal_get_breadcrumb();
$title = db_query("SELECT {node_revision}.title FROM {node_revision}\n LEFT JOIN {node} ON {node}.vid = {node_revision}.vid\n WHERE {node}.nid = :nid", array(
':nid' => $nid,
))
->fetchField();
$breadcrumb[] = l($title, "node/{$nid}");
drupal_set_breadcrumb($breadcrumb);
if (!$tid) {
return t("No term was found for this group ! Please contact your system administrator.");
}
else {
return tft($tid, $nid);
}
}