Index: relatedlinks.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/relatedlinks/relatedlinks.info,v
retrieving revision 1.2
diff -u -p -r1.2 relatedlinks.info
--- relatedlinks.info	18 Jun 2007 22:53:56 -0000	1.2
+++ relatedlinks.info	19 May 2008 21:19:11 -0000
@@ -1,3 +1,4 @@
 ; $Id: relatedlinks.info,v 1.2 2007/06/18 22:53:56 dww Exp $
 name = Related Links
-description = Displays links related to content.
+description = Displays links related to content.
+core = 6.x
Index: relatedlinks.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/relatedlinks/relatedlinks.install,v
retrieving revision 1.19
diff -u -p -r1.19 relatedlinks.install
--- relatedlinks.install	26 Feb 2007 17:26:10 -0000	1.19
+++ relatedlinks.install	19 May 2008 21:19:11 -0000
@@ -5,66 +5,21 @@
  * Implementation of hook_install().
  */
 function relatedlinks_install() {
-  $ret = array();
-
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      db_query("CREATE TABLE {relatedlinks} (
-        lid int(11) unsigned NOT NULL auto_increment,
-        nid int(11) unsigned NOT NULL default 0,
-        url varchar(255) NOT NULL default '',
-        title varchar(255) default NULL,
-        type tinyint(4) unsigned NOT NULL default 1,
-        PRIMARY KEY (lid),
-        KEY nid (nid),
-        KEY nid_type (nid, type))
-        COMMENT = 'Relatedlinks module: store manual and parsed links.'
-        /*!40100 default CHARACTER SET utf8 */"
-      );
-      db_query("CREATE TABLE {relatedlinks_tracker} (
-        nid int(11) UNSIGNED NOT NULL,
-        keywords varchar(255) NULL,
-        updated int(11) NOT NULL default 0,
-        PRIMARY KEY (nid),
-        KEY (updated))
-        COMMENT = 'Table keeping track of discovered links.'
-        /*!40100 default CHARACTER SET utf8 */"
-      );
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {relatedlinks} (
-        lid serial,
-        nid integer NOT NULL default 0,
-        url varchar(255) NOT NULL default '',
-        title varchar(255) default NULL,
-        type smallint NOT NULL default 1
-        PRIMARY KEY (lid))"
-      );
-      db_query("CREATE INDEX {relatedlinks}_nid_idx ON {relatedlinks}(nid)");
-      db_query("CREATE INDEX {relatedlinks}_nid_type_idx ON {relatedlinks}(nid, type)");
-      db_query("CREATE TABLE {relatedlinks_tracker} (
-        nid integer NOT NULL default 0,
-        keywords varchar(255) NULL,
-        updated integer NOT NULL default 0
-        PRIMARY KEY (nid))"
-      );
-      db_query("CREATE INDEX {relatedlinks_tracker}_updated_idx ON {relatedlinks_tracker}(updated)");
-  }
-  drupal_set_message(t('The relatedlinks module installation script has completed.'));
   if (!module_exists('taxonomy') && !module_exists('search')) {
     drupal_set_message(t('The discovered links feature of the relatedlinks module requires one of the following modules:
 <ul>
   <li>Taxonomy</li>
   <li>Search</li>
 </ul>'));
+    return;
   }
-  
-  return $ret;
+
+  // Create tables.
+  drupal_install_schema('relatedlinks');
 }
 
 /**
- * Convert existing variables from strings to internal constants used in the 
+ * Convert existing variables from strings to internal constants used in the
  * module.
  */
 function relatedlinks_update_2() {
@@ -99,25 +54,13 @@ function relatedlinks_update_2() {
 function relatedlinks_update_3() {
   $ret = array();
 
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      $ret[] = update_sql("ALTER TABLE {relatedlinks} ADD lid int(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
-      $ret[] = update_sql("ALTER TABLE {relatedlinks} CHANGE link url varchar(255) NOT NULL default ''");
-      $ret[] = update_sql("ALTER TABLE {relatedlinks} ADD title varchar(255) DEFAULT NULL AFTER url");
-      // nid and type are UNSIGNED fields.
-      $ret[] = update_sql("ALTER TABLE {relatedlinks} CHANGE nid nid int(11) UNSIGNED NOT NULL DEFAULT 0");
-      $ret[] = update_sql("ALTER TABLE {relatedlinks} CHANGE type type tinyint(4) UNSIGNED NOT NULL DEFAULT 1");
-      $ret[] = update_sql("ALTER TABLE {relatedlinks} ADD INDEX nid_type (nid, type)");
-      break;
-    case 'pgsql':
-      // Needs testing. Field ordering needs to be added.
-      db_add_column($ret, 'relatedlinks', 'lid', 'serial');
-      db_change_column($ret, 'relatedlinks', 'link', 'url', 'varchar(255)', array('default' => "''", 'not null' => TRUE));
-      db_add_column($ret, 'relatedlinks', 'title', 'varchar(255)', array('default' => "NULL"));
-      $ret[] = update_sql("CREATE INDEX {relatedlinks}_nid_type_idx ON {relatedlinks}(nid, type)");
-      break;
-  }
+  db_drop_primary_key($ret, 'relatedlinks');
+  db_add_field($ret, 'relatedlinks', 'lid', array('type' => 'serial', 'size' => 'tiny', 'not null' => TRUE));
+  db_change_field($ret, 'relatedlinks', 'link', 'url', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
+  db_add_field($ret, 'relatedlinks', 'title', array('type' => 'varchar', 'length' => '255', 'default' => NULL));
+  db_change_field($ret, 'relatedlinks', 'nid', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
+  db_change_field($ret, 'relatedlinks', 'type', array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1));
+  db_add_index($ret, 'relatedlinks', 'nid_type', array('nid', 'type'));
 
   $result = db_query("SELECT * FROM {relatedlinks}");
   while ($link = db_fetch_array($result)) {
@@ -127,7 +70,7 @@ function relatedlinks_update_3() {
       db_query("UPDATE {relatedlinks} SET url = '%s', title = '%s' WHERE lid = %d", $matches[1], trim($matches[3]), $link['lid']);
     }
   }
-  
+
   return $ret;
 }
 
@@ -137,29 +80,31 @@ function relatedlinks_update_3() {
 function relatedlinks_update_4() {
   $ret = array();
 
-  switch ($GLOBALS['db_type']) {
-    case 'mysqli':
-    case 'mysql':
-      $ret[] = update_sql("CREATE TABLE {relatedlinks_tracker} (
-        nid int(11) UNSIGNED NOT NULL,
-        keywords varchar(255) NULL,
-        updated int(11) NOT NULL default 0,
-        PRIMARY KEY (nid),
-        KEY (updated))
-        COMMENT = 'Table keeping track of discovered links.'
-        /*!40100 default CHARACTER SET utf8 */"
-      );
-      break;
-    case 'pgsql':
-      $ret[] = update_sql("CREATE TABLE {relatedlinks_tracker} (
-        nid integer NOT NULL default 0,
-        keywords varchar(255) NULL,
-        updated integer NOT NULL default 0
-        PRIMARY KEY (nid))"
-      );
-      $ret[] = update_sql("CREATE INDEX {relatedlinks_tracker}_updated_idx ON {relatedlinks_tracker}(updated)");
-  }
+  $schema['relatedlinks_tracker'] = array(
+    'description' => t('Table keeping track of discovered links.'),
+    'fields' => array(
+      'nid' => array(
+        'type' => 'serial',
+        'size' => 'tiny',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'keywords' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => FALSE),
+      'updated' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 0),
+    ),
+    'indexes' => array(
+      'updated' => array('updated'),
+    ),
+    'primary key' => array('nid'),
+  );
 
+  db_create_table($ret, 'relatedlinks_tracker', $schema);
   $ret[] = update_sql("INSERT INTO {relatedlinks_tracker} (nid) SELECT DISTINCT(nid) FROM {relatedlinks}");
 
   return $ret;
@@ -169,7 +114,77 @@ function relatedlinks_update_4() {
  * Implementation of hook_uninstall().
  */
 function relatedlinks_uninstall() {
-  db_query('DROP TABLE {relatedlinks_tracker}, {relatedlinks}');
+  $ret = array();
+  db_drop_table($ret, 'relatedlinks');
+  db_drop_table($ret, 'relatedlinks_tracker');
   variable_del('relatedlinks_types');
   variable_del('relatedlinks_node_types');
 }
+
+/**
+ * Implementation of hook_schema().
+ */
+function relatedlinks_schema() {
+  $schema['relatedlinks'] = array(
+    'description' => t('Relatedlinks module: store manual and parsed links.'),
+    'fields' => array(
+      'lid' => array(
+        'type' => 'serial',
+        'size' => 'tiny',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'nid' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'unsigned' => TRUE,
+        'default' => 0),
+      'url' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => ''),
+      'title' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => FALSE,
+        'default' => NULL),
+      'type' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+         'default' => 1),
+    ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      'nid_type' => array('nid', 'type'),
+    ),
+    'primary key' => array('lid'),
+  );
+  
+  $schema['relatedlinks_tracker'] = array(
+    'description' => t('Table keeping track of discovered links.'),
+    'fields' => array(
+      'nid' => array(
+        'type' => 'serial',
+        'size' => 'tiny',
+        'unsigned' => TRUE,
+        'not null' => TRUE),
+      'keywords' => array(
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => FALSE),
+      'updated' => array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => TRUE,
+        'default' => 0),
+    ),
+    'indexes' => array(
+      'updated' => array('updated'),
+    ),
+    'primary key' => array('nid'),
+  );
+
+  return $schema;
+}
Index: relatedlinks.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/relatedlinks/relatedlinks.module,v
retrieving revision 1.58.2.5
diff -u -p -r1.58.2.5 relatedlinks.module
--- relatedlinks.module	9 May 2008 06:23:59 -0000	1.58.2.5
+++ relatedlinks.module	19 May 2008 21:19:11 -0000
@@ -26,8 +26,8 @@ define('RELATEDLINKS_DISCOVERED', 3);
 /**
  * Implementation of hook_help().
  */
