Completed
Pull Request — master (#1325)
by Nick
06:30 queued 01:28
created
www/docs/section.php 2 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.
scripts/populate-policy-images.php 2 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.
tests/Bootstrap.php 2 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.
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 2 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.
classes/User.php 3 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.
www/docs/user/index.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
         // And make sure the user is allowed to do this!
33 33
 
34 34
         $template = 'user/form';
35
-        if (is_numeric( get_http_var("u") ) && $THEUSER->is_able_to("edituser")) {
35
+        if (is_numeric(get_http_var("u")) && $THEUSER->is_able_to("edituser")) {
36 36
 
37 37
             $data = $user->getUserDetails(get_http_var('u'));
38 38
             $data['showall'] = true;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * page so leave it like that for now.
6 6
  */
7 7
 
8
-$new_style_template = TRUE;
8
+$new_style_template = true;
9 9
 
10 10
 include_once '../../includes/easyparliament/init.php';
11 11
 # need to include this as login code uses error_message
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                 $data['errors'] = $results['errors'];
128 128
                 $template = 'user/form';
129 129
             } else {
130
-                $data['edited'] = True;
130
+                $data['edited'] = true;
131 131
                 if (isset($results['email_changed'])) {
132 132
                     $data['email_changed'] = $results['email_changed'];
133 133
                 }
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -106,12 +106,12 @@
 block discarded – undo
106 106
 
107 107
 // if data has been submitted then handle that
108 108
 if (
109
-      get_http_var("submitted") == "true" && (
109
+        get_http_var("submitted") == "true" && (
110 110
         $this_page == 'useredit' || $this_page == 'otheruseredit' || $this_page == 'userjoin'
111
-      )
112
-   ) {
111
+        )
112
+    ) {
113 113
     // Put all the user-submitted data in an array.
114
-     $data = $user->getUpdateDetails($this_page, $THEUSER);
114
+        $data = $user->getUpdateDetails($this_page, $THEUSER);
115 115
 
116 116
     if ($this_page == 'useredit') {
117 117
         $data['facebook_user'] = $THEUSER->facebook_user();
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/user/form.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
                   <span class="label">Security status:</span>
126 126
                   <span class="formw"><select name="status">
127 127
                   <?php
128
-                  foreach ($statuses as $n => $status_name) { ?>
128
+                    foreach ($statuses as $n => $status_name) { ?>
129 129
                     <option value="<?= $status_name ?>"<?= $status_name == $status ? ' selected' : '' ?>>
130 130
                       <?= $status_name ?>
131 131
                     </option>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@
 block discarded – undo
174 174
 
175 175
                 <input type="hidden" name="submitted" value="true">
176 176
 
177
-                <?php if (isset($ret) && $ret != '' ) { ?>
177
+                <?php if (isset($ret) && $ret != '') { ?>
178 178
                     <input type="hidden" name="ret" value="<?= _htmlentities($ret) ?>">
179 179
                 <?php } ?>
180 180
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                 <input type="hidden" name="pg" value="edit">
35 35
               </form>
36 36
             <?php } else { ?>
37
-              <?php if (isset($showall) && $showall == True && isset($user_id)) { ?>
37
+              <?php if (isset($showall) && $showall == true && isset($user_id)) { ?>
38 38
               <h1>Edit the user&rsquo;s details</h1>
39 39
               <?php } else { ?>
40 40
               <h1>Edit your details</h1>
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                     <input type="radio" name="emailpublic" id="emailpublicfalse" value="false" <?= $emailpublic == 'No' ? ' checked' : '' ?>> <label for="emailpublicfalse">No</label></span>
143 143
                 </div>
144 144
 
145
-                <?php if (isset($showall) && $showall == True) { ?>
145
+                <?php if (isset($showall) && $showall == true) { ?>
146 146
                   <?php if (isset($errors['status'])) { ?>
147 147
                   <p class="error">
148 148
                       <?= $errors['status'] ?>
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                     <input type="hidden" name="pg" value="<?= $pg ?>">
211 211
                 <?php } ?>
212 212
 
213
-                <?php if (isset($showall) && $showall == True && isset($user_id)) { ?>
213
+                <?php if (isset($showall) && $showall == true && isset($user_id)) { ?>
214 214
                     <input type="hidden" name="u" value="<?= _htmlentities($user_id) ?>">
215 215
                 <?php } ?>
216 216
 
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/user/index.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
           <h1>Your details</h1>
13 13
           <?php if (isset($edited)) { ?>
14 14
             <p>
15
-              <strong>have been updated<?= isset($email_changed) && $email_changed == True ? " and we&rsquo;ve sent a confirmation email to your new email address" : '' ?>.</strong>
15
+              <strong>have been updated<?= isset($email_changed) && $email_changed == true ? " and we&rsquo;ve sent a confirmation email to your new email address" : '' ?>.</strong>
16 16
             </p>
17 17
           <?php } else { ?>
18 18
           <p>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 
43 43
           <div class="row">
44 44
             <span class="label">Website</span>
45
-            <span class="formw"><?= $website == '' ? 'none' : '<a href="' . _htmlentities($website) . '">'. _htmlentities($website) . '</a>' ?></span>
45
+            <span class="formw"><?= $website == '' ? 'none' : '<a href="' . _htmlentities($website) . '">' . _htmlentities($website) . '</a>' ?></span>
46 46
           </div>
47 47
 
48 48
           <?php if ($facebook_user) { ?>
Please login to merge, or discard this patch.