mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 03:25:15 +02:00
rework autocomplete: add NavBar forum search
This commit is contained in:
parent
00e319faa2
commit
aff775e55c
3 changed files with 35 additions and 14 deletions
|
@ -395,11 +395,12 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
if(!local_user())
|
||||
return "";
|
||||
|
||||
$start = (x($_REQUEST,'start')?$_REQUEST['start']:0);
|
||||
$count = (x($_REQUEST,'count')?$_REQUEST['count']:100);
|
||||
$search = (x($_REQUEST,'search')?$_REQUEST['search']:"");
|
||||
$type = (x($_REQUEST,'type')?$_REQUEST['type']:"");
|
||||
$conv_id = (x($_REQUEST,'conversation')?$_REQUEST['conversation']:null);
|
||||
$start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
|
||||
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
|
||||
$search = (x($_REQUEST,'search') ? $_REQUEST['search'] : "");
|
||||
$type = (x($_REQUEST,'type') ? $_REQUEST['type'] : "");
|
||||
$mode = (x($_REQUEST,'mode') ? $_REQUEST['mode'] : "");
|
||||
$conv_id = (x($_REQUEST,'conversation') ? $_REQUEST['conversation'] : null);
|
||||
|
||||
// For use with jquery.textcomplete for private mail completion
|
||||
|
||||
|
@ -673,6 +674,7 @@ function navbar_complete(&$a) {
|
|||
$localsearch = get_config('system','poco_local_search');
|
||||
|
||||
$search = $prefix.notags(trim($_REQUEST['search']));
|
||||
$mode = $_REQUEST['mode'];
|
||||
|
||||
// don't search if search term has less than 2 characters
|
||||
if(! $search || mb_strlen($search) < 2)
|
||||
|
@ -682,7 +684,7 @@ function navbar_complete(&$a) {
|
|||
$search = substr($search,1);
|
||||
|
||||
if($localsearch) {
|
||||
$x = dir::global_search_by_name($search);
|
||||
$x = dir::global_search_by_name($search, $mode);
|
||||
return $x;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,10 @@ class dir {
|
|||
* @brief Search global contact table by nick or name
|
||||
* *
|
||||
* @param string $search Name or nick
|
||||
* @param string $mode Search mode
|
||||
* @return array
|
||||
*/
|
||||
public static function global_search_by_name($search) {
|
||||
public static function global_search_by_name($search, $mode = '') {
|
||||
|
||||
if($search) {
|
||||
// check supported networks
|
||||
|
@ -30,6 +31,12 @@ class dir {
|
|||
else
|
||||
$ostatus = NETWORK_DFRN;
|
||||
|
||||
// check if fo
|
||||
if($mode === "community")
|
||||
$extra_sql = " AND `community`";
|
||||
else
|
||||
$extra_sql = "";
|
||||
|
||||
$results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
|
||||
`gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`
|
||||
FROM `gcontact`
|
||||
|
@ -38,13 +45,12 @@ class dir {
|
|||
AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
|
||||
WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `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`.`nick` REGEXP '%s'
|
||||
)
|
||||
(`gcontact`.`name` REGEXP '%s' OR `gcontact`.`nick` REGEXP '%s') $extra_sql
|
||||
GROUP BY `gcontact`.`nurl`
|
||||
ORDER BY `gcontact`.`updated` DESC ",
|
||||
intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
|
||||
dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
|
||||
dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));
|
||||
dbesc(escape_tags($search)), dbesc(escape_tags($search)));
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue