| 7 shortcut.module | shortcut_current_displayed_set($account = NULL) |
| 8 shortcut.module | 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.
11 calls to shortcut_current_displayed_set()
1 string reference to 'shortcut_current_displayed_set'
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;
}
Login or register to post comments