From 63e4750b4abfd0ce80caf65b20d73d9ec9ef756f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 23 Jan 2017 09:50:25 +0100 Subject: [PATCH] more coding convention applied: - added curly braces - added spaces where needed - $r only needs to be tested with dbm::is_result() - made SQL keywords all uper-case MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- mod/contacts.php | 18 +++++++++++------- mod/crepair.php | 18 +++++++++++------- mod/message.php | 3 ++- mod/profiles.php | 10 ++++++---- mod/settings.php | 7 ++++--- mod/wall_upload.php | 8 ++++---- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/mod/contacts.php b/mod/contacts.php index a2a77e2a5c..70f4b73508 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -136,8 +136,7 @@ function contacts_batch_actions(App $a) { if (x($_SESSION,'return_url')) { goaway('' . $_SESSION['return_url']); - } - else { + } else { goaway('contacts'); } @@ -194,8 +193,10 @@ function contacts_post(App $a) { $ffi_keyword_blacklist = escape_tags(trim($_POST['ffi_keyword_blacklist'])); $priority = intval($_POST['poll']); - if($priority > 5 || $priority < 0) + + if ($priority > 5 || $priority < 0) { $priority = 0; + } $info = escape_tags(trim($_POST['info'])); @@ -212,17 +213,20 @@ function contacts_post(App $a) { intval($contact_id), intval(local_user()) ); - if($r) + if ($r) { info( t('Contact updated.') . EOL); - else + } else { notice( t('Failed to update contact record.') . EOL); + } - $r = q("select * from contact where id = %d and uid = %d limit 1", + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_user()) ); - if($r && dbm::is_result($r)) + + if (dbm::is_result($r)) { $a->data['contact'] = $r[0]; + } return; diff --git a/mod/crepair.php b/mod/crepair.php index 902a129303..ef7908661b 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -20,10 +20,11 @@ function crepair_init(App $a) { } } - if(! x($a->page,'aside')) + if (! x($a->page,'aside')) { $a->page['aside'] = ''; + } - if($contact_id) { + if ($contact_id) { $a->data['contact'] = $r[0]; $contact = $r[0]; profile_load($a, "", 0, get_contact_details_by_url($contact["url"])); @@ -35,9 +36,12 @@ function crepair_post(App $a) { return; } + // Init $r here if $cid is not set + $r = false; + $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); - if($cid) { + if ($cid) { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), intval(local_user()) @@ -78,18 +82,18 @@ function crepair_post(App $a) { local_user() ); - if($photo) { + if ($photo) { logger('mod-crepair: updating photo from ' . $photo); require_once("include/Photo.php"); update_contact_avatar($photo,local_user(),$contact['id']); } - if($r) + if ($r) { info( t('Contact settings applied.') . EOL); - else + } else { notice( t('Contact update failed.') . EOL); - + } return; } diff --git a/mod/message.php b/mod/message.php index 9e96691466..df5b4709b4 100644 --- a/mod/message.php +++ b/mod/message.php @@ -251,8 +251,9 @@ function message_content(App $a) { // ); //} - if($r) + if ($r) { info( t('Conversation removed.') . EOL ); + } } //goaway(App::get_baseurl(true) . '/message' ); goaway($_SESSION['return_url']); diff --git a/mod/profiles.php b/mod/profiles.php index 4c6ff926b6..e359e9efb9 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -34,8 +34,9 @@ function profiles_init(App $a) { intval($a->argv[2]), intval(local_user()) ); - if($r) + if ($r) { info(t('Profile deleted.').EOL); + } goaway('profiles'); return; // NOTREACHED @@ -473,11 +474,12 @@ function profiles_post(App $a) { intval(local_user()) ); - if($r) + if ($r) { info( t('Profile updated.') . EOL); + } - if($namechanged && $is_default) { + if ($namechanged && $is_default) { $r = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d", dbesc($name), dbesc(datetime_convert()), @@ -489,7 +491,7 @@ function profiles_post(App $a) { ); } - if($is_default) { + if ($is_default) { $location = formatted_location(array("locality" => $locality, "region" => $region, "country-name" => $country_name)); q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d", diff --git a/mod/settings.php b/mod/settings.php index 94b93f9b95..b77b1336d1 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -397,7 +397,7 @@ function settings_post(App $a) { dbesc($password), intval(local_user()) ); - if($r) { + if ($r) { info( t('Password changed.') . EOL); } else { notice( t('Password update failed. Please try again.') . EOL); @@ -602,8 +602,9 @@ function settings_post(App $a) { dbesc($language), intval(local_user()) ); - if($r) + if ($r) { info( t('Settings updated.') . EOL); + } // clear session language unset($_SESSION['language']); @@ -622,7 +623,7 @@ function settings_post(App $a) { ); - if($name_change) { + if ($name_change) { q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `self`", dbesc($username), dbesc(datetime_convert()), diff --git a/mod/wall_upload.php b/mod/wall_upload.php index 1f71f36b62..fa30a8ad37 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -228,14 +228,14 @@ function wall_upload_post(App $a, $desktopmode = true) { if($width > 640 || $height > 640) { $ph->scaleImage(640); $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 1, 0, $defperm); - if($r) + if ($r) $smallest = 1; } - if($width > 320 || $height > 320) { + if ($width > 320 || $height > 320) { $ph->scaleImage(320); $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 2, 0, $defperm); - if($r AND ($smallest == 0)) + if ($r AND ($smallest == 0)) $smallest = 2; } @@ -244,7 +244,7 @@ function wall_upload_post(App $a, $desktopmode = true) { if (!$desktopmode) { $r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash); - if (!$r){ + if (!dbm::is_result($r)) { if ($r_json) { echo json_encode(array('error'=>'')); killme(); -- 2.39.5