Merge pull request #954 from fabrixxm/issue_936
Show unknown contacts in thread comment mention autocomplete
This commit is contained in:
commit
1a5da0ae60
5 changed files with 88 additions and 13 deletions
|
@ -382,7 +382,7 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
$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);
|
||||
|
||||
// For use with jquery.autocomplete for private mail completion
|
||||
|
||||
|
@ -450,6 +450,7 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
$contact_count = 0;
|
||||
}
|
||||
|
||||
|
||||
$tot = $group_count+$contact_count;
|
||||
|
||||
$groups = array();
|
||||
|
@ -553,6 +554,52 @@ function acl_lookup(&$a, $out_type = 'json') {
|
|||
|
||||
$items = array_merge($groups, $contacts);
|
||||
|
||||
if ($conv_id) {
|
||||
/* if $conv_id is set, get unknow contacts in thread */
|
||||
/* but first get know contacts url to filter them out */
|
||||
function _contact_link($i){ return dbesc($i['link']); }
|
||||
$known_contacts = array_map(_contact_link, $contacts);
|
||||
$unknow_contacts=array();
|
||||
$r = q("select
|
||||
`author-avatar`,`author-name`,`author-link`
|
||||
from item where parent=%d
|
||||
and (
|
||||
`author-name` LIKE '%%%s%%' OR
|
||||
`author-link` LIKE '%%%s%%'
|
||||
) and
|
||||
`author-link` NOT IN ('%s')
|
||||
GROUP BY `author-link`
|
||||
ORDER BY `author-name` ASC
|
||||
",
|
||||
intval($conv_id),
|
||||
dbesc($search),
|
||||
dbesc($search),
|
||||
implode("','", $known_contacts)
|
||||
);
|
||||
if (is_array($r) && count($r)){
|
||||
foreach($r as $row) {
|
||||
// nickname..
|
||||
$up = parse_url($row['author-link']);
|
||||
$nick = explode("/",$up['path']);
|
||||
$nick = $nick[count($nick)-1];
|
||||
$nick .= "@".$up['host'];
|
||||
// /nickname
|
||||
$unknow_contacts[] = array(
|
||||
"type" => "c",
|
||||
"photo" => $row['author-avatar'],
|
||||
"name" => $row['author-name'],
|
||||
"id" => '',
|
||||
"network" => "unknown",
|
||||
"link" => $row['author-link'],
|
||||
"nick" => $nick,
|
||||
"forum" => false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$items = array_merge($items, $unknow_contacts);
|
||||
$tot += count($unknow_contacts);
|
||||
}
|
||||
|
||||
if($out_type === 'html') {
|
||||
$o = array(
|
||||
|
|
|
@ -19,6 +19,8 @@ function ref_session_read ($id) {
|
|||
if(count($r)) {
|
||||
$session_exists = true;
|
||||
return $r[0]['data'];
|
||||
} else {
|
||||
logger("no data for session $id", LOGGER_TRACE);
|
||||
}
|
||||
return '';
|
||||
}}
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
* This is the old template engine, now deprecated.
|
||||
* Friendica's default template engine is Smarty3 (see include/friendica_smarty.php)
|
||||
*
|
||||
*/
|
||||
require_once 'object/TemplateEngine.php';
|
||||
|
||||
define("KEY_NOT_EXISTS", '^R_key_not_Exists^');
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<?php
|
||||
|
||||
// This is our template processor.
|
||||
// $s is the string requiring macro substitution.
|
||||
// $r is an array of key value pairs (search => replace)
|
||||
// returns substituted string.
|
||||
// WARNING: this is pretty basic, and doesn't properly handle search strings that are substrings of each other.
|
||||
// For instance if 'test' => "foo" and 'testing' => "bar", testing could become either bar or fooing,
|
||||
// depending on the order in which they were declared in the array.
|
||||
|
||||
require_once("include/template_processor.php");
|
||||
require_once("include/friendica_smarty.php");
|
||||
|
||||
|
@ -661,6 +653,9 @@ function attribute_contains($attr,$s) {
|
|||
}}
|
||||
|
||||
if(! function_exists('logger')) {
|
||||
/* setup int->string log level map */
|
||||
$LOGGER_LEVELS = array();
|
||||
|
||||
/**
|
||||
* log levels:
|
||||
* LOGGER_NORMAL (default)
|
||||
|
@ -678,9 +673,16 @@ function logger($msg,$level = 0) {
|
|||
// turn off logger in install mode
|
||||
global $a;
|
||||
global $db;
|
||||
|
||||
global $LOGGER_LEVELS;
|
||||
|
||||
if(($a->module == 'install') || (! ($db && $db->connected))) return;
|
||||
|
||||
if (count($LOGGER_LEVEL)==0){
|
||||
foreach (get_defined_constants() as $k=>$v){
|
||||
if (substr($k,0,7)=="LOGGER_") $LOGGER_LEVELS[$v] = substr($k,7,7);
|
||||
}
|
||||
}
|
||||
|
||||
$debugging = get_config('system','debugging');
|
||||
$loglevel = intval(get_config('system','loglevel'));
|
||||
$logfile = get_config('system','logfile');
|
||||
|
@ -688,8 +690,19 @@ function logger($msg,$level = 0) {
|
|||
if((! $debugging) || (! $logfile) || ($level > $loglevel))
|
||||
return;
|
||||
|
||||
$callers = debug_backtrace();
|
||||
$logline = sprintf("%s@%s\t[%s]:%s:%s:%s\t%s\n",
|
||||
datetime_convert(),
|
||||
session_id(),
|
||||
$LOGGER_LEVELS[$level],
|
||||
basename($callers[0]['file']),
|
||||
$callers[0]['line'],
|
||||
$callers[1]['function'],
|
||||
$msg
|
||||
);
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
@file_put_contents($logfile, datetime_convert() . ':' . session_id() . ' ' . $msg . "\n", FILE_APPEND);
|
||||
@file_put_contents($logfile, $logline, FILE_APPEND);
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
return;
|
||||
}}
|
||||
|
|
|
@ -14,6 +14,11 @@ function ACPopup(elm,backend_url){
|
|||
this.kp_timer = false;
|
||||
this.url = backend_url;
|
||||
|
||||
this.conversation_id = null;
|
||||
var conv_id = this.element.id.match(/\d+$/);
|
||||
if (conv_id) this.conversation_id = conv_id[0];
|
||||
console.log("ACPopup elm id",this.element.id,"conversation",this.conversation_id);
|
||||
|
||||
var w = 530;
|
||||
var h = 130;
|
||||
|
||||
|
@ -67,6 +72,7 @@ ACPopup.prototype._search = function(){
|
|||
count:100,
|
||||
search:this.searchText,
|
||||
type:'c',
|
||||
conversation: this.conversation_id,
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
|
@ -79,8 +85,10 @@ ACPopup.prototype._search = function(){
|
|||
if (data.tot>0){
|
||||
that.cont.show();
|
||||
$(data.items).each(function(){
|
||||
html = "<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo, this.name, this.nick)
|
||||
that.add(html, this.nick.replace(' ','') + '+' + this.id + ' - ' + this.link);
|
||||
var html = "<img src='{0}' height='16px' width='16px'>{1} ({2})".format(this.photo, this.name, this.nick);
|
||||
var nick = this.nick.replace(' ','');
|
||||
if (this.id!=='') nick += '+' + this.id;
|
||||
that.add(html, nick + ' - ' + this.link);
|
||||
});
|
||||
} else {
|
||||
that.cont.hide();
|
||||
|
|
Loading…
Reference in a new issue