Index: tracker2.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tracker2/tracker2.info,v
retrieving revision 1.9
diff -u -p -r1.9 tracker2.info
--- tracker2.info	1 Apr 2008 15:56:29 -0000	1.9
+++ tracker2.info	24 Oct 2008 21:37:15 -0000
@@ -1,4 +1,5 @@
 ; $Id: tracker2.info,v 1.9 2008/04/01 15:56:29 straussd Exp $
 name = Tracker 2
 description = Enables tracking of recent posts for users.
-dependencies = comment
+dependencies[] = comment
+core = 6.x
Index: tracker2.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tracker2/tracker2.install,v
retrieving revision 1.8
diff -u -p -r1.8 tracker2.install
--- tracker2.install	1 Apr 2008 15:56:29 -0000	1.8
+++ tracker2.install	24 Oct 2008 21:39:36 -0000
@@ -2,70 +2,21 @@
 
 // $Id: tracker2.install,v 1.8 2008/04/01 15:56:29 straussd Exp $
 
-function tracker2_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE IF NOT EXISTS {tracker2_node} (
-        nid int(10) unsigned NOT NULL,
-        published tinyint(1) NOT NULL,
-        changed int(10) unsigned NOT NULL,
-        PRIMARY KEY  (nid),
-        KEY tracker (published,changed)
-      )");
-        
-      db_query("CREATE TABLE IF NOT EXISTS {tracker2_user} (
-        nid int(10) unsigned NOT NULL,
-        published tinyint(1) NOT NULL,
-        uid int(10) unsigned NOT NULL,
-        changed int(10) unsigned NOT NULL,
-        PRIMARY KEY  (nid,uid),
-        KEY tracker (uid,published,changed)
-      )");
-    
-      db_query('ALTER TABLE {comments} ADD INDEX tracker_changed (nid, status, timestamp)');
-      db_query('ALTER TABLE {comments} ADD INDEX tracker_subscription (uid, nid, status)');
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {tracker2_node} (
-        nid int_unsigned NOT NULL,
-        published smallint NOT NULL,
-        changed int_unsigned NOT NULL,
-        PRIMARY KEY  (nid)
-      )");
-      db_query('CREATE INDEX {tracker2_node}_tracker_idx ON {tracker2_node} (published, changed)');
-    
-      db_query("CREATE TABLE {tracker2_user} (
-        nid int_unsigned NOT NULL,
-        published smallint NOT NULL,
-        uid int_unsigned NOT NULL,
-        changed int_unsigned NOT NULL,
-        PRIMARY KEY  (nid, uid)
-      )");
-      db_query('CREATE INDEX {tracker2_user}_tracker_idx ON {tracker2_user} (uid, published, changed)');
+  
+/**
+ * @file
+ * The (un)install and update code for the tracker2 module.
+ *
+ * @ingroup tracker2
+ */
 
-      db_query('CREATE INDEX {comments}_tracker_changed_idx ON {comments} (nid, status, timestamp)');
-      db_query('CREATE INDEX {comments}_tracker_subscription_idx ON {comments} (uid, nid, status)');
-      break;
-  }
+function tracker2_install() {
+  drupal_install_schema('tracker2');
+  tracker2_update_6001();
 }
 
 function tracker2_uninstall() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query('DROP TABLE IF EXISTS {tracker2_node}');
-      db_query('DROP TABLE IF EXISTS {tracker2_user}');
-      db_query('ALTER TABLE {comments} DROP INDEX tracker_changed');
-      db_query('ALTER TABLE {comments} DROP INDEX tracker_subscription');
-      break;
-    case 'pgsql':
-      db_query('DROP TABLE {tracker2_node}');
-      db_query('DROP TABLE {tracker2_user}');
-      db_query('DROP INDEX {comments}_tracker_changed_idx');
-      db_query('DROP INDEX {comments}_tracker_subscription_idx');
-      break;
-  }
+  drupal_uninstall_schema('tracker2');
   variable_del('tracker2_index_nid');
 }
 
