Thank You for lightweight and useful module Better Formats!
I use it in own project and found this issue:
After module enable user with administrator role can't use "Text format" select in any site form.
This issue appears because:
- User with administrator role have checked all permissions checkboxes (on /admin/people/permissions page)
- Because administrator should have all permissions
- Permissions checkboxes can't be un-checked for administrator role
- Better Formats module have 3 type of permissions:
- Hide format tips
- Hide more format tips link
- Hide format selection for @entitys
- 3 listed above permissions is checked (by default and can't be unchecked) for any user with administrator role
- Means site administrators:
- Can't see format tips
- Can't see more format tips link
- Can't choose Text format
From my point of view ability:
- Hide format tips,
- Hide more format tips link,
- Hide format selection for @entitys
Should be field instance based. Means: Should be ability setup this settings on any "formatted text field setup form" because this way is more flexible and provide ability use this great module in more use cases.
Attached patch add ability setup: "Hide format tips", "Hide more format tips link", "Hide format selection" for any formatted text field and fix "Text format" selection for users with administrator role.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2791203-better_formats-hide_format_per_field_1.patch | 4.79 KB | Antonnavi |
|
Comments
Comment #2
AntonnaviComment #3
andypostAnton, interesting idea to replace permissions with settings!
There's still need to have permissions - to disallow some roles change text format for some fields!!!
So no way to remove permissions totally, but it makes sense to have this settings per field or field storage.
In d8 text format, field, field storage are entities so looks better to use https://api.drupal.org/api/drupal/8.2.x/search/ThirdPartySettingsInterface
So please xplore proper place to store settings: suppose filter defines defaults, field storage => field
This is what I will missing, one of use cases is when I wanna prevent some users to change text format
Comment #4
Alienpruts CreditAttribution: Alienpruts commentedJust my two cents :
In the meantime, would it not be better to reverse the permissions in code and put the opposite effect in place?
I mean :
NOW : permission "Hide format selection for nodes", which cannot be disabled for administrators.
PROPOSAL : change permission text to "Show format selection for nodes" and reverse the outcome of the code that checks for the permission.
OUTCOME : that way, by default, only administrators will be able to see and use the format selection box , whilst all other roles will need to have that permission enabled for those roles to be able to use those selection box.
Worth a look into? :)
EDIT : this seems to have been the way some time ago and was reversed, with the known results... See https://www.drupal.org/node/2771301#comment-11630783
Comment #5
AntonnaviThank You for review andypost and Alienpruts!
Patch was updated, currently:
Comment #6
Alienpruts CreditAttribution: Alienpruts commentedHello Antonnavi,
first off, thank you for your hard work on this patch. It goes without saying that any solution at this point is welcome.
However, if I may utter some remarks : I would like to say that this solution using a setting per field is not very scalable : in essence this means that for a site using quite a lot of fields this might turn into a maintenance nightmare.
You already did the right thing and set the 'Override for admin users' as default value, which is a good thing. But whenever one option on one field is changed you kind of have to 'remember' on which field it has been changed.
Now, this is manageable on a site with 2 Content Types, setting those options on one field each. It is quite another challenge when your site has 38 CT's, each sprouting 4 fields which use Better Formats. Imagine having to remember on which CT's (and subsequently on which fields of those CT's) you changed those settings.
The whole purpose of a globalized permission system is just that : it is globalized and by definition easily manageable across your whole site.
Now don't get me wrong : your solution works, and at the moment it is the only solution we have. It needs a few tweaks (comments and a few small code changes), but as it stands, it is a great patch and it should be installed by those who seek a solution to this problem.
However : I still stand by my remark that the permissions of Better Formats need to be switched back to the right order meaning that you need to set permission on a role to DO something (in this case : show format selection options), not set a permission to HIDE something. In that regard I stand by this comment by @alexpott on a similar issue : (https://www.drupal.org/node/2771301#comment-11453649).
We can only hope our pleas reach the maintainer :)
Comment #7
nevergone CreditAttribution: nevergone commentedPlease re-roll this patch, thanks! :)