You are here

function nodequeue_get_qids in Nodequeue 6.2

Same name and namespace in other branches
  1. 5.2 nodequeue.module \nodequeue_get_qids()
  2. 7.2 nodequeue.module \nodequeue_get_qids()

Get an array of qids applicable to this node type.

Parameters

$type: The node type.

$account: The account to test against. Defaults to the currently logged in user.

$bypass_cache: Boolean value indicating whether to bypass the cache or not.

Return value

$qids An array in the format: @code { array($qid => array('qid' => $qid, 'show_in_tab' ' => true/false, 'show_in_links' => true/false }

2 calls to nodequeue_get_qids()
nodequeue_load_queues_by_type in ./nodequeue.module
Fetch a list of available queues for a given location. These queues will be fully loaded and ready to go.
nodequeue_node_access in ./nodequeue.module
Return TRUE if $user can queue(s) for this node.

File

./nodequeue.module, line 586
Maintains queues of nodes in arbitrary order.

Code

function nodequeue_get_qids($type, $account = NULL, $bypass_cache = FALSE) {
  if (!isset($account)) {
    global $user;
    $account = $user;
  }
  static $cache = array();
  if ($bypass_cache || !isset($cache[$type])) {
    $roles_join = $roles_where = '';
    $roles = array();

    // superuser always has access.
    if (!user_access('manipulate all queues', $account)) {
      $roles_join = "INNER JOIN {nodequeue_roles} nr ON nr.qid = nq.qid ";
      $roles = array_keys((array) $account->roles) + array(
        DRUPAL_AUTHENTICATED_RID,
      );
      $roles_where .= "AND nr.rid IN (" . db_placeholders($roles, 'int') . ")";
    }
    $sql = 'SELECT nq.qid, nq.show_in_tab, nq.show_in_links, nq.show_in_ui, nq.i18n ' . 'FROM {nodequeue_queue} nq ' . 'INNER JOIN {nodequeue_types} nt ON nt.qid = nq.qid ' . $roles_join . "WHERE nt.type = '%s' " . $roles_where;
    $result = db_query($sql, array_merge(array(
      $type,
    ), $roles));
    $qids = array();
    while ($qid = db_fetch_object($result)) {
      $qids[$qid->qid] = $qid;
    }
    $cache[$type] = $qids;
  }
  return $cache[$type];
}