Automating Setting of Permissions #113
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#113
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I posted this a while back, but it was closed without discussion, so I'm going to repost it, as I believe that this would be a major improvement to JCB.
I think a great enhancement to JCB would be the "automatic" setting of permissions upon install. This can, from my own experience, be accomplished by a two-step process. Someone might have a better implementation, but this is what worked on my 21 site views.
To extend JCB to support automatic ACL settings:
Add 2 new fields to JCB -> Admin Views -> Permissions repeatable field. 1 field would query and populate from #__viewlevels, the other from #__usergroups.
On compile of the component, the compiler would add to the compile of the permissions already being done. Right now it does similar to {} in the rules field in the assets table, until you go in and manually set every permission and save, which could be extremely frustrating for end users. The code below would set the looks and looking views on the DEMO component to automatically accessible by public on install, and create to registered.
Any thoughts?
Note: The code above would be generated in the PHP Postflight (install) in script.php.
The problem we have here is that 99% the public group is ID 1, but it is a movable ID and setting it hard coded in your component could be an issue.
What we did is we added the option to remove permission control on the view, so that it does no have a permissions check. This is not ideal but it is an option, since if the view is set by default to public access, it may not even need access control.
But okay lets say we want to access control in there, and yet start it off as public upon install of the component, witch is the only group we can really target with 99% accuracy. We have two options:
To me the second option seems more like the freedom we like to have, yet the first really is the expected way it should have worked... or so it seems.
What do you think.
We also will now need to check if a developer has not already added his/her own implementation of this feature... and only if not found add the JCB automated implementation... man this is fun....lol
Don't forget that there is also permissions per fields and back-end views. I have a component here on Github... look at this permission nightmare, and this is a small one. In a learning manager I have so huge a permission structure, I had to make database adjustments to insure the field does not get cut.
So to just target the site permissions is the first step of a very big issue here. I have been thinking about it for months now... how to set the permissions per/field per/view in JCB so that the component on install has a well formed default permissions in place for all groups, and options.
Just can't find a consistent way as yet.
But to start with these site-views seems very important... just though you need to also think about the bigger reality at hand. Maybe you have some thoughts that could help 👍
Going the route that you are suggesting, I would vote for option 2 above (Add a switch). In my own component, I have a site view call Favorites. On one of the item views, I have a button that when clicked added a record to a favorites table with the user id and the item id. The favorites view then displays the items that they have added to their favorites. This favorites site view would never be public, since it's querying for the user id upon loading.
In my suggestion, I was looking at what the majority of components in the JED do. I haven't come across any that you install and have to set all the site views. The site views are being pre-set.
Okay for a start I will add the second option to JCB in the next release... we take it from there.
I will say that documentation one how to set defaults was very limited out on searches. That's when I finally found the example that I posted, which works 99.9% of the time on my test installs. But, there could be instances where someone deletes the core Joomla! ACL, and adds only their own. I do think that those types will be the "minority".
Maybe @ro-ot will have some suggestions as well.
Joomla in the global options has a "Default Access Level" lets use that to get the default group and then use that ID for the default access level (during install). This should be as good as it will get to identify the public/default access group. Since by default that will be public, yet if someone has change that it means they don't want stuff to default be public, but instead this other group... so they get what they expect, and we can set a notice in case the id is not 1 (the default public group).
Well this is to get a 100% accuracy in setting the site-views permissions.
Far as I know you can't just delete the Public Group ID 1, you can rename it, but not remove it. You can check me on this.
So just use 1 and let the 0.1% deal with their own mess 👍
About the solution, option 2 sounds about right. Like always @Llewellynvdm is a star 🥇
Okay I have the first part of this issue resolved, we now have site access (default public) switch and implementation in compiler.
Yet how to add the fields and back-end views to this will not be that easy, we will have to spend some more time on this latter. For now please test the pull request... and let me know if it works as expected.
@mwweb we are waiting for your feedback 👍
I will test it today and give my feedback