call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
+ foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
else
$exclude = false;
$size = 4;
- if(is_array($options)) {
- if(x($options,'size'))
+ if (is_array($options)) {
+ if (x($options,'size'))
$size = $options['size'];
- if(x($options,'mutual_friends'))
+ if (x($options,'mutual_friends')) {
$mutual = true;
- if(x($options,'single'))
+ }
+ if (x($options,'single')) {
$single = true;
- if(x($options,'multiple'))
+ }
+ if (x($options,'multiple')) {
$single = false;
- if(x($options,'exclude'))
+ }
+ if (x($options,'exclude')) {
$exclude = $options['exclude'];
+ }
- if(x($options,'networks')) {
+ if (x($options,'networks')) {
switch($options['networks']) {
case 'DFRN_ONLY':
$networks = array(NETWORK_DFRN);
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\r\n";
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
- WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+ WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
$sql_extra
ORDER BY `name` ASC ",
intval(local_user())
call_hooks($a->module . '_pre_' . $selname, $arr);
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ foreach ($r as $rr) {
+ if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" ";
- else
+ } else {
$selected = '';
+ }
$trimmed = mb_substr($rr['name'],0,20);
$o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\r\n";
$r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
- WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+ WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
$sql_extra
ORDER BY `name` ASC ",
intval(local_user())
$receiverlist = array();
if (dbm::is_result($r)) {
- foreach($r as $rr) {
- if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ foreach ($r as $rr) {
+ if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" ";
- else
+ }
+ else {
$selected = '';
+ }
- if($privmail)
+ if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
- else
+ } else {
$trimmed = mb_substr($rr['name'],0,20);
+ }
$receiverlist[] = $trimmed;
function prune_deadguys($arr) {
- if(! $arr)
+ if (! $arr) {
return $arr;
+ }
+
$str = dbesc(implode(',',$arr));
+
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
- if($r) {
+
+ if (dbm::is_result($r)) {
$ret = array();
- foreach($r as $rr)
+ foreach ($r as $rr) {
$ret[] = intval($rr['id']);
+ }
return $ret;
}
+
return array();
}
}
-function construct_acl_data(&$a, $user) {
+function construct_acl_data(App $a, $user) {
// Get group and contact information for html ACL selector
$acl_data = acl_lookup($a, 'html');
}
-function acl_lookup(&$a, $out_type = 'json') {
+function acl_lookup(App $a, $out_type = 'json') {
- if(!local_user())
- return "";
+ if (!local_user()) {
+ return '';
+ }
$start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0);
$count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100);
// autocomplete for editor mentions
if ($type=='' || $type=='c'){
$r = q("SELECT COUNT(*) AS c FROM `contact`
- WHERE `uid` = %d AND `self` = 0
- AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+ WHERE `uid` = %d AND NOT `self`
+ AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND `notify` != '' $sql_extra2" ,
intval(local_user())
);
// autocomplete for Private Messages
$r = q("SELECT COUNT(*) AS c FROM `contact`
- WHERE `uid` = %d AND `self` = 0
- AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+ WHERE `uid` = %d AND NOT `self`
+ AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND `network` IN ('%s','%s','%s') $sql_extra2" ,
intval(local_user()),
dbesc(NETWORK_DFRN),
// autocomplete for Contacts
$r = q("SELECT COUNT(*) AS c FROM `contact`
- WHERE `uid` = %d AND `self` = 0
- AND `pending` = 0 $sql_extra2" ,
+ WHERE `uid` = %d AND NOT `self`
+ AND NOT `pending` $sql_extra2" ,
intval(local_user())
);
$contact_count = (int)$r[0]['c'];
if ($type==''){
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
- WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+ WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
AND NOT (`network` IN ('%s', '%s'))
$sql_extra2
ORDER BY `name` ASC ",
elseif ($type=='c'){
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
- WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
+ WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
AND NOT (`network` IN ('%s'))
$sql_extra2
ORDER BY `name` ASC ",
}
elseif($type == 'm') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact`
- WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0
+ WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND `network` IN ('%s','%s','%s')
$sql_extra2
ORDER BY `name` ASC ",
dbesc(NETWORK_ZOT),
dbesc(NETWORK_DIASPORA)
);
- }
- elseif($type == 'a') {
+ } elseif ($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND `pending` = 0
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user())
);
- }
- elseif($type == 'x') {
+ } elseif ($type == 'x') {
// autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a);
$contacts = array();
- if($r) {
- foreach($r as $g) {
+ if ($r) {
+ foreach ($r as $g) {
$contacts[] = array(
- "photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
- "name" => $g['name'],
- "nick" => (x($g['addr']) ? $g['addr'] : $g['url']),
- "network" => $g['network'],
- "link" => $g['url'],
- "forum" => (x($g['community']) ? 1 : 0),
+ 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
+ 'name' => $g['name'],
+ 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
+ 'network' => $g['network'],
+ 'link' => $g['url'],
+ 'forum' => (x($g['community']) ? 1 : 0),
);
}
}
$o = array(
'start' => $start,
- 'count' => $count,
- 'items' => $contacts,
+ 'count' => $count,
+ 'items' => $contacts,
);
echo json_encode($o);
killme();
- }
- else
+ } else {
$r = array();
+ }
if (dbm::is_result($r)) {
- foreach($r as $g){
+ foreach ($r as $g){
$contacts[] = array(
- "type" => "c",
- "photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
- "name" => htmlentities($g['name']),
- "id" => intval($g['id']),
- "network" => $g['network'],
- "link" => $g['url'],
- "nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
- "forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
+ 'type' => 'c',
+ 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
+ 'name' => htmlentities($g['name']),
+ 'id' => intval($g['id']),
+ 'network' => $g['network'],
+ 'link' => $g['url'],
+ 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
+ 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
);
}
}
implode("','", $known_contacts)
);
if (dbm::is_result($r)){
- foreach($r as $row) {
+ foreach ($r as $row) {
// nickname..
$up = parse_url($row['author-link']);
$nick = explode("/",$up['path']);
$nick .= "@".$up['host'];
// /nickname
$unknow_contacts[] = array(
- "type" => "c",
- "photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
- "name" => htmlentities($row['author-name']),
- "id" => '',
- "network" => "unknown",
- "link" => $row['author-link'],
- "nick" => htmlentities($nick),
- "forum" => false
+ 'type' => 'c',
+ 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
+ 'name' => htmlentities($row['author-name']),
+ 'id' => '',
+ 'network' => 'unknown',
+ 'link' => $row['author-link'],
+ 'nick' => htmlentities($nick),
+ 'forum' => false
);
}
}
}
$results = array(
- "tot" => $tot,
- "start" => $start,
- "count" => $count,
- "groups" => $groups,
- "contacts" => $contacts,
- "items" => $items,
- "type" => $type,
- "search" => $search,
+ 'tot' => $tot,
+ 'start' => $start,
+ 'count' => $count,
+ 'groups' => $groups,
+ 'contacts' => $contacts,
+ 'items' => $items,
+ 'type' => $type,
+ 'search' => $search,
);
call_hooks('acl_lookup_end', $results);
if($out_type === 'html') {
$o = array(
- 'tot' => $results["tot"],
- 'start' => $results["start"],
- 'count' => $results["count"],
- 'groups' => $results["groups"],
- 'contacts' => $results["contacts"],
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'groups' => $results['groups'],
+ 'contacts' => $results['contacts'],
);
return $o;
}
$o = array(
- 'tot' => $results["tot"],
- 'start' => $results["start"],
- 'count' => $results["count"],
- 'items' => $results["items"],
+ 'tot' => $results['tot'],
+ 'start' => $results['start'],
+ 'count' => $results['count'],
+ 'items' => $results['items'],
);
echo json_encode($o);
}
/**
* @brief Searching for global contacts for autocompletion
- *
+ *
* @param App $a
* @return array with the search results
*/
-function navbar_complete(&$a) {
+function navbar_complete(App $a) {
// logger('navbar_complete');
- if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
return;
}
$mode = $_REQUEST['smode'];
// don't search if search term has less than 2 characters
- if(! $search || mb_strlen($search) < 2)
+ if (! $search || mb_strlen($search) < 2) {
return array();
+ }
- if(substr($search,0,1) === '@')
+ if (substr($search,0,1) === '@') {
$search = substr($search,1);
+ }
- if($localsearch) {
+ if ($localsearch) {
$x = DirSearch::global_search_by_name($search, $mode);
return $x;
}
- if(! $localsearch) {
+ if (! $localsearch) {
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
$x = z_fetch_url(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
- if($x['success']) {
+ if ($x['success']) {
$t = 0;
$j = json_decode($x['body'],true);
- if($j && $j['results']) {
+ if ($j && $j['results']) {
return $j['results'];
}
}
}
+
+ /// @TODO Not needed here?
return;
}