Closed (fixed)
Project:
Drupal Commons
Component:
Groups
Priority:
Major
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Apr 2013 at 14:24 UTC
Updated:
4 Jan 2014 at 02:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ezra-g commentedComment #2
amitaibuThis should be done after #1961302: Streamline group privacy settings fieldset
Comment #3
amitaibuWork in progress
Comment #4
amitaibuPatch includes the WIP from #1964282: Streamline group privacy settings fieldset
The selection handler is working :)

Comment #5
itamar commentedPatching commons to enable og_access and the OG access fields.
Comment #6
itamar commentedPatching commons_groups:
Comment #7
amitaibuReady for review.
Comment #8
amitaibuThis field should be moved to commons_groups_privacy() (and all the logic related to it).
This means that we can indeed decouple #5 and move it to it's own issue. for real :)
Comment #9
itamar commented@amitaibu The commons_groups_privacy module is not currently enabled by default. Should we enable it?
Comment #10
amitaibu> Should we enable it?
No. They want to avoid having node-access if not needed.
Comment #11
itamar commented@amitaibu There's a slight problem moving the selection handler to commons_group_privacy; The og_group_ref field defined in commons_group is supposed to use that handler.
Perhaps it should use the default OG selection handler and be switched to the group_privacy handler when group_privacy is enabled?
Comment #12
amitaibuNo the selection handler stays in commons-groups.
Just the private field moves to the privacy module
Comment #13
amitaibuog_group_permissions field should be added on every group, and it's default to be "Override global roles and permissions", and hook_field_access() it, so it's always overridden.
When the field
field_og_subscribe_settingsvalue changes, we need to setup the permissions.Something along the lines:
Since we don't have a hook for permissions change, lets form_alter() and remove those option from the UI.
Comment #14
itamar commentedPatch for commons_groups containing all of the above.
Comment #15
amitaibuMinor nitpicks:
Return early, and hide field if og_access is disabled.
node => node's group-content
Comment #16
itamar commentedIncluding fixes from #15.
Comment #17
ezra-g commentedThanks!
I made a few tweaks:
- Removed hard-coded field instances from commons_groups.info and instead added to commons_groups_system_info_alter():
- I then went to enable Commons Group Privacy module as is currently the workflow for private groups in Commons, but was unable to do so because that module conflicted with Commons Groups. Since we define the OG access control fields in Commons groups with this patch, I removed the Commons Group Privacy module entirely :). Seems like we can instead direct people to enable OG_access.module if they need group access control.
- I added a hook_update_N() implementation to update the Commons Groups feature for users upgrading from a previous version of Commons.
Before I did functional testing, I checked out the latest 7.x-2.x version of OG, meaning I tested *without* the og_group_ref() patch specified in the Commons make file.
- Then, I reverted the Commons Groups feature and created a private group, with the "Joining requires admin approval" setting.
So far, so good!
- With a second, non-admin user account, I went to the newly created private group, and saw that I was presented with a "create post" link.
However, my expectation is that as a non-member of the private group, I should *not* see the create post link when viewing a private group where I am not a member.
It's possible that this patch needs to include an update to the commons_groups_og_user_access_alter() implementation to detect group privacy properly, though my expectation is that it already properly respects group privacy. Note, I believe we still need this implementation of hook_og_user_access_alter() in order to ensure that the content creation links appear on the group homepages for non-group members. It's our new og_commons Entityreference handler that eliminates the need for the patch to OG referenced above.
- I tried to continue with additional functional testing, but when editing the group node, the radios for "Privacy settings" were all disabled/greyed out, even for user 1, so I was unable to continue functional testing,
Comment #18
amitaibuI actually thought doing it the other way -- hiding those permissions from the OG-permissions page.
That field should be out-side of Og-access. It's not about access, it's about the subscribe settings (e.g. subscribe with or without approval)
Comment #19
bricel commentedAlso need to send an email when a message is sent.
Comment #20
itamar commentedRe-rolling #17 - See separate diff file.
Patch removes commons_group_privacy and fixes synchronization between the subscription settings field and the relevant permissions.
Not tested at all yet.
Currently the privacy field is not created when the module is installed without og_access. I assume we'll need to add the field manually in case og_access is enabled later, right?
Comment #21
ezra-g commentedThe same is true for when invitations are sent and accepted.
Comment #22
ezra-g commentedComments #19 and 21 were meant to be on #1975198: [Meta] Trusted Contacts & Private messaging.
If we can detect when og_access is enabled and do a features_revert on the field base and instance components for Commons_groups, that seems ideal.
Comment #23
amitaibu> Comments #19 and 21 were meant to be on #1975198: [Meta] Trusted Contacts & Private messaging.
I was just about to write scope creep ;) @ezra can you please open a separate issue for notifications (+ explain there what "accept invitation" means)
> If we can detect when og_access is enabled and do a features_revert on the field base and instance components for Commons_groups,
@itamar, we can hook_modules_enabled() and do the features revert. We need to see the features revert is only on our module, so we don't time out.
Comment #24
ezra-g commentedYes -- Please see the referenced issue for full details :).
Comment #25
itamar commentedRe-rolling #20:
- Fixing problems in the subscription field synchronization.
- Creating the privacy field anyway and hiding it when og_access is disabled. (To avoid the need in feature revert when enabling og_access).
Notice that the patch depends on #1975844: Create hooks for notifying when OG role permissions are changed, which is already in OG's dev.
Comment #26
itamar commentedFixing status.
Comment #27
ezra-g commented@itamar, Thanks for the interdiff - Super helpful!
Does #20 address the functional issues in #17?
Also, looks like some hard-coded field instances crept back into the info file - I made these dynamic with #17:
Comment #28
ezra-g commentedCross-post: I reviewed 20 as itamar posted 25 :).
Comment #29
itamar commentedRe-rolling #27:
Removing field instances declaration per #27 + Cleanup.
This setting is currently synced with the subscriptions permissions and does not determine the ability to post content to the group.
Comment #30
ezra-g commentedThe workflow in Commons is that when a group is open for membership to all authenticated users, any authenticated user can post into the group before joining, and is automatically added as a member when she first creates a node or comment in the group.
If a group has moderated membership, we should therefore ensure that users cannot post into a group before she has joined. Marking as needs work on that basis.
I'm in #drupal-commons in IRC if you'd like to chat to clarify.
Comment #31
amitaibuThat's wrong, the selection handler does check for this field, so settings back to needs review.
Also, note that instead of features_revert if og_access() exists, we simply hide the field if it's not in use -- IMO it's a more sane workflow.
Comment #32
ezra-g commentedThe reason I marked this as "needs work" in #17, is
Comment #33
amitaibuOverhauled
commons_groups_og_user_access_alter()to look for the new changes. btw, we need to find a better term for "private" group. It's not really "Private" (i.e. node-access), it just doesn't allow users to join without approval. Maybe "Moderated groups"?Comment #34
amitaibuPatch makes sure to hide the field when not needed.
Comment #35
amitaibu@itamar
We actually need to act on Og-access being enabled, and add the relevant fields using
og_create_field()This should be done in 2 places:
hook modules enabled()-- When OG-access is enabledhook_field_attach_create_bundle()-- When a new group-content is added, after OG-access is already enabled@ezra-g, I believe those fields should not be in features, as they have specific settings for OG + we solve the problem of adding a new bundle after OG-access is enabled.
Comment #36
itamar commentedRe-rolling 34; Creating the access fields when og_access is enabled and when a new group content type is created.
Comment #37
amitaibuFix access contorl, @itamar please check.
Comment #38
itamar commentedI believe it should be $access_create = TRUE;
Comment #39
itamar commentedRe-rolling #37.
I made the following tests (On the patch attached here) and all worked as I expected.
With OG Access off:
Group subscription is not public - "Joining requires approval":
- Group member is able to post content and sees the post button.
- Pending / Blocked group member and non-member are unable to post nor see the post button.
Group subscription is public:
- Group member / Non-member are able to post.
OG Access is on:
Group subscription is public:
- Group member / pending member / non-member is able to post.
Group subscription is "Joining requires approval":
- Non-member is unable to post.
Comment #40
itamar commentedRe-rolling; Hiding the content access field.
I verified that the "Hide contributed content from non-members" setting changes the access setting on new group nodes.
Comment #41
amitaibuGreat!
@ezra-g, when testing make sure you have OG 2.x --dev
Comment #42
itamar commentedRe-rolling;
- Creating the access fields with features.
- Hiding the group access field and setting its value according to subscription settings.
Comment #43
ezra-g commentedThanks, itamar & amitaibu!
This is getting close. I love the revised og_user_access_alter() implementation!
I did some functional testing and discovered that the Commons_Groups field instance and field base components were not reverting.
I re-rolled the patch to resolve this, which required refactoring in several places. Note that now we define the field bases irrespective of whether og_access module is enabled -- we only define the instances when og_access is enabled.
It would be great if you could verify that this particular bit of code and the comments seem accurate:
The privacy settings field seems to have the correct options, both with and without og_access enabled.
A) However, it seems that the selected option gets overridden upon node save and set to "Joining requires admin approval" regardless of the setting that is specified when creating the group.
B) When OG_Access module is enabled, I get a validation error when trying to create a group node: "Group visibility is required." This prevented me from doing further functional testing with OG Access enabled.
C) For upgrading sites, existing public groups will need a value set for the privacy settings field. I would accept this as a followup issue.
Marking as "needs work" based on A and B.
Comment #44
ezra-g commentedNow with even more patch.
Comment #45
amitaibuSorry about #43.
#44 doesn't install properly, we are working on fixing the issue and submit a patch later on. Stay tuned.
Comment #46
itamar commentedFixing points A and B from #43.
Notice that when enabling OG access from the UI, the fields do not revert properly, but that was also the case for me with patch #43. When enabling OG access from drush, the fields revert but the instances are shown as overridden in the features overview even though they aren't.
Comment #47
ezra-g commentedThanks!
I re-rolled 46 to address the fields that wouldn't revert.
Two remaining functional problems:
A) The "Privacy settings" field value is still overridden on the first save of a group node.
B) When a non-member attempts to post into a public group, the node title isn't present in the autocompelte widget and there is no form validation error, but the resulting node isn't posted into any group.
I would expect either a validation error, or success posting into the target group. I believe you can reproduce this by following a "create [content]" link from any public group node with the patch applied.
Comment #48
itamar commented@ezra-g I couldn't reproduce the privacy settings being overridden (A);
I'm able to create groups with "privacy settings" set to " Anyone can join" and it doesn't get overridden to "Joining requires admin approval". And so is the case when editing existing groups.
I tried both possibilities with and without og_access. Can you give me an advice on how to reproduce it?
Comment #49
itamar commentedI verified that this problem disappears when OG and Entityreference-prepopulate are updated to their latest releases. The attached patch updates them.
I'm leaving status as needs work because of #48.
Comment #50
ezra-g commentedI'll try again with the Entityreference_Prepopulate 1.3 and OG 7.x-2.x dev on a fresh install of Commons.
Comment #51
ezra-g commentedI am still able to reproduce on a fresh install.
For reference, I'm testing with a fresh installation of Commons using the HEAD of the 7.x-3.x branch of Commons Groups, switching to the patch from #47, running drush cc all, drush updatedb and doing node/add/group as user 1.
I create a group with the "Anyone can join" and upon editing the new group node the Privacy settings value is instead set to " Joining requires admin approval".
Comment #52
itamar commented@ezra-g I created a fresh installation from 7.x-3.x (But with OG and entityreference-prepopulate updated to their latest releases), and then performed exactly what you described on #51, and the group stayed as "Anyone can join".
So I'm assuming also this problem disappears with the latest OG and entityreference-prepopulate.
Comment #53
ezra-g commentedI tested #47 again after building Commons with build-commons-dev.make and replacing OG and Entityreference_Prepopulate to their latest official releases, and this is working as expected now.
I tweaked commons_groups_modules_enabled() to revert the field bases before the instances so that the updated base definition will take effect and committed.
Thanks, itamar and amitaibu!
http://drupalcode.org/project/commons_groups.git/commit/7d0c734
Comment #54
ezra-g commentedFollowup to remove group privacy module that I missed in the previous commit: http://drupalcode.org/project/commons_groups.git/commit/473eaa3.
Comment #55
ezra-g commented@itamar/@amitaibu: Will it be necessary to update group nodes on existing Commons sites to set values for the fields added in this issue?