? LICENSE.txt
? modules
? preprocessor.patch
Index: advanced_forum.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advanced_forum/advanced_forum.module,v
retrieving revision 1.45
diff -u -p -r1.45 advanced_forum.module
--- advanced_forum.module	9 Apr 2008 03:47:01 -0000	1.45
+++ advanced_forum.module	16 Apr 2008 17:15:25 -0000
@@ -1,13 +1,24 @@
 <?php
 // $Id: advanced_forum.module,v 1.45 2008/04/09 03:47:01 michellec Exp $
 
-/*****************************************************************************/
-/******************************** HOOKS **************************************/
-/*****************************************************************************/
+/**
+ * @file
+ *   Advanced Forum is a "glue" module that provides a layer between the core
+ * forum module and all all the various modules that add the functionality
+ * found in stand alone forum software.
+ *
+ * Template files:
+ *   - advf-forum-post - Used to theme forum nodes and comments.
+ *   - advf-forum-user - Used to theme users in forum posts.
+ *   - advf-forums - Wrapper around forum listing.
+ *   - advf-forums-list - Forum listing.
+ *   - advf-forums-submitted - Submitted info for forum list.
+ *
+ */
 
 /**
  * Implementation of hook_perm().
-*/
+ */
 function advanced_forum_perm() {
   return array('administer advanced forum');
 }
@@ -37,14 +48,10 @@ function advanced_forum_menu($may_cache)
   } else {
     advanced_forum_add_css();
   }
-  
+
   return $items;
 }
 
-/*****************************************************************************/
-/************************* SETTINGS PAGE *************************************/
-/*****************************************************************************/
-
 /**
  * Define settings form
  */
@@ -56,22 +63,19 @@ function advanced_forum_settings_page() 
     '#description' => t('Path from site theme directory to advanced forum theme directory. Defaults to "advforum"'),
     '#default_value' => variable_get('advanced_forum_themedir','advforum'),
   );
