Continued with code convention:

- added more curly braces
- added space betweent if/foreach and brace
- added spaces for beautification
- converted some " to ' (mixed usage)

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-22 15:30:23 +01:00
parent 20e71d21a6
commit c9194b0381
4 changed files with 111 additions and 96 deletions

View file

@ -85,6 +85,7 @@ function contact_remove($id) {
function terminate_friendship($user,$self,$contact) { function terminate_friendship($user,$self,$contact) {
/// @TODO Get rid of this, include/datetime.php should care about by itself
$a = get_app(); $a = get_app();
require_once('include/datetime.php'); require_once('include/datetime.php');
@ -103,12 +104,10 @@ function terminate_friendship($user,$self,$contact) {
require_once('include/salmon.php'); require_once('include/salmon.php');
slapper($user,$contact['notify'],$slap); slapper($user,$contact['notify'],$slap);
} }
} } elseif ($contact['network'] === NETWORK_DIASPORA) {
elseif($contact['network'] === NETWORK_DIASPORA) {
require_once('include/diaspora.php'); require_once('include/diaspora.php');
Diaspora::send_unshare($user,$contact); Diaspora::send_unshare($user,$contact);
} } elseif ($contact['network'] === NETWORK_DFRN) {
elseif($contact['network'] === NETWORK_DFRN) {
require_once('include/dfrn.php'); require_once('include/dfrn.php');
dfrn::deliver($user,$contact,'placeholder', 1); dfrn::deliver($user,$contact,'placeholder', 1);
} }

View file

