When creating a forum topic, all groups and associated terms are displayed in the "Foums" dropdown selection box. Obviously, this selection should be limited to said group's forum. I guess if you were creating a forum topic through create content > forum topic, it would be a little different, but creating a topic through the group block should automatically select and display only that group's forum.

Comments

jo1ene’s picture

jo1ene’s picture

Title: All terms displyed in the Forums dropdown selection » All terms displayed in the Forums dropdown selection
jo1ene’s picture

/**
 * Implementation of hook_db_rewrite_sql().
 *
 * Restricts forum viewing by organic group.
 */
function og_forum_db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid') {
  global $user;

  if ($primary_field == 'tid') {

    // Only do this on forum nodes
    if (arg(0) == 'forum' || db_result(db_query('SELECT type FROM {node} WHERE nid = %d', arg(1))) == 'forum') {
      $restrict = TRUE;
    }
    else if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'forum') {
      $restrict = TRUE;
    }

    // If on a forum node, prevent display of all forums; only the ones for this organic group
    // The forum vocab should have a lower weight than any other vocabulary assigned to forum nodes.
    static $og_vocab = FALSE;
    if ($restrict) {
      $return['join'] = "INNER JOIN {og_term} ogt ON $primary_table.tid = ogt.tid LEFT JOIN {og_uid} ogu ON ogt.nid = ogu.nid AND ogu.uid = $user->uid";
      $return['where'] = '1=1';
      if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == 'forum') {
        $og_nid = intval($_GET['edit']['og_groups'][0]);
        if ($og_nid && !$og_vocab) {
          $og_vocab = TRUE;
          $return['where'] = "ogt.nid = $og_nid";
        }
      }
      $return['distinct'] = TRUE;
      return $return;
    }
    else {
      return NULL;
    }

  }
}

This leads me to believe that one SHOULD NOT be able to see all groups' forums and therefore this is a bug.

jo1ene’s picture

In:

function og_forum_db_rewrite_sql

If you change:

static $og_vocab = FALSE;

to:

$og_vocab = FALSE;

This issue is resolved for the "create forum topic" link int he group menu.

If you navigate to the forum first from the group menu, we still ahev a big issue with all categories being displayed for all groups.

Natalie@drupal.ru’s picture

Yes, that's a much needed issue.

Natalie@drupal.ru’s picture

Also, your patch makes a forum creation node to show only the current group forum, but not the other groups you're subscribed to. Ideally, it should show all available depending on your subscription.

Steel Rat’s picture

This is an important bug for me. Trying to setup a Role-PLaying site, and groups need to be totally encapsulated. Right now non group members can post content to a group forum, even though the audience isn't the group in question, it still clutters up someone else's group.

I don't think group forums should show in Create Content>Forum post, unless you're a subscriber to the group.

fax8’s picture

in my multiple forum patch (http://drupal.org/node/68295#comment-128397)
I did a work around for this problem.

I changed

$return['join'] = "INNER JOIN {og_term} ogt ON $primary_table.tid = ogt.tid LEFT JOIN {og_uid} ogu ON ogt.nid = ogu.nid AND ogu.uid = $user->uid";
      $return['where'] = '1=1';

to

$return['join'] = "INNER JOIN {og_term} ogt ON $primary_table.tid = ogt.tid INNER JOIN {og_uid} ogu ON ogt.nid = ogu.nid AND ogu.uid = $user->uid";
      $return['where'] = 'ogu.is_active=1';
darren oh’s picture

Version: master » 4.7.x-1.x-dev
darren oh’s picture

Status: Active » Closed (duplicate)