You are here

function oa_toolbar_get_jump_links in Open Atrium Toolbar 7.2

Get jump links to create Spaces/Sections of a particular type.

Parameters

string $base: Either the string 'space' or 'section'.

array $url_query: Associative array to use as the URL query string.

Return value

string|NULL Returns a string containing the rendered jump links or NULL if there are less than 2 links.

2 calls to oa_toolbar_get_jump_links()
oa_toolbar_oa_space_structure_render in plugins/content_types/oa_space_structure.inc
Render callback.
template_preprocess_oa_toolbar in ./oa_toolbar.module
Preprocess function for the oa_toolbar block.

File

./oa_toolbar.module, line 233
Provides hook implementations and functionality for oa_toolbar.

Code

function oa_toolbar_get_jump_links($base, $url_query = array()) {
  $vocab_name = $base . '_type';
  $node_type = 'oa-' . $base;

  // Get all the type terms.
  $query = db_select('taxonomy_term_data', 'td');
  $query
    ->join('taxonomy_vocabulary', 'v', 'v.vid = td.vid');
  $query
    ->fields('td', array(
    'tid',
    'name',
  ))
    ->condition('v.machine_name', $vocab_name);
  $terms = $query
    ->execute()
    ->fetchAllKeyed();

  // Allow altering the terms that are shown via jump links.
  drupal_alter('oa_toolbar_jump_links', $terms);
  if (count($terms) > 1) {
    $links = array();
    foreach ($terms as $tid => $name) {
      if (oa_core_get_taxonomy_term_access($tid, NULL, $vocab_name)) {
        $links[] = array(
          'title' => t('Create new @type', array(
            '@type' => $name,
          )),
          'href' => "node/add/{$node_type}/{$tid}",
          'query' => $url_query,
        );
      }
    }
    return theme('links', array(
      'links' => $links,
      'attributes' => array(
        'class' => array(
          'dropdown-menu',
        ),
      ),
    ));
  }
}