? .svn
? 266682_statistics.patch
? 321590_term_description.patch
? modules/.svn
? po/.svn
? styles/.svn
? styles/blue_lagoon/.svn
? styles/blue_lagoon/images/.svn
? styles/naked/.svn
? styles/naked/images/.svn
? styles/naked_stacked/.svn
? styles/naked_stacked/images/.svn
Index: advanced_forum.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advanced_forum/advanced_forum.module,v
retrieving revision 1.103
diff -u -p -r1.103 advanced_forum.module
--- advanced_forum.module	8 Oct 2008 02:54:54 -0000	1.103
+++ advanced_forum.module	15 Oct 2008 16:30:06 -0000
@@ -734,6 +734,20 @@ function advanced_forum_preprocess_forum
       $variables['container_description'] = $variables['parents']['0']->description;
     }
   }
+
+  $variables['topics'] = advanced_forum_statistics_topics();
+  $variables['posts'] = advanced_forum_statistics_comments() + $variables['topics'];
+  $variables['users'] = advanced_forum_statistics_users();
+
+  $authenticated_users = advanced_forum_statistics_online_users();
+  $variables['online_users'] = implode(', ', $authenticated_users);
+  $variables['current_users'] = count($authenticated_users);
+  $variables['current_guests'] = sess_count(time() - variable_get('user_block_seconds_online', 900));
+  $variables['current_total'] = $variables['current_users'] + $variables['current_guests'];
+
+  $latest_user = advanced_forum_statistics_latest_user();
+  $variables['latest_user_name'] = $latest_user['name'];
+  $variables['latest_user_id'] = $latest_user['uid'];
 }
 
 /**
@@ -1331,3 +1345,46 @@ function advanced_forum_drupal_adds() {
   drupal_add_css("$style_directory/advanced_forum-structure.css" );
   drupal_add_css("$style_directory/advanced_forum.css" );
 }
+
+// STATISTICS ****************************************************************/
+
+/**
+ * Count total amount of forum threads.
+ */
+function advanced_forum_statistics_topics() {
+  return db_result(db_query('SELECT COUNT(DISTINCT(nid)) FROM {forum}'));
+}
+
+/**
+ * Count total amount of comments on forum threads.
+ */
+function advanced_forum_statistics_comments() {
+  return db_result(db_query('SELECT COUNT(cid) FROM {comments} c INNER JOIN {forum} f ON (f.nid = c.nid)'));
+}
+
+/**
+ * Count total amount of active users.
+ */
+function advanced_forum_statistics_users() {
+  return db_result(db_query('SELECT COUNT(uid) FROM {users} WHERE status = 1'));
+}
+
+/**
+ * Return the latest active user.
+ */
+function advanced_forum_statistics_latest_user() {
+  return db_fetch_array(db_query('SELECT uid, name FROM {users} WHERE status = 1 ORDER BY created DESC'));
+}
+
+/**
+ * Return an array of online usernames, linked to their profiles.
+ */
+function advanced_forum_statistics_online_users() {
+  $interval = time() - variable_get('user_block_seconds_online', 900);
+  $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
+  while ($account = db_fetch_object($authenticated_users)) {
+    $list[] = l($account->name, 'user/' . $account->uid);
+  }
+  return $list;
+}
+
Index: styles/naked/advanced_forum.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advanced_forum/styles/naked/advanced_forum.css,v
retrieving revision 1.11
diff -u -p -r1.11 advanced_forum.css
--- styles/naked/advanced_forum.css	2 Oct 2008 04:19:17 -0000	1.11
+++ styles/naked/advanced_forum.css	15 Oct 2008 16:30:06 -0000
@@ -82,4 +82,28 @@ see advanced_forum-structure.css.
 /* Signature */
 .author-signature {
   font-size: .8em;
-}
\ No newline at end of file
+}
+
+/*** FORUM STATISTICS *********************************************************/
+
+#forum-statistics {
+  border: 1px solid #242021;
+}
+
+#forum-statistics-header,
+.forum-statistics-sub-header,
+.forum-statistics-sub-body {
+  padding: 0.3em 0.5em;
+}
+
+#forum-statistics-header {
+  background-color: #242021;
+  color: #494949;
+  font-weight: bold;
+}
+
+.forum-statistics-sub-header {
+  background-color: #cccccc;
+  color: #455067;
+  font-weight: bold;
+}
Index: styles/naked/advf-forum-list.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advanced_forum/styles/naked/advf-forum-list.tpl.php,v
retrieving revision 1.15
diff -u -p -r1.15 advf-forum-list.tpl.php
--- styles/naked/advf-forum-list.tpl.php	9 Oct 2008 04:00:27 -0000	1.15
+++ styles/naked/advf-forum-list.tpl.php	15 Oct 2008 16:30:07 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: advf-forum-list.tpl.php,v 1.15 2008/10/09 04:00:27 michellec Exp $
+// $Id: advf-forum-list.tpl.php,v 1.13 2008/10/02 04:19:17 michellec Exp $
 
 /**
  * @file advf-forum-list.tpl.php
@@ -102,3 +102,24 @@
     <?php endforeach; ?>
   </tbody>
 </table>
+
+<div id="forum-statistics">
+  <div id="forum-statistics-header"><?php print t('What\'s Going On?'); ?></div>
+
+  <div id="forum-statistics-active-header" class="forum-statistics-sub-header">
+    <?php print t('Currently active users: !current_total (!current_users users and !current_guests guests)', array('!current_total' => $current_total, '!current_users' => $current_users, '!current_guests' => $current_guests)); ?>
+  </div>
+
+  <div id="forum-statistics-active-body" class="forum-statistics-sub-body">
+    <?php print $online_users; ?>
+  </div>
+
+  <div id="forum-statistics-statistics-header" class="forum-statistics-sub-header">
+    <?php print t('Statistics'); ?>
+  </div>
+
+  <div id="forum-statistics-statistics-body" class="forum-statistics-sub-body">
+    <?php print t('Topics: !topics, Posts: !posts, Users: !users', array('!topics' => $topics, '!posts' => $posts, '!users' => $users)); ?>
+    <br /><?php print t('Welcome to our latest member, !user', array('!user' => l($latest_user_name, 'user/' . $latest_user_id))); ?>
+  </div>
+</div>
\ No newline at end of file