@ -69,14 +69,18 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
if (x($options,'size')) if (x($options,'size'))
$size = $options['size']; $size = $options['size'];
if(x($options,'mutual_friends')) if (x($options,'mutual_friends')) {
$mutual = true; $mutual = true;
if(x($options,'single')) }
if (x($options,'single')) {
$single = true; $single = true;
if(x($options,'multiple')) }
if (x($options,'multiple')) {
$single = false; $single = false;
if(x($options,'exclude')) }
if (x($options,'exclude')) {
$exclude = $options['exclude']; $exclude = $options['exclude'];
}
if (x($options,'networks')) { if (x($options,'networks')) {
switch($options['networks']) { switch($options['networks']) {
@ -146,10 +150,11 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected)) if ((is_array($preselected)) && in_array($rr['id'], $preselected)) {
$selected = " selected=\"selected\" "; $selected = " selected=\"selected\" ";
else } else {
$selected = ''; $selected = '';
}
$trimmed = mb_substr($rr['name'],0,20); $trimmed = mb_substr($rr['name'],0,20);
@ -231,8 +236,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
if ($privmail) { if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false); $trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
} } else {
else {
$trimmed = mb_substr($rr['name'],0,20); $trimmed = mb_substr($rr['name'],0,20);
} }
@ -260,16 +264,22 @@ function fixacl(&$item) {
function prune_deadguys($arr) { function prune_deadguys($arr) {
if(! $arr) if (! $arr) {
return $arr; return $arr;
}
$str = dbesc(implode(',',$arr)); $str = dbesc(implode(',',$arr));
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
if ($r) { if ($r) {
$ret = array(); $ret = array();
foreach($r as $rr) foreach ($r as $rr) {
$ret[] = intval($rr['id']); $ret[] = intval($rr['id']);
}
return $ret; return $ret;
} }
return array(); return array();
} }
@ -545,28 +555,26 @@ function acl_lookup(&$a, $out_type = 'json') {
dbesc(NETWORK_ZOT), dbesc(NETWORK_ZOT),
dbesc(NETWORK_DIASPORA) dbesc(NETWORK_DIASPORA)
); );
} } elseif ($type == 'a') {
elseif($type == 'a') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact` $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND `pending` = 0 WHERE `uid` = %d AND `pending` = 0
$sql_extra2 $sql_extra2
ORDER BY `name` ASC ", ORDER BY `name` ASC ",
intval(local_user()) intval(local_user())
); );
} } elseif ($type == 'x') {
elseif($type == 'x') {
// autocomplete for global contact search (e.g. navbar search) // autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a); $r = navbar_complete($a);
$contacts = array(); $contacts = array();
if ($r) { if ($r) {
foreach ($r as $g) { foreach ($r as $g) {
$contacts[] = array( $contacts[] = array(
"photo" => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
"name" => $g['name'], 'name' => $g['name'],
"nick" => (x($g['addr']) ? $g['addr'] : $g['url']), 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
"network" => $g['network'], 'network' => $g['network'],
"link" => $g['url'], 'link' => $g['url'],
"forum" => (x($g['community']) ? 1 : 0), 'forum' => (x($g['community']) ? 1 : 0),
); );
} }
} }
@ -585,14 +593,14 @@ function acl_lookup(&$a, $out_type = 'json') {
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
foreach ($r as $g){ foreach ($r as $g){
$contacts[] = array( $contacts[] = array(
"type" => "c", 'type' => 'c',
"photo" => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
"name" => htmlentities($g['name']), 'name' => htmlentities($g['name']),
"id" => intval($g['id']), 'id' => intval($g['id']),
"network" => $g['network'], 'network' => $g['network'],
"link" => $g['url'], 'link' => $g['url'],
"nick" => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
"forum" => ((x($g['forum']) || x($g['prv'])) ? 1 : 0), 'forum' => ((x($g['forum']) || x($g['prv'])) ? 1 : 0),
); );
} }
} }
@ -626,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') {
$nick .= "@".$up['host']; $nick .= "@".$up['host'];
// /nickname // /nickname
$unknow_contacts[] = array( $unknow_contacts[] = array(
"type" => "c", 'type' => 'c',
"photo" => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($row['author-avatar'], false, PROXY_SIZE_MICRO),
"name" => htmlentities($row['author-name']), 'name' => htmlentities($row['author-name']),
"id" => '', 'id' => '',
"network" => "unknown", 'network' => 'unknown',
"link" => $row['author-link'], 'link' => $row['author-link'],
"nick" => htmlentities($nick), 'nick' => htmlentities($nick),
"forum" => false 'forum' => false
); );
} }
} }
@ -643,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') {
} }
$results = array( $results = array(
"tot" => $tot, 'tot' => $tot,
"start" => $start, 'start' => $start,
"count" => $count, 'count' => $count,
"groups" => $groups, 'groups' => $groups,
"contacts" => $contacts, 'contacts' => $contacts,
"items" => $items, 'items' => $items,
"type" => $type, 'type' => $type,
"search" => $search, 'search' => $search,
); );
call_hooks('acl_lookup_end', $results); call_hooks('acl_lookup_end', $results);
if($out_type === 'html') { if($out_type === 'html') {
$o = array( $o = array(
'tot' => $results["tot"], 'tot' => $results['tot'],
'start' => $results["start"], 'start' => $results['start'],
'count' => $results["count"], 'count' => $results['count'],
'groups' => $results["groups"], 'groups' => $results['groups'],
'contacts' => $results["contacts"], 'contacts' => $results['contacts'],
); );
return $o; return $o;
} }
$o = array( $o = array(
'tot' => $results["tot"], 'tot' => $results['tot'],
'start' => $results["start"], 'start' => $results['start'],
'count' => $results["count"], 'count' => $results['count'],
'items' => $results["items"], 'items' => $results['items'],
); );
echo json_encode($o); echo json_encode($o);
@ -698,11 +706,13 @@ function navbar_complete(App &$a) {
$mode = $_REQUEST['smode']; $mode = $_REQUEST['smode'];
// don't search if search term has less than 2 characters // 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(); return array();
}
if(substr($search,0,1) === '@') if (substr($search,0,1) === '@') {
$search = substr($search,1); $search = substr($search,1);
}
if ($localsearch) { if ($localsearch) {
$x = DirSearch::global_search_by_name($search, $mode); $x = DirSearch::global_search_by_name($search, $mode);
@ -721,5 +731,7 @@ function navbar_complete(App &$a) {
} }
} }
} }
/// @TODO Not needed here?
return; return;
} }

View file

@ -117,8 +117,7 @@ function fbrowser_content(App &$a){
if ($a->theme['template_engine'] === 'internal') { if ($a->theme['template_engine'] === 'internal') {
$filename_e = template_escape($rr['filename']); $filename_e = template_escape($rr['filename']);
} } else {
else {
$filename_e = $rr['filename']; $filename_e = $rr['filename'];
} }

View file

@ -21,21 +21,24 @@ function ostatus_subscribe_content(App &$a) {
if (get_pconfig($uid, "ostatus", "legacy_friends") == "") { if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
if ($_REQUEST["url"] == "") if ($_REQUEST["url"] == "") {
return $o.t("No contact provided."); return $o.t("No contact provided.");
}
$contact = probe_url($_REQUEST["url"]); $contact = probe_url($_REQUEST["url"]);
if (!$contact) if (!$contact) {
return $o.t("Couldn't fetch information for contact."); return $o.t("Couldn't fetch information for contact.");
}
$api = $contact["baseurl"]."/api/"; $api = $contact["baseurl"]."/api/";
// Fetching friends // Fetching friends
$data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]); $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
if (!$data["success"]) if (!$data["success"]) {
return $o.t("Couldn't fetch friends for contact."); return $o.t("Couldn't fetch friends for contact.");
}
set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]); set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
} }
@ -61,12 +64,14 @@ function ostatus_subscribe_content(App &$a) {
$data = probe_url($url); $data = probe_url($url);
if ($data["network"] == NETWORK_OSTATUS) { if ($data["network"] == NETWORK_OSTATUS) {
$result = new_contact($uid,$url,true); $result = new_contact($uid,$url,true);
if ($result["success"]) if ($result["success"]) {
$o .= " - ".t("success"); $o .= " - ".t("success");
else } else {
$o .= " - ".t("failed"); $o .= " - ".t("failed");
} else }
} else {
$o .= " - ".t("ignored"); $o .= " - ".t("ignored");
}
$o .= "</p>"; $o .= "</p>";