I just today discovered the documents content type (was I living under a rock?) so I have enabled and configured it.
Problem is that Document-related permissions are NOT enabled in my groups, so regular users cannot create documents. I have reproduced this problem with existing groups on out-of-the-box Commons3.5.
I have more than a dozen groups already on my production site and would like to skip all the clicking to set the permissions by hand.
I noticed this issue of permissions for pre-existing groups when enabling the Document content type was mentioned in this older report #2030021: Creating document is not properly synched with groups and permissions, where in comment #3 the question is asked "I'm not sure if the update function should be expanded to automatically add these permissions to all existing groups."
My response is: "Yes, yes it should." :)
EDIT: Removed some comments I had written regarding confusing behavior I was noticing, which I now think was because I had enabled commons_documents (module) but had not done a features revert on commons_document (feature). Now that I've done the latter, things are much better.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | default_document_permissions-2162127-7.patch | 7.52 KB | japerry |
Comments
Comment #1
WebSinPat commentedComment #2
WebSinPat commentedI have no idea if I'm on the right track, but attached is a patch that worked for me, by looping through all groups in the db and setting the default permissions via og_role_change_permissions.
Comment #3
WebSinPat commentedHmm, I'm noticing a problem with my patch that I put the code in the install file with the thought that it would get run when the content type is first enabled. But as written it will also run when commons_documents is upgraded, at which point the user may have already configured the document related permissions for their existing groups and this code would clobber their configs.
So again, not sure if i'm on the right track at all, but it did work for me in my particular use-case.
Comment #4
japerryUpdated the patch to include some more work on the install file.
hook_enable will revert the commons_documents feature
hook_install will perform the one time permissions application to all previous setup groups.
Keeping for review and marking for the 3.12 radar
Comment #5
rosemeria commentedHI Jakob,
Did a quick check of the patch on an existing development site (commons 7.x-3.9 -- 29 existing private groups):
Maybe I will try to run another test over the weekend.
Comment #6
japerryahh yes, so the problem here is that new groups, when they are created they get assigned the new permissions, but the existing groups do not. We'll have to go through an explicitly add these permissions for the old groups.
Comment #7
japerryIn discovering why permissions weren't set for some groups, it was discovered that -any- CT that was disabled or not enabled for a time would cause groups not to get permissions.
This patch fixes documents and all of the other commons content types. It also adds commons_groups_features_permission_rebuild which is a copy of the og rebuild function, except it takes in a $gid so you can loop through groups and set permissions by default upon enable.
Patch is a revision of the previous one and incorporates its changes in a cleaner way.