Failed Conditions
Pull Request — master (#1324)
by Nick
34:37 queued 19:37
created
www/docs/topic/image.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
     $topic = $topics->getTopic($slug);
9 9
 }
10 10
 
11
-if (!$slug || !isset($topic) || $topic === NULL) {
11
+if (!$slug || !isset($topic) || $topic === null) {
12 12
     header('HTTP/1.0 404 Not Found');
13 13
     exit();
14 14
 }
Please login to merge, or discard this patch.
www/docs/admin/featured.php 3 patches
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     $related2 = get_http_var('related2');
108 108
     $related3 = get_http_var('related3');
109 109
 
110
-    $gid = $url ? get_gid_from_url($url) : NULL;
111
-    $related_gid1 = $related1 ? get_gid_from_url($related1) : NULL;
112
-    $related_gid2 = $related2 ? get_gid_from_url($related2) : NULL;
113
-    $related_gid3 = $related3 ? get_gid_from_url($related3) : NULL;
110
+    $gid = $url ? get_gid_from_url($url) : null;
111
+    $related_gid1 = $related1 ? get_gid_from_url($related1) : null;
112
+    $related_gid2 = $related2 ? get_gid_from_url($related2) : null;
113
+    $related_gid3 = $related3 ? get_gid_from_url($related3) : null;
114 114
 
115 115
     print "<h2>Preview Content</h2>";
116
-    if ( $gid !== NULL ) {
116
+    if ( $gid !== null ) {
117 117
         $h = new MySociety\TheyWorkForYou\Homepage;
118 118
         $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 ));
119 119
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 }
154 154
 
