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
Comment #1
rconstantine commentedI'll review and consider this for inclusion. Thanks for the post.
Comment #2
rconstantine commented@Paul
Here is a possible patch for http://drupal.org/node/274296
Comment #3
Anonymous (not verified) commentedPostponing this feature request for D6.
Comment #4
Anonymous (not verified) commentedIll look at this in the morning
Comment #5
Anonymous (not verified) commentedComment #6
Anonymous (not verified) commentedI shall look at this after we have an official release of this module up on drupal.org
Comment #7
Anonymous (not verified) commentedComment #8
Anonymous (not verified) commentedComment #9
Anonymous (not verified) commentedComment #10
jday commentednot 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?
Comment #11
jday commentedok nevermind, I installed the .dev version and it works perfectly, sorry for the bother, thank you for adding the patch
Comment #12
Anonymous (not verified) commented