From e3fb51d5bb74e5f6ec0dd6cb88f9722279e453d5 Mon Sep 17 00:00:00 2001 From: rutiolma Date: Thu, 2 Mar 2017 10:05:08 +1300 Subject: [PATCH] Issue #2856979 by rmarques, stefan.r, Jeff Burnz: Add a permission for configuring toolbar themes --- toolbar_themes.install | 22 ++++++++++++++++++++++ toolbar_themes.permissions.yml | 2 ++ toolbar_themes.routing.yml | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 toolbar_themes.permissions.yml diff --git a/toolbar_themes.install b/toolbar_themes.install index 3d54488..7025697 100644 --- a/toolbar_themes.install +++ b/toolbar_themes.install @@ -10,3 +10,25 @@ function toolbar_themes_modules_installed($modules) { drupal_flush_all_caches(); } } + +/** + * Implements hook_install(). + */ +function toolbar_themes_install() { + if ($roles = user_roles(FALSE, 'access toolbar')) { + foreach ($roles as $rid => $role) { + user_role_grant_permissions($rid, ['configure toolbar_themes']); + } + } +} + +/** + * Assign "Configure administration toolbar themes" permission to all roles. + */ +function toolbar_themes_update_8001() { + if ($roles = user_roles(FALSE, 'access toolbar')) { + foreach ($roles as $rid => $role) { + user_role_grant_permissions($rid, ['configure toolbar_themes']); + } + } +} diff --git a/toolbar_themes.permissions.yml b/toolbar_themes.permissions.yml new file mode 100644 index 0000000..c770a01 --- /dev/null +++ b/toolbar_themes.permissions.yml @@ -0,0 +1,2 @@ +configure toolbar_themes: + title: 'Configure toolbar themes' diff --git a/toolbar_themes.routing.yml b/toolbar_themes.routing.yml index da7b1bc..2b836a0 100644 --- a/toolbar_themes.routing.yml +++ b/toolbar_themes.routing.yml @@ -4,4 +4,4 @@ toolbar_themes.settings: _form: '\Drupal\toolbar_themes\Form\ToolbarThemesSettingsForm' _title: 'Toolbar Themes' requirements: - _permission: 'access toolbar' + _permission: 'configure toolbar_themes' -- 2.9.3