From 79bfe13c35022a3a881f1e471521180d724f52cb Mon Sep 17 00:00:00 2001 From: kcozens Date: Mon, 2 Jul 2012 18:09:01 +0000 Subject: [PATCH] This commit properly fixes searching for classified ads regardless of type (PG, Mature, or Adult). The previous commit didn't handle Adult rated ads. NOTE: For searches of classified ads to work correctly you must use revision 106 of profile.php from the osprofile addon module. Any classifieds that were created before using revision 106 of profile.php will need to be updated to ensure that the PG bit is set in the classifiedflags field in the database. git-svn-id: http://forge.opensimulator.org/svn/ossearch/trunk@190 109abde3-1f22-4c10-b5d7-b6b0135cd00c --- webroot/query.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/webroot/query.php b/webroot/query.php index b6e8e90..3840a3c 100644 --- a/webroot/query.php +++ b/webroot/query.php @@ -423,20 +423,24 @@ function dir_classified_query ($method_name, $params, $app_data) $type = ""; - //Viewer only allows setting classifieds as PG or Mature but not both. - //Restrict search based on classifiedflags when just one flag is set. - if (($flags & 12) != 12) - { - if ($flags & 4) //PG (1 << 2) - $type = "classifiedflags & 8 = 0"; - if ($flags & 8) //Mature (1 << 3) - $type = "classifiedflags & 8 = 8"; - } + //Renew Weekly flag is bit 5 (32) in $flags. + $terms = array(); + if ($flags & 4) //PG (1 << 2) + $terms[] = "classifiedflags & 4 = 4"; + if ($flags & 8) //Mature (1 << 3) + $terms[] = "classifiedflags & 8 = 8"; + if ($flags & 64) //Adult (1 << 6) + $terms[] = "classifiedflags & 64 = 64"; - if ($category <> 0) - $category = "category = ".$category.""; - else + //Was there at least one PG, Mature, or Adult flag? + if (count($terms) > 0) + $type = join_terms(" OR ", $terms, True); + + //Don't restrict results based on category if it is 0 (Any Category) + if ($category == 0) $category = ""; + else + $category = "category = " . $category; if ($type == "" || $category == "") $where = " WHERE " . $type . $category;