@@ -75,10 +26,73 @@ function tracker2_enable() {
   drupal_set_message(t('Tracker will index from node %nid downward.', array('%nid' => $max_nid)));
 }
 
-function tracker2_update_1() {
+function tracker2_update_6001() {
   $ret = array();
-  $ret[] = update_sql('ALTER TABLE {comments} DROP INDEX tracker');
-  $ret[] = update_sql('ALTER TABLE {comments} ADD INDEX tracker_changed (nid, status, timestamp)');
-  $ret[] = update_sql('ALTER TABLE {comments} ADD INDEX tracker_subscription (uid, nid, status)');
+  db_drop_index($ret,'comments','tracker');
+  db_add_index($ret,'comments','tracker_changed',array('nid','status','timestamp'));
+  db_add_index($ret,'comments','tracker_subscription',array('uid','nid','status'));
   return $ret;
 }
+
+function tracker2_schema() {
+  $schema['tracker2_node'] = array(
+    'description' => t('Track changes to content'),
+    'fields' => array(
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t("{node}.nid"),
+      ),
+      'published' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'description' => t("True if {node}.status == 1"),
+      ),
+      'changed' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t("{node}.changed"),
+      ),
+    ),
+    'primary key' => array('nid'),
+    'indexes' => array(
+      'tracker' => array('published','changed'),
+    ),
+  );
+  $schema['tracker2_user'] = array(
+    'fields' => array(
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t("{node}.nid"),
+      ),
+      'uid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t("{user}.uid"),
+      ),
+      'published' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'description' => t("True if {node}.status == 1"),
+      ),
+      'changed' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'description' => t("{node}.changed"),
+      ),
+    ),
+    'primary key' => array('nid','uid'),
+    'indexes' => array(
+      'tracker' => array('uid','published','changed'),
+    ),
+  );
+  return $schema;
+}
Index: tracker2.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tracker2/tracker2.module,v
retrieving revision 1.13
diff -u -p -r1.13 tracker2.module
--- tracker2.module	2 Jun 2008 04:06:49 -0000	1.13
+++ tracker2.module	24 Oct 2008 21:20:59 -0000
@@ -1,11 +1,27 @@
 <?php
 
 // $Id: tracker2.module,v 1.13 2008/06/02 04:06:49 straussd Exp $
+  
+/**
+ * @file
+ * Enables tracking of recent posts for users.
+ */
+
+/**
+ * Implementation of hook_help().
+ */
+function tracker2_help($path, $arg) {
+  switch ($path) {
+    case 'admin/help#tracker2':
+      $output = '<p>'. t('The Tracker2 module is a much more efficient tracker that maintains seperate database tables of updated items.') .'</p>';
+      return $output;
+  }
+}
 
 /**
  * Implementation of hook_menu().
  */
