Fixing OG Forum (Organic Groups forums)

Organic Groups is a module -- a broad suite of modules actually -- allowing you to create and maintain private groups inside of the Drupal content management system.  While Drupal has a powerful roles and taxonomy system with lots of third-party node access tools, Organic Groups (OG) is an out-of-the-box solution that doesn't require much knowledge of Drupal internals to get yourself up and running.

What is OG?  Think "Yahoo Groups".  It's a way to partition a Drupal site to support multiple private, semi-priviate and/or public groups, each with their own features.

Naturally, one of those features is forums so Organic Forum was born.  The problem is that Organic Forum is a third-party module, not something in Drupal core.   Third-party modules are independent projects with a dependency on a volunteer group of developers (which is often just one person) staying on top of bug reports and updates to other modules which could have an impact on their own.  Sometimes those people drop the ball. in turn stays on top of projects which aren't being maintained in a timely manner, which is where things went wrong with Organic Forum.  Its developer may have become overtaxed with real-world work or simply lost interest in the project.  Whatever the case, Drupal deprecated Organic Forum and marked it "abandoned".   Worse, there were several fairly serious security issues with it so Drupal also recommended that nobody use it.

The problem is that that's not an option if you already have forums running inside of OG or you have a project that requires them.

That was the situation I found myself in.  A client in the nonprofit education industry demanded forums for its private groups and Organic Forum was the only practical solution besides ditching Drupal entirely for something like Acquia Commons, which has Organic Groups built in with a nice third-party forum system.

The client wasn't overly concerned about unauthorized people seeing content in those private forums but there was a bigger problem.  The client had a landing page where it wanted a list of teasers for all forums for which the user had access, both public and private.  The "Active Forum Topics" block in Drupal's stock forum.module doesn't know about OG's privacy and the "Active Forum Topics in group" block in Organic Forum only displays on Organic Group pages, not from the Community landing page the client wanted.

One of the nice things about Drupal is that you can override themes, or how data is displayed.  However, this function isn't a theme but a hook that generates data and hooks can't be overridden.  The only option was to write a new Active Forum Topics hook incorporating the client's requirements, which is what I did.   By creating it as a small module, it also meant that I didn't have to hack Drupal core or a third party module to do it.

The module is attached.  There's not much to it except a couple of slightly dense SQL queries incorporating a UNION to extract both public discussions and authorized private discussions into one result set.  Otherwise it's a standard Drupal hook_block(). Just unpack it in your modules directory and enable it in admin/build/modules/list.  Two new blocks will appear under admin/build/block/list: OG Forum Fixes: Active forum topics and OG Forum Fixes: New forum topics.  Use these as you would the blocks that come standard with Drupal's forum module.