Verified Commit 680039ff authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3204810 by andypost, RoSk0, smustgrave, quietone, cedewey, Amber Himes...

Issue #3204810 by andypost, RoSk0, smustgrave, quietone, cedewey, Amber Himes Matz, larowlan, benjifisher: Add new permission for accessing help pages
parent fe8ce5b0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ protected function setUp(): void {
    $this->adminUser = $this->drupalCreateUser([
      'administer site configuration',
      'access administration pages',
      'access help pages',
      'access site reports',
      'administer users',
    ]);
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ protected function setUp(): void {

    // Create the admin user.
    $this->adminUser = $this->drupalCreateUser([
      'access administration pages',
      'access help pages',
      'view the administration theme',
    ]);
  }
+2 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ protected function setUp(): void {
    // Create users.
    $this->adminUser = $this->drupalCreateUser([
      'access administration pages',
      'access help pages',
      'administer modules',
      'administer blocks',
      'administer forums',
@@ -107,6 +108,7 @@ protected function setUp(): void {
    ]);
    $this->editAnyTopicsUser = $this->drupalCreateUser([
      'access administration pages',
      'access help pages',
      'create forum content',
      'edit any forum content',
      'delete any forum content',
+2 −0
Original line number Diff line number Diff line
access help pages:
  title: 'Use help pages'
+15 −0
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@
 * Post update functions for the Help module.
 */

use Drupal\Core\Config\Entity\ConfigEntityUpdater;
use Drupal\search\Entity\SearchPage;
use Drupal\user\RoleInterface;

/**
 * Install or update config for help topics if the search module installed.
@@ -95,3 +97,16 @@ function help_post_update_help_topics_uninstall() {
    \Drupal::service('module_installer')->uninstall(['help_topics'], FALSE);
  }
}

/**
 * Grant all admin roles the 'access help pages' permission.
 */
function help_post_update_add_permissions_to_roles(?array &$sandbox = []): void {
  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'user_role', function (RoleInterface $role): bool {
    if ($role->isAdmin() || !$role->hasPermission('access administration pages')) {
      return FALSE;
    }
    $role->grantPermission('access help pages');
    return TRUE;
  });
}
Loading