1
0
Fork 0

Saved searches now can search for tags as well

This commit is contained in:
Michael Vogel 2012-05-26 11:51:48 +02:00
parent a612b10b2a
commit a5dc41ab13
2 changed files with 17 additions and 6 deletions

View file

@ -402,10 +402,22 @@ function network_content(&$a, $update = 0) {
if(x($_GET,'search')) { if(x($_GET,'search')) {
$search = escape_tags($_GET['search']); $search = escape_tags($_GET['search']);
$sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", if (get_config('system','use_fulltext_engine')) {
dbesc(protect_sprintf('%' . $search . '%')), if(strpos($search,'#') === 0)
dbesc(protect_sprintf('%]' . $search . '[%')) $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
); dbesc(protect_sprintf($search))
);
else
$sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ",
dbesc(protect_sprintf($search)),
dbesc(protect_sprintf($search))
);
} else {
$sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ",
dbesc(protect_sprintf('%' . $search . '%')),
dbesc(protect_sprintf('%]' . $search . '[%'))
);
}
} }
if(strlen($file)) { if(strlen($file)) {
$sql_extra .= file_tag_file_query('item',unxmlify($file)); $sql_extra .= file_tag_file_query('item',unxmlify($file));

View file

@ -71,7 +71,7 @@ function search_content(&$a) {
notice( t('Public access denied.') . EOL); notice( t('Public access denied.') . EOL);
return; return;
} }
nav_set_selected('search'); nav_set_selected('search');
require_once("include/bbcode.php"); require_once("include/bbcode.php");
@ -96,7 +96,6 @@ function search_content(&$a) {
$o .= search($search,'search-box','/search',((local_user()) ? true : false)); $o .= search($search,'search-box','/search',((local_user()) ? true : false));
if(strpos($search,'#') === 0) { if(strpos($search,'#') === 0) {
$tag = true; $tag = true;
$search = substr($search,1); $search = substr($search,1);