-function tracker2_menu($may_cache) {
+function tracker2_menu() {	//in progress
   global $user;
   $items = array();
 
@@ -16,58 +32,64 @@ function tracker2_menu($may_cache) {
     $user_base = 'track';
   }
 
-  if ($may_cache) {
-    $items[] = array(
-      'path' => $base,
-      'title' => t('Recent posts'),
-      'callback' => 'tracker2_page',
-      'access' => user_access('access content'),
+    $items[$base] = array(
+      'title' => 'Recent posts',
+      'page callback' => 'tracker2_page',
+      'access arguments' => array('access content'),
       'weight' => 1,
     );
 
-    if ($user->uid) {
-      $items[] = array(
-        'path' => $base . '/all',
-        'title' => t('All recent posts'),
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-      );
-      $items[] = array(
-        'path' => $base . '/'. $user->uid,
-        'title' => t('My recent posts'),
-        'type' => MENU_LOCAL_TASK,
-      );
-    }
+	$items[$base.'/all'] = array(
+	  'title' => 'All recent posts',
+	  'type' => MENU_DEFAULT_LOCAL_TASK,
+	);
+	$items[$base . '/%user_uid_optional'] = array(
+	  'title' => 'My recent posts',
+	  'access callback' => '_tracker2_myrecent_access',
+	  'access arguments' => array(1),
+	  'page arguments' => array(1),
+	  'type' => MENU_LOCAL_TASK,
+	);
     
-    $items[] = array(
-      'path' => 'admin/settings/tracker2',
+    $items['admin/settings/tracker2'] = array(
       'title' => 'Tracker 2',
-      'description' => t('High-performance reimplementation of the Tracker module.'),
-      'callback' => 'drupal_get_form',
-      'access' => user_access('administer tracker'),
-      'callback arguments' => array('tracker2_admin_settings')
+      'description' => 'High-performance reimplementation of the Tracker module.',
+      'page callback' => 'drupal_get_form',
+      'access arguments' => array('administer tracker'),
+      'page arguments' => array('tracker2_admin_settings')
+    );
+
+    $items['user/%user/'.$user_base] = array(
+      'title' => 'Track',
+      'page callback' => 'tracker2_track_user',
+      'access arguments' => array('access content'),
+      'type' => MENU_LOCAL_TASK,
+    );
+    $items['user/%user/'.$user_base.'/posts'] = array(
+      'title' => 'Track posts',
+      'type' => MENU_DEFAULT_LOCAL_TASK,
     );
-  }
-  else {
-    if (arg(0) == 'user' && is_numeric(arg(1))) {
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/' . $user_base,
-        'title' => t('Track'),
-        'callback' => 'tracker2_track_user',
-        'access' => user_access('access content'),
-        'type' => MENU_IS_LOCAL_TASK
-      );
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/' . $user_base . '/posts',
-        'title' => t('Track posts'),
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-      );
-    }
-  }
 
   return $items;
 }
 
 /**
+ * Access callback for tracker/%user_uid_optional
+ */
+function _tracker2_myrecent_access($account) {
+  // This path is only allowed for authenticated users looking at their own posts.
+  return $account->uid && ($GLOBALS['user']->uid == $account->uid) && user_access('access content');
+}
+
+/**
+ * Access callback for user/%user/track
+ */
+function _tracker2_user_access($account) {
+  return user_view_access($account) && user_access('access content');
+}
+
+
+/**
  * Implementation of hook_perm().
  */
 function tracker2_perm() {
@@ -84,11 +106,13 @@ function tracker2_admin_settings() {
   
   if ($max_nid) {
     $form['max_nid'] = array(
+      '#type' => 'value',
       '#value' => t('Max node ID for indexing on the next cron run: @max', array('@max' => $max_nid)),
     );
   }
   else {
     $form['max_nid'] = array(
+      '#type' => 'value',
       '#value' => t('Existing nodes have finished tracker indexing.'),
     );
   }
@@ -145,7 +169,7 @@ function tracker2_cron() {
       // Prepare a starting point for the next run
       variable_set('tracker2_index_nid', $last_nid - 1);
       
-      watchdog('tracker2', t('Indexed %count nodes for tracking.', array('%count' => $count)));
+      watchdog('tracker2', 'Indexed %count nodes for tracking.', array('%count' => $count));
     }
     else {
       // If all nodes have been indexed, set to zero to skip future cron runs
@@ -157,7 +181,7 @@ function tracker2_cron() {
 /**
  * Implementation of hook_form_alter().
  */
-function tracker2_form_alter($form_id, &$form) {
+function tracker2_form_alter(&$form, $form_state, $form_id) {
   if ($form_id == 'node_admin_nodes') {
     $form['#submit']['tracker2_batch_node_alter'] = array();
   }
@@ -265,7 +289,7 @@ function _tracker2_remove($nid, $uid = N
 /**
  * Implementation of hook_nodeapi().
  */
-function tracker2_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+function tracker2_nodeapi(&$node, $op) {
   if ($op == 'insert' || $op == 'update') {
     _tracker2_add($node->nid, $node->uid, $node->changed);
   }
