--- yahoo_terms.module
+++ (clipboard)
@@ -1,4 +1,5 @@
 <?php
+// $Id$
 /**
  * @file
  * Provides an interface to other modules to use Yahoo Term Extractor service
@@ -7,7 +8,7 @@
  *
  * @author
  * Aron Novak <aron at novaak dot net>
- * 
+ *
  */
 
 /**
@@ -74,14 +75,15 @@
   }
   if ($limit != -1) {
     $result = array_slice($result['ResultSet']['Result'], 0, $limit);
-  } else {
+  }
+  else {
     $result = $result['ResultSet']['Result'];
   }
   $result = array_unique($result);
   // Drop the blacklist items
   if (count($blacklist) > 0) {
-    foreach($result as $id => $term) {
-      if(in_array($term, $blacklist)) {
+    foreach ( $result as $id => $term ) {
+      if (in_array( $term, $blacklist )) {
         unset($result[$id]);
       }
     }
@@ -99,7 +101,7 @@
 }
 
 /**
- * Parse the given node's body and assign 
+ * Parse the given node's body and assign
  *
  * @param object $node
  * The node to be parsed
@@ -229,7 +231,7 @@
  */
 function yahoo_terms_link($type, $node = NULL, $teaser = FALSE) {
   $vid = _yahoo_terms_which_vocab($node->type);
-  $count = db_num_rows(db_query("SELECT vid FROM {vocabulary_node_types} WHERE vid = %d AND type = '%s'", $vid, $node->type));
+  $count = db_result(db_query("SELECT COUNT(*) FROM {vocabulary_node_types} WHERE vid = %d AND type = '%s'", $vid, $node->type));
   if ($count != 0) {
     if ($type == 'node' && $node != NULL) {
       if (user_access(YAHOO_TERMS_USE) && user_access("administer nodes") && variable_get('yahoo_terms_enable_link', FALSE)) {
@@ -243,18 +245,29 @@
 /**
  * Implements hook_menu()
  */
-function yahoo_terms_menu($may_cache) {
+function yahoo_terms_menu() {
   
   $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'yahoo_terms', 'title' => t('Extraction...'),
-        'callback' => '_yahoo_terms_process_node', 'access' => user_access(YAHOO_TERMS_USE),
-        'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'admin/settings/yahoo_terms', 'title' => t('Yahoo Terms'),
-        'callback' => 'drupal_get_form', 'callback arguments' => array('yahoo_terms_admin_settings'));
-    $items[] = array('path' => 'yahoo_terms/batch', 'title' => t('Yahoo Terms batch processing'),
-        'callback' => 'yahoo_terms_batch_page', 'access' => user_access(YAHOO_TERMS_USE) && user_access('administer nodes'));
-  }
+  $items['yahoo_terms'] = array(
+    'title' => t('Extraction...'),
+    'page callback' => '_yahoo_terms_process_node',
+    'access callback' => 'user_access',
+    'access arguments' => array('YAHOO_TERMS_USE'),
+    'type' => MENU_CALLBACK
+    );
+  $items['admin/settings/yahoo_terms'] = array(
+    'title' => t('Yahoo Terms'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('yahoo_terms_admin_settings'),
+    'access callback' => 'user_access',
+    'access arguments' => array('YAHOO_TERMS_USE')
+    );
+  $items['yahoo_terms/batch'] = array(
+    'title' => t('Yahoo Terms batch processing'),
+    'page callback' => 'yahoo_terms_batch_page',
+    'access callback' =>  'user_access',
+    'access arguments' => array('YAHOO_TERMS_USE', 'administer nodes')
+    );
   return $items;
 }
 
@@ -317,7 +330,7 @@
   }
 }
 
-function yahoo_terms_form_alter($form_id, &$form) {
+function yahoo_terms_form_alter(&$form, &$form_state, $form_id) {
   if (isset($form['#node_type']) && 'node_type_form' == $form_id) {
     $node_type = $form['old_type']['#value'];
     $select_voc = _yahoo_terms_vocab_select($node_type);
@@ -352,7 +365,7 @@
       '#return_value' => TRUE,
       '#required' => FALSE,
       '#default_value' => variable_get('yahoo_terms_process_existing_'. $node_type, FALSE),
-    ); 
+    );
   }
 }
 
@@ -407,31 +420,31 @@
 /**
  * Batch tagging a specific content type
  */
-function yahoo_terms_batch_submit($form_id, $form_values) {
+function yahoo_terms_batch_submit($form, &$form_state, $form_values) {
   timer_start("yahoo_terms_batch");
   $num_of_processed = 0;
-  $limit_number = $form_values['limit_number'];
+  $limit_number = $form_state['limit_number'];
   if ($limit_number == 0) {
-    $result = db_query("SELECT nid FROM {node} WHERE type = '%s'", 
-                       $form_values['type']);
+    $result = db_query("SELECT nid FROM {node} WHERE type = '%s'",
+    $form_state['type']);
   }
   else {
-    if (!$form_values['rewrite']) {
+    if (!$form_state['rewrite']) {
       $result = db_query("SELECT n.nid FROM {node} n LEFT JOIN {term_node} t ON t.nid=n.nid WHERE t.nid IS NULL and type = '%s' ORDER BY created DESC LIMIT %d",
-                          $form_values['type'], $form_values['limit_number']
+      $form_state['type'], $form_state['limit_number']
       );
     }
     else {
       $result = db_query("SELECT nid FROM {node}
                           WHERE type = '%s' LIMIT %d",
-                          $form_values['type'], $form_values['limit_number']
+                          $form_state['type'], $form_state['limit_number']
       );
     }
   }
   while ($node = db_fetch_array($result)) {
     $node = node_load($node['nid']);
-    if ( (!isset($node->taxonomy) || count($node->taxonomy) == 0) || $form_values['rewrite']) {
-      yahoo_terms_node_assign_keywords($node, "", array(), $form_values['vid']);
+    if ( (!isset($node->taxonomy) || count($node->taxonomy) == 0) || $form_state['rewrite']) {
+      yahoo_terms_node_assign_keywords($node, "", array(), $form_state['vid']);
       $num_of_processed++;
     }
   }
@@ -460,7 +473,7 @@
     $select_voc[$voc['vid']] = $voc['name'];
   }
   if (count($select_voc) < 1) {
-    $select_voc[0] = 'No vocabularies found'; 
+    $select_voc[0] = 'No vocabularies found';
   }
   return $select_voc;
 }
@@ -471,7 +484,7 @@
  */
 function yahoo_terms_cron() {
   $types = node_get_types();
-  foreach($types as $type => $type_object) {
+  foreach ($types as $type => $type_object) {
     if (variable_get('yahoo_terms_process_existing_'. $type, FALSE) == TRUE) {
       variable_set('yahoo_terms_process_existing_'. $type, FALSE);
       $result = db_query("SELECT nid FROM {node} WHERE type = '%s'", $type);
