diff options
-rw-r--r-- | include/text.php | 8 | ||||
-rw-r--r-- | mod/display.php | 3 | ||||
-rw-r--r-- | mod/network.php | 44 |
3 files changed, 24 insertions, 31 deletions
diff --git a/include/text.php b/include/text.php index 7163d5e88..1825ec572 100644 --- a/include/text.php +++ b/include/text.php @@ -1364,6 +1364,14 @@ function file_tag_file_query($table,$s,$type = 'file') { ); } +function term_query($table,$s,$type = TERM_UNKNOWN) { + + return sprintf(" AND " . (($table) ? dbesc($table) . '.' : '') . "id in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = " . (($table) ? dbesc($table) . '.' : '') . "uid ) ", + intval($type), + protect_sprintf(dbesc($s)) + ); +} + // ex. given music,video return <music><video> or [music][video] function file_tag_list_to_file($list,$type = 'file') { $tag_list = ''; diff --git a/mod/display.php b/mod/display.php index 81ed174ac..91bc82d64 100644 --- a/mod/display.php +++ b/mod/display.php @@ -12,7 +12,7 @@ function display_content(&$a) { require_once('include/security.php'); require_once('include/conversation.php'); require_once('include/acl_selectors.php'); - + require_once('include/items.php'); $o = '<div id="live-display"></div>' . "\r\n"; @@ -121,6 +121,7 @@ EOT; ); } + $r = fetch_post_tags($r); $o .= conversation($a,$r,'display', false); diff --git a/mod/network.php b/mod/network.php index 49600f39e..a1294cea5 100644 --- a/mod/network.php +++ b/mod/network.php @@ -531,45 +531,29 @@ function network_content(&$a, $update = 0) { if(x($_GET,'search')) { $search = escape_tags($_GET['search']); - if (get_config('system','use_fulltext_engine')) { - if(strpos($search,'#') === 0) - $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(strpos($search,'#') === 0) + $sql_extra .= term_query('item',substr($search,1),TERM_HASHTAG); + else + $sql_extra .= sprintf(" AND `item`.`body` like '%s' ", + dbesc(protect_sprintf('%' . $search . '%')) ); - } } + if(strlen($file)) { - $sql_extra .= file_tag_file_query('item',unxmlify($file)); + $sql_extra .= term_query('item',$file,TERM_FILE); } if($conv) { - $myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname']; + // find a substring of my profile url that can be normalised + $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname']; $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace('www.','',$myurl); - $diasp_url = str_replace('/profile/','/u/',$myurl); - if (get_config('system','use_fulltext_engine')) - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($myurl)), - dbesc(protect_sprintf($diasp_url)) - ); - else - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", - dbesc(protect_sprintf('%' . $myurl)), - dbesc(protect_sprintf('%' . $myurl . ']%')), - dbesc(protect_sprintf('%' . $diasp_url . ']%')) - ); + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `item`.`author-link` like '%s' or `item`.`id` in (select term.oid from term where term.type = %d and term.term = '%s' and term.uid = `item`.`uid`))) ", + dbesc(protect_sprintf('%' . $myurl)), + intval(TERM_MENTION), + dbesc(protect_sprintf($a->user['username'])) + ); } if($update) { |