Designating a default group forum container is great, because otherwise the system stores each group forum container ID in the serialized system variable "forum_containers". It also does away with the automatically created default forum whether you want one or not.

On sites that are switching to a default forum container, here's a function that takes the old default group forums, renames them to the name of the group container, then deletes the group container. Renaming the forums instead of simply converting containers to forums was necessary to preserve existing forum topics.

<?php
/*
 * Set og forums to new container, rename forum to og container, and delete
 * og container if og forums share container setting
 *
 * @param $vid ID of og forum vocabulary
 * @param $newparent ID of container to put all og forums into
 */
function og_forum_convert_default_forums($vid, $newparent) {
  if (variable_get('forum_default_container_yn', FALSE)) {
    // Get og forums
    $sql = "SELECT td.*, th.parent FROM {term_data} td JOIN {term_hierarchy} th ON td.tid = th.tid WHERE vid=%d";
    $result = db_query($sql, $vid);
    $og_terms = array();
    while ($row = db_fetch_array($result)) {
      $og_terms[] = $row;
    }
    foreach($og_terms as $og_term) {
      // Get forum parent
      if ($og_term['parent'] != 0) {
        $parents = taxonomy_get_parents($og_term['tid']);
        $parent = reset($parents);
        if ($og_term['parent'] != $newparent) {
          $og_term['name'] = $parent->name;
          $og_term['parent'] = $newparent;
          taxonomy_save_term($og_term);
          taxonomy_del_term($parent->tid);
        }
      }
    }
  }
}
?>

I ran this in the Developer code execution box, but it would be better to be able to do this from the og_forums settings page.

Comments

rconstantine’s picture

I'll review and consider this for inclusion. Thanks for the post.

rconstantine’s picture

@Paul

Here is a possible patch for http://drupal.org/node/274296

Anonymous’s picture

Assigned: Unassigned »
Status: Needs review » Postponed

Postponing this feature request for D6.

Anonymous’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev

Ill look at this in the morning

Anonymous’s picture

Status: Postponed » Needs review
Anonymous’s picture

Status: Needs review » Postponed

I shall look at this after we have an official release of this module up on drupal.org

Anonymous’s picture

Title: Convert group containers to forums if default group forum container is set » [WORK PRIORITY 3] Convert group containers to forums if default group forum container is set
Status: Postponed » Active
Anonymous’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Anonymous’s picture

Title: [WORK PRIORITY 3] Convert group containers to forums if default group forum container is set » Convert group containers to forums if default group forum container is set
Assigned: » Unassigned
jday’s picture

not sure what 8 and 9 mean, is the patch working it's way into the module? I think it is confusing for users to be sent to the group forum container where there is a 'add new topic' option but you really can't add a new forum post there you have to click on the group forum below it to actually add a topic...

is there another way to have the group forum tab go directly to the forum rather than the container?

jday’s picture

ok nevermind, I installed the .dev version and it works perfectly, sorry for the bother, thank you for adding the patch

Anonymous’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.