X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fsearch.php;h=d467764b01a57049581ad9f051f9014ae9ab9988;hb=7c6e8b30b28a3656f536ba338c3b124533fdadb7;hp=4ca7db9bb111c4e3000cdf8b672d4603a3d742e0;hpb=43d5876e8b35d53a0bef5248c5d63e5bc209dbbf;p=friendica.git diff --git a/mod/search.php b/mod/search.php index 4ca7db9bb1..d467764b01 100644 --- a/mod/search.php +++ b/mod/search.php @@ -87,11 +87,26 @@ function search_content(&$a) { else $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); + $tag = false; + if(x($_GET,'tag')) { + $tag = true; + $search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : ''); + } + + $o .= search($search,'search-box','/search',((local_user()) ? true : false)); if(! $search) return $o; + if($tag) + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + + + + // Here is the way permissions work in the search module... // Only public posts can be shown // OR your own posts if you are a logged in member @@ -103,10 +118,8 @@ function search_content(&$a) { AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) OR `item`.`uid` = %d ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) group by `item`.`uri` ", - intval(local_user()), - dbesc(preg_quote($search)), - dbesc('\\]' . preg_quote($search) . '\\[') + $sql_extra group by `item`.`uri` ", + intval(local_user()) ); if(count($r)) @@ -127,18 +140,19 @@ function search_content(&$a) { AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) OR `item`.`uid` = %d ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) + $sql_extra group by `item`.`uri` ORDER BY `received` DESC LIMIT %d , %d ", intval(local_user()), - dbesc(preg_quote($search)), - dbesc('\\]' . preg_quote($search) . '\\['), intval($a->pager['start']), intval($a->pager['itemspage']) ); - $o .= '

Search results for: ' . $search . '

'; + if($tag) + $o .= '

Items tagged with: ' . $search . '

'; + else + $o .= '

Search results for: ' . $search . '

'; $o .= conversation($a,$r,'search',false);