diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php index 3c56353..ba8ba2c 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php @@ -23,16 +23,17 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A switch ($operation) { case 'create': case 'update': - if (user_access('administer shortcuts', $account)) { + if ($account->hasPermission('administer shortcuts')) { return TRUE; } - if (user_access('customize shortcut links', $account)) { + if ($account->hasPermission('customize shortcut links')) { return !isset($entity) || $entity == shortcut_current_displayed_set($account); } return FALSE; break; + case 'delete': - if (!user_access('administer shortcuts', $account)) { + if (!$account->hasPermission('administer shortcuts')) { return FALSE; } return $entity->id() != 'default'; diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index b406787..8c7ebbc 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -27,7 +27,7 @@ * @see shortcut_set_switch_submit() */ function shortcut_set_switch($form, &$form_state, $account = NULL) { - global $user; + $user = Drupal::request()->attributes->get('_account'); if (!isset($account)) { $account = $user; } @@ -42,7 +42,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) { } // Only administrators can add shortcut sets. - $add_access = user_access('administer shortcuts'); + $add_access = $user->hasPermission('administer shortcuts'); if ($add_access) { $options['new'] = t('New set'); } diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 57ff7d7..cc0e5a2 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -11,7 +11,7 @@ * Implements hook_help(). */ function shortcut_help($path, $arg) { - global $user; + $user = Drupal::request()->attributes->get('_account'); switch ($path) { case 'admin/help#shortcut': @@ -31,7 +31,7 @@ function shortcut_help($path, $arg) { case 'admin/config/user-interface/shortcut': case 'admin/config/user-interface/shortcut/%': - if (user_access('switch shortcut sets')) { + if ($user->hasPermission('switch shortcut sets')) { $output = '

' . t('Define which shortcut set you are using on the Shortcuts tab of your account page.', array('@shortcut-link' => url("user/{$user->id()}/shortcuts"))) . '

'; return $output; } @@ -170,12 +170,13 @@ function shortcut_admin_paths() { * otherwise. */ function shortcut_set_edit_access($shortcut_set = NULL) { + $account = Drupal::request()->attributes->get('_account'); // Sufficiently-privileged users can edit their currently displayed shortcut // set, but not other sets. Shortcut administrators can edit any set. - if (user_access('administer shortcuts')) { + if ($account->hasPermission('administer shortcuts')) { return TRUE; } - if (user_access('customize shortcut links')) { + if ($account->hasPermission('customize shortcut links')) { return !isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set(); } return FALSE; @@ -194,14 +195,14 @@ function shortcut_set_edit_access($shortcut_set = NULL) { * provided account, FALSE otherwise. */ function shortcut_set_switch_access($account = NULL) { - global $user; + $user = Drupal::request()->attributes->get('_account');; - if (user_access('administer shortcuts')) { + if ($user->hasPermission('administer shortcuts')) { // Administrators can switch anyone's shortcut set. return TRUE; } - if (!user_access('switch shortcut sets')) { + if (!$user->hasPermission('switch shortcut sets')) { // The user has no permission to switch anyone's shortcut set. return FALSE; }