--- D:/Profiles/nathan/Desktop/community_tags/community_tags.module	Thu Jul 17 09:49:33 2008
+++ C:/Programs/WAMP/www/TRUNK/sites/all/modules/community_tags/community_tags.module	Fri Jul 18 09:55:34 2008
@@ -2,6 +2,11 @@
 // $Id: community_tags.module,v 1.32.2.6 2008/02/19 10:59:22 owahab Exp $
 
 /**
+ * @file
+ * Implements community tagging of nodes using a specific vocabulary for Drupal v6.x
+ */
+
+/**
  * Display modes.
  */
 define('COMMUNITY_TAGS_MODE_BLOCK', 0);
@@ -11,43 +16,45 @@
 /**
  * Implementation of hook_help().
  */
-function community_tags_help($section) {
-  switch ($section) {
+function community_tags_help($path, $arg) {
+  switch ($path) {
     case 'admin/settings/community-tags':
       return t('To set up community tagging, you must first <a href="@taxonomy">create a normal free tagged vocabulary</a>. Then activate community tagging on such a vocabulary below, and set the <a href="@workflow">workflow options</a> for node types to control how users can tag nodes.', array('@taxonomy' => url('admin/content/taxonomy'), '@workflow' => url('admin/content/types')));
       break;
   }
 }
 
-/** 
- * Implementation oh hook_update_index().
+/**
+ * Implementation of hook_update_index().
  */
 function community_tags_update_index() {
   // Last cron run
   $last = variable_get('node_cron_last', 0);
   $limit = (int)variable_get('search_cron_limit', 100);
- 
+
   $sql = "SELECT nid FROM {community_tags} WHERE date > %d";
+  $sqlcount = "SELECT COUNT(nid) FROM {community_tags} WHERE date > %d";
   $result = db_query_range($sql, $last, 0, $limit);
- 
-  if ($result && db_num_rows($result) > 0) {
+  $resultcount = db_query_range($sqlcount, $last, 0, $limit);
+
+  if ($result && db_result($resultcount) > 0) {
     while ($data = db_fetch_object($result)) {
       $node = node_load($data->nid);
       // Build the node body.
       $node = node_build_content($node, FALSE, FALSE);
       $node->body = drupal_render($node->content);
- 
+
       // Allow modules to modify the fully-built node.
       node_invoke_nodeapi($node, 'alter');
- 
+
       $text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
- 
+
       // Fetch extra data normally not visible
       $extra = node_invoke_nodeapi($node, 'update index');
       foreach ($extra as $t) {
         $text .= $t;
       }
- 
+
       // Update index
       search_index($node->nid, 'node', $text);
     }
@@ -65,7 +72,7 @@
     ),
     'community_tags' => array(
       'arguments' => array('tags' => NULL),
-    ),    
+    ),
   );
 }
 
@@ -77,7 +84,7 @@
 
   $items['admin/settings/community-tags'] = array(
     'title' => 'Community tags',
-    'description' => t('Configure community tagging.'),
+    'description' => 'Configure community tagging.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('community_tags_settings'),
     'access arguments' => array('administer site configuration'),
@@ -88,9 +95,9 @@
     'page callback' => 'community_tags_from_js',
     'access callback' => '_community_tags_menu_access',
     'type' => MENU_CALLBACK,
-    'file' => 'community_tags.pages.inc',  
+    'file' => 'community_tags.pages.inc',
   );
-  
+
   $items['community-tags/user'] = array(
     'page callback' => 'community_tags_by_user',
     'access callback' => '_community_tags_menu_access',
@@ -158,6 +165,7 @@
  * Implementation of hook_block().
  */
 function community_tags_block($op = 'list', $delta = 0, $edit = array()) {
+  include_once("community_tags.pages.inc"); // allows the use of community_tags_node_view from community_tags.pages.inc
   global $user;
   switch ($op) {
 
@@ -168,7 +176,7 @@
     case 'view':
       if (user_access('access content') && user_access('tag content')) {
         if (arg(0) == 'node' && is_numeric(arg(1)) && (arg(2) == '' || arg(2) == 'view')) {
-          $node = node_load(arg(1));
+          $node = menu_get_object();
           if ($node && variable_get('community_tags_display_'. $node->type, COMMUNITY_TAGS_MODE_TAB) == COMMUNITY_TAGS_MODE_BLOCK) {
             $block['subject'] = t('Tag this');
             $block['content'] = community_tags_node_view($node, TRUE);
@@ -255,7 +263,7 @@
       COMMUNITY_TAGS_MODE_INLINE => t('Inline'),
     );
     $form['workflow']['community_tags_display'] = array(
-      '#type' => 'radios', 	
+      '#type' => 'radios',
       '#title' => t('Community tagging form'),
       '#default_value' => variable_get('community_tags_display_'. $form['#node_type']->type, COMMUNITY_TAGS_MODE_TAB),
       '#options' => $modes,
@@ -335,7 +343,7 @@
         }
 
         // If there was an existing tag by this user, load that data.
-        $tag_node = new StdClass();
+        $tag_node = new stdClass();
         $tag_node->tid = $typed_term_tid;
         $tag_node->nid = $nid;
         $tag_node->uid = $uid;
@@ -521,5 +529,4 @@
 function _community_tags_tag_access($node) {
   $vids = community_tags_vids_for_node($node);
   return _community_tags_menu_access() && count($vids);
-}
-
+}
\ No newline at end of file
