summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpfspot.class.php46
1 files changed, 35 insertions, 11 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index d67c7e3..8272252 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -196,11 +196,34 @@ class PHPFSPOT {
$this->avail_tags = Array();
$count = 0;
- $result = $this->db->db_query("
- SELECT id,name
- FROM tags
- ORDER BY sort_priority ASC
- ");
+ if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) {
+ $query_str="
+ SELECT
+ DISTINCT t1.id,t1.name
+ FROM
+ photo_tags pt1
+ INNER JOIN photo_tags
+ pt2 ON pt1.photo_id=pt2.photo_id
+ INNER JOIN tags t1
+ ON t1.id=pt1.tag_id
+ INNER JOIN tags t2
+ ON t2.id=pt2.tag_id
+ WHERE
+ t2.name IN ('
+ ".implode("','",$this->cfg->show_tags)."
+ ')
+ ORDER BY
+ t1.sort_priority ASC";
+ $result = $this->db->db_query($query_str);
+ }
+ else
+ {
+ $result = $this->db->db_query("
+ SELECT id,name
+ FROM tags
+ ORDER BY sort_priority ASC
+ ");
+ }
while($row = $this->db->db_fetch_object($result)) {
@@ -214,13 +237,14 @@ class PHPFSPOT {
if(in_array($row['name'], $this->cfg->hide_tags))
continue;
- /* if the user has specified to only show certain tags which
- are specified in phpfspot's configuration, ignore all others
- so they will not be added to the tag list.
- */
+ /* if you include the following if-clause and the user has specified
+ to only show certain tags which are specified in phpfspot's
+ configuration, ignore all others so they will not be added to the
+ tag list.
if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags) &&
!in_array($row['name'], $this->cfg->show_tags))
continue;
+ */
$this->tags[$tag_id] = $tag_name;
$this->avail_tags[$count] = $tag_id;
@@ -739,10 +763,10 @@ class PHPFSPOT {
INNER JOIN photos p
ON pt1.photo_id=p.id
";
- $query_str.= "WHERE pt1.tag_id=". $_SESSION['selected_tags'][0];
+ $query_str.= "WHERE pt2.tag_id=". $_SESSION['selected_tags'][0]." ";
for($i = 1; $i < count($_SESSION['selected_tags']); $i++) {
$query_str.= "
- AND pt". ($i+1) .".tag_id=". $_SESSION['selected_tags'][$i] ."
+ AND pt". ($i+2) .".tag_id=". $_SESSION['selected_tags'][$i] ."
";
}
if(isset($additional_where_cond))