Continued with coding convention:

- added curly braces around conditional code blocks
- added space between if/foreach/... and brace
- made some SQL keywords upper-cased and added back-ticks to columns/table names

Signed-off-by: Roland Haeder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-20 21:31:05 +01:00
parent 04d90d9780
commit 536f078ed4
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
9 changed files with 78 additions and 56 deletions

View file

@ -66,7 +66,7 @@ function do_like($item_id, $verb) {
$owner_uid = $item['uid']; $owner_uid = $item['uid'];
if(! can_write_wall($a,$owner_uid)) { if (! can_write_wall($a,$owner_uid)) {
return false; return false;
} }
@ -81,8 +81,9 @@ function do_like($item_id, $verb) {
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
return false; return false;
} }
if(! $r[0]['self']) if (! $r[0]['self']) {
$remote_owner = $r[0]; $remote_owner = $r[0];
}
} }
// this represents the post owner on this system. // this represents the post owner on this system.
@ -91,21 +92,22 @@ function do_like($item_id, $verb) {
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1", WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid) intval($owner_uid)
); );
if (dbm::is_result($r)) if (dbm::is_result($r)) {
$owner = $r[0]; $owner = $r[0];
}
if(! $owner) { if (! $owner) {
logger('like: no owner'); logger('like: no owner');
return false; return false;
} }
if(! $remote_owner) if (! $remote_owner) {
$remote_owner = $owner; $remote_owner = $owner;
}
// This represents the person posting // This represents the person posting
if((local_user()) && (local_user() == $owner_uid)) { if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner; $contact = $owner;
} }
else { else {
@ -116,7 +118,7 @@ function do_like($item_id, $verb) {
if (dbm::is_result($r)) if (dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
} }
if(! $contact) { if (! $contact) {
return false; return false;
} }
@ -125,7 +127,7 @@ function do_like($item_id, $verb) {
// event participation are essentially radio toggles. If you make a subsequent choice, // event participation are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice. // we need to eradicate your first choice.
if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) { if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' "; $verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
} }
@ -162,8 +164,9 @@ function do_like($item_id, $verb) {
$uri = item_new_uri($a->get_hostname(),$owner_uid); $uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status')); $post_type = (($item['resource-id']) ? t('photo') : t('status'));
if($item['object-type'] === ACTIVITY_OBJ_EVENT) if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$post_type = t('event'); $post_type = t('event');
}
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ); $objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
$link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ; $link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$body = $item['body']; $body = $item['body'];
@ -179,20 +182,31 @@ function do_like($item_id, $verb) {
<content>$body</content> <content>$body</content>
</object> </object>
EOT; EOT;
if($verb === 'like') if ($verb === 'like') {
$bodyverb = t('%1$s likes %2$s\'s %3$s'); $bodyverb = t('%1$s likes %2$s\'s %3$s');
if($verb === 'dislike') }
if ($verb === 'dislike') {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s'); $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
if($verb === 'attendyes') }
if ($verb === 'attendyes') {
$bodyverb = t('%1$s is attending %2$s\'s %3$s'); $bodyverb = t('%1$s is attending %2$s\'s %3$s');
if($verb === 'attendno') }
if ($verb === 'attendno') {
$bodyverb = t('%1$s is not attending %2$s\'s %3$s'); $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
if($verb === 'attendmaybe') }
if ($verb === 'attendmaybe') {
$bodyverb = t('%1$s may attend %2$s\'s %3$s'); $bodyverb = t('%1$s may attend %2$s\'s %3$s');
}
if(! isset($bodyverb)) if (! isset($bodyverb)) {
return false; return false;
}
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
/// @TODO Or rewrite this to multi-line initialization of the array?
$arr = array(); $arr = array();
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
@ -212,12 +226,7 @@ EOT;
$arr['author-name'] = $contact['name']; $arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url']; $arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb']; $arr['author-avatar'] = $contact['thumb'];
$ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink ); $arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
$arr['verb'] = $activity; $arr['verb'] = $activity;
$arr['object-type'] = $objtype; $arr['object-type'] = $objtype;
$arr['object'] = $obj; $arr['object'] = $obj;
@ -231,7 +240,7 @@ EOT;
$post_id = item_store($arr); $post_id = item_store($arr);
if(! $item['visible']) { if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)

