(continued from http://drupal.org/node/555964)

Description:
In certain circumstances when creating new topics, the "Forum:" menu is not populated with choices. Since that field is required, this issue prevents the user from being able to create the node.

Repeatable:
Always

Steps to repeat:
Click the "Create new Forum topic" link (specifically, it's the path node/add/forum that causes the problem).

Details:
The issue appears to be in og_forum_db_rewrite_sql() (og_forum.module), when $_GET['qids'] is unset.

Some proposed solutions are in the previous thread.

Comments

kentr’s picture

kentr’s picture

Title: Forum taxonomy menu not populated » Forum taxonomy menu not populated when creating new node

Here's what I've tried with the query.

Change these lines:

og_forum.module ~line 416

    if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'forum' && empty($_GET['gids'])) {
      $return['join'] = "LEFT JOIN {og_term} ogt ON t.tid = ogt.tid";
      $return['where'] = "ogt.nid IS NULL";

to:

    if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'forum' && empty($_GET['gids'])) {
      $return['join'] = "LEFT JOIN {og_term} ogt ON t.tid = ogt.tid LEFT JOIN {og_uid} u  on u.nid = ogt.nid";
      $return['where'] = "(ogt.nid IS NULL OR (ogt.nid = u.nid AND u.uid = {$user->uid} )) ";

Seems to be working with User 1 and an Authenticated User (typical permissions), under these conditions:

  • User 1 is a member of all groups
  • Authenticated User is only a member of 1 group
  • All forums are in a group (container)

Needs to be tested with:

  • The existence of forums not in a group (where ogt.nid is NULL) Tested: OK
  • Perhaps other forum publicity settings of which I'm not aware?
kentr’s picture

StatusFileSize
new800 bytes

Here's a patch for the above.

kentr’s picture

Status: Active » Needs review
Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new133.26 KB

I have a single site wide forum and can see that when i go /node/add/forum

kentr’s picture

@#5

Sorry, I'm confused. Does that mean your test case is working as intended?

I dug into publicity a little more. Does the publicity of the forum need to be considered at this point the code (og_forum_db_rewrite_sql()), or is that handled somewhere else? Note: publicity issues appear to be related to http://drupal.org/node/579734

If they need to be considered in og_forum_db_rewrite_sql(), need info on the status codes.

Questions:

  • Is testing against the 'public' column in `og_term` enough, or are there cases where that column value is overridden at runtime by automated publicity or whatever?
  • If testing against the 'public' column is enough, is any value > 0 considered to be public? (i.e. will it suffice to add ogt.public > 0 somewhere in the query)?
capellic’s picture

Thanks for the patch! It's working for my "authenticated user" who belongs to the private group that has this forum.

Anonymous’s picture

Assigned: Unassigned »

Thanks for all your help here kentr

I'll have a look at this tomorrow as a priority.

Best, Paul

Anonymous’s picture

"In certain circumstances when creating new topics, the "Forum:" menu is not populated with choices. Since that field is required, this issue prevents the user from being able to create the node."

Would you mind clarifying exactly what the circumstances were so that i can repeat the problem
and investigate more efficiently.

If there are no site wide forums defined then it is true that you will not be able to make a post
on /node/add/forum (not sure if that helps)

kentr’s picture

Paul,

Sorry it wasn't clear...

One example based on my setup (from memory. I can't repeat b/c I'm using the patch above):

Steps to repeat

  1. Set up the containers & forums so that you can view a list of forums without being "inside" a group container.
    Example:
    • Two containers, each at the root level, each belonging to a different group.
    • Several forums in each of the containers mentioned above.
    • No forums at root level.
  2. Create a new node:
    • When viewing the top level of the forums, click the Post new Forum topic link at the top of the forum list. More specifically, when not "inside" a group - for my site, this is the default module page, at /forum
    • From any other page on the site, in the Navigation menu (or Administration menu), click Create content -> Forum topic
    • By any other mechanism that uses the simple path node/add/forum or node/add/forum/nn without gids in the path.

Update:

I just noticed this:

If there are no site wide forums defined then it is true that you will not be able to make a post
on /node/add/forum (not sure if that helps)

Ok, didn't know you were aware of this. This is the bug, IMO.

Expected behavior:

Clicking a link entitled "Post new Forum topic" that leads to node/add/forum will allow user to successfully create a forum topic.

Proposed solution:

  • Modify SQL query for forum list (in og_forum_db_rewrite_sql()) so that in cases where $_GET['qids'] is unset, the query returns all forums for which user has permission to post, regardless of whether there are site-wide forums defined. That's what patch #3 is attempting to accomplish.
  • Since this could get unwieldy when there are many forums, possibly add a configuration setting to optionally declare a default forum or container to display in the taxonomy SELECT in the node edit form for this case.
kentr’s picture

Updated previous comment for clarity & details.

kentr’s picture

Updated #10 to more succinctly state proposed solution.

sebzur’s picture

Subscribing.

chriskip’s picture

Subscribed

tobiberlin’s picture

subscribing - for me this issue appeared with the last update

benjamin_dk’s picture

Version: 6.x-2.x-dev » 6.x-2.0-rc5

subscribing - I am experiencing the same with version 6.x-2.0. I can select forum in the OG forum, but not in any other. I tried the patch, but to no avail. I got no error reports from using the patch.

Edit: I closed the new issue I made for the 6.x.-2.0 version, and post the information here instead (on suggestion from kentr.)

Description

Repeatable: Always

Steps to repeat:

  1. download and unzip og_forum from  http://ftp.drupal.org/files/projects/og_forum-6.x-2.0.tar.gz into the modules folder.
  2. Setup forum structure and Organic Forum settings as described below
  3. goto URL node/add/forum

Expected results:

The forum dropdown list populated with the forums the user have access to post to.

Actual results:

The forum dropdown list is empty ("please select" being the only entry). It is not possible to add new forum topic.

Further details:

After updating OG forum to the latest version (6.x.2.0) it is no longer possible to add new forum topics via the URL node/add/forum, since the forum taxonomy dropdown is not populated , neither as anonymous, authenticated user or user 1.

If I make forum topics as a group member into the OG forum -  node/add/forum/83?gids[]=147 - the dropdown is populated with the OG forums. 

If I deactivete OG forum everything works as it should (except of course now the former OG forum appears in the forum list for all users).

We have the following forum structure - admin/content/forum:

  • Public forum container 1
    • Public forum a
    • Public forum b
  • Public forum container 2
    • Public forum c
    • Public forum d
    • ...
  • OG Forum container
    • OG forum a
    • OG forum b
    • ...

Settings:

Organic groups access configuration admin/og/og_access >

  • Visibility of posts : Visible only within the targeted groups.

Private groups

  • New group home pages and default audience are always private.

OG forum admin/og/og_forum > group forum container >

  • Would you like all group forums to be placed in the same container? : checked
  • Forum publicity administration: nothing checked

Content type forum - admin/content/node-type/forum >

  • Organic groups settings: May not be posted into a group (I also tried "Standard group post (typically only author may edit)").

Hope someone can clarify what has gone wrong. The error happened after a lot of modules being updated + Drupal core updated to 6.14 - so other things might play a role!

kentr’s picture

For cases when the patch didn't work: any errors, or did the patch just not apply?

If it were me, I'd appreciate having the threads combined, even though they're different versions. Easier to keep track of, and many people are already subscribed to this thread.

kentr’s picture

Version: 6.x-2.0-rc5 » 6.x-2.x-dev
StatusFileSize
new695 bytes

Here's a new patch against 6.x-2.x-dev, 2009-Nov-11.

Please also look for issues with non-public forums showing up in the dropdown when they shouldn't.

benjamin_dk’s picture

Version: 6.x-2.0-rc5 » 6.x-2.x-dev

Yesterday I un-installed the old version of OG forum completely before I tried with the 6.x-2.0 version. This brought back the taxonomy in the dropdown - but suddenly the former hidden og forum (minus threads/nodes) was also visible to non-members. I tried to fiddle around to make it work, but couldn't.

Today I did the same with the 6.x-2.x-dev, 2009-Nov-11 version and the og_forum-580452-18.patch. The result was the same - the dropdown populated, but the og forum visible to non-members at /forum. After I set the group forum container to the "old" one at OG forum admin/og/og_forum > group forum container >, this container and its forums disappeared from the dropdown menu - both for non-members AND members. It is as if the old og forums (and/or container?) needs to be reconnected to the group/defined as og forums once again?

I thought about choosing the "retroactively update old groups" option, but I am not sure this will help me out, since I already have my forums.

kentr’s picture

I can possibly fix the issue with hidden forums showing up because of the patch, but I need more information on hidden forums since I'm not familiar with them.

@benjamin_dk (or someone else):

What are the conditions under which a forum is hidden? And if possible: how is that info stored in the database (what table / column)?

benjamin_dk’s picture

As far as I can see from og_forum.module, the conditions that control the visibility of a forum has to do with the og_forum_is_public-function (line 1294). Here a row from the og_term table is tested for content and the status of the public-field.

When I look in my DB I can see, that I have no content in my og_term-table! I guess this is where my old og-forum ought to be?

Here are some more values from the DB regarding my old og-group that might be relevant:

Organic Group-table "og":

og_selective: 1
...
...
og_register: 1
og_directory: 1
og_private: 0

yonailo’s picture

Patch #18 worked for me, subscribing.

Anonymous’s picture

Currently if you go to /node/add/forum you will only see the public forum or no forums if you have no public forums.

This approach looks to allow you go to /node/add/forum and see both public forums & group forums for groups the user is subscribed to. Is this what is being called for here? (Sorry i don't have the time to go through the whole thread right now)

Best,
Paul Booker

kentr’s picture

This approach looks to allow you go to /node/add/forum and see both public forums & group forums for groups the user is subscribed to. Is this what is being called for here?

Yes.

#18 adds a join to group membership tables to accomplish this.

According to #19, my patch had an undesirable side-effect. Haven't had time to look into it.

kentr’s picture

This brought back the taxonomy in the dropdown - but suddenly the former hidden og forum (minus threads/nodes) was also visible to non-members

Making sure I understand: the formerly hidden forums suddenly appeared in the forum listing at /forum, not in the taxonomy dropdown on the node edit form, correct?

In other words, after the patch, the taxonomy menu was working as you expected / desired, and the main forum view page was not?

After I set the group forum container to the "old" one at OG forum admin/og/og_forum > group forum container >, this container and its forums disappeared from the dropdown menu - both for non-members AND members. It is as if the old og forums (and/or container?) needs to be reconnected to the group/defined as og forums once again?

Please open a new issue for this, since this appears to a separate issue (sounds like it the empty og_term table is part of this problem).

kentr’s picture

but suddenly the former hidden og forum (minus threads/nodes) was also visible to non-members.

#19: I can't recreate this problem. How are your private forums set up?

nzcodarnoc’s picture

Subscribing

freddyseubert’s picture

Is this solved in dev? I ran into the same issue with og_forum 2.2...

cleanthes’s picture

Just to add my voice to this: still an issue with 6.x-2.x-dev (as of today), but the patch appears to work. My setup has two groups, each with their own forum, but when creating a Forum Topic the 'Forum' drop-down was empty. Applied the patch above and it seems to work. I've not done extensive testing yet, though.

Beki’s picture

subscribe - but patch worked great :)

boabjohn’s picture

Sorry: patch fails for me on both 6.x-2.2 and x-dev. The x-dev version looks different to what the patch is expecting. Was tempted to hand-edit, but am wondering:

- which version was the patch supposed to be against?
- the -dev version appears to incorporate some elements from the patch, but there's no mention of the patch being rolled into dev (unless I missed it?)

Here's the patch.rej

***************
*** 419,426 ****
          return;
        }
      }
