Skip to content
Snippets Groups Projects
Commit a6738db9 authored by mxh's avatar mxh
Browse files

Issue #3328816 by robertom: Add "access storage overview" permission

parent 50af7bc6
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ display:
access:
type: perm
options:
perm: 'administer storage entities'
perm: 'access storage overview'
cache:
type: tag
options: { }
......
......@@ -6,6 +6,9 @@ administer storage entities:
description: 'Create, edit and delete all storage entities.'
restrict access: true
access storage overview:
title: 'Access the overview page of Storage entities'
delete storage entities:
title: 'Delete any Storage entity'
restrict access: true
......
<?php
use Drupal\user\Entity\Role;
use Drupal\views\Entity\View;
use Drupal\views\ViewEntityInterface;
/**
* Migrate "administer storage entities" to "access storage overview".
*/
function storage_post_update_access_overview_permission(&$sandbox = NULL) {
foreach (Role::loadMultiple() as $role) {
if ($role->hasPermission('administer storage entities')) {
$role->grantPermission('access storage overview');
$role->save();
}
}
}
/**
* Update permission required for `storage` view if it exists.
*/
function storage_post_update_admin_view_permission(&$sandbox = NULL) {
$view = View::load('storage');
if (!$view instanceof ViewEntityInterface) {
return;
}
$display =& $view->getDisplay('default');
if (($display['display_options']['access']['type'] ?? NULL) !== 'perm'
|| ($display['display_options']['access']['options']['perm'] ?? NULL) !== 'administer storage entities') {
return;
}
$display['display_options']['access'] = [
'type' => 'perm',
'options' => ['perm' => 'access storage overview'],
];
$view->save();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment