diff --git a/mod/dirfind.php b/mod/dirfind.php index 45fc93b7e8..d5cfcbcab0 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -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), diff --git a/mod/search.php b/mod/search.php index 339efc92db..a01984d244 100644 --- a/mod/search.php +++ b/mod/search.php @@ -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;