-       $return['join'] = "LEFT JOIN {og_term} ogt ON t.tid = ogt.tid";
-       $return['where'] = "ogt.nid IS NULL";
        if ($og_forum_container = variable_get('forum_default_container', FALSE)) {
          $return['where'] .= " AND t.tid != $og_forum_container";
        }
--- 419,426 ----
          return;
        }
      }
+       $return['join'] = "LEFT JOIN {og_term} ogt ON t.tid = ogt.tid LEFT JOIN {og_uid} u  on u.nid = ogt.nid";
+       $return['where'] = "(ogt.nid IS NULL OR (ogt.nid = u.nid AND u.uid = {$user->uid} )) ";
        if ($og_forum_container = variable_get('forum_default_container', FALSE)) {
          $return['where'] .= " AND t.tid != $og_forum_container";
        }

Thanks for any pointers: I have no forums in my drop downs.

Anonymous’s picture

Assigned: » Unassigned
kentr’s picture

StatusFileSize
new692 bytes

Looks like my patches problematic b/c my editor was converting tabs to spaces and removing whitespace at line endings from the original files. I tested it via command line "patch" on a fresh download.

This patch is made against 6.x-2.x-dev, 2010-Mar-19, where the lines to be changed are 446, 447.

Also tested on 6.x-2.2, where the lines to be changed are 443, 444.

