issue116, don't allow hidden-tags to be added to the selected-tag list
[phpfspot.git] / phpfspot.class.php
index a279effe0555b3a3dacf316f70d86eb4f7f34bb1..ec041bfd122e61329495f5619a0efc377b3833b4 100644 (file)
@@ -767,10 +767,15 @@ class PHPFSPOT {
       if(isset($_SESSION['searchfor_tag']))
          unset($_SESSION['searchfor_tag']);
 
       if(isset($_SESSION['searchfor_tag']))
          unset($_SESSION['searchfor_tag']);
 
+      // has the user requested to hide this tag, and still someone,
+      // somehow tries to add it, don't allow this.
+      if(!isset($this->cfg->hide_tags) &&
+         in_array($this->get_tag_name($tag), $this->cfg->hide_tags))
+         return "ok";
+
       if(!in_array($tag, $_SESSION['selected_tags']))
          array_push($_SESSION['selected_tags'], $tag);
 
       if(!in_array($tag, $_SESSION['selected_tags']))
          array_push($_SESSION['selected_tags'], $tag);
 
-
       return "ok";
    
    } // addTag()
       return "ok";
    
    } // addTag()
@@ -2927,6 +2932,30 @@ class PHPFSPOT {
 
    } // get_mime_info()
 
 
    } // get_mime_info()
 
+   /**
+    * return tag-name by tag-idx
+    *
+    * this function returns the tag-name for the requested
+    * tag specified by tag-idx.
+    * @param integer $idx
+    * @return string
+    */
+   public function get_tag_name($idx)
+   {
+       if($result = $this->db->db_fetchSingleRow("
+         SELECT name
+         FROM tags
+         WHERE
+            id LIKE '". $idx ."'")) {
+
+         return $result['name'];
+
+      }
+
+      return 0;
+      
+   } // get_tag_name()
+
 } // class PHPFSPOT
 
 ?>
 } // class PHPFSPOT
 
 ?>