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

Issue #5484 - Adding default permissions for editors to manage files #4717

Open
wants to merge 4 commits into
base: 1.x
Choose a base branch
from

Conversation

stpaultim
Copy link
Member

@backdrop-ci
Copy link
Collaborator

Related to: backdrop/backdrop-issues#5484

@@ -550,6 +556,7 @@ function standard_install() {
'view files',
$filtered_html_permission,
);
$editor_permissions = array_merge($editor_permissions, $file_type_permissions);
Copy link
Contributor

Choose a reason for hiding this comment

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

This approach (creating a new array and then merging) is slightly inefficient. I suggest the following (pasting the whole chunk for clarity):

// Create a default editor role, for users who need to be able to edit
  // content, but do not need to access advanced admin features.
  $editor_role = new stdClass();
  $editor_role->name = 'editor';
  $editor_role->label = 'Editor';
  $editor_role->description = 'Can edit most content on the site, but cannot modify site configuration settings.';
  $editor_role->weight = 2;
  user_role_save($editor_role);

  $editor_permissions = array(
    'view own unpublished content',
    'view any unpublished content',
    'view revisions',
    'revert revisions',
    'delete revisions',
    'create page content',
    'edit own page content',
    'edit any page content',
    'delete own page content',
    'create post content',
    'edit own post content',
    'edit any post content',
    'delete own post content',
    'create card content',
    'edit own card content',
    'edit any card content',
    'delete own card content',
    'view hidden paths',
    'access dashboard',
    'view the administration theme',
    'access administration bar',
    'access content overview',
    'access administration pages',
    'access site in maintenance mode',
    'flush caches',
    'edit terms in tags',
    'delete terms in tags',
    'administer taxonomy',
    'administer nodes',
    'search content',
    'use advanced search',
    $filtered_html_permission,
  );

  $file_types = file_permissions_get_configured_types();
  foreach ($file_types as $file_type) {
    $editor_permissions[] = "edit own $file_type files";
    $editor_permissions[] = "download own $file_type files";
  }
  user_role_grant_permissions('editor', $editor_permissions);

Copy link
Contributor

Choose a reason for hiding this comment

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

Basically I've moved the loop AFTER the rest of the permissions have been added to the array.

Copy link
Member Author

Choose a reason for hiding this comment

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

This makes sense. Testing now.

@stpaultim stpaultim closed this Apr 29, 2024
@stpaultim stpaultim reopened this Apr 29, 2024
@dragonbot
Copy link
Collaborator

Tugboat has finished building a preview for this pull request!

Website: https://pr4717-ggtnac92nqpsqpacqdw6x6djcovfjevr.tugboatqa.com/
Username: admin
Password: fd33aa59aec8

This preview will automatically expire on the 29th of June, 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants