Passed
Pull Request — master (#1700)
by Struan
04:10
created
www/includes/easyparliament/templates/html/divisions/_vote_summary.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <p>
2 2
     <a href="#for"><?= sprintf(gettext('%s for'), $division['for']) ?></a>,
3 3
     <a href="#against"><?= sprintf(gettext('%s against'), $division['against']) ?></a><?php
4
-  if ($division['both'] > 0) { ?>,
4
+    if ($division['both'] > 0) { ?>,
5 5
     <a href="#both"><?= sprintf(gettext('%s abstained'), $division['both']) ?></a><?php
6
-  }
7
-  if ($division['absent'] > 0) { ?>,
6
+    }
7
+    if ($division['absent'] > 0) { ?>,
8 8
     <a href="#absent"><?= sprintf(gettext('%s absent'), $division['absent']) ?></a><?php
9
-  } ?>.
9
+    } ?>.
10 10
 </p>
Please login to merge, or discard this patch.
www/includes/easyparliament/templates/html/divisions/_name_vote_list.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!function_exists('print_voter')) {
4
-  function print_voter($vote){
4
+    function print_voter($vote){
5 5
     echo sprintf(
6
-      '<li><a href="/mp/?p=%d">%s</a> <span class="party">%s%s</span></li>',
7
-      $vote['person_id'],
8
-      $vote['name'],
9
-      $vote['party'],
10
-      $vote['proxy'] ? " (proxy vote cast by $vote[proxy])" : ''
6
+        '<li><a href="/mp/?p=%d">%s</a> <span class="party">%s%s</span></li>',
7
+        $vote['person_id'],
8
+        $vote['name'],
9
+        $vote['party'],
10
+        $vote['proxy'] ? " (proxy vote cast by $vote[proxy])" : ''
11 11
     );
12
-  }
12
+    }
13 13
 }
14 14
 
