You are here

function tft_get_add_content_links in Taxonomy File Tree 7.2

Render the add file and add folder links.

Parameters

int $tid = 0: The term tid of the current folder, or 0 for root

Return value

array

Related topics

2 calls to tft_get_add_content_links()
tft in includes/tft.pages.inc
Page callback: file content list.
tft_ajax_get_folder in includes/tft.ajax.inc
Page callback: get folder content via AJAX.

File

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

Code

function tft_get_add_content_links($tid = 0) {
  $links = array();
  $add_file_query = array(
    'destination' => $_SESSION['tft']['q'] . "#tft/{$tid}",
  );
  $add_term_query = array(
    'destination' => $_SESSION['tft']['q'] . "#tft/{$tid}",
  );
  $setting = tft_get_file_setting();

  // Do we have a tid ?
  if ($tid) {
    $add_file_query['tid'] = $tid;
    $add_term_query['parent'] = $tid;
  }

  // Can the user create files ?
  if (user_access('create ' . $setting['type'] . ' content') && tft_term_access($tid, NULL, 'add-file')) {
    $links['add_file'] = array(
      'title' => t("Add a file"),
      'href' => 'node/add/' . str_replace('_', '-', $setting['type']),
      'attributes' => array(
        'id' => 'add-child-file',
      ),
      'query' => array_reverse($add_file_query),
    );
  }
  if (tft_term_access($tid, NULL, 'add-folder')) {
    $links['add_term'] = array(
      'title' => t("Add a folder"),
      'href' => 'tft/term/add',
      'attributes' => array(
        'id' => 'add-child-folder',
      ),
      'query' => array_reverse($add_term_query),
    );
  }
  drupal_alter('tft_get_add_content_links', $links, $tid);
  return $links;
}