-function relatedlinks_help($section) {
-  switch ($section) {
+function relatedlinks_help($path, $arg) {
+  switch ($path) {
     case 'admin/settings/relatedlinks':
       return t('Select the types of links to store and display.');
     case 'admin/settings/relatedlinks/discovered':
@@ -57,45 +57,37 @@ Links:
 /**
  * Implementation of hook_menu().
  */
-function relatedlinks_menu($may_cache) {
+function relatedlinks_menu() {
   $items = array();
 
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/relatedlinks',
-      'title' => t('Related links'),
-      'description' => t('Configure related links settings.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('_relatedlinks_settings_form'),
-      'access' => user_access('administer related links')
-    );
-    $items[] = array(
-      'path' => 'admin/settings/relatedlinks/configure',
-      'title' => t('Settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('_relatedlinks_settings_form'),
-      'access' => user_access('administer related links'),
-      'type' => MENU_DEFAULT_LOCAL_TASK
-    );
-    $items[] = array(
-      'path' => 'admin/settings/relatedlinks/discovered',
-      'title' => t('Discovered links'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('_relatedlinks_discovered_settings_form'),
-      'access' => user_access('administer related links'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 2
-    );
-  }
-  else {
-    $items[] = array(
-      'path' => 'relatedlinks/autocomplete',
-      'callback' => 'relatedlinks_autocomplete',
-      'callback arguments' => array(arg(2)),
-      'access' => user_access('add related links'),
-      'type' => MENU_CALLBACK
-    );
-  }
+  $items['admin/settings/relatedlinks'] = array(
+    'title' => 'Related links',
+    'description' => 'Configure related links settings.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('_relatedlinks_settings_form'),
+    'access arguments' => array('administer related links')
+  );
+  $items['admin/settings/relatedlinks/configure'] = array(
+    'title' => 'Settings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('_relatedlinks_settings_form'),
+    'access arguments' => array('administer related links'),
+    'type' => MENU_DEFAULT_LOCAL_TASK
+  );
+  $items['admin/settings/relatedlinks/discovered'] = array(
+    'title' => 'Discovered links',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('_relatedlinks_discovered_settings_form'),
+    'access arguments' => array('administer related links'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 2
+  );
+  $items['relatedlinks/autocomplete'] = array(
+    'page callback' => 'relatedlinks_autocomplete',
+    'page arguments' => array(arg(2)),
+    'access arguments' => array('add related links'),
+    'type' => MENU_CALLBACK
+  );
 
   return $items;
 }
@@ -132,7 +124,7 @@ function relatedlinks_block($op = 'list'
       // This is only valid if we're looking at a node now.
       if (arg(0) == 'node' && is_numeric(arg(1))) {
         $block = array();
-        $node = node_load(arg(1));
+        $node = menu_get_object();
         // Only display if node type is associated with this module.
         if ($node && in_array($node->type, variable_get('relatedlinks_node_types', _relatedlinks_node_get_types(TRUE)))) {
           $link_types = variable_get('relatedlinks_types', _relatedlinks_get_type_defaults());
@@ -248,7 +240,7 @@ function relatedlinks_nodeapi(&$node, $o
 /**
  * Implementation of hook_form_alter().
  */
-function relatedlinks_form_alter($form_id, &$form) {
+function relatedlinks_form_alter(&$form, $form_state, $form_id) {
   if (user_access('add related links') && isset($form['type']) &&
     ($form['type']['#value'] .'_node_form' == $form_id)) {
 
@@ -325,7 +317,7 @@ function relatedlinks_cron() {
   if (_relatedlinks_get_type_property(RELATEDLINKS_DISCOVERED, 'enabled') && $discovered['cron']) {
     $updated = time() - ($discovered['cron'] * 24 * 60 * 60);
     // Select all stale nodes.
-    $result = db_query("SELECT nid FROM {relatedlinks_tracker} WHERE updated != 0 AND updated < %d", $updated);
+    $result = db_query("SELECT nid FROM {relatedlinks_tracker} WHERE updated <> 0 AND updated < %d", $updated);
     $nids = array();
     while ($node = db_fetch_array($result)) {
       $nids[] = $node['nid'];
@@ -425,21 +417,21 @@ Related links blocks and forms will only
 /**
  * Process relatedlinks settings form submissions.
  */
-function _relatedlinks_settings_form_submit($form_id, $form_values) {
+function _relatedlinks_settings_form_submit($form, &$form_state) {
   // Sort on 'weight'.
-  uasort($form_values['relatedlinks_types'], '_relatedlinks_compare');
+  uasort($form_state['values']['relatedlinks_types'], '_relatedlinks_compare');
 
   // Store the entire relatedlinks_types table.
-  variable_set('relatedlinks_types', $form_values['relatedlinks_types']);
+  variable_set('relatedlinks_types', $form_state['values']['relatedlinks_types']);
 
-  $node_types = array_filter($form_values['relatedlinks_node_types']);
+  $node_types = array_filter($form_state['values']['relatedlinks_node_types']);
   variable_set('relatedlinks_node_types', array_keys($node_types));
 
   // Block table needs to be reset.
   _block_rehash();
   cache_clear_all();
 
-  drupal_set_message(t('Configuration settings saved. If necessary, relatedlinks 
+  drupal_set_message(t('Configuration settings saved. If necessary, relatedlinks
 blocks can be configured via the <a href="!block-page">block configuration</a> page.', array('!block-page' => url('admin/build/block'))));
 }
 
@@ -548,7 +540,7 @@ that they be periodically purged and rec
   $form['relatedlinks_discovered']['cron']['refresh'] = array(
     '#type' => 'select',
     '#title' => t('Automatically update discovered links older than'),
-    '#description' => t('This feature requires <a href="!cron">cron</a> to be enabled.', array('!cron' => url('admin/logs/status'))),
+    '#description' => t('This feature requires <a href="!cron">cron</a> to be enabled.', array('!cron' => url('admin/reports/status'))),
     '#parents' => array('relatedlinks_discovered', 'cron'),
     '#options' => array(
       1 => t('One day'),
@@ -568,17 +560,17 @@ that they be periodically purged and rec
 /**
  * Validate discovered links settings form submissions.
  */
-function _relatedlinks_discovered_settings_form_validate($form_id, $form_values) {
-  if ($form_values['relatedlinks_discovered']['ranking']['taxonomy'] === $form_values['relatedlinks_discovered']['ranking']['search'] && 
-    $form_values['relatedlinks_discovered']['ranking']['taxonomy'] === 0) {
+function _relatedlinks_discovered_settings_form_validate($form, &$form_state) {
+  if ($form_state['values']['relatedlinks_discovered']['ranking']['taxonomy'] === $form_state['values']['relatedlinks_discovered']['ranking']['search'] &&
+    $form_state['values']['relatedlinks_discovered']['ranking']['taxonomy'] === 0) {
 
     $error = t('The discovered links feature requires either taxonomy or search results to be enabled.');
     form_set_error('relatedlinks_discovered][criteria][ranking', $error);
   }
-  if ($form_values['relatedlinks_discovered']['ranking']['taxonomy'] === 'taxonomy' && !module_exists('taxonomy')) {
+  if ($form_state['values']['relatedlinks_discovered']['ranking']['taxonomy'] === 'taxonomy' && !module_exists('taxonomy')) {
     form_set_error('relatedlinks_discovered][criteria][ranking', t('The taxonomy module needs to be enabled for taxonomy results to be calculated.'));
   }
-  if ($form_values['relatedlinks_discovered']['ranking']['search'] === 'search' && !module_exists('search')) {
+  if ($form_state['values']['relatedlinks_discovered']['ranking']['search'] === 'search' && !module_exists('search')) {
     form_set_error('relatedlinks_discovered][criteria][ranking', t('The search module needs to be enabled for taxonomy results to be calculated.'));
   }
 }
@@ -586,16 +578,16 @@ function _relatedlinks_discovered_settin
 /**
  * Process discovered links settings form submissions.
  */
-function _relatedlinks_discovered_settings_form_submit($form_id, $form_values) {
+function _relatedlinks_discovered_settings_form_submit($form, &$form_state) {
   $indices = array('ranking', 'vocabularies', 'node_types');
   foreach ($indices as $index) {
-    if (isset($form_values['relatedlinks_discovered'][$index])) {
-      $form_values['relatedlinks_discovered'][$index] = array_filter($form_values['relatedlinks_discovered'][$index]);
-      $form_values['relatedlinks_discovered'][$index] = array_keys($form_values['relatedlinks_discovered'][$index]);
+    if (isset($form_state['values']['relatedlinks_discovered'][$index])) {
+      $form_state['values']['relatedlinks_discovered'][$index] = array_filter($form_state['values']['relatedlinks_discovered'][$index]);
+      $form_state['values']['relatedlinks_discovered'][$index] = array_keys($form_state['values']['relatedlinks_discovered'][$index]);
     }
   }
 
-  variable_set('relatedlinks_discovered', $form_values['relatedlinks_discovered']);
+  variable_set('relatedlinks_discovered', $form_state['values']['relatedlinks_discovered']);
 }
 
 /**
@@ -1164,14 +1156,23 @@ function _relatedlinks_node_candidates($
 }
 
 /**
+ * Implementation of hook_theme().
+ */
+function relatedlinks_theme() {
+  return array(
+    'relatedlinks_types_table' => array('form' => NULL),
+  );
+}
+
+/**
  * Theme the related links configuration table.
- * 
+ *
  * @param $form
  *   The configuration form to theme.
- * 
+ *
  * @return
  *   A themed table of configuration settings.
- * 
+ *
  * @todo
  *   Get rid of the inline styles.
  */
