summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-04-13 07:09:18 +0200
committerAndreas Unterkircher <unki@netshadow.at>2008-04-13 07:09:18 +0200
commit66085a7572b5ce488134e5f9642a1b96e61dc45e (patch)
tree32d473917e56b2711bf64c26011158b1b52c78bc
parent8b5da769f4de61b359c5b5aad51d365e2aa55ba5 (diff)
issue116, take care that get_random_photo() will return also only photos which are tagged with show_tags (if specified)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
-rw-r--r--phpfspot.class.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index ec041bf..c56ecec 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -2535,11 +2535,26 @@ class PHPFSPOT {
{
$all = Array();
- $result = $this->db->db_query("
- SELECT id
- FROM photos
- ");
-
+ $query_str = "
+ SELECT p.id
+ FROM photos p
+ ";
+
+ /* if show_tags is set, only return details for photos which
+ are specified to be shown
+ */
+ if(isset($this->cfg->show_tags) && !empty($this->cfg->show_tags)) {
+ $query_str.= "
+ INNER JOIN photo_tags pt
+ ON p.id=pt.photo_id
+ INNER JOIN tags t
+ ON pt.tag_id=t.id
+ WHERE
+ t.name IN ('".implode("','",$this->cfg->show_tags)."')";
+ }
+
+ $result = $this->db->db_query($query_str);
+
while($row = $this->db->db_fetch_object($result)) {
array_push($all, $row['id']);
}