-  
+
   $form['advanced_forum_theme_all_comments'] = array(
     '#type' => 'radios',
     '#title' => t('Treat all site comments like forum comments'),
     '#options' => array("No","Yes"),
-    '#description' => t('Choosing yes causes advanced forum to consider every comment a forum comment and attempt to theme it that way. Some changes to your theme may be required.'),
+    '#description' => t('Choosing yes causes advanced forum to consider every comment a forum comment and attempt to theme it
+ that way. Some changes to your theme may be required.'),
     '#default_value' => variable_get('advanced_forum_theme_all_comments',0),
   );
 
   // Send our form to Drupal to make a settings page
   return system_settings_form($form);
-} 
-
-/*****************************************************************************/
-/******************* TEMPLATE PREPROCESS *************************************/
-/*****************************************************************************/
+}
 
 /**
  * D5 compatability wrapper for node/comment preprocess functions.
@@ -79,16 +83,53 @@ function advanced_forum_settings_page() 
 function advanced_forum_addvars($hook, $vars) {
   switch ($hook) {
     case 'node':
-      advanced_forum_preprocess_node($vars);
-      break;
     case 'comment':
-      advanced_forum_preprocess_comment($vars);
+      _advanced_forum_load_preprocessors();
+      advanced_forum_call_preprocess($hook, $vars);
       break;
+
   }
 
   return $vars;
 }
 
+/**
+ * Load advanced forum preprocessors on behalf of modules.
+ */
+function _advanced_forum_load_preprocessors() {
+  static $finished = FALSE;
+  if ($finished) {
+    return;
+  }
+  require_once drupal_get_path('module', 'advanced_forum') . '/preprocessor.inc';
+  advanced_forum_include('forum.inc');
+}
+
+/**
+ * Load advanced forum files on behalf of modules.
+ *
+ * Blatent rip of views include system.
+ */
+function advanced_forum_include($file) {
+  $advanced_forum_path = drupal_get_path('module', 'advanced_forum') . '/modules';
+  foreach (module_list() as $module) {
+    $module_path = drupal_get_path('module', $module);
+    if (file_exists("$module_path/$module.$file")) {
+      require_once "./$module_path/$module.$file";
+    }
+    else if (file_exists("$module_path/includes/$module.$file")) {
+      require_once "./$module_path/includes/$module.$file";
+    }
+    else if (file_exists("$advanced_forum_path/$module.$file")) {
+      require_once "./$advanced_forum_path/$module.$file";
+    }
+  }
+}
+
+
+/**
+ * Helper function that adds addition variables for nodes.
+ */
 function advanced_forum_preprocess_node(&$vars) {
   if (_is_forum('node', $vars)) {
     // Use our combined node/comment template file
@@ -98,40 +139,43 @@ function advanced_forum_preprocess_node(
 
     // The node is the first post, aka topic
     $vars['top_post'] = TRUE;
-    
+
     // Node is being shown in the forum (not on the front page or in a view)
     $vars['is_forum'] = TRUE;
-    
+
     if (!empty($vars['node']->links) && !empty($vars['node']->links['comment_add'])) {
       // Change first post from "add comment" to "Reply"
       $vars['node']->links['comment_add']['title'] = t('Reply');
       $vars['links'] = theme('links', $vars['node']->links, array('class' => 'links inline forumlinks'));
-      
+
       // Make a separate variable for the reply link so it can be put on top of the thread
       $reply_link = $vars['node']->links['comment_add'];
       $reply_link['title'] = t("Post Reply");
       $vars['reply_link'] = theme('links', array('topic_reply' => $reply_link), array('class' => 'forumlinks'));
     }
-    
+
     // Make an array version of $links
     $vars['links_array'] = $vars['node']->links;
 
     // User information
     $vars['accountid'] = $vars['node']->uid;
-    $vars['user_info_pane'] = theme('forum_user', $vars['accountid']);   
+    $vars['user_info_pane'] = theme('forum_user', $vars['accountid']);
   }
 }
 
+/**
+ * Helper function that adds addition variables for comments.
+ */
 function advanced_forum_preprocess_comment(&$vars) {
   if (_is_forum('comment', $vars)) {
     // Use our combined node/comment template file
     // D5 won't find templates in subdirectories so we need to give it that
     $forum_theme = advanced_forum_get_forum_theme_directory();
     $vars['template_files'][] = "$forum_theme/advf-forum-post";
-    
+
     // Thread is being shown in the forum (not on the front page or in a view)
     $vars['is_forum'] = TRUE;
-    
+
     // This is a comment, not the node.
     $vars['top_post'] = FALSE;
 
@@ -147,17 +191,17 @@ function advanced_forum_preprocess_comme
       // Assign the subject to the title variable for consistancy with nodes.
       $vars['title'] = check_plain($vars['comment']->subject);
     }
-    
+
     // Just use the date for the submitted on.
     $vars['submitted'] = format_date($vars['comment']->timestamp);
 
     // Assign the comment to the content variable for consistancy with nodes.
     $vars['content'] = $vars['comment']->comment;
-      
+
     // User information
     $vars['accountid'] = $vars['comment']->uid;
     $vars['user_info_pane'] = theme('forum_user', $vars['accountid']);
-             
+
     // Because the $links array isn't available here, we recreate it
     $links = module_invoke_all('link', 'comment', $vars['comment'], 1);
     foreach (module_implements('link_alter') as $module) {
@@ -167,7 +211,7 @@ function advanced_forum_preprocess_comme
     unset($links['comment_parent']);
     $vars['links'] = theme('links', $links, array('class' => 'links forumlinks'));
     $vars['links_array'] = $links;
-    
+
 
     // Comment number with link
     if (!isset($post_number)) {
@@ -177,10 +221,10 @@ function advanced_forum_preprocess_comme
 
     $post_per_page = _comment_get_display_setting('comments_per_page', $vars['node']);
     $page_number = $_GET['page'];
-    if (!$page_number) { 
-      $page_number = 0; 
+    if (!$page_number) {
+      $page_number = 0;
     }
-    
+
     $post_number++;
     $fragment = 'comment-' . $vars['comment']->cid;
     $query = ($page_number) ? 'page=' . $page_number : NULL;
@@ -201,28 +245,33 @@ function advanced_forum_preprocess_comme
 function theme_forum_user($uid = 0) {
   $variables = array();
   $variables['accountid'] = $uid;
-  
+
   // Call our preprocess function to create all the variables
-  template_preprocess_forum_user($variables);
-  
+  advanced_forum_call_preprocess('forum_user', $variables);
+
   $forum_theme =  advanced_forum_get_forum_theme_directory();
-  
+
   // Send the variables to the advf-forum-user.tpl.php
   return _phptemplate_callback("$forum_theme/advf-forum-user", $variables);
 }
 
+/**
+ * Preprocess the forum_user theme hook.
+ *
+ * Inputs: $accountid
+ */
 function template_preprocess_forum_user(&$variables) {
   // The passed in $variables['accountid'] refers to the user who's info is in the pane.
   $accountid = $variables['accountid'];
-  $account = user_load(array('uid' => $accountid));
-  
+  $account = $variables['account'] = user_load(array('uid' => $accountid));
+
   // Get a reference to the currently logged in user.
   global $user;
-  
+
   // Username
   $variables['name_raw'] =  theme('username', $account);
   $variables['name'] =  '<div class="username">' .$variables['name_raw'] . '</div>';
-   
+
   // Avatar
   $variables['picture'] = theme('user_picture', $account);
 
@@ -230,8 +279,8 @@ function template_preprocess_forum_user(
   if ($accountid === 0) {
     return;
   }
-  
-  $themedir =  advanced_forum_get_forum_theme_directory();
+
+  $themedir = advanced_forum_get_forum_theme_directory();
 
   // Join date / since
   $variables['joined_raw'] = format_date($account->created, 'custom', 'Y-m-d');
@@ -239,7 +288,7 @@ function template_preprocess_forum_user(
 
   $variables['member_since_raw'] = format_interval(time() - $account->created);
   $variables['member_since'] = '<div class="account-member-since">' . t('Member since: ') . $variables['member_since_raw'] . '</div>';
-  
+
   // Online status
   if (round((time()-$account->access)/60) < 15) {
     $variables['online_class'] = 'user-online';
@@ -253,98 +302,16 @@ function template_preprocess_forum_user(
     $variables['online_status'] = '<div class="user-offline">' . $variables['online_icon'] . ' ' . $variables['online_text'] . '</div>';
   }
 
-  // Profile
-  if (module_exists('profile')) {
-    $variables['profile'] = profile_view_profile($account);
-  }
-  
-  // Points
-  if (module_exists('userpoints')) {
-    $variables['points_raw'] = userpoints_get_current_points($accountid);
-    $variables['points'] = '<div class="user-points"><strong>' . t('Points: ') . '</strong>' . $variables['points_raw'] . '</div>';
-  }
-
-  // Posts / IP
-  if (module_exists('user_stats')) {
-    $variables['posts_raw'] = user_stats_get_stats('post_count', $accountid);
-    $variables['posts'] = '<div class="user-posts"><strong>' . t('Posts: ') . '</strong>' . $variables['posts_raw'] . '</div>';
-    
-    // IP is only visible if the viewer has access, so do an extra check
-    $ip = user_stats_get_stats('ip_address', $accountid);
-    if (!empty($ip)) {
-      $variables['ip_raw'] = $ip;
-      $variables['ip'] = '<div class="user-ip"><strong>' . t('IP: ') . '</strong>' . $variables['ip_raw'] . '</div>';
-    }
-  }
- 
-  // Title
-  if (module_exists('user_titles')) {
-    $variables['user_title_raw'] = user_titles_get_user_title($accountid);
-    $variables['user_title'] = '<div class="user-title">' . $variables['user_title_raw'] . '</div>';
-  }
-
-  // Badges
-  if (module_exists('user_badges')) {
-    $variables['user_badges_raw'] = user_badges_for_uid($accountid);
-    $variables['user_badges'] = '<div class="user-badges">' . $variables['user_badges_raw'] . '</div>';
-  }
-
   // Contact user
   if (($account->contact) && ($account->uid != $user->uid) && ($user->uid != 0)) {
     $variables['contact_class'] = "contact";
     $variables['contact_icon'] = theme_image(path_to_theme() . '/' . $themedir . "/images/email.png", 'Email', 'Email', NULL, TRUE);
     $variables['contact_text'] = t('Email');
     $variables['contact_link'] = 'user/'. $accountid . '/contact';
-    $variables['contact'] = '<div class="contact">' . 
-                          l($variables['contact_icon'] . ' '  . $variables['contact_text'], $variables['contact_link'], NULL, NULL, NULL, NULL, TRUE) . 
+    $variables['contact'] = '<div class="contact">' .
+                          l($variables['contact_icon'] . ' '  . $variables['contact_text'], $variables['contact_link'], NULL, NULL, NULL, NULL, TRUE) .
                           '</div>';
   }
-           
-  // Send private message
-  if (module_exists('privatemsg') && 
-     ($account->uid != $user->uid) && 
-     user_access('access private messages') && 
-     (isset($account->privatemsg_allow) ? $account->privatemsg_allow : 1)) { 
-    $variables['privatemsg_icon'] = theme_image(path_to_theme() . '/' . $themedir . "/images/user_comment.png", 'Private Message', 'Private Message', NULL, TRUE);
-    $variables['privatemsg_text'] = t('Send PM');
-    $variables['privatemsg_link'] = 'privatemsg/new/'. $accountid;
-    $variables['privatemsg'] = '<div class="privatemsg">' . 
-      l($variables['privatemsg_icon'] . ' '  . 
-      $variables['privatemsg_text'], $variables['privatemsg_link'],NULL,NULL,NULL,NULL,TRUE) . '</div>';
-  }
-
-  // Add / remove from buddylist
-  if (module_exists('buddylist')) {
-  
-    if (user_access('maintain buddy list') && @in_array($accountid, array_keys(buddylist_get_buddies($user->uid)))) {
-      // Remove buddy
-      $variables['buddylist_class'] = "buddy-remove";
-      $variables['buddylist_icon'] = theme_image(path_to_theme() . '/' . $themedir . "/images/group_delete.png", 'Remove Buddy', 'Remove Buddy', NULL, TRUE);
-      $variables['buddylist_text'] = t('Remove buddy');
-      $variables['buddylist_link'] = 'buddy/delete/'. $accountid;
-    } else {
-      // Add buddy
-      if ($accountid != $user->uid && user_access('maintain buddy list')) {
-        $variables['buddylist_class'] = "buddy-add";
-        $variables['buddylist_icon'] = theme_image(path_to_theme() . '/' . $themedir . "/images/group_add.png", 'Add to buddy list', 'Add to buddy list', NULL, TRUE);
-        $variables['buddylist_text'] = t('Add buddy');
-        $variables['buddylist_link'] = 'buddy/add/'. $accountid;
-      }
-    }
-    
-    $variables['buddylist'] = '<div class="' . $variables['buddylist_class'] . '">' . 
-                         l($variables['buddylist_icon'] . ' '  . $variables['buddylist_text'], $variables['buddylist_link'],NULL,NULL,NULL,NULL,TRUE) . 
-                         '</div>';
-  } 
-  // Subscribe to user's posts 
-  // D6 alert: this assumes forum type.
-  if (module_exists('subscriptions')) { 
-    if (user_access('subscribe to content types')) {
-      $variables['subscribe_link'] = "subscriptions/add/type/forum/" . $account->uid;
-      $variables['subscribe'] = l(t("Subscribe"), $variables['subscribe_link'], array('title' => 'Subscribe to forum posts by this user'));
-    }
-  }
-
 }
 
 
@@ -352,8 +319,10 @@ function template_preprocess_forum_user(
 
 /********************** FORUM MODULE THEME OVERRIDES *************************/
 
-// Add in the D6 backports from the forum, taxonomy, and comment modules
-include_once drupal_get_path('module', 'advanced_forum') .'/d6_compat.inc';
+if (!function_exists('_theme_build_registry')) {
+  // Add in the D6 backports from the forum, taxonomy, and comment modules
+  include_once drupal_get_path('module', 'advanced_forum') .'/d6_compat.inc';
+}
 
 /**
  * Implementation of theme_forum_display
@@ -366,7 +335,7 @@ function phptemplate_forum_display($foru
   $variables['tid'] = $tid;
   $variables['sortby'] = $sortby;
   $variables['forum_per_page'] = $forum_per_page;
-   
+
   // Pass the parameters into the D6 preprocess function
   template_preprocess_forums($variables);
 
@@ -418,10 +387,10 @@ function phptemplate_forum_list($forums,
 
   // Pass the parameters into the D6 preprocess function
   template_preprocess_forum_list($variables);
-   
+
   // Pass the parameters into our preprocess function
   advanced_forum_preprocess_forum_list($variables);
-   
+
   // Look for the .tpl file in the theme. If found, use it. If not found, default
   // to the stock forum code and put up a warning.
   $forum_theme = advanced_forum_get_forum_theme_directory();
@@ -442,21 +411,21 @@ function advanced_forum_preprocess_forum
   }
 }
 
-/*
+/**
  * D5 compatability wrapper for theme_forum_submitted.
  * Note: this function does not exist at all in D5's forum.module
  */
 function phptemplate_forum_submitted($topic) {
   // Create a $variables array from the parameters
   $variables['topic'] = $topic;
-   
+
   // Pass the parameters into the D6 preprocess function
   template_preprocess_forum_submitted($variables);
- 
+
   // Pass the parameters into our preprocess function
   advanced_forum_preprocess_forum_submitted($variables);
 
-  // Look for the .tpl file in the theme. If found, use it. If not found, 
+  // Look for the .tpl file in the theme. If found, use it. If not found,
   // just warn because there is no stock code to default to.
   $forum_theme = advanced_forum_get_forum_theme_directory();
   if (file_exists(path_to_theme() . '/' . $forum_theme . "/advf-forum-submitted.tpl.php")) {
@@ -484,13 +453,13 @@ function phptemplate_forum_topic_list($t
   $variables['topics'] = $topics;
   $variables['sortby'] = $sortby;
   $variables['forum_per_page'] = $forum_per_page;
-   
+
   // Pass the parameters into the D6 preprocess function
   template_preprocess_forum_topic_list($variables);
-  
+
   // Pass the parameters into our preprocess function
   advanced_forum_preprocess_forum_topic_list($variables);
-      
+
   // Look for the .tpl file in the theme. If found, use it. If not found, default
   // to the stock forum code and put up a warning.
   $forum_theme = advanced_forum_get_forum_theme_directory();
@@ -506,44 +475,44 @@ function advanced_forum_preprocess_forum
   // Do our own topic processing.
   if (!empty($variables['topics'])) {
     $row = 0;
-      
+
     // Find out how many pages to show on the topic pager. We do this outside
     // the loop because it will be the same for all topics.
     $max_pages_to_display = variable_get('advforum_topic_pager_max', 5);
-    
+
     foreach ($variables['topics'] as $id => $topic) {
-      
+
       // Find the number of comments per page for the node type of the topic.
       // It's the same for all types in D5, but varies in D6.
       $comments_per_page = _comment_get_display_setting('comments_per_page', $topic);
-      
+
       if ($max_pages_to_display > 0 && $topic->num_comments > $comments_per_page) {
         // Topic has more than one page and a pager is wanted. Start off the
         // first page because that doesn't have a query.
         $pager_array = array();
         $current_display_page = 1;
         $pager_array[] = l('1', "node/$topic->nid");
-        
+
         // Find the ending point. The pager URL is always 1 less than
         // the number being displayed because the first page is 0.
         $last_display_page = ceil($topic->num_comments / $comments_per_page);
         $last_pager_page = $last_display_page - 1;
-        
+
         // Add pages until we run out or until we hit the max to show.
         while (($current_display_page < $last_display_page) && ($current_display_page < $max_pages_to_display)) {
           // Move to the next page
           $current_display_page++;
-          
+
           // The page number we link to is 1 less than what's displayed
           $link_to_page = $current_display_page - 1;
-          
+
           // Add the link to the array
           $pager_array[] =  l($current_display_page, "node/$topic->nid", NULL, 'page=' . $link_to_page);
         }
-        
+
         // Move to the next page
         $current_display_page++;
-            
+
         if ($current_display_page == $last_display_page) {
           // We are one past the max to display, but it's the last page,
           // so putting the ...last is silly. Just display it normally.
@@ -558,11 +527,11 @@ function advanced_forum_preprocess_forum
           $text = t('Last Page') . '(' . $last_display_page . ')';
           $pager_last = ' &hellip; ' . l($text, "node/$topic->nid", NULL, 'page=' . $last_pager_page);
         }
-            
+
         // Put it all together
         $variables['topics'][$id]->pager = '[' . t('Page') . ' '. implode(", ", $pager_array) . $pager_last . ']';
       }
-     
+
       // Make shadow copy point to actual thread and tell you new the forum name
       if ($variables['topics'][$id]->moved == TRUE) {
         $term = taxonomy_get_term($topic->tid);
@@ -589,7 +558,7 @@ function phptemplate_forum_icon($new_pos
   $variables['num_posts'] = $num_posts;
   $variables['comment_mode'] = $comment_mode;
   $variables['sticky'] = $sticky;
-   
+
   // Pass the parameters into the D6 preprocess function
   template_preprocess_forum_icon($variables);
 
@@ -619,7 +588,7 @@ function advanced_forum_preprocess_forum
     }
   }
   $variables['iconpath'] = $iconpath;
-  
+
   return;
 }
 
@@ -646,14 +615,14 @@ function advanced_forum_markasread() {
     $sql .= ' AND r.tid = %d';
     $args[] = $tid;
   }
-  
+
   //*D6* Need to change this for all forum types
   $type = 'forum';
   $sql .= ' AND n.type = \'%s\'';
   $args[] = $type;
 
   db_query($sql, $args);
-  
+
   if ($tid) {
     drupal_set_message(t('All topics in forum marked as read'));
     drupal_goto('forum/'.$tid);
@@ -661,7 +630,7 @@ function advanced_forum_markasread() {
     drupal_set_message(t('All forum posts have been marked as read'));
     drupal_goto('forum');
   }
-  
+
   drupal_goto('forum');
 }
 
@@ -671,49 +640,49 @@ function advanced_forum_markasread() {
 function advanced_forum_get_all_last_topics() {
   // Query the info about the latest topic for the given forum
   $query = "
-    SELECT n.title AS topictitle, 
-           r.title AS replytitle, 
-           r.time timestamp, 
-           r.type AS replytype, 
-           n.type AS topictype, 
-           n.nid AS topicid, 
-           t.tid, 
-           r.cid AS cid, 
+    SELECT n.title AS topictitle,
+           r.title AS replytitle,
+           r.time timestamp,
+           r.type AS replytype,
+           n.type AS topictype,
+           n.nid AS topicid,
+           t.tid,
+           r.cid AS cid,
            r.uid,
            u.name
-    FROM {node} AS n 
-    INNER JOIN 
+    FROM {node} AS n
+    INNER JOIN
       (
-        (SELECT title, 
+        (SELECT title,
                 created AS time,
-                nid, 
-                uid, 
-                type, 
-                'cid' AS cid 
+                nid,
+                uid,
+                type,
+                'cid' AS cid
          FROM {node}
          )
-         UNION 
-         (SELECT subject, 
-                  timestamp, 
-                  nid, 
-                  uid, 
-                  'comment', 
-                  cid 
+         UNION
+         (SELECT subject,
+                  timestamp,
+                  nid,
+                  uid,
+                  'comment',
+                  cid
            FROM {comments}
            WHERE {comments}.status = %d
-         ) 
+         )
          ORDER BY time DESC
-      ) AS r ON n.nid=r.nid 
-      INNER JOIN {term_node} AS t ON n.nid = t.nid 
+      ) AS r ON n.nid=r.nid
+      INNER JOIN {term_node} AS t ON n.nid = t.nid
       INNER JOIN {users} AS u ON r.uid = u.uid
-      WHERE n.status = 1 
+      WHERE n.status = 1
       GROUP BY tid;";
 
   $result = db_query($query, COMMENT_PUBLISHED);
   $topics = array();
   while ($topic = db_fetch_object($result)) {
     $topics[$topic->tid] = $topic;
-  }   
+  }
 
   return $topics;
 }
@@ -729,7 +698,7 @@ function _is_forum($hook, $vars) {
   // Setting this static means the check only needs to be done once per page
   // as long as we haven't hit a non forum node on the page
   static $forum_node_id;
-  
+
   switch ($hook) {
     case 'node':
       // Make sure this is a forum node type and that it's not being
@@ -744,7 +713,7 @@ function _is_forum($hook, $vars) {
         unset($forum_node_id);
         return false;
       }
-      
+
     case 'comment':
       if (isset($forum_node_id)) {
         // We already know the node ID of the forum
@@ -762,7 +731,7 @@ function _is_forum($hook, $vars) {
         }
         return false;
       }
-    
+
     default:
       return false;
   }
@@ -774,11 +743,11 @@ function _is_forum($hook, $vars) {
  */
 function _topic_nid($nodeid = 0) {
   static $nid;
-  
+
   if (!empty($nodeid)) {
     $nid = $nodeid;
   }
-  
+
   return $nid;
 }
 
@@ -799,7 +768,7 @@ function advanced_forum_add_css() {
 
   // Load the structural CSS (heights, floats, padding, margins, etc)
   drupal_add_css($csspath . '/advanced_forum-structure.css');
-  
+
   // Add on the colors and graphics part
   drupal_add_css($csspath . '/advanced_forum.css');
 }
Index: preprocessor.inc
===================================================================
RCS file: preprocessor.inc
diff -N preprocessor.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ preprocessor.inc	16 Apr 2008 17:15:25 -0000
@@ -0,0 +1,75 @@
+<?php
+
+
+function advanced_forum_call_preprocess($hook, &$variables) {
+  $functions = advanced_forum_get_preprocess($hook);
+  $args = array(&$variables, $hook);
+  foreach ($functions as $function) {
+    call_user_func_array($function, $args);
+  }
+}
+
+/**
+ *
+ * NOTE - This contains D5 specific cache calls.
+ */
+function advanced_forum_get_preprocess($hook) {
+  static $registry;
+
+  if (!isset($registry)) {
+    // Check the theme registry cache; if it exists, use it.
+    $cache = cache_get("advforum_registry:$name", 'cache');
+    if (isset($cache->data) && $cache->data) {
+      $registry = unserialize($cache->data);
+    }
+    else {
+      // We'll build it below.
+      $registry = array();
+    }
+  }
+
+  // Build our little registry of functions.
+  if (empty($registry) || !isset($registry[$hook])) {
+    // If not, build one and cache it.
+    $registry[$hook] = advanced_forum_build_preprocess($hook);
+    cache_set("advforum_registry:$name", 'cache', serialize($registry));
+  }
+
+  return $registry[$hook];
+}
+
+/**
+ * Invoke our api to provide pluggable preprocessing.
+ *
+ * Part of D5 compatibility. Simplified version of preprocessing calls from D6.
+ *
+ * NOTE - This could conflict with D6 modules for things like node and comment
+ * so we need to provide peppered versions as well.
+ */
+function advanced_forum_build_preprocess($hook) {
+  static $d5;
+  if (!isset($d5)) {
+    $d5 = !function_exists('_theme_build_registry');
+  }
+
+  $return = array();
+  // Default preprocessor prefix.
+  $prefixes[] = 'template';
+  // Add all modules so they can intervene with their own preprocessors. This allows them
+  // to provide preprocess functions even if they are not the owner of the current hook.
+  $prefixes += module_list();
+
+  foreach ($prefixes as $prefix) {
+    if ($d5 && function_exists($prefix .'_preprocess')) {
+      $return[] = $prefix .'_preprocess';
+    }
+    if ($d5 && function_exists($prefix .'_preprocess_'. $hook)) {
+      $return[] = $prefix .'_preprocess_'. $hook;
+    }
+    if (function_exists($prefix .'_preprocess_advforum_'. $hook)) {
+      $return[] = $prefix .'_preprocess_'. $hook;
+    }
+  }
+  return $return;
+}
+