Anonymous’s picture

@kentr

If i recall correctly the module previously did work along the lines that are being suggested above but the modifications did not scale very well for sites with large numbers of groups. I would be interested in getting some feedback on performance before committing.

Best,
Paul Booker
Appcoast

kentr’s picture

Makes sense. Perhaps a config setting so the admin can choose the behavior would help.

The largest concern I had was that clicking the link just failed, leaving the user with no indication of how to make a successful forum post.

I can't offer much relevant feedback on performance. Perhaps one of the others can.

janis_lv’s picture

has this been fixed?

users can see, when adding a forum node, taxonomy from groups. forums which are not in groups are not showing up in the menu. but are browsable in from the site.com/forum

using dev version.

aaronbauman’s picture

Status: Needs review » Needs work

The patch in #33 does not apply cleanly @ DEV using patch.
When applied manually, it does not solve the issue described herein.

Once I figure out what it's supposed to be doing, I'll post a new patch.

aaronbauman’s picture

For non-group members (including user/1), this issue persists.

From what I can see, there are a few possible solutions:
1. a user with "administer forums" permission can add a forum wherever they please, regardless of og membership
2. a user with "administer organic groups" + "administer forums" should be able to add a forum wherever they please.
3. add an "administer og forums" permission to overcome this issue.
I've rolled one patch for each of the options above, because I'm not sure which one makes the most sense.

