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.

Comments

WebSinPat’s picture

Issue summary: View changes
WebSinPat’s picture

Status: Active » Needs review
StatusFileSize
new1.5 KB

I 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.

WebSinPat’s picture

Hmm, 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.

japerry’s picture

Version: 7.x-3.5 » 7.x-3.x-dev
Issue tags: +commons 7.x-3.12 radar
StatusFileSize
new2.46 KB

Updated 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

rosemeria’s picture

HI Jakob,
Did a quick check of the patch on an existing development site (commons 7.x-3.9 -- 29 existing private groups):

  • no error messages
  • permissions showing correctly in OG permissions overview for both admin and member
  • permissions working correctly for group administrators
  • I am experiencing permission working a bit strange for group members -- members can add document content on homepage BW short form and long form, by entering group name; but inside of the private group the BW does not show input form under "document tab", members have no access to short or long form for documents content type (all other content types are working).

Maybe I will try to run another test over the weekend.

japerry’s picture

Status: Needs review » Needs work

ahh 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.

japerry’s picture

Status: Needs work » Needs review
StatusFileSize
new7.52 KB

In 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.

  • Commit 1be8a71 on 7.x-3.x by japerry:
    Issue #2162127 by japerry: Rebuild OG permissions for documents and...