155 155
 function get_gid_from_url($url) {
156
-    $gid = NULL;
156
+    $gid = null;
157 157
     $parts = parse_url($url);
158 158
     parse_str($parts['query'], $query);
159 159
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $out = '';
13 13
 if (get_http_var('preview')) {
14 14
     preview_featured();
15
-} else if ( get_http_var('confirm') ) {
15
+} else if (get_http_var('confirm')) {
16 16
     $out = update_featured();
17 17
 }
18 18
 
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 print '</div>';
24 24
 
25 25
 function gid_to_url($gid) {
26
-    if ( !$gid ) {
26
+    if (!$gid) {
27 27
         return '';
28 28
     }
29 29
     global $hansardmajors;
30 30
     global $db;
31 31
 
32
-    $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ));
32
+    $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
33 33
     $url_gid = fix_gid_from_db($gid);
34 34
     $url = new \URL($hansardmajors[$q->field(0, 'major')]['page']);
35 35
     $url->insert(array('id' => $url_gid));
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     $related = $featured->get_related();
44 44
     $context = $featured->get_context();
45 45
 
46
-    if ( get_http_var('url') ) {
46
+    if (get_http_var('url')) {
47 47
         $url = get_http_var('url');
48 48
         $title = get_http_var('title');
49 49
         $context = get_http_var('context');
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
     $related_gid3 = $related3 ? get_gid_from_url($related3) : NULL;
114 114
 
115 115
     print "<h2>Preview Content</h2>";
116
-    if ( $gid !== NULL ) {
116
+    if ($gid !== NULL) {
117 117
         $h = new MySociety\TheyWorkForYou\Homepage;
118
-        $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 ));
118
+        $featured = $h->getFeaturedDebate($gid, $title, $context, array($related_gid1, $related_gid2, $related_gid3));
119 119
 
120 120
         include INCLUDESPATH . 'easyparliament/templates/html/homepage/featured.php';
121 121
     } else {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     $parts = parse_url($url);
158 158
     parse_str($parts['query'], $query);
159 159
 
160
-    if ( $query['id'] ) {
160
+    if ($query['id']) {
161 161
         if (strpos($parts['path'], 'lords') !== false) {
162 162
             $gid = 'uk.org.publicwhip/lords/';
163 163
         } elseif (strpos($parts['path'], 'whall') !== false) {
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@  discard block
 block discarded – undo
12 12
 $out = '';
13 13
 if (get_http_var('preview')) {
14 14
     preview_featured();
15
-} else if ( get_http_var('confirm') ) {
15
+}
16
+else if ( get_http_var('confirm') ) {
16 17
     $out = update_featured();
17 18
 }
18 19
 
@@ -50,7 +51,8 @@  discard block
 block discarded – undo
50 51
         $related1 = get_http_var('related1');
51 52
         $related2 = get_http_var('related2');
52 53
         $related3 = get_http_var('related3');
53
-    } else {
54
+    }
55
+    else {
54 56
         $url = gid_to_url($gid);
55 57
         $related1 = gid_to_url($related[0]);
56 58
         $related2 = gid_to_url($related[1]);
@@ -118,7 +120,8 @@  discard block
 block discarded – undo
118 120
         $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 ));
119 121
 
120 122
         include INCLUDESPATH . 'easyparliament/templates/html/homepage/featured.php';
121
-    } else {
123
+    }
124
+    else {
122 125
         print "<p>A random debate from the last 7 days will be displayed</p>";
123 126
     }
124 127
 
@@ -160,9 +163,11 @@  discard block
 block discarded – undo
160 163
     if ( $query['id'] ) {
161 164
         if (strpos($parts['path'], 'lords') !== false) {
162 165
             $gid = 'uk.org.publicwhip/lords/';
163
-        } elseif (strpos($parts['path'], 'whall') !== false) {
166
+        }
167
+        elseif (strpos($parts['path'], 'whall') !== false) {
164 168
             $gid = 'uk.org.publicwhip/westminhall/';
165
-        } else {
169
+        }
170
+        else {
166 171
             $gid = 'uk.org.publicwhip/debate/';
167 172
         }
168 173
         $gid .= $query['id'];
Please login to merge, or discard this patch.
www/docs/admin/photos.php 3 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 </form>
140 140
 
141 141
 <p style="clear:both; margin-top: 3em"><a href="/images/mps/photo-status.php">List MPs without photos</a></p>
142
-EOF;
142
+eof;
143 143
 
144 144
     return $out;
145 145
 }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     <span class="formw"><input type="submit" name="submit" value="Update attribution"></span>
194 194
 </div>
195 195
 </form>
196
-EOF;
196
+eof;
197 197
 
198 198
     return $out;
199 199
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
     $houses = array(1 => 'MP', 'Lord', 'MLA', 'MSP');
96 96
 
97
-    for ($i=0; $i<$q->rows(); $i++) {
97
+    for ($i = 0; $i < $q->rows(); $i++) {
98 98
         $p_id = $q->field($i, 'person_id');
99 99
         $house = $q->field($i, 'house');
100 100
         $desc = member_full_name($house, $q->field($i, 'title'), $q->field($i, 'given_name'), $q->field($i, 'family_name'), $q->field($i, 'lordofname')) .
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         } else {
113 113
             $desc .= ' [no photo]';
114 114
         }
115
-        $out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n";
115
+        $out .= '<option value="' . $p_id . '">' . $desc . '</option>' . "\n";
116 116
     }
117 117
 
118 118
     $out .= ' </select></span> </div> ';
Please login to merge, or discard this patch.
Braces   +45 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,7 +26,8 @@  discard block
 block discarded – undo
26 26
 $out = '';
27 27
 if (get_http_var('submit')) {
28 28
     $out = DEVSITE ? submit_photo() : submit_attribution();
29
-} else {
29
+}
30
+else {
30 31
     $out = DEVSITE ? display_photo_form() : display_attribution_form();
31 32
 }
32 33
 print $out;
@@ -36,28 +37,36 @@  discard block
 block discarded – undo
36 37
     $pid = intval(get_http_var('pid'));
37 38
     $errors = array();
38 39
 
39
-    if (!array_key_exists('photo', $_FILES))
40
-        array_push($errors, 'Not got the photo.');
41
-    elseif ($_FILES['photo']['error'] > 0)
42
-        array_push($errors, 'There was an error uploading the photo.');
43
-    elseif (!is_uploaded_file($_FILES['photo']['tmp_name']))
44
-        array_push($errors, 'Did not get an uploaded file.');
40
+    if (!array_key_exists('photo', $_FILES)) {
41
+            array_push($errors, 'Not got the photo.');
42
+    }
43
+    elseif ($_FILES['photo']['error'] > 0) {
44
+            array_push($errors, 'There was an error uploading the photo.');
45
+    }
46
+    elseif (!is_uploaded_file($_FILES['photo']['tmp_name'])) {
47
+            array_push($errors, 'Did not get an uploaded file.');
48
+    }
45 49
     else {
46 50
         $tmp_name = $_FILES['photo']['tmp_name'];
47 51
 
48 52
         $image = new Imagick();
49 53
         $image->readImage($tmp_name);
50
-        if (!$image)
51
-            array_push($errors, 'Failed to read image from uploaded file');
54
+        if (!$image) {
55
+                    array_push($errors, 'Failed to read image from uploaded file');
56
+        }
52 57
             $imageS = clone $image;
53
-        if (!$image->scaleImage(0, 118))
54
-            array_push($errors, 'Scaling large failed');
55
-        if (!$imageS->scaleImage(0, 59))
56
-            array_push($errors, 'Scaling small failed');
57
-        if (!$image->writeImage("$dir/mpsL/$pid.jpeg"))
58
-            array_push($errors, "Saving to $dir/mpsL/$pid.jpeg failed");
59
-        if (!$imageS->writeImage("$dir/mps/$pid.jpeg"))
60
-            array_push($errors, "Saving to $dir/mps/$pid.jpeg failed");
58
+        if (!$image->scaleImage(0, 118)) {
59
+                    array_push($errors, 'Scaling large failed');
60
+        }
61
+        if (!$imageS->scaleImage(0, 59)) {
62
+                    array_push($errors, 'Scaling small failed');
63
+        }
64
+        if (!$image->writeImage("$dir/mpsL/$pid.jpeg")) {
65
+                    array_push($errors, "Saving to $dir/mpsL/$pid.jpeg failed");
66
+        }
67
+        if (!$imageS->writeImage("$dir/mps/$pid.jpeg")) {
68
+                    array_push($errors, "Saving to $dir/mps/$pid.jpeg failed");
69
+        }
61 70
         if (!$errors) {
62 71
             print "<pre>";
63 72
             chdir($dir);
@@ -70,8 +79,9 @@  discard block
 block discarded – undo
70 79
         }
71 80
     }
72 81
 
73
-    if ($errors)
74
-        return display_photo_form($errors);
82
+    if ($errors) {
83
+            return display_photo_form($errors);
84
+    }
75 85
     return "<p><em>Photo uploaded and resized for pid $pid</em> &mdash; check how it looks <a href=\"/mp?p=$pid\">on their page</a></p>" . display_photo_form();
76 86
 }
77 87
 
@@ -99,7 +109,9 @@  discard block
 block discarded – undo
99 109
         $house = $q->field($i, 'house');
100 110
         $desc = member_full_name($house, $q->field($i, 'title'), $q->field($i, 'given_name'), $q->field($i, 'family_name'), $q->field($i, 'lordofname')) .
101 111
                 " " . $houses[$house];
102
-        if ($q->field($i, 'party')) $desc .= ' (' . $q->field($i, 'party') . ')';
112
+        if ($q->field($i, 'party')) {
113
+            $desc .= ' (' . $q->field($i, 'party') . ')';
114
+        }
103 115
         if ($q->field($i, 'constituency')) {
104 116
             $desc .= ', ' . $q->field($i, 'constituency');
105 117
         }
@@ -107,9 +119,11 @@  discard block
 block discarded – undo
107 119
         list($dummy, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($p_id);
108 120
         if ($sz == 'L') {
109 121
             $desc .= ' [has large photo]';
110
-        } elseif ($sz == 'S') {
122
+        }
123
+        elseif ($sz == 'S') {
111 124
             $desc .= ' [has small photo]';
112
-        } else {
125
+        }
126
+        else {
113 127
             $desc .= ' [no photo]';
114 128
         }
115 129
         $out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n";
@@ -150,13 +164,16 @@  discard block
 block discarded – undo
150 164
     $attr_link = get_http_var('attr_link');
151 165
     $errors = array();
152 166
 
153
-    if (!$pid || !$attr_text)
154
-        array_push($errors, 'Missing information');
155
-    elseif ($attr_link && substr($attr_link, 0, 4) != 'http')
156
-        array_push($errors, 'Bad link');
167
+    if (!$pid || !$attr_text) {
168
+            array_push($errors, 'Missing information');
169
+    }
170
+    elseif ($attr_link && substr($attr_link, 0, 4) != 'http') {
171
+            array_push($errors, 'Bad link');
172
+    }
157 173
 
158
-    if ($errors)
159
-        return display_attribution_form($errors);
174
+    if ($errors) {
175
+            return display_attribution_form($errors);
176
+    }
160 177
 
161 178
     # UPDATE
162 179
     global $db;
Please login to merge, or discard this patch.
www/docs/section.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 }
14 14
 
15 15
 if ($type = ucfirst(get_http_var('type'))) {
16
-    $class_name = "MySociety\TheyWorkForYou\SectionView\\${type}View";
16
+    $class_name = "MySociety\TheyWorkForYou\SectionView\\${type}view";
17 17
     $view = new $class_name();
18 18
     $data = $view->display();
19 19
     if ($data) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     $view = new $class_name();
18 18
     $data = $view->display();
19 19
     if ($data) {
20
-        if ( !empty($data['template']) ) {
20
+        if (!empty($data['template'])) {
21 21
             $template = $data['template'];
22 22
         } else {
23 23
             $template = 'section/section';
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@
 block discarded – undo
19 19
     if ($data) {
20 20
         if ( !empty($data['template']) ) {
21 21
             $template = $data['template'];
22
-        } else {
22
+        }
23
+        else {
23 24
             $template = 'section/section';
24 25
         }
25 26
         MySociety\TheyWorkForYou\Renderer::output($template, $data);
Please login to merge, or discard this patch.
scripts/populate-policy-images.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
49
+while ( ( $policy = fgetcsv($file) ) !== false ) {
50 50
     if ( intval($policy[0]) ) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     exit(1);
34 34
 }
35 35
 
36
-if ( !file_exists($csvfile) ) {
36
+if (!file_exists($csvfile)) {
37 37
     print "$csvfile cannot be found\n";
38 38
     exit(1);
39 39
 }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
50
-    if ( intval($policy[0]) ) {
49
+while (($policy = fgetcsv($file)) !== FALSE) {
50
+    if (intval($policy[0])) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
53 53
         $title = $policy[2];
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                 ':image_attribution' => $attribution,
70 70
                 ':license_url' => $licence_url)
71 71
         );
72
-        if ( $q->success() ) {
72
+        if ($q->success()) {
73 73
             $count += $q->affected_rows();
74 74
         } else {
75 75
             print "failed to update data for $policy_id\n";
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,8 @@
 block discarded – undo
71 71
         );
72 72
         if ( $q->success() ) {
73 73
             $count += $q->affected_rows();
74
-        } else {
74
+        }
75
+        else {
75 76
             print "failed to update data for $policy_id\n";
76 77
         }
77 78
     }
Please login to merge, or discard this patch.
tests/Bootstrap.php 3 patches
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 // Test to make sure we have the test DB environment variables. If not, this isn't testing, so abort.
9 9
 // Define the DB connection constants before we do anything else.
10 10
 if (
11
-    isset($_SERVER['TWFY_TEST_DB_HOST']) AND
12
-    isset($_SERVER['TWFY_TEST_DB_USER']) AND
13
-    isset($_SERVER['TWFY_TEST_DB_PASS']) AND
11
+    isset($_SERVER['TWFY_TEST_DB_HOST']) and
12
+    isset($_SERVER['TWFY_TEST_DB_USER']) and
13
+    isset($_SERVER['TWFY_TEST_DB_PASS']) and
14 14
     isset($_SERVER['TWFY_TEST_DB_NAME'])
15 15
 ) {
16 16
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 }
38 38
 
39 39
 // Explicitly declare we're in testing (avoids trying deploy-only things)
40
-define('TESTING', TRUE);
40
+define('TESTING', true);
41 41
 
42 42
 // Load up the init script (handles the rest of the config, DB connection etc)
43 43
 include_once('www/includes/easyparliament/init.php');
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
     define('OPTION_TWFY_DB_NAME', $_SERVER['TWFY_TEST_DB_NAME']);
22 22
     
23 23
     // Define the base directory
24
-    define ("BASEDIR", dirname(__FILE__) . '/../www/docs'); 
24
+    define("BASEDIR", dirname(__FILE__) . '/../www/docs'); 
25 25
 
26 26
     # point to the default mapit
27 27
     define('OPTION_MAPIT_URL', 'https://mapit.mysociety.org/');
28 28
 
29 29
     // If there isn't a config file (most likely this is running an automated test) copy one in.
30
-    if ( ! file_exists(dirname(__FILE__) . '/../conf/general')) {
30
+    if (!file_exists(dirname(__FILE__) . '/../conf/general')) {
31 31
         copy(dirname(__FILE__) . '/../conf/general-example', dirname(__FILE__) . '/../conf/general');
32 32
     }
33 33
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
         copy(dirname(__FILE__) . '/../conf/general-example', dirname(__FILE__) . '/../conf/general');
32 32
     }
33 33
 
34
-} else {
34
+}
35
+else {
35 36
     echo "Testing environment variables not set. This will cause bad things to happen if testing happens on production. Aborting.\n";
36 37
     exit(1);
37 38
 }
Please login to merge, or discard this patch.
www/docs/alert/update-mp/index.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$new_style_template = TRUE;
3
+$new_style_template = true;
4 4
 
5 5
 include_once '../../../includes/easyparliament/init.php';
6 6
 include_once INCLUDESPATH . 'easyparliament/member.php';
Please login to merge, or discard this patch.
www/docs/user/login/fb.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     If the input is not OK, the form is displayed again with error messages.
10 10
 */
11 11
 
12
-$new_style_template = TRUE;
12
+$new_style_template = true;
13 13
 
14 14
 include_once '../../../includes/easyparliament/init.php';
15 15
 # need to include this as login code uses error_message
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
 
28 28
 $data['fb_login_url'] = $login->getLoginURL();
29 29
 if (isset($data['token'])) {
30
-  $success = $login->loginUser($data['token']);
31
-  if (!$success) {
30
+    $success = $login->loginUser($data['token']);
31
+    if (!$success) {
32 32
     $data['error'] = 'Could not login using Facebook token';
33 33
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
34
-  }
34
+    }
35 35
 } else {
36 36
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
37 37
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,6 +32,7 @@
 block discarded – undo
32 32
     $data['error'] = 'Could not login using Facebook token';
33 33
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
34 34
   }
35
-} else {
35
+}
36
+else {
36 37
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
37 38
 }
Please login to merge, or discard this patch.
classes/User.php 4 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 class User {
15
-    public function getUserDetails($user_id = False) {
15
+    public function getUserDetails($user_id = false) {
16 16
         global $THEUSER;
17 17
 
18 18
         $user = $THEUSER;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             }
251 251
 
252 252
             if ($details['email'] != $THEUSER->email()) {
253
-                $results['email_changed'] = True;
253
+                $results['email_changed'] = true;
254 254
             }
255 255
 
256 256
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -321,6 +321,9 @@
 block discarded – undo
321 321
         return array();
322 322
     }
323 323
 
324
+    /**
325
+     * @param Member $member
326
+     */
324 327
     private function constructMPData($member, $user, $mp_house) {
325 328
         $mp_data = array();
326 329
         $mp_data['name'] = $member->full_name();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
         $data['email'] = $user->email();
34 34
         $data['emailpublic'] = $user->emailpublic() == true ? "Yes" : "No";
35 35
         $data['optin'] = $user->optin() == true ? "Yes" : "No";
36
-        $data['postcode']	= $user->postcode();
36
+        $data['postcode'] = $user->postcode();
37 37
         $data['website']	= $user->url();
38
-        $data['registrationtime']	= $user->registrationtime();
39
-        $data['status']= $user->status();
38
+        $data['registrationtime'] = $user->registrationtime();
39
+        $data['status'] = $user->status();
40 40
         $data["deleted"] = $user->deleted();
41 41
         $data["confirmed"] = $user->confirmed();
42 42
         $data["status"] = $user->status();
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
         // Who are we updating? $THEUSER or someone else?
244 244
         if ($this_page == "otheruseredit") {
245 245
             $who = 'the user&rsquo;s';
246
-            $success = $THEUSER->update_other_user ( $details );
246
+            $success = $THEUSER->update_other_user($details);
247 247
         } else {
248 248
             $who = 'your';
249
-            $success = $THEUSER->update_self ( $details );
249
+            $success = $THEUSER->update_self($details);
250 250
         }
251 251
 
252 252
 
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
         // If this goes well, the user will have their data
279 279
         // added to the database and a confirmation email
280 280
         // will be sent to them.
281
-        $success = $THEUSER->add ( $details );
281
+        $success = $THEUSER->add($details);
282 282
 
283 283
         $errors = array();
284 284
 
285 285
         if (!$success) {
286
-            $errors["db"] = "Sorry, we were unable to create an account for you. Please <a href=\"mailto:". str_replace('@', '&#64;', CONTACTEMAIL) . "\">let us know</a>. Thanks.";
286
+            $errors["db"] = "Sorry, we were unable to create an account for you. Please <a href=\"mailto:" . str_replace('@', '&#64;', CONTACTEMAIL) . "\">let us know</a>. Thanks.";
287 287
         }
288 288
 
289 289
         return $errors;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
     public function getRep($cons_type, $mp_house) {
293 293
         global $THEUSER;
294
-        if ( !$THEUSER->has_postcode() ) {
294
+        if (!$THEUSER->has_postcode()) {
295 295
             return array();
296 296
         }
297 297
 
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
         // Scottish homepage
305 305
         try {
306 306
             $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($THEUSER->postcode());
307
-            if ( isset($constituencies[$cons_type]) ) {
307
+            if (isset($constituencies[$cons_type])) {
308 308
                 $constituency = $constituencies[$cons_type];
309 309
                 $MEMBER = new Member(array('constituency'=>$constituency, 'house'=> $mp_house));
310 310
             }
311
-        } catch ( MemberException $e ) {
311
+        } catch (MemberException $e) {
312 312
             return array();
313 313
         }
314 314
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         $mreg = array();
346 346
         if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
347 347
             $reps = \MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, $mp_house, $cons_type);
348
-            foreach ( $reps as $rep ) {
348
+            foreach ($reps as $rep) {
349 349
                 $member = new \MySociety\TheyWorkForYou\Member(array('person_id' => $rep['person_id']));
350 350
                 $mreg[$rep['person_id']] = $this->constructMPData($member, $THEUSER, $mp_house);
351 351
             }
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -62,7 +62,8 @@  discard block
 block discarded – undo
62 62
             $details = $this->getUserDetails();
63 63
             $details["password"] = '';
64 64
             $details["emailpublic"] = false;
65
-        } else {
65
+        }
66
+        else {
66 67
             $details["firstname"] = trim(get_http_var("firstname"));
67 68
             $details["lastname"] = trim(get_http_var("lastname"));
68 69
 
@@ -96,14 +97,16 @@  discard block
 block discarded – undo
96 97
             if (get_http_var("deleted") != "") {
97 98
                 $deleted = get_http_var("deleted");
98 99
                 $details["deleted"] = $deleted[0] == "true" ? true : false;
99
-            } else {
100
+            }
101
+            else {
100 102
                 $details['deleted'] = false;
101 103
             }
102 104
 
103 105
             if (get_http_var("confirmed") != "") {
104 106
                 $confirmed = get_http_var("confirmed");
105 107
                 $details["confirmed"] = $confirmed[0] == "true" ? true : false;
106
-            } else {
108
+            }
109
+            else {
107 110
                 $details['confirmed'] = false;
108 111
             }
109 112
         }
@@ -139,11 +142,13 @@  discard block
 block discarded – undo
139 142
                 if ($details["email"] == "") {
140 143
                     $errors["email"] = "Please enter an email address";
141 144
 
142
-                } elseif (!validate_email($details["email"])) {
145
+                }
146
+                elseif (!validate_email($details["email"])) {
143 147
                     // validate_email() is in includes/utilities.php
144 148
                     $errors["email"] = "Please enter a valid email address";
145 149
 
146
-                } else {
150
+                }
151
+                else {
147 152
 
148 153
                     $USER = new \USER;
149 154
                     $id_of_user_with_this_addresss = $USER->email_exists($details["email"], true);
@@ -159,7 +164,8 @@  discard block
 block discarded – undo
159 164
                             $errors["email"] = "Someone else has already joined with this email address";
160 165
                         }
161 166
 
162
-                    } else {
167
+                    }
168
+                    else {
163 169
                         // User is joining. Check no one is already here with this email.
164 170
                         if ($this_page == "userjoin" && $id_of_user_with_this_addresss) {
165 171
                             $errors["email"] = "There is already a user with this email address";
@@ -175,7 +181,8 @@  discard block
 block discarded – undo
175 181
                 if ($details["password"] == "") {
176 182
                     $errors["password"] = "Please enter a password";
177 183
 
178
-                } elseif (strlen($details["password"]) < 6) {
184
+                }
185
+                elseif (strlen($details["password"]) < 6) {
179 186
                     $errors["password"] = "Please enter at least six characters";
180 187
                 }
181 188
 
@@ -187,7 +194,8 @@  discard block
 block discarded – undo
187 194
                     $errors["password"] = "The passwords did not match. Please try again.";
188 195
                 }
189 196
 
190
-            } else {
197
+            }
198
+            else {
191 199
 
192 200
                 // Update details pages.
193 201
 
@@ -205,7 +213,8 @@  discard block
 block discarded – undo
205 213
         if ($details["postcode"] != "") {
206 214
             if (!validate_postcode($details["postcode"])) {
207 215
                 $errors["postcode"] = "Sorry, this isn't a valid UK postcode.";
208
-            } else {
216
+            }
217
+            else {
209 218
                 try {
210 219
                     $mp = new \MySociety\TheyWorkForYou\Member(array(
211 220
                         'postcode' => $details['postcode'],
@@ -244,7 +253,8 @@  discard block
 block discarded – undo
244 253
         if ($this_page == "otheruseredit") {
245 254
             $who = 'the user&rsquo;s';
246 255
             $success = $THEUSER->update_other_user ( $details );
247
-        } else {
256
+        }
257
+        else {
248 258
             $who = 'your';
249 259
             $success = $THEUSER->update_self ( $details );
250 260
         }
@@ -255,7 +265,8 @@  discard block
 block discarded – undo
255 265
 
256 266
             if ($this_page == 'otheruseredit') {
257 267
                 $this_page = "userview";
258
-            } else {
268
+            }
269
+            else {
259 270
                 $this_page = "userviewself";
260 271
             }
261 272
 
@@ -264,7 +275,8 @@  discard block
 block discarded – undo
264 275
             }
265 276
 
266 277
 
267
-        } else {
278
+        }
279
+        else {
268 280
             $results['errors'] = array("db" => "Sorry, we were unable to update $who details. Please <a href=\"mailto:" . str_replace('@', '&#64;', CONTACTEMAIL) . "\">let us know</a> what you were trying to change. Thanks.");
269 281
         }
270 282
 
Please login to merge, or discard this patch.