? modules
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 22:45:23 -0000
@@ -79,16 +79,50 @@ 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";
+    }
+  }
+}
+
 function advanced_forum_preprocess_node(&$vars) {
   if (_is_forum('node', $vars)) {
     // Use our combined node/comment template file
@@ -203,7 +237,7 @@ function theme_forum_user($uid = 0) {
   $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();
   
@@ -214,7 +248,7 @@ function theme_forum_user($uid = 0) {
 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;
@@ -253,42 +287,6 @@ 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";
@@ -299,52 +297,6 @@ function template_preprocess_forum_user(
                           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'));
-    }
-  }
-
 }
 
 
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 22:45:23 -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;
+}
+
