Problem/Motivation
Currently there is one permission that handles all access. It would be helpful if we could at least have two permissions. One for global settings and one for editing individual settings for entities.
We should also discuss how fine grained the permissions should be. F.E. we can have permissions generated with a permission callback for every entity enabled?
Proposed resolution
For now split up the global permission on two permissions. One for global settings and one for editing individual entity sitemap's settings.
Remaining tasks
Discuss if the provided patch is satisfactory or if we should create a fine grained permission solution.
Add new tests and/or change current tests depending on the decision.
User interface changes
New permissions will appear in the permissions overview.
API changes
None.
Data model changes
None.
Release notes snippet
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | 3033792-28.patch | 2.88 KB | johan_vm |
| #21 | simple_sitemap-split_up_permission-3033792-20-2.patch | 2.47 KB | Andreas Hansson |
| #11 | simple_sitemap-split_up_permission-3033792-11-D8.patch | 1.29 KB | ndf |
| #11 | interdiff-02-11.txt | 1.7 KB | ndf |
| #2 | simple_xml_sitemap_permissions.png | 42.21 KB | stefdewa |
Issue fork simple_sitemap-3033792
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3033792-provide-more-granular
changes, plain diff MR !38
Comments
Comment #2
stefdewa commentedProvided patch splits up the global permission in two permissions. One for global settings and one for editing individual entities their sitemap settings. I'll set this to needs review but feel free to set this to needs work and discuss if this solution is acceptable.
Comment #3
kbeck303 commentedI have tested the patch in comment #2 running Drupal 8.7.6
Comment #4
svdhout commentedI can confirm that the patch works on Drupal 8.8 wit simple_sitemap 8.3.5
Comment #5
manuel.adanThat's a basic support that works but it would be great to set permission per enabled entity type and bundle.
Comment #6
ndf commentedThis machinename feels a bit off for me. Because when committed its difficult to change, I would prefer to improve this in the issue here.
In other content-management/edit permissions words like "any", "content"/"nodes" and "override" are used.
@seanB came up with
administer entity sitemap settingsIs this correct? Does this work with either one of the permissions, or does a user needs both permissions. (i will doublecheck manually).
@5 That would be great, but I am fine with doing more granular permission in a follow-up.
Then this issue could only be
Comment #7
ndf commentedChanged the new permission name to
edit entity sitemap settingsAnd fixed a logic error where one could not access the edit-form without the new permission.
Permissions behavior in new patch:
- When on entity-edit form; one must have either 'Administer sitemap settings' or 'Edit entity sitemap settings'
- Otherwise one must have 'Administer sitemap settings'
Comment #9
ndf commentedIt's 30 degrees here in Amsterdam and the if-then-conditionals made my mind spin
Comment #10
ndf commentedComment #11
ndf commentedComment #12
seanbThis is kind of hard to read. Maybe we should put things in variables?
Comment #13
ndf commentedComment #15
ndf commentedComment #16
mrshowermanI can apply the patch from the MR on 4.1.1 nicely and it seems to do what is desired. But in 4.1.2, the patch no longer applies.
Comment #17
immaculatexavier commentedComment #18
immaculatexavier commentedComment #19
mrshowermanShould work with 4.1.2 now.
Comment #20
Andreas Hansson commenteddeleted
Comment #21
Andreas Hansson commentedMade a patch for the same issue before we found out that this issue already existed.
Patch #20-2 is not built on #11, and also it will not enable the option to regenerate the sitemap when saving a node if you are not administrator.
Patch #20-2 is from current -dev branch, seems #11 wont apply anymore.
Comment #24
joshahubbers commentedPatch-file of #19, because .diff can change if more changes are pushed to the mr.
Comment #25
joshahubbers commentedComment #26
caspervoogt commentedThanks everyone for the work on this important change to this module. I tested the patch from #24 and it worked for me, on PHP 8.1 / Drupal 9.5.8 / simple_sitemap 4.1.4. Looks good to me. This was marked 'needs work' but it doesn't look like it needs work. I changed it to 'Needs review' but if I am wrong please feel free to set it back to 'needs work'. RTBC in my book.
Comment #27
joncjordan commentedNote that the patch will cause fatal errors with the simple_sitemap_engines module, since Drupal\simple_sitemap_engines\Form\FormHelper extends Drupal\simple_sitemap\Form\FormHelper.
Fatal error: Declaration of Drupal\simple_sitemap_engines\Form\FormHelper::formAlterAccess(): bool must be compatible with Drupal\simple_sitemap\Form\FormHelper::formAlterAccess(Drupal\Core\Entity\EntityFormInterface $form_object): bool in /app/web/modules/contrib/simple_sitemap/modules/simple_sitemap_engines/src/Form/FormHelper.php on line 63
Comment #28
johan_vm commentedI couldn't apply the MR 38 patch to I checked out the branch locally and merged 4.2.1 and made a diff.
This patch should work for 4.2.1
Comment #29
stefdewa commentedReviewed MR38, tested manually and it works!
Comment #35
walkingdexter commentedSimplified and committed, thanks! Thoughts from #21 are respected. Credits saved for the guys from #3441488: New permission to only edit entity sitemap settings .