some tagging work
This commit is contained in:
parent
5a9e9284c2
commit
f923d21df3
@ -268,15 +268,15 @@ class Acl extends \Zotlabs\Web\Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(intval(get_config('system','taganyone')) || intval(get_pconfig(local_channel(),'system','taganyone'))) {
|
if((count($r) < 100) && $type == 'c') {
|
||||||
if((count($r) < 100) && $type == 'c') {
|
$r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
|
||||||
$r2 = q("SELECT substr(xchan_hash,1,18) as id, xchan_hash as hash, xchan_name as name, xchan_photo_s as micro, xchan_url as url, xchan_addr as nick, 0 as abook_their_perms, 0 as abook_flags, 0 as abook_self
|
FROM xchan
|
||||||
FROM xchan
|
WHERE xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc"
|
||||||
WHERE xchan_deleted = 0 $sql_extra2 order by $order_extra2 xchan_name asc"
|
);
|
||||||
);
|
if($r2) {
|
||||||
if($r2)
|
$r = array_merge($r,$r2);
|
||||||
$r = array_merge($r,$r2);
|
$r = unique_multidim_array($r,'hash');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($type == 'm') {
|
elseif($type == 'm') {
|
||||||
|
@ -3402,3 +3402,18 @@ function unpunify($s) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function unique_multidim_array($array, $key) {
|
||||||
|
$temp_array = array();
|
||||||
|
$i = 0;
|
||||||
|
$key_array = array();
|
||||||
|
|
||||||
|
foreach($array as $val) {
|
||||||
|
if (!in_array($val[$key], $key_array)) {
|
||||||
|
$key_array[$i] = $val[$key];
|
||||||
|
$temp_array[$i] = $val;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return $temp_array;
|
||||||
|
}
|
@ -8,20 +8,20 @@ function contact_search(term, callback, backend_url, type, extra_channels, spine
|
|||||||
$(spinelement).show();
|
$(spinelement).show();
|
||||||
}
|
}
|
||||||
// Check if there is a cached result that contains the same information we would get with a full server-side search
|
// Check if there is a cached result that contains the same information we would get with a full server-side search
|
||||||
var bt = backend_url+type;
|
// var bt = backend_url+type;
|
||||||
if(!(bt in contact_search.cache)) contact_search.cache[bt] = {};
|
// if(!(bt in contact_search.cache)) contact_search.cache[bt] = {};
|
||||||
|
|
||||||
var lterm = term.toLowerCase(); // Ignore case
|
// var lterm = term.toLowerCase(); // Ignore case
|
||||||
for(var t in contact_search.cache[bt]) {
|
// for(var t in contact_search.cache[bt]) {
|
||||||
if(lterm.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results
|
// if(lterm.indexOf(t) >= 0) { // A more broad search has been performed already, so use those results
|
||||||
$(spinelement).hide();
|
// $(spinelement).hide();
|
||||||
// Filter old results locally
|
// Filter old results locally
|
||||||
var matching = contact_search.cache[bt][t].filter(function (x) { return (x.name.toLowerCase().indexOf(lterm) >= 0 || (typeof x.nick !== 'undefined' && x.nick.toLowerCase().indexOf(lterm) >= 0)); }); // Need to check that nick exists because groups don't have one
|
// var matching = contact_search.cache[bt][t].filter(function (x) { return (x.name.toLowerCase().indexOf(lterm) >= 0 || (typeof x.nick !== 'undefined' && x.nick.toLowerCase().indexOf(lterm) >= 0)); }); // Need to check that nick exists because groups don't have one
|
||||||
matching.unshift({taggable:false, text: term, replace: term});
|
// matching.unshift({taggable:false, text: term, replace: term});
|
||||||
setTimeout(function() { callback(matching); } , 1); // Use "pseudo-thread" to avoid some problems
|
// setTimeout(function() { callback(matching); } , 1); // Use "pseudo-thread" to avoid some problems
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
var postdata = {
|
var postdata = {
|
||||||
start:0,
|
start:0,
|
||||||
@ -41,9 +41,9 @@ function contact_search(term, callback, backend_url, type, extra_channels, spine
|
|||||||
success: function(data){
|
success: function(data){
|
||||||
// Cache results if we got them all (more information would not improve results)
|
// Cache results if we got them all (more information would not improve results)
|
||||||
// data.count represents the maximum number of items
|
// data.count represents the maximum number of items
|
||||||
if(data.items.length -1 < data.count) {
|
// if(data.items.length -1 < data.count) {
|
||||||
contact_search.cache[bt][lterm] = data.items;
|
// contact_search.cache[bt][lterm] = data.items;
|
||||||
}
|
// }
|
||||||
var items = data.items.slice(0);
|
var items = data.items.slice(0);
|
||||||
items.unshift({taggable:false, text: term, replace: term});
|
items.unshift({taggable:false, text: term, replace: term});
|
||||||
callback(items);
|
callback(items);
|
||||||
|
Reference in New Issue
Block a user