15 15
 if (count($votes) > 0) { ?>
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
       <?php $tellers = array(); ?>
19 19
       <ul class="division-names js-vote-accordion" data-show-all="<?= gettext('Show All') ?>">
20 20
         <?php foreach ($votes as $vote) {
21
-          if ($vote['teller']) {
22
-              $tellers[] = $vote;
23
-          } else {
21
+            if ($vote['teller']) {
22
+                $tellers[] = $vote;
23
+            } else {
24 24
             print_voter($vote);
25
-          }
25
+            }
26 26
         } ?>
27 27
       </ul>
28 28
     <?php if (count($tellers) > 0) { ?>
29 29
       <h4><?= gettext('Tellers') ?></h4>
30 30
       <ul class="division-names">
31 31
         <?php foreach($tellers as $teller) {
32
-          print_voter($teller);
32
+            print_voter($teller);
33 33
         } ?>
34 34
       </p>
35 35
     <?php } ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!function_exists('print_voter')) {
4
-  function print_voter($vote){
4
+  function print_voter($vote) {
5 5
     echo sprintf(
6 6
       '<li><a href="/mp/?p=%d">%s</a> <span class="party">%s%s</span></li>',
7 7
       $vote['person_id'],
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     <?php if (count($tellers) > 0) { ?>
29 29
       <h4><?= gettext('Tellers') ?></h4>
30 30
       <ul class="division-names">
31
-        <?php foreach($tellers as $teller) {
31
+        <?php foreach ($tellers as $teller) {
32 32
           print_voter($teller);
33 33
         } ?>
34 34
       </p>
Please login to merge, or discard this patch.
www/includes/easyparliament/user.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
 
57 57
 class USER {
58 58
 
59
-    public $user_id = "0";         // So we have an ID for non-logged in users reporting comments etc.
60
-    public $firstname = "Guest";   // So we have something to print for non-logged in users.
59
+    public $user_id = "0"; // So we have an ID for non-logged in users reporting comments etc.
60
+    public $firstname = "Guest"; // So we have something to print for non-logged in users.
61 61
     public $lastname = "";
62
-    public $password = "";         // This will be a hashed version of a plaintext pw.
62
+    public $password = ""; // This will be a hashed version of a plaintext pw.
63 63
     public $email = "";
64 64
     public $postcode = "";
65 65
     public $url = "";
66
-    public $lastvisit = "";        // Last time the logged-in user loaded a page (GMT).
66
+    public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT).
67 67
     public $registrationtime = ""; // When they registered (GMT).
68
-    public $registrationip = "";   // Where they registered from.
69
-    public $optin = "";            // boolean - Do they want emails from us?
70
-    public $deleted = "";          // User can't log in or have their info displayed.
71
-    public $confirmed = '';        // boolean - Has the user confirmed via email?
72
-    public $facebook_id = '';      // Facebook ID for users who login with FB
73
-    public $facebook_token = '';   // Facebook token for users who login with FB
68
+    public $registrationip = ""; // Where they registered from.
69
+    public $optin = ""; // boolean - Do they want emails from us?
70
+    public $deleted = ""; // User can't log in or have their info displayed.
71
+    public $confirmed = ''; // boolean - Has the user confirmed via email?
72
+    public $facebook_id = ''; // Facebook ID for users who login with FB
73
+    public $facebook_token = ''; // Facebook token for users who login with FB
74 74
     // Don't use the status to check access privileges - use the is_able_to() function.
75 75
     public $status = "Viewer";
76 76
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
     }
144 144
 
145
-    public function add($details, $confirmation_required=true) {
145
+    public function add($details, $confirmation_required = true) {
146 146
         // Adds a new user's info into the db.
147 147
         // Then optionally (and usually) calls another function to
148 148
         // send them a confirmation email.
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             // This will be sent to them via email, so we can confirm they exist.
225 225
             // The token will be the first 16 characters of a hash.
226 226
 
227
-            $token = substr( password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16 );
227
+            $token = substr(password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16);
228 228
 
229 229
             // Full stops don't work well at the end of URLs in emails, so
230 230
             // replace them. And double slash would be treated as single and
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             $r = $this->db->query("UPDATE users
238 238
                             SET registrationtoken = :registrationtoken
239 239
                             WHERE   user_id = :user_id
240
-                            ", array (
240
+                            ", array(
241 241
                                 ':registrationtoken' => $this->registrationtoken,
242 242
                                 ':user_id' => $this->user_id
243 243
                             ));
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     }
285 285
 
286 286
     public function add_facebook_id($facebook_id) {
287
-        $q = $this->db->query ("UPDATE users SET facebook_id = :facebook_id WHERE email = :email",
287
+        $q = $this->db->query("UPDATE users SET facebook_id = :facebook_id WHERE email = :email",
288 288
             array(
289 289
                 ':facebook_id' => $facebook_id,
290 290
                 ':email' => $this->email
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
             !isset($details['email']) ||
306 306
             $details['email'] == '' ||
307 307
             !isset($details['token']) ||
308
-            $details['token'] == '' ) {
308
+            $details['token'] == '') {
309 309
             return false;
310 310
         }
311 311
 
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
         $confirmurl = 'https://' . DOMAIN . '/E/' . $urltoken;
318 318
 
319 319
         // Arrays we need to send a templated email.
320
-        $data = array (
320
+        $data = array(
321 321
             'to'        => $details['email'],
322 322
             'template'  => 'email_confirmation'
323 323
         );
324 324
 
325
-        $merge = array (
325
+        $merge = array(
326 326
             'CONFIRMURL'    => $confirmurl
327 327
         );
328 328
 
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
         }
361 361
 
362 362
         // Arrays we need to send a templated email.
363
-        $data = array (
363
+        $data = array(
364 364
             'to'        => $details['email'],
365 365
             'template'  => 'join_confirmation'
366 366
         );
367 367
 
368
-        $merge = array (
368
+        $merge = array(
369 369
             'CONFIRMURL'    => $confirmurl
370 370
         );
371 371
 
@@ -425,23 +425,23 @@  discard block
 block discarded – undo
425 425
             $this->email = $email;
426 426
             for (;;) {
427 427
 
428
-                $pwd=null;
429
-                $o=null;
428
+                $pwd = null;
429
+                $o = null;
430 430
 
431 431
                 // Generates the password ....
432
-                for ($x=0; $x < 6;) {
433
-                    $y = rand(1,1000);
434
-                    if($y>350 && $y<601) $d=chr(rand(48,57));
435
-                    if($y<351) $d=chr(rand(65,90));
436
-                    if($y>600) $d=chr(rand(97,122));
437
-                    if ($d!=$o && !preg_match('#[O01lI]#', $d)) {
438
-                        $o=$d; $pwd.=$d; $x++;
432
+                for ($x = 0; $x < 6;) {
433
+                    $y = rand(1, 1000);
434
+                    if ($y > 350 && $y < 601) $d = chr(rand(48, 57));
435
+                    if ($y < 351) $d = chr(rand(65, 90));
436
+                    if ($y > 600) $d = chr(rand(97, 122));
437
+                    if ($d != $o && !preg_match('#[O01lI]#', $d)) {
438
+                        $o = $d; $pwd .= $d; $x++;
439 439
                     }
440 440
                 }
441 441
 
442 442
                 // If the PW fits your purpose (e.g. this regexpression) return it, else make a new one
443 443
                 // (You can change this regular-expression how you want ....)
444
-                if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/",$pwd)) {
444
+                if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/", $pwd)) {
445 445
                     break;
446 446
                 }
447 447
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
         $passwordforDB = password_hash($pwd, PASSWORD_BCRYPT);
461 461
 
462
-        $q = $this->db->query ("UPDATE users SET password = :password WHERE email = :email",
462
+        $q = $this->db->query("UPDATE users SET password = :password WHERE email = :email",
463 463
             array(
464 464
                 ':password' => $passwordforDB,
465 465
                 ':email' => $email
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
             return false;
488 488
         }
489 489
 
490
-        $data = array (
490
+        $data = array(
491 491
             'to'            => $this->email(),
492 492
             'template'      => 'new_password'
493 493
         );
494 494
 
495 495
         $URL = new \MySociety\TheyWorkForYou\Url("userlogin");
496 496
 
497
-        $merge = array (
497
+        $merge = array(
498 498
             'EMAIL'         => $this->email(),
499 499
             'LOGINURL'      => "https://" . DOMAIN . $URL->generate(),
500 500
             'PASSWORD'      => $this->password()
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     public function facebook_id_exists($id, $return_id = false) {
550 550
         // Returns true if there's a user with this facebook id.
551 551
 
552
-        if ($id!= "") {
552
+        if ($id != "") {
553 553
             $q = $this->db->query("SELECT user_id FROM users WHERE facebook_id = :id", array(':id' => $id))->first();
554 554
             if ($q) {
555 555
                 if ($return_id) {
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                 /* Everyone */              return true;
625 625
 
626 626
             default:
627
-                $PAGE->error_message ("You need to set permissions for '$action'!");
627
+                $PAGE->error_message("You need to set permissions for '$action'!");
628 628
 
629 629
                 return false;
630 630
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
         // Maybe there's a way of fetching these from the DB,
643 643
         // so we don't duplicate them here...?
644 644
 
645
-        $statuses = array ("Viewer", "User", "Moderator", "Administrator", "Superuser");
645
+        $statuses = array("Viewer", "User", "Moderator", "Administrator", "Superuser");
646 646
 
647 647
         return $statuses;
648 648
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
             return $details;
798 798
 
799 799
         } else {
800
-            $PAGE->error_message ("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'");
800
+            $PAGE->error_message("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'");
801 801
 
802 802
             return false;
803 803
         }
@@ -870,13 +870,13 @@  discard block
 block discarded – undo
870 870
 
871 871
                     if ($this->facebook_user) {
872 872
                         if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) {
873
-                            twfy_debug ("THEUSER", "init SUCCESS: setting as logged in");
873
+                            twfy_debug("THEUSER", "init SUCCESS: setting as logged in");
874 874
                             $this->loggedin = true;
875
-                        } elseif (md5 ($this->facebook_token()) != $matches[2]) {
876
-                            twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie");
875
+                        } elseif (md5($this->facebook_token()) != $matches[2]) {
876
+                            twfy_debug("THEUSER", "init FAILED: Facebook token doesn't match cookie");
877 877
                             $this->loggedin = false;
878 878
                         } else {
879
-                            twfy_debug ("THEUSER", "init FAILED: User is deleted");
879
+                            twfy_debug("THEUSER", "init FAILED: User is deleted");
880 880
                             $this->loggedin = false;
881 881
                         }
882 882
                     } else {
@@ -889,30 +889,30 @@  discard block
 block discarded – undo
889 889
                             // to need. Their preferences and saved things or something.
890 890
 
891 891
 
892
-                            twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in");
892
+                            twfy_debug("THEUSER init SUCCEEDED", "setting as logged in");
893 893
                             $this->loggedin = true;
894 894
 
895
-                        } elseif (md5 ($this->password()) != $matches[2]) {
896
-                            twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie");
895
+                        } elseif (md5($this->password()) != $matches[2]) {
896
+                            twfy_debug("THEUSER init FAILED", "Password doesn't match cookie");
897 897
                             $this->loggedin = false;
898 898
                         } else {
899
-                            twfy_debug ("THEUSER init FAILED", "User is deleted");
899
+                            twfy_debug("THEUSER init FAILED", "User is deleted");
900 900
                             $this->loggedin = false;
901 901
                         }
902 902
                     }
903 903
 
904 904
                 } else {
905
-                    twfy_debug ("THEUSER init FAILED", "didn't get 1 row from db");
905
+                    twfy_debug("THEUSER init FAILED", "didn't get 1 row from db");
906 906
                     $this->loggedin = false;
907 907
                 }
908 908
 
909 909
             } else {
910
-                twfy_debug ("THEUSER init FAILED", "cookie's user_id is not numeric");
910
+                twfy_debug("THEUSER init FAILED", "cookie's user_id is not numeric");
911 911
                 $this->loggedin = false;
912 912
             }
913 913
 
914 914
         } else {
915
-            twfy_debug ("THEUSER init FAILED", "cookie is not of the correct form");
915
+            twfy_debug("THEUSER init FAILED", "cookie is not of the correct form");
916 916
             $this->loggedin = false;
917 917
         }
918 918
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             // Set last_visit to now.
939 939
             $date_now = gmdate("Y-m-d H:i:s");
940 940
             $this->db->query("UPDATE users SET lastvisit = :lastvisit WHERE user_id = :user_id",
941
-                [ ':lastvisit' => $date_now, ':user_id' => $this->user_id() ]);
941
+                [':lastvisit' => $date_now, ':user_id' => $this->user_id()]);
942 942
 
943 943
             $this->lastvisit = $date_now;
944 944
         }
@@ -994,20 +994,20 @@  discard block
 block discarded – undo
994 994
 
995 995
             } else {
996 996
                 // Failed.
997
-                return array ("invalidemail" => $error_string);
997
+                return array("invalidemail" => $error_string);
998 998
 
999 999
             }
1000 1000
 
1001 1001
         } else {
1002 1002
             // Failed.
1003
-            return array ("invalidemail" => $error_string);
1003
+            return array("invalidemail" => $error_string);
1004 1004
         }
1005 1005
 
1006 1006
     }
1007 1007
 
1008 1008
     public function has_postcode() {
1009 1009
         $has_postcode = false;
1010
-        if ( $this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set() ) {
1010
+        if ($this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set()) {
1011 1011
             $has_postcode = true;
1012 1012
         }
1013 1013
         return $has_postcode;
@@ -1021,28 +1021,28 @@  discard block
 block discarded – undo
1021 1021
         twfy_debug("THEUSER", "Faceook login, facebook_id " . $this->facebook_id);
1022 1022
         twfy_debug("THEUSER", "Faceook login, email" . $this->email);
1023 1023
         if ($this->facebook_id() == "") {
1024
-            $PAGE->error_message ("We don't have a facebook id for this user.", true);
1024
+            $PAGE->error_message("We don't have a facebook id for this user.", true);
1025 1025
 
1026 1026
             return;
1027 1027
         }
1028 1028
 
1029 1029
         twfy_debug("THEUSER", "Faceook login, facebook_token: " . $accessToken);
1030 1030
 
1031
-        $q = $this->db->query ("UPDATE users SET facebook_token = :token WHERE email = :email",
1031
+        $q = $this->db->query("UPDATE users SET facebook_token = :token WHERE email = :email",
1032 1032
             array(
1033 1033
                 ':token' => $accessToken,
1034 1034
                 ':email' => $this->email
1035 1035
             ));
1036 1036
 
1037 1037
         if (!$q->success()) {
1038
-            $PAGE->error_message ("There was a problem logging you in", true);
1038
+            $PAGE->error_message("There was a problem logging you in", true);
1039 1039
             twfy_debug("THEUSER", "Faceook login, failed to set accessToken");
1040 1040
 
1041 1041
             return false;
1042 1042
         }
1043 1043
 
1044 1044
         // facebook login users probably don't have a password
1045
-        $cookie = $this->user_id() . "." . md5 ($accessToken);
1045
+        $cookie = $this->user_id() . "." . md5($accessToken);
1046 1046
         twfy_debug("THEUSER", "Faceook login, cookie: " . $cookie);
1047 1047
 
1048 1048
         twfy_debug("USER", "logging in user from facebook " . $this->user_id);
@@ -1074,21 +1074,21 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
         // Various checks about the user - if they fail, we exit.
1076 1076
         if ($this->user_id() == "" || $this->password == "") {
1077
-            $PAGE->error_message ("We don't have the user_id or password to make the cookie.", true);
1077
+            $PAGE->error_message("We don't have the user_id or password to make the cookie.", true);
1078 1078
 
1079 1079
             return;
1080 1080
         } elseif ($this->deleted) {
1081
-            $PAGE->error_message ("This user has been deleted.", true);
1081
+            $PAGE->error_message("This user has been deleted.", true);
1082 1082
 
1083 1083
             return;
1084 1084
         } elseif (!$this->confirmed) {
1085
-            $PAGE->error_message ("You have not yet confirmed your account by clicking the link in the confirmation email we sent to you. If you don't have the email, you can <a href='/user/login/?resend=" . $this->user_id() . "'>have it resent</a>. If it still doesn't arrive, get in touch.", true);
1085
+            $PAGE->error_message("You have not yet confirmed your account by clicking the link in the confirmation email we sent to you. If you don't have the email, you can <a href='/user/login/?resend=" . $this->user_id() . "'>have it resent</a>. If it still doesn't arrive, get in touch.", true);
1086 1086
 
1087 1087
             return;
1088 1088
         }
1089 1089
 
1090 1090
         // Reminder: $this->password is actually a hashed version of the plaintext pw.
1091
-        $cookie = $this->user_id() . "." . md5 ($this->password());
1091
+        $cookie = $this->user_id() . "." . md5($this->password());
1092 1092
 
1093 1093
         $this->_login($returl, $expire, $cookie);
1094 1094
     }
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
         $cookie_expires = 0;
1105 1105
         if ($expire == 'never') {
1106 1106
             twfy_debug("THEUSER", "cookie never expires");
1107
-            $cookie_expires = time()+86400*365*20;
1107
+            $cookie_expires = time() + 86400 * 365 * 20;
1108 1108
         } elseif (is_int($expire) && $expire > time()) {
1109 1109
             twfy_debug("THEUSER", "cookie expires at " . $expire);
1110 1110
             $cookie_expires = $expire;
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
         }
1143 1143
     }
1144 1144
 
1145
-    public function confirm_email($token, $redirect=true) {
1145
+    public function confirm_email($token, $redirect = true) {
1146 1146
         $arg = '';
1147 1147
         if (strstr($token, '::')) $arg = '::';
1148 1148
         if (strstr($token, '-')) $arg = '-';
@@ -1155,24 +1155,24 @@  discard block
 block discarded – undo
1155 1155
             FROM    tokens
1156 1156
             WHERE   token = :token
1157 1157
             AND   type = 'E'
1158
-        ", array (':token' => $registrationtoken))->first();
1158
+        ", array(':token' => $registrationtoken))->first();
1159 1159
 
1160 1160
         if ($q) {
1161 1161
             $expires = $q['expires'];
1162 1162
             $expire_time = strtotime($expires);
1163
-            if ( $expire_time < time() ) {
1163
+            if ($expire_time < time()) {
1164 1164
                 global $PAGE;
1165 1165
                 if ($PAGE && $redirect) {
1166
-                    $PAGE->error_message ("Sorry, that token seems to have expired");
1166
+                    $PAGE->error_message("Sorry, that token seems to have expired");
1167 1167
                 }
1168 1168
 
1169 1169
                 return false;
1170 1170
             }
1171 1171
 
1172
-            list( $user_id, $email ) = explode('::', $q['data']);
1172
+            list($user_id, $email) = explode('::', $q['data']);
1173 1173
 
1174 1174
             // if we are logged in as someone else don't change the email
1175
-            if ( $this->user_id() != 0 && $this->user_id() != $user_id ) {
1175
+            if ($this->user_id() != 0 && $this->user_id() != $user_id) {
1176 1176
                 return false;
1177 1177
             }
1178 1178
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 
1322 1322
             twfy_debug("THEUSER", "User with ID found to confirm: " . $this->user_id());
1323 1323
             // We'll need these to be set before logging the user in.
1324
-            $this->email    = $q['email'];
1324
+            $this->email = $q['email'];
1325 1325
 
1326 1326
             // Set that they're confirmed in the DB.
1327 1327
             $r = $this->db->query("UPDATE users
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
         $this->postcode = $pc;
1370 1370
         if (!headers_sent()) // if in debug mode
1371
-            setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN);
1371
+            setcookie(POSTCODE_COOKIE, $pc, time() + 7 * 86400, "/", COOKIEDOMAIN);
1372 1372
 
1373 1373
         twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain");
1374 1374
     }
1375 1375
 
1376 1376
     public function unset_postcode_cookie() {
1377 1377
         if (!headers_sent()) // if in debug mode
1378
-            setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN);
1378
+            setcookie(POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN);
1379 1379
     }
1380 1380
 
1381 1381
     // mostly here for updating from facebook where we do not need
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
 
1389 1389
             // this is checked elsewhere but just in case we check here and
1390 1390
             // bail out to be on the safe side
1391
-            if ( isset($details['email'] ) ) {
1392
-                if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) {
1391
+            if (isset($details['email'])) {
1392
+                if ($details['email'] != $this->email() && $this->email_exists($details['email'])) {
1393 1393
                     return false;
1394 1394
                 }
1395 1395
             }
@@ -1437,8 +1437,8 @@  discard block
 block discarded – undo
1437 1437
             // this is checked elsewhere but just in case we check here and
1438 1438
             // bail out to be on the safe side
1439 1439
             $email = '';
1440
-            if ( isset($details['email'] ) ) {
1441
-                if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) {
1440
+            if (isset($details['email'])) {
1441
+                if ($details['email'] != $this->email() && $this->email_exists($details['email'])) {
1442 1442
                     return false;
1443 1443
                 }
1444 1444
                 $email = $details['email'];
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
                 }
1466 1466
 
1467 1467
                 if ($email && $email != $this->email) {
1468
-                    $token = substr( password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16 );
1468
+                    $token = substr(password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16);
1469 1469
                     $data = $this->user_id() . '::' . $email;
1470 1470
                     $r = $this->db->query("INSERT INTO tokens
1471 1471
                         ( expires, token, type, data )
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
                     ));
1483 1483
 
1484 1484
                     // send confirmation email here
1485
-                    if ( $r->success() ) {
1485
+                    if ($r->success()) {
1486 1486
                         $newdetails['email'] = $email;
1487 1487
                         $newdetails['token'] = $token;
1488 1488
                         if ($confirm_email) {
Please login to merge, or discard this patch.
www/includes/easyparliament/init.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 First some things to help make our PHP nicer and betterer
5 5
 ********************************************************************************/
6 6
 
7
-error_reporting (E_ALL);
7
+error_reporting(E_ALL);
8 8
 
9 9
 /********************************************************************************
10 10
 Now some constants that are the same for live and dev versions
@@ -12,21 +12,21 @@  discard block
 block discarded – undo
12 12
 ********************************************************************************/
13 13
 
14 14
 // In case we need to switch these off globally at some point...
15
-define ("ALLOWCOMMENTS", true);
15
+define("ALLOWCOMMENTS", true);
16 16
 
17 17
 // These variables are so we can keep date/time formats consistent across the site
18 18
 // and change them easily.
19 19
 // Formats here: http://www.php.net/manual/en/function.date.php
20
-define ("LONGERDATEFORMAT",		"%A, %e %B %Y");// Monday, 31 December 2003
21
-define ("LONGDATEFORMAT", 		"%e %B %Y"); 	// 31 December 2003
22
-define ("SHORTDATEFORMAT", 		"%e %b %Y");	// 31 Dec 2003
23
-define ("TIMEFORMAT", 			"%l:%M %p");	// 11:59 pm
20
+define("LONGERDATEFORMAT", "%A, %e %B %Y"); // Monday, 31 December 2003
21
+define("LONGDATEFORMAT", "%e %B %Y"); // 31 December 2003
22
+define("SHORTDATEFORMAT", "%e %b %Y"); // 31 Dec 2003
23
+define("TIMEFORMAT", "%l:%M %p"); // 11:59 pm
24 24
 
25
-define ("SHORTDATEFORMAT_SQL",	"%e %b %Y"); // 31 Dec 2003
26
-define ("TIMEFORMAT_SQL", 		"%l:%i %p"); // 11:59 PM
25
+define("SHORTDATEFORMAT_SQL", "%e %b %Y"); // 31 Dec 2003
26
+define("TIMEFORMAT_SQL", "%l:%i %p"); // 11:59 PM
27 27
 
28 28
 // Where we store the postcode of users if they search for an MP by postcode.
29
-define ('POSTCODE_COOKIE', 		'eppc');
29
+define('POSTCODE_COOKIE', 'eppc');
30 30
 
31 31
 /********************************************************************************
32 32
 And now all the files we'll include on every page.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 textdomain('TheyWorkForYou');
53 53
 
54 54
 // Set the default timezone
55
-if(function_exists('date_default_timezone_set')) {
55
+if (function_exists('date_default_timezone_set')) {
56 56
     date_default_timezone_set(TIMEZONE);
57 57
 }
58 58
 
@@ -83,39 +83,39 @@  discard block
 block discarded – undo
83 83
 
84 84
 // The time the page starts, so we can display the total at the end.
85 85
 // getmicrotime() is in utiltity.php.
86
-define ("STARTTIME", getmicrotime());
86
+define("STARTTIME", getmicrotime());
87 87
 if (!isset($_SERVER['WINDIR'])) {
88 88
     $rusage = getrusage();
89
-    define ('STARTTIMES', $rusage['ru_stime.tv_sec']*1000000 + $rusage['ru_stime.tv_usec']);
90
-    define ('STARTTIMEU', $rusage['ru_utime.tv_sec']*1000000 + $rusage['ru_utime.tv_usec']);
89
+    define('STARTTIMES', $rusage['ru_stime.tv_sec'] * 1000000 + $rusage['ru_stime.tv_usec']);
90
+    define('STARTTIMEU', $rusage['ru_utime.tv_sec'] * 1000000 + $rusage['ru_utime.tv_usec']);
91 91
 }
92 92
 
93 93
 $DATA = new \MySociety\TheyWorkForYou\Data;
94 94
 
95 95
 class ParlDB extends \MySociety\TheyWorkForYou\Db\Connection {
96 96
     public function __construct() {
97
-        $this->init (OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
97
+        $this->init(OPTION_TWFY_DB_HOST, OPTION_TWFY_DB_USER, OPTION_TWFY_DB_PASS, OPTION_TWFY_DB_NAME);
98 98
     }
99 99
 }
100 100
 
101 101
 $filter = new \MySociety\TheyWorkForYou\Utility\LibFilter;
102 102
 
103
-include_once (INCLUDESPATH."easyparliament/user.php");
103
+include_once (INCLUDESPATH . "easyparliament/user.php");
104 104
 
105 105
 // Test to see if this is a new-style template using the renderer class.
106
-if (! isset($new_style_template) or $new_style_template !== true) {
106
+if (!isset($new_style_template) or $new_style_template !== true) {
107 107
 
108 108
     // This is an old-style page. Use the old page classes.
109
-    include_once (INCLUDESPATH."easyparliament/page.php");
109
+    include_once (INCLUDESPATH . "easyparliament/page.php");
110 110
 
111 111
 }
112 112
 
113
-include_once (INCLUDESPATH."easyparliament/hansardlist.php");
114
-include_once (INCLUDESPATH."dbtypes.php");
115
-include_once (INCLUDESPATH."easyparliament/commentlist.php");
116
-include_once (INCLUDESPATH."easyparliament/comment.php");
113
+include_once (INCLUDESPATH . "easyparliament/hansardlist.php");
114
+include_once (INCLUDESPATH . "dbtypes.php");
115
+include_once (INCLUDESPATH . "easyparliament/commentlist.php");
116
+include_once (INCLUDESPATH . "easyparliament/comment.php");
117 117
 
118 118
 // Added in as new module by Richard Allan MP
119
-include_once (INCLUDESPATH."easyparliament/alert.php");
119
+include_once (INCLUDESPATH . "easyparliament/alert.php");
120 120
 
121 121
 twfy_debug_timestamp("at end of init.php");
Please login to merge, or discard this patch.
www/includes/utility.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 # Pass it a brief header word and some debug text and it'll be output.
14 14
 # If TEXT is an array, call the user function, assuming it's a class.
15
-function twfy_debug($header, $text="") {
15
+function twfy_debug($header, $text = "") {
16 16
 
17 17
     // We set ?DEBUGTAG=n in the URL.
18 18
     // (DEBUGTAG is set in config.php).
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     if ($debug_level != '') {
30 30
 
31 31
         // Set which level shows which types of debug info.
32
-        $levels = array (
33
-            1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'),
34
-            2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'),
35
-            3 => array ('SQLRESULT')
32
+        $levels = array(
33
+            1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'),
34
+            2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'),
35
+            3 => array('SQLRESULT')
36 36
             // Higher than this: 'DATA', etc.
37 37
         );
38 38
 
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         }
47 47
 
48 48
         for ($n = 1; $n <= $max_level_to_show; $n++) {
49
-            $allowed_headers = array_merge ($allowed_headers, $levels[$n] );
49
+            $allowed_headers = array_merge($allowed_headers, $levels[$n]);
50 50
         }
51 51
 
52 52
         // If we can show this header, then, er, show it.
53
-        if ( in_array($header, $allowed_headers) || $debug_level >= 4) {
53
+        if (in_array($header, $allowed_headers) || $debug_level >= 4) {
54 54
             if (is_array($text)) $text = call_user_func($text);
55 55
             print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n";
56 56
         }
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
     global $PAGE;
68 68
 
69 69
     # Ignore errors we've asked to ignore
70
-    if (error_reporting()==0) return;
70
+    if (error_reporting() == 0) return;
71 71
 
72 72
    // define an assoc array of error string
73 73
    // in reality the only entries we should
74 74
    // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
75 75
    // E_USER_WARNING and E_USER_NOTICE
76 76
    # Commented out are ones that a user function cannot handle.
77
-    $errortype = array (
77
+    $errortype = array(
78 78
         #E_ERROR            => "Error",
79 79
         E_WARNING           => "Warning",
80 80
         #E_PARSE            => "Parsing Error",
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
         $source = file($filename);
134 134
         $err .= "\nSource:\n\n";
135 135
         // Show the line, plus prev and next, with line numbers.
136
-        $err .= $linenum-2 . " " . $source[$linenum-3];
137
-        $err .= $linenum-1 . " " . $source[$linenum-2];
138
-        $err .= $linenum . " " . $source[$linenum-1];
139
-        $err .= $linenum+1 . " " . $source[$linenum];
140
-        $err .= $linenum+2 . " " . $source[$linenum+1];
136
+        $err .= $linenum - 2 . " " . $source[$linenum - 3];
137
+        $err .= $linenum - 1 . " " . $source[$linenum - 2];
138
+        $err .= $linenum . " " . $source[$linenum - 1];
139
+        $err .= $linenum + 1 . " " . $source[$linenum];
140
+        $err .= $linenum + 2 . " " . $source[$linenum + 1];
141 141
     }
142 142
 
143 143
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
             header('HTTP/1.0 500 Internal Server Error');
182 182
             print "<p>Oops, sorry, an error has occurred!</p>\n";
183 183
         }
184
-        if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) {
185
-            mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n".  "X-Mailer: PHP/" . phpversion() );
184
+        if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) {
185
+            mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n" . "X-Mailer: PHP/" . phpversion());
186 186
         }
187 187
     }
188 188
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 }
201 201
 
202 202
 // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php
203
-function adodb_backtrace($print=true)
203
+function adodb_backtrace($print = true)
204 204
 {
205 205
   $s = '';
206 206
   if (PHPVERSION() >= 4.3) {
@@ -209,26 +209,26 @@  discard block
 block discarded – undo
209 209
 
210 210
     $traceArr = debug_backtrace();
211 211
     array_shift($traceArr);
212
-    $tabs = sizeof($traceArr)-1;
212
+    $tabs = sizeof($traceArr) - 1;
213 213
     foreach ($traceArr as $arr) {
214
-      for ($i=0; $i < $tabs; $i++) $s .= ' &nbsp; ';
214
+      for ($i = 0; $i < $tabs; $i++) $s .= ' &nbsp; ';
215 215
       $tabs -= 1;
216
-      if (isset($arr['class'])) $s .= $arr['class'].'.';
216
+      if (isset($arr['class'])) $s .= $arr['class'] . '.';
217 217
       $args = array();
218 218
       if (isset($arr['args'])) foreach ($arr['args'] as $v) {
219 219
     if (is_null($v)) $args[] = 'null';
220
-    elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']';
221
-    elseif (is_object($v)) $args[] = 'Object:'.get_class($v);
220
+    elseif (is_array($v)) $args[] = 'Array[' . sizeof($v) . ']';
221
+    elseif (is_object($v)) $args[] = 'Object:' . get_class($v);
222 222
     elseif (is_bool($v)) $args[] = $v ? 'true' : 'false';
223 223
     else {
224 224
       $v = (string) @$v;
225
-      $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN));
225
+      $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN));
226 226
       if (strlen($v) > $MAXSTRLEN) $str .= '...';
227 227
       $args[] = $str;
228 228
     }
229 229
       }
230 230
 
231
-      $s .= $arr['function'].'('.implode(', ',$args).')';
231
+      $s .= $arr['function'] . '(' . implode(', ', $args) . ')';
232 232
       //      $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,".
233 233
       //            " file: <a href=\"file:/%s\">%s</a></font>",
234 234
       //        $arr['line'],$arr['file'],$arr['file']);
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 // Returns the unixtime in microseconds.
244 244
 function getmicrotime() {
245 245
     $mtime = microtime();
246
-    $mtime = explode(" ",$mtime);
246
+    $mtime = explode(" ", $mtime);
247 247
     $mtime = $mtime[1] + $mtime[0];
248 248
 
249 249
     return $mtime;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     global $timestamp_last, $timestamp_start;
257 257
     $t = getmicrotime();
258 258
     twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s",
259
-            ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label));
259
+            ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label));
260 260
     $timestamp_last = $t;
261 261
 }
262 262
 
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
         list($string, $year, $month, $day) = $matches;
292 292
         if ($year < 1902) { # gmdate fns only go back to Dec. 1901
293 293
             if ($format == SHORTDATEFORMAT) {
294
-                return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year";
294
+                return ($day + 0) . ' ' . $format_date_months_short[$month + 0] . " $year";
295 295
             } else {
296
-                return ($day+0) . ' ' . $format_date_months[$month+0] . " $year";
296
+                return ($day + 0) . ' ' . $format_date_months[$month + 0] . " $year";
297 297
             }
298 298
         }
299 299
 
@@ -334,16 +334,16 @@  discard block
 block discarded – undo
334 334
     $in_seconds = strtotime($datetime);
335 335
     $now = time();
336 336
 
337
-    $diff   =  $now - $in_seconds;
338
-    $months =  floor($diff/2419200);
337
+    $diff   = $now - $in_seconds;
338
+    $months = floor($diff / 2419200);
339 339
     $diff   -= $months * 2419200;
340
-    $weeks  =  floor($diff/604800);
341
-    $diff   -= $weeks*604800;
342
-    $days   =  floor($diff/86400);
340
+    $weeks  = floor($diff / 604800);
341
+    $diff   -= $weeks * 604800;
342
+    $days   = floor($diff / 86400);
343 343
     $diff   -= $days * 86400;
344
-    $hours  =  floor($diff/3600);
344
+    $hours  = floor($diff / 3600);
345 345
     $diff   -= $hours * 3600;
346
-    $minutes = floor($diff/60);
346
+    $minutes = floor($diff / 60);
347 347
     $diff   -= $minutes * 60;
348 348
     $seconds = $diff;
349 349
 
@@ -357,27 +357,27 @@  discard block
 block discarded – undo
357 357
         $relative_date = '';
358 358
         if ($weeks > 0) {
359 359
             // Weeks and days
360
-            $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':'');
361
-            $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):'';
360
+            $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
361
+            $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
362 362
         } elseif ($days > 0) {
363 363
             // days and hours
364
-            $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':'');
365
-            $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):'';
364
+            $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '');
365
+            $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
366 366
         } elseif ($hours > 0) {
367 367
             // hours and minutes
368
-            $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':'');
369
-            $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):'';
368
+            $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '');
369
+            $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
370 370
         } elseif ($minutes > 0) {
371 371
             // minutes only
372
-            $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':'');
372
+            $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
373 373
         } else {
374 374
             // seconds only
375
-            $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':'');
375
+            $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds > 1 ? 's' : '');
376 376
         }
377 377
     }
378 378
 
379 379
     // Return relative date and add proper verbiage
380
-    return $relative_date.' ago';
380
+    return $relative_date . ' ago';
381 381
 
382 382
 }
383 383
 
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
         $text = substr($text, $start);
427 427
 
428 428
         // Word boundary.
429
-        if (preg_match ("/.+?\b(.*)/", $text, $matches)) {
429
+        if (preg_match("/.+?\b(.*)/", $text, $matches)) {
430 430
             $text = $matches[1];
431 431
             // Strip spare space at the start.
432
-            $text = preg_replace ("/^\s/", '', $text);
432
+            $text = preg_replace("/^\s/", '', $text);
433 433
         }
434 434
         $text = '...' . $text;
435 435
     }
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
         $text = substr($text, 0, $length - 3);
442 442
 
443 443
         // Word boundary.
444
-        if (preg_match ("/(.*)\s.+/", $text, $matches)) {
444
+        if (preg_match("/(.*)\s.+/", $text, $matches)) {
445 445
             $text = $matches[1];
446 446
             // Strip spare space at the end.
447
-            $text = preg_replace ("/\s$/", '', $text);
447
+            $text = preg_replace("/\s$/", '', $text);
448 448
         }
449 449
         // We don't want to use the HTML entity for an ellipsis (&#8230;), because then
450 450
         // it screws up when we subsequently use htmlentities() to print the returned
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 
477 477
     if ($filter_type == 'strict') {
478 478
         // No tags allowed at all!
479
-        $filter->allowed = array ();
479
+        $filter->allowed = array();
480 480
     } else {
481 481
         // Comment.
482 482
         // Only allowing <a href>, <b>, <strong>, <i> and <em>
483
-        $filter->allowed = array (
483
+        $filter->allowed = array(
484 484
             'a' => array('href'),
485 485
             'strong' => array(),
486 486
             'em' => array(),
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 
594 594
     // $gid will be like 'uk.org.publicwhip/debate/2003-02-28.475.3'.
595 595
 
596
-    $newgid = substr($gid, strrpos($gid, '/')+1 );
596
+    $newgid = substr($gid, strrpos($gid, '/') + 1);
597 597
     return $newgid;
598 598
 }
599 599
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
     // will be like 2003-11-20.966.0
605 605
     // This function returns 966.0
606 606
 
607
-    return substr( $gid, (strpos($gid, '.') + 1) );
607
+    return substr($gid, (strpos($gid, '.') + 1));
608 608
 }
609 609
 
610 610
 function preg_replacement_quote($s) {
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
     global $PAGE;
649 649
 
650 650
     if (!isset($data['to']) || $data['to'] == '') {
651
-        $PAGE->error_message ("We need an email address to send to.");
651
+        $PAGE->error_message("We need an email address to send to.");
652 652
         return false;
653 653
     }
654 654
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         if (isset($data['subject'])) {
692 692
             $subject = trim($data['subject']);
693 693
         } else {
694
-            $subject = trim( substr($firstline, 8) );
694
+            $subject = trim(substr($firstline, 8));
695 695
         }
696 696
 
697 697
         // Either way, remove this subject line from the template.
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
     } elseif (isset($data['subject'])) {
701 701
         $subject = $data['subject'];
702 702
     } else {
703
-        $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent.");
703
+        $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent.");
704 704
         return false;
705 705
     }
706 706
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     $replace = array();
711 711
 
712 712
     foreach ($merge as $key => $val) {
713
-        $search[] = '/{'.$key.'}/';
713
+        $search[] = '/{' . $key . '}/';
714 714
         $replace[] = preg_replacement_quote($val);
715 715
     }
716 716
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     $htmltext = preg_replace($search, $replace, $htmltext);
719 719
 
720 720
     // Send it!
721
-    $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext);
721
+    $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces, $htmltext);
722 722
 
723 723
     return $success;
724 724
 
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     return $envelope_sender;
734 734
 }
735 735
 
736
-function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html='') {
736
+function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false, $html = '') {
737 737
     // Use this rather than PHP's mail() direct, so we can make alterations
738 738
     // easily to all the emails we send out from the site.
739 739
     // eg, we might want to add a .sig to everything here...
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 // http://www.iamcal.com/publish/article.php?id=13
780 780
 
781 781
 // Call this with a key name to get a GET or POST variable.
782
-function get_http_var($name, $default='') {
782
+function get_http_var($name, $default = '') {
783 783
     if (array_key_exists($name, $_GET)) {
784 784
         return clean_var($_GET[$name]);
785 785
     }
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 }
806 806
 
807 807
 // Call this with a key name to get a COOKIE variable.
808
-function get_cookie_var($name, $default='') {
808
+function get_cookie_var($name, $default = '') {
809 809
     if (array_key_exists($name, $_COOKIE)) {
810 810
         return clean_var($_COOKIE[$name]);
811 811
     }
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 // Pass it an array of key names that should not be generated as
817 817
 // hidden form variables. It then outputs hidden form variables
818 818
 // based on the session_vars for this page.
819
-function hidden_form_vars ($omit = array()) {
819
+function hidden_form_vars($omit = array()) {
820 820
     global $DATA, $this_page;
821 821
 
822 822
     $session_vars = $DATA->page_metadata($this_page, "session_vars");
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 }
830 830
 
831 831
 // Deprecated. Use hidden_form_vars, above, instead.
832
-function hidden_vars ($omit = array()) {
832
+function hidden_vars($omit = array()) {
833 833
     global $DATA;
834 834
 
835 835
     foreach ($args as $key => $val) {
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 function entities_to_numbers($string) {
873 873
     $string = str_replace(
874 874
         array('&Ouml;', '&acirc;', '&uacute;', '&aacute;', '&iacute;', '&ocirc;', '&eacute;'),
875
-        array('&#214;', '&#226;',  '&#250;',   '&#225;',   '&#237;',   '&#244;',  '&#233;'  ),
875
+        array('&#214;', '&#226;', '&#250;', '&#225;', '&#237;', '&#244;', '&#233;'),
876 876
         $string
877 877
     );
878 878
     return $string;
@@ -889,9 +889,9 @@  discard block
 block discarded – undo
889 889
         }
890 890
     }
891 891
 
892
-    $s   = array(' ', '&amp;', '&ocirc;',  '&Ouml;',  '&ouml;',   '&acirc;',  '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
893
-    $s2  = array(" ", "&",     "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93");
894
-    $r   = array('_', 'and',   'o',        'o',       'o',        'a',        'i',        'a',        'u',        'e',        'o',        'o');
892
+    $s   = array(' ', '&amp;', '&ocirc;', '&Ouml;', '&ouml;', '&acirc;', '&iacute;', '&aacute;', '&uacute;', '&eacute;', '&oacute;', '&Oacute;');
893
+    $s2  = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93");
894
+    $r   = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o');
895 895
     $name = preg_replace('#^the #', '', strtolower($name));
896 896
 
897 897
     $out = '';
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
                 }
1050 1050
                 $out .= '<li>' . $body . '<ul>';
1051 1051
             } else {
1052
-                $LISTURL->insert( array( 'id' => $gid ) );
1053
-                $out .= '<li><a href="'.$LISTURL->generate().'">';
1052
+                $LISTURL->insert(array('id' => $gid));
1053
+                $out .= '<li><a href="' . $LISTURL->generate() . '">';
1054 1054
                 $out .= $body . '</a>';
1055 1055
             }
1056 1056
         }
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
     return $return;
1120 1120
 }
1121 1121
 
1122
-function redirect($url, $code=302) {
1122
+function redirect($url, $code = 302) {
1123 1123
     if (defined('TESTING')) {
1124 1124
         print "Location: $url";
1125 1125
     } else {
Please login to merge, or discard this patch.
classes/People.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $data = $this->_get_data_by_group($args);
37 37
 
38 38
         $user = new User();
39
-        if ( $reps = $this->getRegionalReps($user) ) {
39
+        if ($reps = $this->getRegionalReps($user)) {
40 40
             $data['reps'] = $reps;
41 41
         }
42 42
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             $args['all'] = true;
72 72
         }
73 73
 
74
-        if ( $this->type == 'peers' ) {
74
+        if ($this->type == 'peers') {
75 75
             $args['order'] = 'name';
76 76
         }
77 77
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 
132 132
     private function addImagesToData($data) {
133 133
         $new_data = array();
134
-        foreach ( $data as $pid => $details ) {
135
-            list($image, ) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image);
134
+        foreach ($data as $pid => $details) {
135
+            list($image,) = Utility\Member::findMemberImage($pid, true, $this->subs_missing_image);
136 136
             $details['image'] = $image;
137 137
             $new_data[$pid] = $details;
138 138
         }
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
 
150 150
         $urls['plain'] = $URL->generate();
151 151
 
152
-        $URL->insert(array( 'o' => 'n'));
152
+        $URL->insert(array('o' => 'n'));
153 153
         $urls['by_name'] = $URL->generate();
154 154
 
155
-        $URL->insert(array( 'o' => 'l'));
155
+        $URL->insert(array('o' => 'l'));
156 156
         $urls['by_last'] = $URL->generate();
157 157
 
158
-        $URL->insert(array( 'o' => 'f'));
158
+        $URL->insert(array('o' => 'f'));
159 159
         $urls['by_first'] = $URL->generate();
160 160
 
161
-        $URL->insert(array( 'o' => 'p'));
161
+        $URL->insert(array('o' => 'p'));
162 162
         $urls['by_party'] = $URL->generate();
163 163
 
164
-        $URL->insert(array( 'f' => 'csv'));
165
-        $URL->remove(array( 'o'));
166
-        if ( $date = get_http_var('date') ) {
164
+        $URL->insert(array('f' => 'csv'));
165
+        $URL->remove(array('o'));
166
+        if ($date = get_http_var('date')) {
167 167
             $URL->insert(array('date' => $date));
168 168
         }
169 169
         $urls['by_csv'] = $URL->generate();
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                 $name = member_full_name($this->house, $row['title'], $row['given_name'], $row['family_name'], $row['lordofname']);
214 214
                 $constituency = gettext($row['constituency']);
215 215
                 $url = make_member_url($name, $constituency, $this->house, $p_id);
216
-                $narray = array (
216
+                $narray = array(
217 217
                     'person_id' 	=> $p_id,
218 218
                     'given_name' => $row['given_name'],
219 219
                     'family_name' => $row['family_name'],
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
             uasort($data, 'by_peer_name');
232 232
         }
233 233
 
234
-        $data = array (
235
-            'info' => array (
234
+        $data = array(
235
+            'info' => array(
236 236
                 'order' => $order
237 237
             ),
238 238
             'data' => $data
Please login to merge, or discard this patch.
classes/Member.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
         return $direction;
107 107
     }
108 108
 
109
-    public function currentPartyComparison(){
109
+    public function currentPartyComparison() {
110 110
         # Simplify the current party when being compared to the original
111 111
         # Stops co-op and labour being seen as different
112 112
         $party = $this->party;
113
-        if ( $party == 'Labour/Co-operative' ) {
113
+        if ($party == 'Labour/Co-operative') {
114 114
             $party = 'Labour';
115 115
         }
116 116
         return $party;
117 117
     }
118 118
 
119
-    public function cohortParty($house = HOUSE_TYPE_COMMONS){
119
+    public function cohortParty($house = HOUSE_TYPE_COMMONS) {
120 120
         // The party being compared against for party comparison purposes
121 121
         // Unless specified by the condition in cohortPartyComparisonDirection
122 122
         // This is the first, not last, party a person has.
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
                  ":person_id" => $person_id))->first();
142 142
         if ($row) {
143 143
             $party = $row["party"];
144
-            if ( $party == 'Labour/Co-operative' ) {
144
+            if ($party == 'Labour/Co-operative') {
145 145
                 $party = 'Labour';
146 146
             }
147 147
             return $party;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             $now = new \DateTime();
170 170
 
171 171
             $diff = $date_entered->diff($now);
172
-            if ( $diff->y == 0 && $diff->m <= 6 ) {
172
+            if ($diff->y == 0 && $diff->m <= 6) {
173 173
                 return true;
174 174
             }
175 175
         }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
         $entered_house = $this->entered_house($house);
192 192
 
193
-        if ( $entered_house ) {
193
+        if ($entered_house) {
194 194
             $date_entered = $entered_house['date'];
195 195
         }
196 196
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
         $left_house = $this->left_house($house);
212 212
 
213
-        if ( $left_house ) {
213
+        if ($left_house) {
214 214
             $date_left = $left_house['date'];
215 215
         }
216 216
 
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 
239 239
         $is_lord = $this->house(HOUSE_TYPE_LORDS);
240 240
         if ($is_lord) {
241
-            list($image,$size) = Utility\Member::findMemberImage($this->person_id(), false, 'lord');
241
+            list($image, $size) = Utility\Member::findMemberImage($this->person_id(), false, 'lord');
242 242
         } else {
243
-            list($image,$size) = Utility\Member::findMemberImage($this->person_id(), false, true);
243
+            list($image, $size) = Utility\Member::findMemberImage($this->person_id(), false, true);
244 244
         }
245 245
 
246 246
         // We can determine if the image exists or not by testing if size is set
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 
264 264
         usort(
265 265
             $departures,
266
-            function ($a, $b) {
267
-                if ( $a['date'] == $b['date'] ) {
266
+            function($a, $b) {
267
+                if ($a['date'] == $b['date']) {
268 268
                     return 0;
269
-                } else if ( $a['date'] < $b['date'] ) {
269
+                } else if ($a['date'] < $b['date']) {
270 270
                     return -1;
271 271
                 } else {
272 272
                     return 1;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             $office = $office['office'];
305 305
 
306 306
             foreach ($office as $row) {
307
-                if ( $officeObject = $this->getOfficeObject($include_only, $ignore_committees, $row) ) {
307
+                if ($officeObject = $this->getOfficeObject($include_only, $ignore_committees, $row)) {
308 308
                     $out[] = $officeObject;
309 309
                 }
310 310
             }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     private function entered_house_line($house, $house_name) {
444 444
         if (isset($this->entered_house[$house]['date'])) {
445 445
             $string = "<strong>";
446
-            if (strlen($this->entered_house[$house]['date_pretty'])==4) {
446
+            if (strlen($this->entered_house[$house]['date_pretty']) == 4) {
447 447
                 $string .= sprintf(gettext("Entered the %s in %s"), $house_name, $this->entered_house[$house]['date_pretty']);
448 448
             } else {
449 449
                 $string .= sprintf(gettext("Entered the %s on %s"), $house_name, $this->entered_house[$house]['date_pretty']);
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
     private function left_house_line($house, $house_name) {
460 460
         if ($this->house($house) && !$this->current_member($house)) {
461 461
             $string = "<strong>";
462
-            if (strlen($this->left_house[$house]['date_pretty'])==4) {
462
+            if (strlen($this->left_house[$house]['date_pretty']) == 4) {
463 463
                 $string .= sprintf(gettext("Left the %s in %s"), $house_name, $this->left_house[$house]['date_pretty']);
464 464
             } else {
465 465
                 $string .= sprintf(gettext("Left the %s on %s"), $house_name, $this->left_house[$house]['date_pretty']);
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
         $policy_diffs = array();
477 477
         $party_positions = $partyCohort->getAllPolicyPositions($policiesList);
478 478
 
479
-        if ( !$party_positions ) {
479
+        if (!$party_positions) {
480 480
             return $policy_diffs;
481 481
         }
482 482
 
483
-        foreach ( $positions->positionsById as $policy_id => $details ) {
484
-            if ( $details['has_strong'] && $details['score'] != -1 && isset($party_positions[$policy_id])) {
483
+        foreach ($positions->positionsById as $policy_id => $details) {
484
+            if ($details['has_strong'] && $details['score'] != -1 && isset($party_positions[$policy_id])) {
485 485
                 $mp_score = $details['score'];
486 486
                 $party_position = $party_positions[$policy_id];
487 487
                 $party_score = $party_position['score'];
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                 $score_diff = $this->calculatePolicyDiffScore($mp_score, $party_score);
497 497
 
498 498
                 // skip anything that isn't a yes vs no diff
499
-                if ( $only_diffs && $score_diff < 2 ) {
499
+                if ($only_diffs && $score_diff < 2) {
500 500
                     continue;
501 501
                 }
502 502
                 $policy_diffs[$policy_id] = [
@@ -517,18 +517,18 @@  discard block
 block discarded – undo
517 517
         return $policy_diffs;
518 518
     }
519 519
 
520
-    private function calculatePolicyDiffScore( $mp_score, $party_score ) {
520
+    private function calculatePolicyDiffScore($mp_score, $party_score) {
521 521
         $score_diff = abs($mp_score - $party_score);
522 522
         // if they are on opposite sides of mixture of for and against
523 523
         if (
524
-            ( $mp_score < 0.4 && $party_score > 0.6 ) ||
525
-            ( $mp_score > 0.6 && $party_score < 0.4 )
524
+            ($mp_score < 0.4 && $party_score > 0.6) ||
525
+            ($mp_score > 0.6 && $party_score < 0.4)
526 526
         ) {
527 527
             $score_diff += 2;
528 528
         // if on is mixture of for and against and one is for/against
529 529
         } else if (
530
-            ( $mp_score > 0.4 && $mp_score < 0.6 && ( $party_score > 0.6 || $party_score < 0.4 ) ) ||
531
-            ( $party_score > 0.4 && $party_score < 0.6 && ( $mp_score > 0.6 || $mp_score < 0.4 ) )
530
+            ($mp_score > 0.4 && $mp_score < 0.6 && ($party_score > 0.6 || $party_score < 0.4)) ||
531
+            ($party_score > 0.4 && $party_score < 0.6 && ($mp_score > 0.6 || $mp_score < 0.4))
532 532
         ) {
533 533
             $score_diff += 1;
534 534
         }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
         $mreg = array();
543 543
         $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode);
544
-        if ( isset($constituencies[$type]) ) {
544
+        if (isset($constituencies[$type])) {
545 545
             $cons_name = $constituencies[$type];
546 546
             $query_base = "SELECT member.person_id, title, lordofname, given_name, family_name, constituency, house
547 547
                 FROM member, person_names
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
                     ':cons_name' => $cons_name
559 559
                 )
560 560
             );
561
-            if ( !$q->rows() && ($dissolution = Dissolution::db()) ) {
561
+            if (!$q->rows() && ($dissolution = Dissolution::db())) {
562 562
                 $q = $db->query("$query_base AND $dissolution[query]",
563 563
                     array(
564 564
                         ':house' => $house,
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
     }
583 583
 
584 584
     public static function getRepNameForHouse($house) {
585
-        switch ( $house ) {
585
+        switch ($house) {
586 586
             case HOUSE_TYPE_COMMONS:
587 587
                 $name = 'MP';
588 588
                 break;
Please login to merge, or discard this patch.
classes/Divisions.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
             ':count' => $number
69 69
         );
70 70
 
71
-        if ( is_string($houses) ) {
72
-            $houses = array( $houses );
71
+        if (is_string($houses)) {
72
+            $houses = array($houses);
73 73
         }
74 74
 
75
-        if ( is_array($houses) && count($houses) > 0 ) {
75
+        if (is_array($houses) && count($houses) > 0) {
76 76
             $where = 'WHERE house IN ("' . implode('", "', $houses) . '")';
77 77
         } elseif (LANGUAGE == 'cy') {
78 78
             $where = "WHERE divisions.division_id NOT LIKE '%-en-%'";
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             $where = "WHERE divisions.division_id NOT LIKE '%-cy-%'";
81 81
         }
82 82
 
83
-        if ( $this->member ) {
83
+        if ($this->member) {
84 84
             $select = "SELECT divisions.*, vote FROM divisions
85 85
                 LEFT JOIN persondivisionvotes ON divisions.division_id=persondivisionvotes.division_id AND person_id=:person_id";
86 86
             $params[':person_id'] = $this->member->person_id;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     public function getMemberDivisionsForPolicy($policyID = null) {
220 220
         $where_extra = '';
221 221
         $args = array(':person_id' => $this->member->person_id);
222
-        if ( $policyID ) {
222
+        if ($policyID) {
223 223
             $where_extra = 'AND policy_id = :policy_id';
224 224
             $args[':policy_id'] = $policyID;
225 225
         }
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 
277 277
           $vote = $row['vote'];
278 278
           $policy_vote = str_replace('3', '', $row['policy_vote']);
279
-          if ( $vote == 'absent' ) {
279
+          if ($vote == 'absent') {
280 280
               $summary['absent'] += $row['total'];
281
-          } else if ( $vote == 'both' ) {
281
+          } else if ($vote == 'both') {
282 282
               $summary['both'] += $row['total'];
283
-          } else if ( strpos($vote, 'tell') !== false ) {
283
+          } else if (strpos($vote, 'tell') !== false) {
284 284
               $summary['tell'] += $row['total'];
285
-          } else if ( $policy_vote == $vote ) {
285
+          } else if ($policy_vote == $vote) {
286 286
               $summary['for'] += $row['total'];
287
-          } else if ( $policy_vote != $vote ) {
287
+          } else if ($policy_vote != $vote) {
288 288
               $summary['against'] += $row['total'];
289 289
           }
290 290
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                     FROM person_names AS pn
382 382
                     WHERE person_id = :person_id
383 383
                     AND start_date <= :division_date AND end_date >= :division_date",
384
-                    [ ':person_id' => $vote['proxy'], ':division_date' => $row['division_date'] ]
384
+                    [':person_id' => $vote['proxy'], ':division_date' => $row['division_date']]
385 385
                 )->first();
386 386
                 $detail['proxy'] = ucfirst(member_full_name(
387 387
                     HOUSE_TYPE_COMMONS, $q['title'], $q['given_name'],
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 
406 406
         foreach ($votes as $vote => $count) { // array('yes_votes', 'no_votes', 'absent_votes', 'both_votes') as $vote) {
407 407
           $votes[$vote . '_by_party'] = $votes[$vote];
408
-          usort($votes[$vote . '_by_party'], function ($a, $b) {
409
-                return $a['party']>$b['party'];
408
+          usort($votes[$vote . '_by_party'], function($a, $b) {
409
+                return $a['party'] > $b['party'];
410 410
             });
411 411
         }
412 412
 
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
             $votes['against'] . ' ' . make_plural('vote', $votes['against']) . ' against'
461 461
         );
462 462
 
463
-        if ( $votes['both'] ) {
463
+        if ($votes['both']) {
464 464
             $actions[] = $votes['both'] . ' ' . make_plural('abstention', $votes['both']);
465 465
         }
466
-        if ( $votes['absent'] ) {
466
+        if ($votes['absent']) {
467 467
             $actions[] = $votes['absent'] . ' ' . make_plural('absence', $votes['absent']);
468 468
         }
469 469
         if ($max == $min) {
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
     }
521 521
 
522 522
     private function constructYesNoVoteDescription($direction, $title, $short_text) {
523
-        $text = ' ' ;
524
-        if ( $short_text ) {
523
+        $text = ' ';
524
+        if ($short_text) {
525 525
             $text .= sprintf(gettext('voted %s'), $short_text);
526 526
         } else {
527 527
             $text .= sprintf(gettext('voted %s on <em>%s</em>'), $direction, $title);
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
          * votes so we need to generate some text using the title of the division
539 539
          */
540 540
 
541
-        switch ( strtolower($vote) ) {
541
+        switch (strtolower($vote)) {
542 542
             case 'yes':
543 543
             case 'aye':
544 544
                 $description = $this->constructYesNoVoteDescription('yes', $division_title, $yes_text);
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 
587 587
         if (array_key_exists('direction', $row)) {
588 588
             $division['direction'] = $row['direction'];
589
-            if ( strpos( $row['direction'], 'strong') !== false ) {
589
+            if (strpos($row['direction'], 'strong') !== false) {
590 590
                 $division['strong'] = true;
591 591
             } else {
592 592
                 $division['strong'] = false;
@@ -618,24 +618,24 @@  discard block
 block discarded – undo
618 618
         foreach ($q as $row) {
619 619
             $policy_id = $row['policy_id'];
620 620
 
621
-            if ( !array_key_exists($policy_id, $policies) ) {
621
+            if (!array_key_exists($policy_id, $policies)) {
622 622
                 $policies[$policy_id] = array(
623 623
                     'policy_id' => $policy_id,
624 624
                     'weak_count' => 0,
625 625
                     'divisions' => array()
626 626
                 );
627
-                if ( $this->policies ) {
627
+                if ($this->policies) {
628 628
                     $policies[$policy_id]['desc'] = $this->policies->getPolicies()[$policy_id];
629 629
                     $policies[$policy_id]['header'] = $this->policies->getPolicyDetails($policy_id);
630 630
                 }
631
-                if ( $this->positions ) {
631
+                if ($this->positions) {
632 632
                     $policies[$policy_id]['position'] = $this->positions->positionsById[$policy_id];
633 633
                 }
634 634
             }
635 635
 
636 636
             $division = $this->getDivisionDetails($row);
637 637
 
638
-            if ( !$division['strong'] ) {
638
+            if (!$division['strong']) {
639 639
                 $policies[$policy_id]['weak_count']++;
640 640
             }
641 641
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 
651 651
         $gid = get_canonical_gid($gid);
652 652
 
653
-        $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array( ':gid' => $gid ))->first();
653
+        $q = $this->db->query("SELECT gid, major FROM hansard WHERE epobject_id = ( SELECT subsection_id FROM hansard WHERE gid = :gid )", array(':gid' => $gid))->first();
654 654
         if (!$q) {
655 655
             return '';
656 656
         }
Please login to merge, or discard this patch.
classes/AlertView/Standard.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                 try {
181 181
                     $MEMBER = new \MEMBER(array('constituency'=>$constituency, 'house' => 1));
182 182
                     $cons[$constituency] = $MEMBER;
183
-                } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
183
+                } catch (\MySociety\TheyWorkForYou\MemberException $e) {
184 184
                     // do nothing
185 185
                 }
186 186
             }
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 
201 201
         // If this goes well, the alert will be added to the database and a confirmation email
202 202
         // will be sent to them.
203
-        $success = $this->alert->add( $this->data, $confirm );
203
+        $success = $this->alert->add($this->data, $confirm);
204 204
 
205
-        if ($success>0 && !$confirm) {
205
+        if ($success > 0 && !$confirm) {
206 206
             $result = 'alert-added';
207
-        } elseif ($success>0) {
207
+        } elseif ($success > 0) {
208 208
             $result = 'alert-confirmation';
209 209
         } elseif ($success == -2) {
210 210
             // we need to make sure we know that the person attempting to sign up
211 211
             // for the alert has that email address to stop people trying to work
212 212
             // out what alerts they are signed up to
213
-            if ( $this->data['email_verified'] || ( $this->user->loggedin && $this->user->email() == $this->data['email'] ) ) {
213
+            if ($this->data['email_verified'] || ($this->user->loggedin && $this->user->email() == $this->data['email'])) {
214 214
                 $result = 'alert-exists';
215 215
             } else {
216 216
                 // don't throw an error message as that implies that they have already signed
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 
237 237
     private function formatSearchTerms() {
238
-        if ( $this->data['alertsearch'] ) {
238
+        if ($this->data['alertsearch']) {
239 239
             $this->data['alertsearch_pretty'] = \MySociety\TheyWorkForYou\Utility\Alert::prettifyCriteria($this->data['alertsearch']);
240 240
             $this->data['search_text'] = $this->data['alertsearch'];
241 241
         } else {
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
     }
263 263
 
264 264
     private function formatSearchMemberData() {
265
-        if ( isset($this->data['postcode']) ) {
265
+        if (isset($this->data['postcode'])) {
266 266
             try {
267 267
                 $postcode = $this->data['postcode'];
268 268
 
269
-                $MEMBER = new \MEMBER( array('postcode' => $postcode) );
269
+                $MEMBER = new \MEMBER(array('postcode' => $postcode));
270 270
                 // move the postcode to the front just to be tidy
271 271
                 $tidy_alertsearch = $postcode . " " . trim(str_replace("$postcode", "", $this->data['alertsearch']));
272 272
                 $alertsearch_display = str_replace("$postcode ", "", $tidy_alertsearch);
@@ -275,29 +275,29 @@  discard block
 block discarded – undo
275 275
                 $this->data['member_displaysearch'] = $alertsearch_display;
276 276
                 $this->data['member'] = $MEMBER;
277 277
 
278
-                if ( isset($this->data['mistakes']['postcode_and']) ) {
278
+                if (isset($this->data['mistakes']['postcode_and'])) {
279 279
                     $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($postcode);
280
-                    if ( isset($constituencies['SPC']) ) {
280
+                    if (isset($constituencies['SPC'])) {
281 281
                         $MEMBER = new \MEMBER(array('constituency' => $constituencies['SPC'], 'house' => HOUSE_TYPE_SCOTLAND));
282 282
                         $this->data['scottish_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
283 283
                         $this->data['scottish_member'] = $MEMBER;
284
-                    } elseif ( isset($constituencies['WAC']) ) {
284
+                    } elseif (isset($constituencies['WAC'])) {
285 285
                         $MEMBER = new \MEMBER(array('constituency' => $constituencies['WAC'], 'house' => HOUSE_TYPE_WALES));
286 286
                         $this->data['welsh_alertsearch'] = str_replace("$postcode", "speaker:" . $MEMBER->person_id, $tidy_alertsearch);
287 287
                         $this->data['welsh_member'] = $MEMBER;
288 288
                     }
289 289
                 }
290
-            } catch ( \MySociety\TheyWorkForYou\MemberException $e ) {
290
+            } catch (\MySociety\TheyWorkForYou\MemberException $e) {
291 291
                 $this->data['member_error'] = 1;
292 292
             }
293 293
         }
294 294
 
295
-        if ( $this->data['pid'] ) {
296
-            $MEMBER = new \MEMBER( array('person_id' => $this->data['pid']) );
295
+        if ($this->data['pid']) {
296
+            $MEMBER = new \MEMBER(array('person_id' => $this->data['pid']));
297 297
             $this->data['pid_member'] = $MEMBER;
298 298
         }
299 299
 
300
-        if ( $this->data['keyword'] ) {
300
+        if ($this->data['keyword']) {
301 301
             $this->data['display_keyword'] = \MySociety\TheyWorkForYou\Utility\Alert::prettifyCriteria($this->data['keyword']);
302 302
         }
303 303
     }
Please login to merge, or discard this patch.