You are here

function tft_add_content_links in Taxonomy File Tree 7

Render the add file and add folder links.

Parameters

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

1 call to tft_add_content_links()
tft_content_table in ./tft.module
Get the folder content in HTML table form

File

./tft.module, line 1012
Module hooks.

Code

function tft_add_content_links($tid = 0, $gid = NULL) {
  $html = '<ul id="folder-add-content-links">';
  $add_file_query = array(
    'destination' => $_SESSION['tft']['q'],
  );
  $add_term_query = array(
    'destination' => $_SESSION['tft']['q'],
  );
  $setting = tft_get_file_setting();

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

    // Is this an OG term, or the child of an OG term ?
    $og_nid = tft_get_og_nid($tid);
  }

  // Can the user create files ?
  if (og_user_access('node', $gid, 'create ' . $setting['type'] . ' content')) {
    if (!empty($og_nid)) {
      $add_file_query['og_group_ref'] = $og_nid;
    }

    // Can they add files in this context ?
    if (og_user_access('node', $gid, TFT_ADD_FILE)) {
      $html .= '<li class="folder-add-content-link">' . l(t("Add a file"), 'node/add/' . str_replace('_', '-', $setting['type']), array(
        'attributes' => array(
          'id' => 'add-child-file',
        ),
        'query' => array_reverse($add_file_query),
      )) . '</li>';
    }
  }

  // Can the user add terms anywhere, only under OG terms or never ?
  if (og_user_access('node', $gid, TFT_ADD_TERMS)) {
    $html .= '<li class="folder-add-content-link">' . l(t("Add a folder"), 'tft/term/add', array(
      'attributes' => array(
        'id' => 'add-child-folder',
      ),
      'query' => array_reverse($add_term_query),
    )) . '</li>';
  }
  return $html . '</ul>';
}