Index: user_tags.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_tags/user_tags.module,v
retrieving revision 1.8.2.1
diff -u -r1.8.2.1 user_tags.module
--- user_tags.module	10 Dec 2006 23:46:05 -0000	1.8.2.1
+++ user_tags.module	11 Mar 2008 22:16:48 -0000
@@ -5,7 +5,7 @@
  */
 function user_tags_help($section) {
   switch ($section) {
-    case 'admin/help#user_tags':      
+    case 'admin/help#user_tags':
     case 'admin/modules#description':
       return t('Allows free tagging of users');
   }
@@ -44,18 +44,19 @@
 
   $vocab = db_query("SELECT vid, name, description FROM {vocabulary}");
   if (db_affected_rows() > 0) {
-    while($vocab_list = db_fetch_object($vocab)) {
+    while ($vocab_list = db_fetch_object($vocab)) {
       $options[$vocab_list->vid] = $vocab_list->name;
       if ($vocab_list->description) {
-        $options[$vocab_list->vid] .=" - ". $vocab_list->description;
+        $options[$vocab_list->vid] .= ' - '. $vocab_list->description;
       }
     }
     $enabled_vocab = db_query("SELECT vu.vid, v.name FROM {user_tags_vocabulary} vu INNER JOIN {vocabulary} v ON v.vid = vu.vid");
-    while($enabled = db_fetch_object($enabled_vocab)) {
+    while ($enabled = db_fetch_object($enabled_vocab)) {
       $match_options[] = $enabled->vid;
     }
-    $form["user_tags_vocabulary_list"] = array("#type" => "select",
-     "#multiple" => true,
+    $form['user_tags_vocabulary_list'] = array(
+      "#type" => "select",
+      "#multiple" => true,
       "#required" => true,
       "#title" => t("Vocabularies Available"),
       "#description" => t("To select multiple items, hold ctrl (command) and click on the items"),
@@ -63,12 +64,14 @@
       "#default_value" => $match_options
     );
 
-    $form["user_tags_display_options"] = array("#type" => "fieldset",
+    $form["user_tags_display_options"] = array(
+      "#type" => "fieldset",
       "#collapsible" => true,
       "#title" => t("Display Options")
     );
 
-    $form["user_tags_display_options"]["user_tags_user_page"] = array("#type" => "checkbox",
+    $form["user_tags_display_options"]["user_tags_user_page"] = array(
+      "#type" => "checkbox",
       "#title" => t("Display tags on user's profile pages (user/username)"),
       "#default_value" => variable_get("user_tag_user_page", true),
       "#return_value" => true,
@@ -83,7 +86,7 @@
 
 
 function user_tags_user($op, &$edit, &$account, $category = NULL) {
-  switch ($op) { 	 
+  switch ($op) {
     case 'view':
       $list = array();
       foreach ($account->taxonomy as $tid => $term) {
@@ -92,12 +95,12 @@
       if (!empty($list)) {
         return array('Tags' => $list);
       }
-    break;
-    
+      break;
+
     case 'delete':
       return user_tags_delete($account->uid);
-    break;  
-  
+      break;
+
     case 'load':
       $result = db_query('SELECT t.* FROM {term_data} t INNER JOIN {term_user} tu WHERE tu.tid = t.tid AND tu.vid = t.vid AND tu.uid = %d ORDER BY weight, name', $account->uid);
       $account->taxonomy = array();
@@ -105,7 +108,7 @@
         $account->taxonomy[$term->tid] = $term;
       }
       return $account->taxonomy;
-    break;
+      break;
   
     case 'categories':
       return array(array('name' =>'tags',
@@ -118,7 +121,7 @@
       if ($category != 'tags') {
         return;
       }
-      
+
       if (!isset($account->taxonomy)) {
            if ($account->uid) {
              $terms = user_tags_get_terms($account->uid);
@@ -130,16 +133,16 @@
          else {
            $terms = $account->taxonomy;
          }
-     
+
         $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {user_tags_vocabulary} u ON v.vid = u.vid ORDER BY v.weight, v.name", 'v', 'vid'));
-  
+
         while ($vocabulary = db_fetch_object($c)) {
            if ($vocabulary->tags) {
              $typed_terms = array();
              foreach ($terms as $term) {
                // Extract terms belonging to the vocabulary in question.
                if ($term->vid == $vocabulary->vid) {
-                
+
                  // Commas and quotes in terms are special cases, so encode 'em.
                  if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) {
                    $term->name = '"'.preg_replace('/"/', '""', $term->name).'"';
@@ -148,7 +151,7 @@
                }
              }
              $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
-            
+
              if ($vocabulary->help) {
                $help = $vocabulary->help;
              }
@@ -177,24 +180,24 @@
              $form['taxonomy']['tags'][$vocabulary->vid]['#weight'] = $vocabulary->weight;
              $form['taxonomy']['tags'][$vocabulary->vid]['#required'] = $vocabulary->required;
            }
-        
+
          if (isset($form['taxonomy'])) {
            $form['taxonomy'] += array('#type' => 'fieldset', '#title' => t('Categories'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#weight' => -3);
           }
         }
       return $form;
     break;
-    
+
     case 'submit':
       if ($category != 'tags') {
         return;
       }
       user_tags_delete($account->uid);
-      
+
       if (is_array($edit['taxonomy'])) {
         if (isset($edit['taxonomy']['freetags'])) {
           foreach ($edit['taxonomy']['freetags'] as $key => $value){
-            $vid = $key; 
+            $vid = $key;
             $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
             preg_match_all($regexp, $value, $matches);
             $typed_terms = $matches[1];
@@ -233,7 +236,7 @@
           }
         }
       }
-      unset($edit['taxonomy']);  
+      unset($edit['taxonomy']);
     break;
   }
 }
@@ -261,11 +264,11 @@
 function user_tags_page($tid = null) {
   global $user;
   $row = array();
-  $rows = array();  
+  $rows = array();
   $term = taxonomy_get_term($tid);
-  
+
   if (!$tid || $term->tid != $tid) {
-    
+
     //print all the tags currently in use.
     $query = db_query('SELECT DISTINCT( td.name ) as termname, tu.tid FROM {term_data} td INNER JOIN {term_user} tu  ON td.tid = tu.tid
                        ORDER BY td.weight, td.name');
@@ -284,7 +287,7 @@
       if ($term->username != $old->username && !empty($row)) {
         $rows[] = array(l($old->username, "user/$old->uid"), implode(', ', $row));
         unset($row); // Cleaning and reinitializing to avoid duplicates.
-        $row = array(); 
+        $row = array();
       }
       $old = $term;
       $row[] = l($term->termname, "tag/user/$term->tid");
@@ -298,10 +301,10 @@
 * Find all terms associated to the user of a given vocabulary.
  */
 function user_tags_get_terms_by_vocabulary($uid, $vid, $key = 'tid') {
-  $result = db_query('SELECT t.* FROM {term_data} t INNER JOIN {term_user} tu WHERE tu.tid = t.tid AND tu.vid = %d AND tu.uid =%d', $vid, $uid);
+  $result = db_query('SELECT t.* FROM {term_data} t INNER JOIN {term_user} tu WHERE tu.tid = t.tid AND tu.vid = %d AND tu.uid = %d', $vid, $uid);
   $terms = array();
   while ($term = db_fetch_object($result)) {
     $terms[$term->$key] = $term;
   }
   return $terms;
-} 
+}
