From 66085a7572b5ce488134e5f9642a1b96e61dc45e Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sun, 13 Apr 2008 07:09:18 +0200 Subject: 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 --- phpfspot.class.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'phpfspot.class.php') 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']); } -- cgit v1.2.3-18-g5258