Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removes access files overview permission #221

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions modules/localgov_roles/localgov_roles.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Install, update and uninstall functions for the localgov_role module.
*/

use Drupal\user\Entity\Role;

/**
* Implements hook_install().
*/
Expand All @@ -13,4 +15,28 @@ function localgov_roles_install() {
foreach ($roles as $role => $permissions) {
user_role_grant_permissions($role, $permissions);
}
_remove_access_files_overview_permission();
}

/**
* Removes the 'access files overview' permission from all roles.
*
* If a particular role needs this permission, it should be added via the
* permissions page.
*/
function _remove_access_files_overview_permission() {
$roles = Role::loadMultiple();
foreach ($roles as $role) {
if ($role->hasPermission('access files overview')) {
$role->revokePermission('access files overview');
$role->save();
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure of this, if there are custom roles that have been assigned this then they will get deleted. Sometimes it is useful if there are files which for what ever reason are not yet in media. I'd limit this to localgov drupal provided roles, and I'd check if they have been altered from default. Noting the update hook also runs this.


/**
* Implements hook_update_N().
*/
function localgov_roles_update_10001() {
_remove_access_files_overview_permission();
}
Loading