shortcut_current_displayed_set

function shortcut_current_displayed_set

shortcut_current_displayed_set($account = NULL)

Returns the current displayed shortcut set for the provided user account.

Parameters

$account: (optional) The user account whose shortcuts will be returned. Defaults to the currently logged-in user.

Return value

An object representing the shortcut set that should be displayed to the current user. If the user does not have an explicit shortcut set defined, the default set is returned.

File

modules/shortcut/shortcut.module, line 481
Allows users to manage customizable lists of shortcut links.

Code

function shortcut_current_displayed_set($account = NULL) {
  $shortcut_sets = &drupal_static(__FUNCTION__, array());
  global $user;
  if (!isset($account)) {
    $account = $user;
  }
  // Try to return a shortcut set from the static cache.
  if (isset($shortcut_sets[$account->uid])) {
    return $shortcut_sets[$account->uid];
  }
  // If none was found, try to find a shortcut set that is explicitly assigned
  // to this user.
  $query = db_select('shortcut_set', 's');
  $query->addField('s', 'set_name');
  $query->join('shortcut_set_users', 'u', 's.set_name = u.set_name');
  $query->condition('u.uid', $account->uid);
  $shortcut_set_name = $query->execute()->fetchField();
  if ($shortcut_set_name) {
    $shortcut_set = shortcut_set_load($shortcut_set_name);
  }
  // Otherwise, use the default set.
  else {
    $shortcut_set = shortcut_default_set($account);
  }

  $shortcut_sets[$account->uid] = $shortcut_set;
  return $shortcut_set;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!shortcut!shortcut.module/function/shortcut_current_displayed_set/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部