View file

@ -646,8 +646,9 @@ function item_post(App &$a) {
intval($mtch) intval($mtch)
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
if(strlen($attachments)) if (strlen($attachments)) {
$attachments .= ','; $attachments .= ',';
}
$attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]'; $attachments .= '[attach]href="' . App::get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
} }
$body = str_replace($match[1],'',$body); $body = str_replace($match[1],'',$body);
@ -656,14 +657,17 @@ function item_post(App &$a) {
$wall = 0; $wall = 0;
if($post_type === 'wall' || $post_type === 'wall-comment') if ($post_type === 'wall' || $post_type === 'wall-comment') {
$wall = 1; $wall = 1;
}
if(! strlen($verb)) if (! strlen($verb)) {
$verb = ACTIVITY_POST ; $verb = ACTIVITY_POST ;
}
if ($network == "") if ($network == "") {
$network = NETWORK_DFRN; $network = NETWORK_DFRN;
}
$gravity = (($parent) ? 6 : 0 ); $gravity = (($parent) ? 6 : 0 );
@ -677,8 +681,9 @@ function item_post(App &$a) {
$uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid, $guid)); $uri = (($message_id) ? $message_id : item_new_uri($a->get_hostname(),$profile_uid, $guid));
// Fallback so that we alway have a thr-parent // Fallback so that we alway have a thr-parent
if(!$thr_parent) if (!$thr_parent) {
$thr_parent = $uri; $thr_parent = $uri;
}
$datarray = array(); $datarray = array();
$datarray['uid'] = $profile_uid; $datarray['uid'] = $profile_uid;

View file

@ -26,7 +26,6 @@ function noscrape_init(App &$a) {
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords); $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
$keywords = explode(',', $keywords); $keywords = explode(',', $keywords);
/// @TODO This query's result is not being used (see below), maybe old-lost code?
$r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d", $r = q("SELECT `photo` FROM `contact` WHERE `self` AND `uid` = %d",
intval($a->profile['uid'])); intval($a->profile['uid']));

View file

