Closed (works as designed)
Project:
Organic Groups
Version:
master
Component:
og.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Mar 2007 at 02:13 UTC
Updated:
13 Oct 2007 at 19:00 UTC
I went into OG config and:
"Audience checkboxes" : unchecked
"Visibility of posts" : Visible only within the targeted groups
"Audience required" : required
"Omitted content types" : none
When user creates a document, no group checkboxes appear and document is submitted to current user group. When user edits that same document, user see checkboxes for all groups. User is not admin.
What function determines what checkboxes appear on the edit/create forms?
Comments
Comment #1
moshe weitzman commentedby design, so user can reaffiliate the post ... search for _audience() ... you can hook_form_alter this is you want. requires developer.
Comment #2
somebodysysop commentedThanks. I am a developer, but I've never used form_alter before, don't know the name of the form, the form id, or even if I did, how to tell whether the process is is a "create" or "edit".
All I want to do is display the same thing (audience defaults to current group, no checkboxes) on "edit" form as is displayed on "create" form.
I found og_form_alter($form_id, &$form). As far as I can tell, it calls og_form_add_og_audience($form_id, $form) where it appears the form is actually built. Assuming I'm right so far, I can't tell from this code how you tell a "create" process from an "edit" process.
Or, am I looking at this all wrong? Can someone who knows what should be done please help? Thanks.
Comment #3
somebodysysop commentedOK, absent any clear direction, what I did here was create a debug snippet that wrote out various values from the og_form_add_og_audience function so I could compare the "create" process with the "edit" process. The difference I found was that when a user creates a group node, there is a value in gids. When a user clicks on the link to edit a node, there is no value in gids. So, I figured I could remedy the situation by placing the current group nid in gids, like so:
See any problems with this?
Comment #4
moshe weitzman commentedwith this code a regular user can never reaffiliate an existing post. most sites will not want that. is impossible to correct a mistake.
Comment #5
somebodysysop commentedThat's not true. First off, if a site administrator wants to limit a user to post only to his current group, he will hardly want to give that same user the ability to re-edit that same post into another group. That simply defeats the purpose of having an "Audience checkboxes" option in the first place.
That said, if the site administrator wants to allow users to post to more than one group, and thus re-affiliate posts, then he simply checks the "Audience checkboxes" box in OG config. If "Audience checkboxes" is checked, even with my modification, the group checkboxes will appear on content creation AND edit forms.
The way OG now works by design, a site administrator can never restrict a user (who belongs to more than one group) to post to only his current group because the user can always re-affiliate his initial post with another group using the edit process. The way OG works with my modification is that a site administrator can now truly restrict a user to posting to just his current group OR optionally allow the user to post to any groups he belongs to.
Furthermore, if the site administrator places a "current group only" restriction on user posts, and a user, seeing the current group clearly in the "Audience" section of the submission form, still submits the content to the wrong group, he can always delete the submission and re-submit to the correct group. So, it is possible for a regular user to correct a mistake. And, if he has to do this a couple times, he'll learn to pay better attention to the group he's posting to. Win-win if you ask me.
Comment #6
Christefano-oldaccount commentedMoshe, this is the same bug we talked about at the Drupal meetup on Wednesday. I understood from you that this was really is a bug and not by design.
I'll explain for the benefit of others why this is a really, really bad bug. I have several sites where all groups are closed (and will be made private when #83005 clears), such as the one I told you about. We have another site which uses OG and the usual project management-type features for conflict resolution between departments in their organization. It has a wiki, which has pages that can be edited by users within the same group. Some users can see all groups when editing a wiki page, even when they are not members of the other groups. Strangely, other users do see their own groups and only those groups in the Audience field.
This behavior is just a disaster waiting to happen. Can it be fixed by checking for a user's groups in
og_form_add_og_audience()on line 1492?Thanks to SomebodySysop for detailing the steps to reproducing this problem.
Comment #7
Christefano-oldaccount commentedSomebodySysop, try changing line 1505 in og.module to:
$subs = $user->og_groups;Getting the subscribed groups this way (instead of using the og_get_subscriptions function) seems to fix the problem. It's a simple change so there's no patch (plus, this feels like a simple bandage for a deeper problem) but I'll change the status to get some eyes on this.
Comment #8
moshe weitzman commentedwe have 2 different issues here. the title is about audience checkboxes on edit form. and indeed that settings has no effect on edit page by design. delting the node and reaffiliating is not an acceptable solution for me, but if you like it then implement it n your site with hook_form_alter().
the other issue about disclosing groups on edit form should be moved to a separate issue and clearly articulated.
Comment #9
Christefano-oldaccount commentedOK, new issue created at #164070.
Comment #10
neurojavi commentedPlease read this forum post http://drupal.org/node/183245 for a discussion about Audience improvement.