Whatever course we agree on, user/1 should not have any restrictions, ever, and all these patches remove those restrictions.

kentr’s picture

From what I can see, there are a few possible solutions:
1. a user with "administer forums" permission can add a forum wherever they please, regardless of og membership
2. a user with "administer organic groups" + "administer forums" should be able to add a forum wherever they please.

This issue isn't about adding forums, it's about the visibility of forums as choices in the "Choose a forum" select element when creating a new topic.

Did you mean add a forum type node (aka, "post", "topic", "thread", etc)?

aaronbauman’s picture

sorry for the miscommunication.
By "a user with 'administer forums' permission can add a forum wherever they please", i mean "a user with 'administer forums' permission can assign a forum to any existing forum vocab term".

In other words, for administrative users the "Choose a forum" menu should not filter any choices -- the patches in #38 accomplish this.

ambereyes’s picture

Only one of my groups shows up in the drop down.

I have two groups each with their own forum. The forums are not inside of the same container, they are both at root level.

The first forum, school (gid=116), is listed using url node/add/forum but my second group, staff (gid=122), is not listed. I am a member and a manager of both.

If I use the form "node/add/forum?gids=[]=122" I get nothing in the drop down. Right now members of the second group have no way to post to their forum.

I had previously commented out line 1380 because of problems with #831006: Invalid og_group_context makes Forums inaccessible I could be wrong, but now I am wondering if these two issues are related in some way.

Is there a patch file for the current version, from 2010-11-18, 6.x-2.x-dev? I am not sure what the patches in #38 are for because from the descriptions they do not seem to have anything to do with this issue.

ambereyes’s picture

After some manual fixes to the og_term table, I finally got the second group to be able to post to their forum, but for folks like myself who are members of both groups, it refuses to show me all my forums in a single drop down form node/add/forum ...

To get it to work for the second group, one has to access the forum via node/[gid]/og/forum/[tid] and then click the link to add a forum post. Otherwise it apparently cannot find the second group for context checking.

This is just crazy .... I should be able to use node/add/forum and pick which ever forum I want my post based on all the forums where I have permission.

Edit: to make the gid and tid visible

achandel’s picture

One of the issues that Forum taxonomy menu not populated when creating new node is that you have the Taxonomy access permissions" module enabled. If you have this module enabled you will have to set the permissions something like:

anonymous user : Forum#1 View (A) Update(I) Delete (I) Create(Uncheked) List(Checked)

authenticated user :Forum#1 View (A) Update(A) Delete (A) Create(Cheked) List(Checked)

Forum#1 is the taxonomy term of your forum.

vegantriathlete’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)