@ -627,7 +627,7 @@ function settings_post(App &$a) {
); );
} }
if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) { if (($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) {
// Update global directory in background // Update global directory in background
$url = $_SESSION['my_url']; $url = $_SESSION['my_url'];
if ($url && strlen(get_config('system','directory'))) { if ($url && strlen(get_config('system','directory'))) {
@ -642,10 +642,10 @@ function settings_post(App &$a) {
update_gcontact_for_user(local_user()); update_gcontact_for_user(local_user());
//$_SESSION['theme'] = $theme; //$_SESSION['theme'] = $theme;
if($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) { if ($email_changed && $a->config['register_policy'] == REGISTER_VERIFY) {
// FIXME - set to un-verified, blocked and redirect to logout /// @TODO set to un-verified, blocked and redirect to logout
// Why? Are we verifying people or email addresses? /// @TODO Why? Are we verifying people or email addresses?
} }

View file

@ -17,7 +17,7 @@ function starred_init(App &$a) {
killme(); killme();
} }
$r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1", $r = q("SELECT `starred` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
); );
@ -25,10 +25,11 @@ function starred_init(App &$a) {
killme(); killme();
} }
if(! intval($r[0]['starred'])) if (! intval($r[0]['starred'])) {
$starred = 1; $starred = 1;
}
$r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d", $r = q("UPDATE `item` SET `starred` = %d WHERE `uid` = %d AND `id` = %d",
intval($starred), intval($starred),
intval(local_user()), intval(local_user()),
intval($message_id) intval($message_id)
@ -38,10 +39,14 @@ function starred_init(App &$a) {
// See if we've been passed a return path to redirect to // See if we've been passed a return path to redirect to
$return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
if($return_path) { if ($return_path) {
$rand = '_=' . time(); $rand = '_=' . time();
if(strpos($return_path, '?')) $rand = "&$rand"; if (strpos($return_path, '?')) {
else $rand = "?$rand"; $rand = "&$rand";
}
else {
$rand = "?$rand";
}
goaway(App::get_baseurl() . "/" . $return_path . $rand); goaway(App::get_baseurl() . "/" . $return_path . $rand);
} }

View file

@ -44,8 +44,9 @@ function subthread_content(App &$a) {
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
return; return;
} }
if(! $r[0]['self']) if (! $r[0]['self']) {
$remote_owner = $r[0]; $remote_owner = $r[0];
}
} }
// this represents the post owner on this system. // this represents the post owner on this system.
@ -57,18 +58,18 @@ function subthread_content(App &$a) {
if (dbm::is_result($r)) if (dbm::is_result($r))
$owner = $r[0]; $owner = $r[0];
if(! $owner) { if (! $owner) {
logger('like: no owner'); logger('like: no owner');
return; return;
} }
if(! $remote_owner) if (! $remote_owner)
$remote_owner = $owner; $remote_owner = $owner;
// This represents the person posting // This represents the person posting
if((local_user()) && (local_user() == $owner_uid)) { if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner; $contact = $owner;
} }
else { else {
@ -79,7 +80,7 @@ function subthread_content(App &$a) {
if (dbm::is_result($r)) if (dbm::is_result($r))
$contact = $r[0]; $contact = $r[0];
} }
if(! $contact) { if (! $contact) {
return; return;
} }
@ -103,8 +104,9 @@ function subthread_content(App &$a) {
EOT; EOT;
$bodyverb = t('%1$s is following %2$s\'s %3$s'); $bodyverb = t('%1$s is following %2$s\'s %3$s');
if(! isset($bodyverb)) if (! isset($bodyverb)) {
return; return;
}
$arr = array(); $arr = array();
@ -144,7 +146,7 @@ EOT;
$post_id = item_store($arr); $post_id = item_store($arr);
if(! $item['visible']) { if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d", $r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']), intval($item['id']),
intval($owner_uid) intval($owner_uid)

View file

@ -94,8 +94,9 @@ EOT;
$bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s'); $bodyverb = t('%1$s tagged %2$s\'s %3$s with %4$s');
if(! isset($bodyverb)) if (! isset($bodyverb)) {
return; return;
}
$termlink = html_entity_decode('&#x2317;') . '[url=' . App::get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; $termlink = html_entity_decode('&#x2317;') . '[url=' . App::get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';

View file

@ -59,7 +59,7 @@ function tagrm_content(App &$a) {
} }
$item = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
if(! $item) { if (! $item) {
goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']); goaway(App::get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED // NOTREACHED
} }
@ -87,8 +87,7 @@ function tagrm_content(App &$a) {
$o .= '<input type="hidden" name="item" value="' . $item . '" />'; $o .= '<input type="hidden" name="item" value="' . $item . '" />';
$o .= '<ul>'; $o .= '<ul>';
foreach ($arr as $x) {
foreach($arr as $x) {
$o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>'; $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
} }
@ -98,5 +97,5 @@ function tagrm_content(App &$a) {
$o .= '</form>'; $o .= '</form>';
return $o; return $o;
} }

View file

@ -41,13 +41,15 @@ function xrd_init(App &$a) {
$profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname']; $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
if ($acct) if ($acct) {
$alias = $profile_url; $alias = $profile_url;
}
else { else {
$alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname(); $alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
if ($a->get_path()) if ($a->get_path()) {
$alias .= '/'.$a->get_path(); $alias .= '/'.$a->get_path();
}
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(
@ -65,7 +67,7 @@ function xrd_init(App &$a) {
'$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', '$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
'$subscribe' => App::get_baseurl() . '/follow?url={uri}', '$subscribe' => App::get_baseurl() . '/follow?url={uri}',
'$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
'$bigkey' => salmon_key($r[0]['pubkey']) '$bigkey' => salmon_key($r[0]['pubkey']),
)); ));