]> git.mxchange.org Git - friendica.git/commitdiff
Added community search mode
authorMichael Vogel <icarus@dabo.de>
Thu, 30 Jul 2015 21:27:50 +0000 (23:27 +0200)
committerMichael Vogel <icarus@dabo.de>
Thu, 30 Jul 2015 21:27:50 +0000 (23:27 +0200)
mod/dirfind.php
mod/search.php

index 45fc93b7e82383d84099f1a7c2a3e9a5a73091cb..d5cfcbcab013d015a03e2a99bcbeabfbcec62386 100644 (file)
@@ -16,6 +16,8 @@ function dirfind_init(&$a) {
 
 function dirfind_content(&$a) {
 
+       $community = false;
+
        $local = get_config('system','poco_local_search');
 
        $search = notags(trim($_REQUEST['search']));
@@ -23,6 +25,11 @@ function dirfind_content(&$a) {
        if(strpos($search,'@') === 0)
                $search = substr($search,1);
 
+       if(strpos($search,'!') === 0) {
+               $search = substr($search,1);
+               $community = true;
+       }
+
        $o = '';
 
        $o .= replace_macros(get_markup_template("section_title.tpl"),array(
@@ -33,12 +40,17 @@ function dirfind_content(&$a) {
 
                if ($local) {
 
+                       if ($community)
+                               $extra_sql = " AND `community`";
+                       else
+                               $extra_sql = "";
+
                        $perpage = 80;
                        $startrec = (($a->pager['page']) * $perpage) - $perpage;
 
                        $count = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND
                                        (`url` REGEXP '%s' OR `name` REGEXP '%s' OR `location` REGEXP '%s' OR
-                                               `about` REGEXP '%s' OR `keywords` REGEXP '%s')",
+                                               `about` REGEXP '%s' OR `keywords` REGEXP '%s')".$extra_sql,
                                        dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA),
                                        dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)),
                                        dbesc(escape_tags($search)), dbesc(escape_tags($search)));
@@ -49,7 +61,7 @@ function dirfind_content(&$a) {
                                        WHERE `gcontact`.`network` IN ('%s', '%s', '%s') AND
                                        ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND
                                        (`gcontact`.`url` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`location` REGEXP '%s' OR
-                                               `gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s')
+                                               `gcontact`.`about` REGEXP '%s' OR `gcontact`.`keywords` REGEXP '%s') $extra_sql
                                                GROUP BY `gcontact`.`nurl`
                                                ORDER BY `gcontact`.`updated` DESC LIMIT %d, %d",
                                        intval(local_user()), dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DIASPORA),
index 339efc92db5750a075851e428424615aea91686e..a01984d2444c7255e363489622e266a1e76c7ed3 100644 (file)
@@ -120,6 +120,10 @@ function search_content(&$a) {
                require_once('mod/dirfind.php');
                return dirfind_content($a);
        }
+       if(strpos($search,'!') === 0) {
+               require_once('mod/dirfind.php');
+               return dirfind_content($a);
+       }
 
        if(! $search)
                return $o;