Index: og_forum.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_forum/Attic/og_forum.module,v
retrieving revision 1.11.2.10
diff -u -p -r1.11.2.10 og_forum.module
--- og_forum.module	3 May 2007 03:52:33 -0000	1.11.2.10
+++ og_forum.module	3 May 2007 05:07:08 -0000
@@ -36,6 +36,12 @@ function og_forum_menu($may_cache) {
       'type' => MENU_CALLBACK,
       'access' => user_access('access content'),
     );
+    $items[] = array(
+      'path' => 'forum',
+      'callback' => 'og_forum_page',
+      'type' => MENU_CALLBACK,
+      'access' => user_access('access content'),
+    );
   }
   else {
     // we expect the group nid as 1st argument
@@ -105,12 +111,168 @@ function og_forum_is_admin($group) {
  * Menu callback; allows us to set group context prior to
  * loading a forum
  */
-function og_forum_page($forum) {
-  $gid = $_GET['edit']['og_groups'][0];
-  og_set_theme($gid);
-  $group = node_load($gid);
-  og_set_group_context($group);
-  return forum_page($forum);
+function og_forum_page($tid = 0) {
+  global $user;
+  if ($tid != 0) {
+    og_forum_set_og_group_context_from_tid($tid);
+    $gid = og_forum_gid_from_tid($tid);
+    if ($gid) {
+      if (!array_key_exists($gid, $user->og_groups) && ($user->uid != 1)) {
+        return drupal_access_denied();
+      }
+    }
+  }
+  elseif (is_numeric(og_get_group_context())) {
+    $tid = og_get_group_context();
+  }
+  //The rest is copied from forum_page with a modified theme call
+  $forum_per_page = variable_get('forum_per_page', 25);
+  $sortby = variable_get('forum_order', 1);
+  $forums = forum_get_forums($tid);
+  $parents = taxonomy_get_parents_all($tid);
+  if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
+    //drupal_set_message('Inside if');
+    $topics = forum_get_topics($tid, $sortby, $forum_per_page);
+  }
+  return theme('og_forum_display', $forums, $topics, $parents, $tid, $sortby, $forum_per_page);
+}
+
+/**
+ * Format the forum body.
+ *
+ * Copied from forum module. Slightly modified to produce correct links and eliminate 'add new topic' links in containers.
+ *
+ * @ingroup themeable
+ */
+function theme_og_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page) {
+  global $user;
+  // forum list, topics list, topic browser and 'add new topic' link
+  $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
+  $title = $vocabulary->name;
+  // Breadcrumb navigation:
+  $breadcrumb = array();
+  if ($parents) {
+    $parents = array_reverse($parents);
+    foreach ($parents as $p) {
+      if ($p->tid == $tid) {
+        $title = $p->name;
+      }
+      else {
+        $breadcrumb[] = array('path' => 'og_forum/'. $p->tid, 'title' => $p->name);
+      }
+    }
+  }
+  drupal_set_title(check_plain($title));
+  $breadcrumb[] = array('path' => $_GET['q']);
+  menu_set_location($breadcrumb);
+  if (count($forums) || count($parents)) {
+    $output  = '<div id="forum">';
+    $output .= '<ul>';
+    if (user_access('create forum topics') && !in_array($tid, variable_get('forum_containers', array())) && ($tid != 0)) {
+      og_forum_set_og_group_context_from_tid($tid);
+      $output .= '<li>'. l(t('Post new forum topic.'), "node/add/forum/$tid") .'</li>';
+    }
+    else if (user_access('create forum topics')) {
+      $output .= '<li>'. t('Select a forum below.') .'</li>';
+    }
+    else if ($user->uid) {
+      $output .= '<li>'. t('You are not allowed to post a new forum topic.') .'</li>';
+    }
+    else {
+      $output .= '<li>'. t('<a href="@login">Login</a> to post a new forum topic.', array('@login' => url('user/login', drupal_get_destination()))) .'</li>';
+    }
+    $output .= '</ul>';
+    $output .= theme('og_forum_list', $forums, $parents, $tid);
+    if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
+      $output .= theme('og_forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
+      drupal_add_feed(url('taxonomy/term/'. $tid .'/0/feed'), 'RSS - '. $title);
+    }
+    $output .= '</div>';
+  }
+  else {
+    drupal_set_title(t('No forums defined'));
+    $output = '';
+  }
+  return $output;
+}
+
+/**
+ * Format the forum listing.
+ *
+ * Copied from forum module. Slightly modified to produce correct links.
+ *
+ * @ingroup themeable
+ */
+function theme_og_forum_list($forums, $parents, $tid) {
+  global $user;
+  if ($forums) {
+    $header = array(t('Forum'), t('Topics'), t('Posts'), t('Last post'));
+    foreach ($forums as $forum) {
+      if ($forum->container) {
+        $description  = '<div style="margin-left: '. ($forum->depth * 30) ."px;\">\n";
+        $description .= ' <div class="name">'. l($forum->name, "og_forum/$forum->tid") ."</div>\n";
+        if ($forum->description) {
+          $description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
+        }
+        $description .= "</div>\n";
+        $rows[] = array(array('data' => $description, 'class' => 'container', 'colspan' => '4'));
+      }
+      else {
+        $new_topics = _forum_topics_unread($forum->tid, $user->uid);
+        $forum->old_topics = $forum->num_topics - $new_topics;
+        if (!$user->uid) {
+          $new_topics = 0;
+        }
+        $description  = '<div style="margin-left: '. ($forum->depth * 30) ."px;\">\n";
+        $description .= ' <div class="name">'. l($forum->name, "og_forum/$forum->tid") ."</div>\n";
+        if ($forum->description) {
+          $description .= ' <div class="description">'. filter_xss_admin($forum->description) ."</div>\n";
+        }
+        $description .= "</div>\n";
+        $rows[] = array(
+          array('data' => $description, 'class' => 'forum'),
+          array('data' => $forum->num_topics . ($new_topics ? '<br />'. l(format_plural($new_topics, '1 new', '@count new'), "og_forum/$forum->tid", NULL, NULL, 'new') : ''), 'class' => 'topics'),
+          array('data' => $forum->num_posts, 'class' => 'posts'),
+          array('data' => _forum_format($forum->last_post), 'class' => 'last-reply'));
+      }
+    }
+    return theme('table', $header, $rows);
+  }
+}
+
+/**
+ * Format the topic listing.
+ *
+ * Copied from forum module. Slightly modified to produce correct links.
+ *
+ * @ingroup themeable
+ */
+function theme_og_forum_topic_list($tid, $topics, $sortby, $forum_per_page) {
+  global $forum_topic_list_header;
+  if ($topics) {
+    foreach ($topics as $topic) {
+      // folder is new if topic is new or there are new comments since last visit
+      if ($topic->tid != $tid) {
+        $rows[] = array(
+          array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
+          array('data' => check_plain($topic->title), 'class' => 'title'),
+          array('data' => l(t('This topic has been moved'), "og_forum/$topic->tid"), 'colspan' => '3')
+        );
+      }
+      else {
+        $rows[] = array(
+          array('data' => theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky), 'class' => 'icon'),
+          array('data' => l($topic->title, "node/$topic->nid"), 'class' => 'topic'),
+          array('data' => $topic->num_comments . ($topic->new_replies ? '<br />'. l(format_plural($topic->new_replies, '1 new', '@count new'), "node/$topic->nid", NULL, NULL, 'new') : ''), 'class' => 'replies'),
+          array('data' => _forum_format($topic), 'class' => 'created'),
+          array('data' => _forum_format(isset($topic->last_reply) ? $topic->last_reply : NULL), 'class' => 'last-reply')
+        );
+      }
+    }
+  }
+  $output = theme('table', $forum_topic_list_header, $rows);
+  $output .= theme('pager', NULL, $forum_per_page, 0);
+  return $output;
 }
 
 /**
