function shortcut_current_displayed_set

Same name in other branches
  1. 9 core/modules/shortcut/shortcut.module \shortcut_current_displayed_set()
  2. 8.9.x core/modules/shortcut/shortcut.module \shortcut_current_displayed_set()
  3. 10 core/modules/shortcut/shortcut.module \shortcut_current_displayed_set()

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()
ShortcutSetsTestCase::testShortcutSetAssign in modules/shortcut/shortcut.test
Tests switching another user's shortcut set.
ShortcutSetsTestCase::testShortcutSetSwitchCreate in modules/shortcut/shortcut.test
Tests switching a user's shortcut set and creating one at the same time.
ShortcutSetsTestCase::testShortcutSetSwitchNoSetName in modules/shortcut/shortcut.test
Tests switching a user's shortcut set without providing a new set name.
ShortcutSetsTestCase::testShortcutSetSwitchOwn in modules/shortcut/shortcut.test
Tests switching a user's own shortcut set.
ShortcutSetsTestCase::testShortcutSetUnassign in modules/shortcut/shortcut.test
Tests unassigning a shortcut set.

... See full list

1 string reference to 'shortcut_current_displayed_set'
shortcut_set_assign_user in modules/shortcut/shortcut.module
Assigns a user to a particular shortcut set.

File

modules/shortcut/shortcut.module, line 481

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);
    }
    else {
        $shortcut_set = shortcut_default_set($account);
    }
    $shortcut_sets[$account->uid] = $shortcut_set;
    return $shortcut_set;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.