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 061bcd7d2f
commit 4011f244d6
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) {
/// @TODO Get rid of this, include/datetime.php should care about by itself
$a = get_app();
require_once('include/datetime.php');
@ -103,12 +104,10 @@ function terminate_friendship($user,$self,$contact) {
require_once('include/salmon.php');
slapper($user,$contact['notify'],$slap);
}
}
elseif($contact['network'] === NETWORK_DIASPORA) {
} elseif ($contact['network'] === NETWORK_DIASPORA) {
require_once('include/diaspora.php');
Diaspora::send_unshare($user,$contact);
}
elseif($contact['network'] === NETWORK_DFRN) {
} elseif ($contact['network'] === NETWORK_DFRN) {
require_once('include/dfrn.php');
dfrn::deliver($user,$contact,'placeholder', 1);
}

View file

@ -69,14 +69,18 @@ function contact_selector($selname, $selclass, $preselected = false, $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')) {
switch($options['networks']) {
@ -146,10 +150,11 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
if (dbm::is_result($r)) {
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\" ";
else
} else {
$selected = '';
}
$trimmed = mb_substr($rr['name'],0,20);
@ -231,8 +236,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
if ($privmail) {
$trimmed = GetProfileUsername($rr['url'], $rr['name'], false);
}
else {
} else {
$trimmed = mb_substr($rr['name'],0,20);
}
@ -260,16 +264,22 @@ function fixacl(&$item) {
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) {
$ret = array();
foreach($r as $rr)
foreach ($r as $rr) {
$ret[] = intval($rr['id']);
}
return $ret;
}
return array();
}
@ -545,28 +555,26 @@ function acl_lookup(&$a, $out_type = 'json') {
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) {
$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),
);
}
}
@ -585,14 +593,14 @@ function acl_lookup(&$a, $out_type = 'json') {
if (dbm::is_result($r)) {
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),
);
}
}
@ -626,14 +634,14 @@ function acl_lookup(&$a, $out_type = 'json') {
$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
);
}
}
@ -643,34 +651,34 @@ function acl_lookup(&$a, $out_type = 'json') {
}
$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);
@ -698,11 +706,13 @@ function navbar_complete(App &$a) {
$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) {
$x = DirSearch::global_search_by_name($search, $mode);
@ -721,5 +731,7 @@ function navbar_complete(App &$a) {
}
}
}
/// @TODO Not needed here?
return;
}

View file

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

View file

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