Help with new rules addon for groups; Collect Ideas how to do

Hi,

first my idea.
Create rules for groups, that only members of a group can Read,Update,Delete ( CRUD ) the collection items.

So i’m thinking of just add new rules
The default seems to be:
“create” : {enabled:false},
“read” : {enabled:false},
“update” : {enabled:false},
“delete” : {enabled:false}
according to modules/Collections/views/collection.php

and i found a lot of hardcoded stuff for exactly these.
I think i can overwrite a lot of it … but then i can fork the project and rewrite the hole permission thing.

So i think i’m in a mind trap :wink:

What do you think what is the easiest way to do it?
Or is there even a way with the collections rules ( the custom php )?

I am looking forward to an idea exchange
Hackbard

Some idea i got now, is to use the trigger collections.save.before and save the current user group if not present. After that i should be able to check that in the custom rule files or not?

I rechecked the source and the respective events should be

  • collections: collections.createcollection
  • singletons: singleton.save.after

The collections-event is triggered after the collection is created and there is only this one event.
The singletons trigger a before and an after event, but for the sake of similar behavior in relation to the collection-creation-event I’d suggest to go with the after event.

The mentioned collections.save.before event is triggered before entry-save.

1 Like

Yes i need the collections.save.before event so i can add the group of the current user.
And after that i can check with the custom rules.

Oh misunderstanding on my side then.
I thought you wanted to set the permissions for a group on collection level.

But yes, if you want to set the permissions on entry-item level then you might want to add a group-ownership info to each entry.

OR you add on-before-view/-edit/-delete a filter / limit access to items owned by current-users-group-member-ids.

I just found this perfect snippet in @raffaelj s snippet collection:

You’d now have to adjust this script to filter by owners-group-member-ids.

Or you add a similar snippet into the collection->permissions->write field which then saves the owner-group to-entry and then you can directly filter by owner-group.

Here is my first try in the develop branch.

I’ve seen the code snippet and i will rework :stuck_out_tongue: that thing looks much better.