@@ -851,8 +851,8 @@ discard block |
||
851 | 851 | if ($cookie == '') { |
852 | 852 | $cookie = get_cookie_var("facebook_id"); |
853 | 853 | if ($cookie != '') { |
854 | - $this->facebook_user = True; |
|
855 | - twfy_debug("THEUSER", "is facebook login"); |
|
854 | + $this->facebook_user = True; |
|
855 | + twfy_debug("THEUSER", "is facebook login"); |
|
856 | 856 | } |
857 | 857 | } |
858 | 858 | |
@@ -873,36 +873,36 @@ discard block |
||
873 | 873 | // And make sure the user hasn't been "deleted". |
874 | 874 | |
875 | 875 | if ($this->facebook_user) { |
876 | - if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) { |
|
877 | - twfy_debug ("THEUSER", "init SUCCESS: setting as logged in"); |
|
878 | - $this->loggedin = true; |
|
879 | - } elseif (md5 ($this->facebook_token()) != $matches[2]) { |
|
880 | - twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
881 | - $this->loggedin = false; |
|
882 | - } else { |
|
883 | - twfy_debug ("THEUSER", "init FAILED: User is deleted"); |
|
884 | - $this->loggedin = false; |
|
885 | - } |
|
876 | + if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) { |
|
877 | + twfy_debug ("THEUSER", "init SUCCESS: setting as logged in"); |
|
878 | + $this->loggedin = true; |
|
879 | + } elseif (md5 ($this->facebook_token()) != $matches[2]) { |
|
880 | + twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
881 | + $this->loggedin = false; |
|
882 | + } else { |
|
883 | + twfy_debug ("THEUSER", "init FAILED: User is deleted"); |
|
884 | + $this->loggedin = false; |
|
885 | + } |
|
886 | 886 | } else { |
887 | - if (md5($this->password()) == $matches[2] && $this->deleted() == false) { |
|
888 | - // The correct password is in the cookie, |
|
889 | - // and the user isn't deleted, so set the user to be logged in. |
|
887 | + if (md5($this->password()) == $matches[2] && $this->deleted() == false) { |
|
888 | + // The correct password is in the cookie, |
|
889 | + // and the user isn't deleted, so set the user to be logged in. |
|
890 | 890 | |
891 | - // This would be an appropriate place to call other functions |
|
892 | - // that might set user info that only a logged-in user is going |
|
893 | - // to need. Their preferences and saved things or something. |
|
891 | + // This would be an appropriate place to call other functions |
|
892 | + // that might set user info that only a logged-in user is going |
|
893 | + // to need. Their preferences and saved things or something. |
|
894 | 894 | |
895 | 895 | |
896 | - twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in"); |
|
897 | - $this->loggedin = true; |
|
896 | + twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in"); |
|
897 | + $this->loggedin = true; |
|
898 | 898 | |
899 | - } elseif (md5 ($this->password()) != $matches[2]) { |
|
900 | - twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie"); |
|
901 | - $this->loggedin = false; |
|
902 | - } else { |
|
903 | - twfy_debug ("THEUSER init FAILED", "User is deleted"); |
|
904 | - $this->loggedin = false; |
|
905 | - } |
|
899 | + } elseif (md5 ($this->password()) != $matches[2]) { |
|
900 | + twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie"); |
|
901 | + $this->loggedin = false; |
|
902 | + } else { |
|
903 | + twfy_debug ("THEUSER init FAILED", "User is deleted"); |
|
904 | + $this->loggedin = false; |
|
905 | + } |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | } else { |
@@ -445,9 +445,15 @@ discard block |
||
445 | 445 | // Generates the password .... |
446 | 446 | for ($x=0; $x < 6;) { |
447 | 447 | $y = rand(1,1000); |
448 | - if($y>350 && $y<601) $d=chr(rand(48,57)); |
|
449 | - if($y<351) $d=chr(rand(65,90)); |
|
450 | - if($y>600) $d=chr(rand(97,122)); |
|
448 | + if($y>350 && $y<601) { |
|
449 | + $d=chr(rand(48,57)); |
|
450 | + } |
|
451 | + if($y<351) { |
|
452 | + $d=chr(rand(65,90)); |
|
453 | + } |
|
454 | + if($y>600) { |
|
455 | + $d=chr(rand(97,122)); |
|
456 | + } |
|
451 | 457 | if ($d!=$o && !preg_match('#[O01lI]#', $d)) { |
452 | 458 | $o=$d; $pwd.=$d; $x++; |
453 | 459 | } |
@@ -1171,8 +1177,12 @@ discard block |
||
1171 | 1177 | |
1172 | 1178 | public function confirm_email($token, $redirect=true) { |
1173 | 1179 | $arg = ''; |
1174 | - if (strstr($token, '::')) $arg = '::'; |
|
1175 | - if (strstr($token, '-')) $arg = '-'; |
|
1180 | + if (strstr($token, '::')) { |
|
1181 | + $arg = '::'; |
|
1182 | + } |
|
1183 | + if (strstr($token, '-')) { |
|
1184 | + $arg = '-'; |
|
1185 | + } |
|
1176 | 1186 | list($user_id, $registrationtoken) = explode($arg, $token); |
1177 | 1187 | |
1178 | 1188 | if (!is_numeric($user_id) || $registrationtoken == '') { |
@@ -1254,8 +1264,12 @@ discard block |
||
1254 | 1264 | |
1255 | 1265 | // Split the token into its parts. |
1256 | 1266 | $arg = ''; |
1257 | - if (strstr($token, '::')) $arg = '::'; |
|
1258 | - if (strstr($token, '-')) $arg = '-'; |
|
1267 | + if (strstr($token, '::')) { |
|
1268 | + $arg = '::'; |
|
1269 | + } |
|
1270 | + if (strstr($token, '-')) { |
|
1271 | + $arg = '-'; |
|
1272 | + } |
|
1259 | 1273 | list($user_id, $registrationtoken) = explode($arg, $token); |
1260 | 1274 | |
1261 | 1275 | if (!is_numeric($user_id) || $registrationtoken == '') { |
@@ -1385,15 +1399,19 @@ discard block |
||
1385 | 1399 | // not-logged-in users. |
1386 | 1400 | |
1387 | 1401 | $this->postcode = $pc; |
1388 | - if (!headers_sent()) // if in debug mode |
|
1402 | + if (!headers_sent()) { |
|
1403 | + // if in debug mode |
|
1389 | 1404 | setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN); |
1405 | + } |
|
1390 | 1406 | |
1391 | 1407 | twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain"); |
1392 | 1408 | } |
1393 | 1409 | |
1394 | 1410 | public function unset_postcode_cookie() { |
1395 | - if (!headers_sent()) // if in debug mode |
|
1411 | + if (!headers_sent()) { |
|
1412 | + // if in debug mode |
|
1396 | 1413 | setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
1414 | + } |
|
1397 | 1415 | } |
1398 | 1416 | |
1399 | 1417 | // mostly here for updating from facebook where we do not need |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | if ($cookie == '') { |
873 | 873 | $cookie = get_cookie_var("facebook_id"); |
874 | 874 | if ($cookie != '') { |
875 | - $this->facebook_user = True; |
|
875 | + $this->facebook_user = true; |
|
876 | 876 | twfy_debug("THEUSER", "is facebook login"); |
877 | 877 | } |
878 | 878 | } |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | twfy_debug("USER", "logging in user from facebook " . $this->user_id); |
1076 | 1076 | |
1077 | - $this->loggedin = True; |
|
1077 | + $this->loggedin = true; |
|
1078 | 1078 | $this->_login($returl, $expire, $cookie, 'facebook_id'); |
1079 | 1079 | return true; |
1080 | 1080 | } |
@@ -56,21 +56,21 @@ discard block |
||
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 | |
@@ -116,22 +116,22 @@ discard block |
||
116 | 116 | // We've got a user, so set them up. |
117 | 117 | |
118 | 118 | $this->user_id = $user_id; |
119 | - $this->firstname = $q->field(0,"firstname"); |
|
120 | - $this->lastname = $q->field(0,"lastname"); |
|
121 | - $this->password = $q->field(0,"password"); |
|
122 | - $this->email = $q->field(0,"email"); |
|
123 | - $this->postcode = $q->field(0,"postcode"); |
|
124 | - $this->facebook_id = $q->field(0,"facebook_id"); |
|
125 | - $this->facebook_token = $q->field(0,"facebook_token"); |
|
126 | - $this->url = $q->field(0,"url"); |
|
127 | - $this->lastvisit = $q->field(0,"lastvisit"); |
|
119 | + $this->firstname = $q->field(0, "firstname"); |
|
120 | + $this->lastname = $q->field(0, "lastname"); |
|
121 | + $this->password = $q->field(0, "password"); |
|
122 | + $this->email = $q->field(0, "email"); |
|
123 | + $this->postcode = $q->field(0, "postcode"); |
|
124 | + $this->facebook_id = $q->field(0, "facebook_id"); |
|
125 | + $this->facebook_token = $q->field(0, "facebook_token"); |
|
126 | + $this->url = $q->field(0, "url"); |
|
127 | + $this->lastvisit = $q->field(0, "lastvisit"); |
|
128 | 128 | $this->registrationtoken = $q->field(0, 'registrationtoken'); |
129 | - $this->registrationtime = $q->field(0,"registrationtime"); |
|
130 | - $this->registrationip = $q->field(0,"registrationip"); |
|
131 | - $this->optin = $q->field(0,"optin") == 1 ? true : false; |
|
132 | - $this->status = $q->field(0,"status"); |
|
133 | - $this->deleted = $q->field(0,"deleted") == 1 ? true : false; |
|
134 | - $this->confirmed = $q->field(0,"confirmed") == 1 ? true : false; |
|
129 | + $this->registrationtime = $q->field(0, "registrationtime"); |
|
130 | + $this->registrationip = $q->field(0, "registrationip"); |
|
131 | + $this->optin = $q->field(0, "optin") == 1 ? true : false; |
|
132 | + $this->status = $q->field(0, "status"); |
|
133 | + $this->deleted = $q->field(0, "deleted") == 1 ? true : false; |
|
134 | + $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false; |
|
135 | 135 | |
136 | 136 | return true; |
137 | 137 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | } |
151 | 151 | |
152 | - public function add($details, $confirmation_required=true) { |
|
152 | + public function add($details, $confirmation_required = true) { |
|
153 | 153 | // Adds a new user's info into the db. |
154 | 154 | // Then optionally (and usually) calls another function to |
155 | 155 | // send them a confirmation email. |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // This will be sent to them via email, so we can confirm they exist. |
232 | 232 | // The token will be the first 16 characters of a hash. |
233 | 233 | |
234 | - $token = substr( password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16 ); |
|
234 | + $token = substr(password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16); |
|
235 | 235 | |
236 | 236 | // Full stops don't work well at the end of URLs in emails, |
237 | 237 | // so replace them. We won't be doing anything clever with the hash |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $r = $this->db->query("UPDATE users |
244 | 244 | SET registrationtoken = :registrationtoken |
245 | 245 | WHERE user_id = :user_id |
246 | - ", array ( |
|
246 | + ", array( |
|
247 | 247 | ':registrationtoken' => $this->registrationtoken, |
248 | 248 | ':user_id' => $this->user_id |
249 | 249 | )); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | public function add_facebook_id($facebook_id) { |
293 | - $q = $this->db->query ("UPDATE users SET facebook_id = :facebook_id WHERE email = :email", |
|
293 | + $q = $this->db->query("UPDATE users SET facebook_id = :facebook_id WHERE email = :email", |
|
294 | 294 | array( |
295 | 295 | ':facebook_id' => $facebook_id, |
296 | 296 | ':email' => $this->email |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | !isset($details['email']) || |
312 | 312 | $details['email'] == '' || |
313 | 313 | !isset($details['token']) || |
314 | - $details['token'] == '' ) { |
|
314 | + $details['token'] == '') { |
|
315 | 315 | return false; |
316 | 316 | } |
317 | 317 | |
@@ -323,12 +323,12 @@ discard block |
||
323 | 323 | $confirmurl = 'https://' . DOMAIN . '/E/' . $urltoken; |
324 | 324 | |
325 | 325 | // Arrays we need to send a templated email. |
326 | - $data = array ( |
|
326 | + $data = array( |
|
327 | 327 | 'to' => $details['email'], |
328 | 328 | 'template' => 'email_confirmation' |
329 | 329 | ); |
330 | 330 | |
331 | - $merge = array ( |
|
331 | + $merge = array( |
|
332 | 332 | 'FIRSTNAME' => $details['firstname'], |
333 | 333 | 'LASTNAME' => $details['lastname'], |
334 | 334 | 'CONFIRMURL' => $confirmurl |
@@ -368,12 +368,12 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | // Arrays we need to send a templated email. |
371 | - $data = array ( |
|
371 | + $data = array( |
|
372 | 372 | 'to' => $details['email'], |
373 | 373 | 'template' => 'join_confirmation' |
374 | 374 | ); |
375 | 375 | |
376 | - $merge = array ( |
|
376 | + $merge = array( |
|
377 | 377 | 'FIRSTNAME' => $details['firstname'], |
378 | 378 | 'LASTNAME' => $details['lastname'], |
379 | 379 | 'CONFIRMURL' => $confirmurl |
@@ -435,23 +435,23 @@ discard block |
||
435 | 435 | $this->email = $email; |
436 | 436 | for (;;) { |
437 | 437 | |
438 | - $pwd=null; |
|
439 | - $o=null; |
|
438 | + $pwd = null; |
|
439 | + $o = null; |
|
440 | 440 | |
441 | 441 | // Generates the password .... |
442 | - for ($x=0; $x < 6;) { |
|
443 | - $y = rand(1,1000); |
|
444 | - if($y>350 && $y<601) $d=chr(rand(48,57)); |
|
445 | - if($y<351) $d=chr(rand(65,90)); |
|
446 | - if($y>600) $d=chr(rand(97,122)); |
|
447 | - if ($d!=$o && !preg_match('#[O01lI]#', $d)) { |
|
448 | - $o=$d; $pwd.=$d; $x++; |
|
442 | + for ($x = 0; $x < 6;) { |
|
443 | + $y = rand(1, 1000); |
|
444 | + if ($y > 350 && $y < 601) $d = chr(rand(48, 57)); |
|
445 | + if ($y < 351) $d = chr(rand(65, 90)); |
|
446 | + if ($y > 600) $d = chr(rand(97, 122)); |
|
447 | + if ($d != $o && !preg_match('#[O01lI]#', $d)) { |
|
448 | + $o = $d; $pwd .= $d; $x++; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | 452 | // If the PW fits your purpose (e.g. this regexpression) return it, else make a new one |
453 | 453 | // (You can change this regular-expression how you want ....) |
454 | - if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/",$pwd)) { |
|
454 | + if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/", $pwd)) { |
|
455 | 455 | break; |
456 | 456 | } |
457 | 457 | |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | $passwordforDB = password_hash($pwd, PASSWORD_BCRYPT); |
471 | 471 | |
472 | - $q = $this->db->query ("UPDATE users SET password = :password WHERE email = :email", |
|
472 | + $q = $this->db->query("UPDATE users SET password = :password WHERE email = :email", |
|
473 | 473 | array( |
474 | 474 | ':password' => $passwordforDB, |
475 | 475 | ':email' => $email |
@@ -497,14 +497,14 @@ discard block |
||
497 | 497 | return false; |
498 | 498 | } |
499 | 499 | |
500 | - $data = array ( |
|
500 | + $data = array( |
|
501 | 501 | 'to' => $this->email(), |
502 | 502 | 'template' => 'new_password' |
503 | 503 | ); |
504 | 504 | |
505 | 505 | $URL = new \MySociety\TheyWorkForYou\Url("userlogin"); |
506 | 506 | |
507 | - $merge = array ( |
|
507 | + $merge = array( |
|
508 | 508 | 'EMAIL' => $this->email(), |
509 | 509 | 'LOGINURL' => "https://" . DOMAIN . $URL->generate(), |
510 | 510 | 'PASSWORD' => $this->password() |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | public function facebook_id_exists($id, $return_id = false) { |
564 | 564 | // Returns true if there's a user with this facebook id. |
565 | 565 | |
566 | - if ($id!= "") { |
|
566 | + if ($id != "") { |
|
567 | 567 | $q = $this->db->query("SELECT user_id FROM users WHERE facebook_id = :id", array(':id' => $id)); |
568 | 568 | if ($q->rows() > 0) { |
569 | 569 | if ($return_id) { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | /* Everyone */ return true; |
643 | 643 | |
644 | 644 | default: |
645 | - $PAGE->error_message ("You need to set permissions for '$action'!"); |
|
645 | + $PAGE->error_message("You need to set permissions for '$action'!"); |
|
646 | 646 | |
647 | 647 | return false; |
648 | 648 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | // Maybe there's a way of fetching these from the DB, |
661 | 661 | // so we don't duplicate them here...? |
662 | 662 | |
663 | - $statuses = array ("Viewer", "User", "Moderator", "Administrator", "Superuser"); |
|
663 | + $statuses = array("Viewer", "User", "Moderator", "Administrator", "Superuser"); |
|
664 | 664 | |
665 | 665 | return $statuses; |
666 | 666 | |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | return $details; |
816 | 816 | |
817 | 817 | } else { |
818 | - $PAGE->error_message ("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'"); |
|
818 | + $PAGE->error_message("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'"); |
|
819 | 819 | |
820 | 820 | return false; |
821 | 821 | } |
@@ -888,13 +888,13 @@ discard block |
||
888 | 888 | |
889 | 889 | if ($this->facebook_user) { |
890 | 890 | if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) { |
891 | - twfy_debug ("THEUSER", "init SUCCESS: setting as logged in"); |
|
891 | + twfy_debug("THEUSER", "init SUCCESS: setting as logged in"); |
|
892 | 892 | $this->loggedin = true; |
893 | - } elseif (md5 ($this->facebook_token()) != $matches[2]) { |
|
894 | - twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
893 | + } elseif (md5($this->facebook_token()) != $matches[2]) { |
|
894 | + twfy_debug("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
895 | 895 | $this->loggedin = false; |
896 | 896 | } else { |
897 | - twfy_debug ("THEUSER", "init FAILED: User is deleted"); |
|
897 | + twfy_debug("THEUSER", "init FAILED: User is deleted"); |
|
898 | 898 | $this->loggedin = false; |
899 | 899 | } |
900 | 900 | } else { |
@@ -907,30 +907,30 @@ discard block |
||
907 | 907 | // to need. Their preferences and saved things or something. |
908 | 908 | |
909 | 909 | |
910 | - twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in"); |
|
910 | + twfy_debug("THEUSER init SUCCEEDED", "setting as logged in"); |
|
911 | 911 | $this->loggedin = true; |
912 | 912 | |
913 | - } elseif (md5 ($this->password()) != $matches[2]) { |
|
914 | - twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie"); |
|
913 | + } elseif (md5($this->password()) != $matches[2]) { |
|
914 | + twfy_debug("THEUSER init FAILED", "Password doesn't match cookie"); |
|
915 | 915 | $this->loggedin = false; |
916 | 916 | } else { |
917 | - twfy_debug ("THEUSER init FAILED", "User is deleted"); |
|
917 | + twfy_debug("THEUSER init FAILED", "User is deleted"); |
|
918 | 918 | $this->loggedin = false; |
919 | 919 | } |
920 | 920 | } |
921 | 921 | |
922 | 922 | } else { |
923 | - twfy_debug ("THEUSER init FAILED", "didn't get 1 row from db"); |
|
923 | + twfy_debug("THEUSER init FAILED", "didn't get 1 row from db"); |
|
924 | 924 | $this->loggedin = false; |
925 | 925 | } |
926 | 926 | |
927 | 927 | } else { |
928 | - twfy_debug ("THEUSER init FAILED", "cookie's user_id is not numeric"); |
|
928 | + twfy_debug("THEUSER init FAILED", "cookie's user_id is not numeric"); |
|
929 | 929 | $this->loggedin = false; |
930 | 930 | } |
931 | 931 | |
932 | 932 | } else { |
933 | - twfy_debug ("THEUSER init FAILED", "cookie is not of the correct form"); |
|
933 | + twfy_debug("THEUSER init FAILED", "cookie is not of the correct form"); |
|
934 | 934 | $this->loggedin = false; |
935 | 935 | } |
936 | 936 | |
@@ -1001,67 +1001,67 @@ discard block |
||
1001 | 1001 | |
1002 | 1002 | if ($q->rows() == 1) { |
1003 | 1003 | // OK. |
1004 | - $dbpassword = $q->field(0,"password"); |
|
1004 | + $dbpassword = $q->field(0, "password"); |
|
1005 | 1005 | if (password_verify($userenteredpassword, $dbpassword)) { |
1006 | - $this->user_id = $q->field(0,"user_id"); |
|
1006 | + $this->user_id = $q->field(0, "user_id"); |
|
1007 | 1007 | $this->password = $dbpassword; |
1008 | 1008 | // We'll need these when we're going to log in. |
1009 | - $this->deleted = $q->field(0,"deleted") == 1 ? true : false; |
|
1010 | - $this->confirmed = $q->field(0,"confirmed") == 1 ? true : false; |
|
1009 | + $this->deleted = $q->field(0, "deleted") == 1 ? true : false; |
|
1010 | + $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false; |
|
1011 | 1011 | |
1012 | 1012 | return true; |
1013 | 1013 | |
1014 | 1014 | } else { |
1015 | 1015 | // Failed. |
1016 | - return array ("invalidemail" => $error_string); |
|
1016 | + return array("invalidemail" => $error_string); |
|
1017 | 1017 | |
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | } else { |
1021 | 1021 | // Failed. |
1022 | - return array ("invalidemail" => $error_string); |
|
1022 | + return array("invalidemail" => $error_string); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | public function has_postcode() { |
1028 | 1028 | $has_postcode = false; |
1029 | - if ( $this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set() ) { |
|
1029 | + if ($this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set()) { |
|
1030 | 1030 | $has_postcode = true; |
1031 | 1031 | } |
1032 | 1032 | return $has_postcode; |
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | |
1036 | - public function facebook_login($returl="", $expire, $accessToken) { |
|
1036 | + public function facebook_login($returl = "", $expire, $accessToken) { |
|
1037 | 1037 | global $PAGE; |
1038 | 1038 | |
1039 | 1039 | twfy_debug("THEUSER", "Faceook login, user_id " . $this->user_id); |
1040 | 1040 | twfy_debug("THEUSER", "Faceook login, facebook_id " . $this->facebook_id); |
1041 | 1041 | twfy_debug("THEUSER", "Faceook login, email" . $this->email); |
1042 | 1042 | if ($this->facebook_id() == "") { |
1043 | - $PAGE->error_message ("We don't have a facebook id for this user.", true); |
|
1043 | + $PAGE->error_message("We don't have a facebook id for this user.", true); |
|
1044 | 1044 | |
1045 | 1045 | return; |
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | twfy_debug("THEUSER", "Faceook login, facebook_token: " . $accessToken); |
1049 | 1049 | |
1050 | - $q = $this->db->query ("UPDATE users SET facebook_token = :token WHERE email = :email", |
|
1050 | + $q = $this->db->query("UPDATE users SET facebook_token = :token WHERE email = :email", |
|
1051 | 1051 | array( |
1052 | 1052 | ':token' => $accessToken, |
1053 | 1053 | ':email' => $this->email |
1054 | 1054 | )); |
1055 | 1055 | |
1056 | 1056 | if (!$q->success()) { |
1057 | - $PAGE->error_message ("There was a problem logging you in", true); |
|
1057 | + $PAGE->error_message("There was a problem logging you in", true); |
|
1058 | 1058 | twfy_debug("THEUSER", "Faceook login, failed to set accessToken"); |
1059 | 1059 | |
1060 | 1060 | return false; |
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | // facebook login users probably don't have a password |
1064 | - $cookie = $this->user_id() . "." . md5 ($accessToken); |
|
1064 | + $cookie = $this->user_id() . "." . md5($accessToken); |
|
1065 | 1065 | twfy_debug("THEUSER", "Faceook login, cookie: " . $cookie); |
1066 | 1066 | |
1067 | 1067 | twfy_debug("USER", "logging in user from facebook " . $this->user_id); |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | return true; |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - public function login($returl="", $expire) { |
|
1074 | + public function login($returl = "", $expire) { |
|
1075 | 1075 | |
1076 | 1076 | // This is used to log the user in. Duh. |
1077 | 1077 | // You should already have checked the user's email and password using |
@@ -1093,21 +1093,21 @@ discard block |
||
1093 | 1093 | |
1094 | 1094 | // Various checks about the user - if they fail, we exit. |
1095 | 1095 | if ($this->user_id() == "" || $this->password == "") { |
1096 | - $PAGE->error_message ("We don't have the user_id or password to make the cookie.", true); |
|
1096 | + $PAGE->error_message("We don't have the user_id or password to make the cookie.", true); |
|
1097 | 1097 | |
1098 | 1098 | return; |
1099 | 1099 | } elseif ($this->deleted) { |
1100 | - $PAGE->error_message ("This user has been deleted.", true); |
|
1100 | + $PAGE->error_message("This user has been deleted.", true); |
|
1101 | 1101 | |
1102 | 1102 | return; |
1103 | 1103 | } elseif (!$this->confirmed) { |
1104 | - $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); |
|
1104 | + $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); |
|
1105 | 1105 | |
1106 | 1106 | return; |
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | // Reminder: $this->password is actually a hashed version of the plaintext pw. |
1110 | - $cookie = $this->user_id() . "." . md5 ($this->password()); |
|
1110 | + $cookie = $this->user_id() . "." . md5($this->password()); |
|
1111 | 1111 | |
1112 | 1112 | $this->_login($returl, $expire, $cookie); |
1113 | 1113 | } |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | $cookie_expires = 0; |
1124 | 1124 | if ($expire == 'never') { |
1125 | 1125 | twfy_debug("THEUSER", "cookie never expires"); |
1126 | - $cookie_expires = time()+86400*365*20; |
|
1126 | + $cookie_expires = time() + 86400 * 365 * 20; |
|
1127 | 1127 | } elseif (is_int($expire) && $expire > time()) { |
1128 | 1128 | twfy_debug("THEUSER", "cookie expires at " . $expire); |
1129 | 1129 | $cookie_expires = $expire; |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
1164 | - public function confirm_email($token, $redirect=true) { |
|
1164 | + public function confirm_email($token, $redirect = true) { |
|
1165 | 1165 | $arg = ''; |
1166 | 1166 | if (strstr($token, '::')) $arg = '::'; |
1167 | 1167 | if (strstr($token, '-')) $arg = '-'; |
@@ -1174,24 +1174,24 @@ discard block |
||
1174 | 1174 | FROM tokens |
1175 | 1175 | WHERE token = :token |
1176 | 1176 | AND type = 'E' |
1177 | - ", array (':token' => $registrationtoken)); |
|
1177 | + ", array(':token' => $registrationtoken)); |
|
1178 | 1178 | |
1179 | 1179 | if ($q->rows() == 1) { |
1180 | 1180 | $expires = $q->field(0, 'expires'); |
1181 | 1181 | $expire_time = strtotime($expires); |
1182 | - if ( $expire_time < time() ) { |
|
1182 | + if ($expire_time < time()) { |
|
1183 | 1183 | global $PAGE; |
1184 | 1184 | if ($PAGE && $redirect) { |
1185 | - $PAGE->error_message ("Sorry, that token seems to have expired"); |
|
1185 | + $PAGE->error_message("Sorry, that token seems to have expired"); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | return false; |
1189 | 1189 | } |
1190 | 1190 | |
1191 | - list( $user_id, $email ) = explode('::', $q->field(0, 'data')); |
|
1191 | + list($user_id, $email) = explode('::', $q->field(0, 'data')); |
|
1192 | 1192 | |
1193 | 1193 | // if we are logged in as someone else don't change the email |
1194 | - if ( $this->user_id() != 0 && $this->user_id() != $user_id ) { |
|
1194 | + if ($this->user_id() != 0 && $this->user_id() != $user_id) { |
|
1195 | 1195 | return false; |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | |
1334 | 1334 | twfy_debug("THEUSER", "User with ID found to confirm: " . $this->user_id()); |
1335 | 1335 | // We'll need these to be set before logging the user in. |
1336 | - $this->email = $q->field(0, 'email'); |
|
1336 | + $this->email = $q->field(0, 'email'); |
|
1337 | 1337 | |
1338 | 1338 | // Set that they're confirmed in the DB. |
1339 | 1339 | $r = $this->db->query("UPDATE users |
@@ -1380,14 +1380,14 @@ discard block |
||
1380 | 1380 | |
1381 | 1381 | $this->postcode = $pc; |
1382 | 1382 | if (!headers_sent()) // if in debug mode |
1383 | - setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN); |
|
1383 | + setcookie(POSTCODE_COOKIE, $pc, time() + 7 * 86400, "/", COOKIEDOMAIN); |
|
1384 | 1384 | |
1385 | 1385 | twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain"); |
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | public function unset_postcode_cookie() { |
1389 | 1389 | if (!headers_sent()) // if in debug mode |
1390 | - setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
|
1390 | + setcookie(POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
|
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | // mostly here for updating from facebook where we do not need |
@@ -1400,8 +1400,8 @@ discard block |
||
1400 | 1400 | |
1401 | 1401 | // this is checked elsewhere but just in case we check here and |
1402 | 1402 | // bail out to be on the safe side |
1403 | - if ( isset($details['email'] ) ) { |
|
1404 | - if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) { |
|
1403 | + if (isset($details['email'])) { |
|
1404 | + if ($details['email'] != $this->email() && $this->email_exists($details['email'])) { |
|
1405 | 1405 | return false; |
1406 | 1406 | } |
1407 | 1407 | } |
@@ -1449,8 +1449,8 @@ discard block |
||
1449 | 1449 | // this is checked elsewhere but just in case we check here and |
1450 | 1450 | // bail out to be on the safe side |
1451 | 1451 | $email = ''; |
1452 | - if ( isset($details['email'] ) ) { |
|
1453 | - if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) { |
|
1452 | + if (isset($details['email'])) { |
|
1453 | + if ($details['email'] != $this->email() && $this->email_exists($details['email'])) { |
|
1454 | 1454 | return false; |
1455 | 1455 | } |
1456 | 1456 | $email = $details['email']; |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | if ($email && $email != $this->email) { |
1480 | - $token = substr( password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16 ); |
|
1480 | + $token = substr(password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16); |
|
1481 | 1481 | $data = $this->user_id() . '::' . $email; |
1482 | 1482 | $r = $this->db->query("INSERT INTO tokens |
1483 | 1483 | ( expires, token, type, data ) |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | )); |
1495 | 1495 | |
1496 | 1496 | // send confirmation email here |
1497 | - if ( $r->success() ) { |
|
1497 | + if ($r->success()) { |
|
1498 | 1498 | $newdetails['email'] = $email; |
1499 | 1499 | $newdetails['token'] = $token; |
1500 | 1500 | if ($confirm_email) { |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | if (get_http_var("submitted") == "true") { |
20 | 20 | // Form has been submitted, so check input. |
21 | 21 | |
22 | - $email = get_http_var("email"); |
|
22 | + $email = get_http_var("email"); |
|
23 | 23 | $password = get_http_var("password"); |
24 | 24 | $remember = get_http_var("remember"); |
25 | 25 | |
26 | 26 | // The user may have tried to do something that requires being logged in. |
27 | 27 | // In which case we should arrive here with that page's URL in 'ret'. |
28 | 28 | // We can then send the user there after log in. |
29 | - $returnurl = get_http_var("ret"); |
|
29 | + $returnurl = get_http_var("ret"); |
|
30 | 30 | |
31 | 31 | $errors = array(); |
32 | 32 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | if ($remember == "true") { |
54 | 54 | $expire = "never"; |
55 | 55 | } else { |
56 | - $expire ="session"; |
|
56 | + $expire = "session"; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // $returnurl is the url of where we'll send the user after login. |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | -function display_page( $errors=array() ) { |
|
99 | +function display_page($errors = array()) { |
|
100 | 100 | global $PAGE, $this_page, $THEUSER; |
101 | 101 | |
102 | 102 | $PAGE->page_start(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <?php |
128 | 128 | |
129 | 129 | $PAGE->stripe_end(array( |
130 | - array ( |
|
130 | + array( |
|
131 | 131 | 'type' => 'include', |
132 | 132 | 'content' => 'userlogin' |
133 | 133 | ) |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | public function tearDown() |
27 | 27 | { |
28 | - $this->db = NULL; |
|
28 | + $this->db = null; |
|
29 | 29 | |
30 | 30 | parent::tearDown(); |
31 | 31 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * Test that the Royal edge-case house is correctly defined. |
11 | 11 | */ |
12 | - public function testRoyalHouseDefined() |
|
12 | + public function testRoyalHouseDefined() |
|
13 | 13 | { |
14 | 14 | $this->assertEquals(0, HOUSE_TYPE_ROYAL); |
15 | 15 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Test that the House of Commons is correctly defined. |
19 | 19 | */ |
20 | - public function testCommonsHouseDefined() |
|
20 | + public function testCommonsHouseDefined() |
|
21 | 21 | { |
22 | 22 | $this->assertEquals(1, HOUSE_TYPE_COMMONS); |
23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | /** |
26 | 26 | * Test that the House of Lords is correctly defined. |
27 | 27 | */ |
28 | - public function testLordsHouseDefined() |
|
28 | + public function testLordsHouseDefined() |
|
29 | 29 | { |
30 | 30 | $this->assertEquals(2, HOUSE_TYPE_LORDS); |
31 | 31 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Test that the Northern Ireland Assembly is correctly defined. |
35 | 35 | */ |
36 | - public function testNIHouseDefined() |
|
36 | + public function testNIHouseDefined() |
|
37 | 37 | { |
38 | 38 | $this->assertEquals(3, HOUSE_TYPE_NI); |
39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Test that the Scottish Parliament is correctly defined. |
43 | 43 | */ |
44 | - public function testScotlandHouseDefined() |
|
44 | + public function testScotlandHouseDefined() |
|
45 | 45 | { |
46 | 46 | $this->assertEquals(4, HOUSE_TYPE_SCOTLAND); |
47 | 47 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Test that the Assembly for Wales is correctly defined. |
51 | 51 | */ |
52 | - public function testWalesHouseDefined() |
|
52 | + public function testWalesHouseDefined() |
|
53 | 53 | { |
54 | 54 | $this->assertEquals(5, HOUSE_TYPE_WALES); |
55 | 55 | } |
@@ -114,7 +114,10 @@ discard block |
||
114 | 114 | // 'foot' - For the bottom stripe on hansard debates/wrans listings. |
115 | 115 | // $id is the value of an id for this div (if blank, not used). |
116 | 116 | ?> |
117 | - <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') echo ' ' . $extra_class; ?>"<?php |
|
117 | + <div class="stripe-<?php echo $type; ?><?php if ($extra_class != '') { |
|
118 | + echo ' ' . $extra_class; |
|
119 | +} |
|
120 | +?>"<?php |
|
118 | 121 | if ($id != '') { |
119 | 122 | print ' id="' . $id . '"'; |
120 | 123 | } |
@@ -479,7 +482,9 @@ discard block |
||
479 | 482 | |
480 | 483 | global $DATA, $this_page; |
481 | 484 | |
482 | - if ($this->page_started()) return; |
|
485 | + if ($this->page_started()) { |
|
486 | + return; |
|
487 | + } |
|
483 | 488 | // The page's HTML hasn't been started yet, so we'd better do it. |
484 | 489 | |
485 | 490 | // Set the page title (in the <title></title>). |
@@ -629,7 +634,9 @@ discard block |
||
629 | 634 | $URL->insert(array('adv' => 1)); |
630 | 635 | echo ' <a href="' . $URL->generate() . '">More options</a>'; |
631 | 636 | echo '<br>'; |
632 | - if ($wtt) print '<input type="hidden" name="wtt" value="1">'; |
|
637 | + if ($wtt) { |
|
638 | + print '<input type="hidden" name="wtt" value="1">'; |
|
639 | + } |
|
633 | 640 | } else { ?> |
634 | 641 | <form action="http://www.writetothem.com/lords" method="get"> |
635 | 642 | <input type="hidden" name="pid" value="<?=_htmlentities(get_http_var('pid')) ?>"> |
@@ -743,8 +750,7 @@ discard block |
||
743 | 750 | // The return url for after the user has logged in. |
744 | 751 | if (get_http_var("ret") != "") { |
745 | 752 | $returl = get_http_var("ret"); |
746 | - } |
|
747 | - else { |
|
753 | + } else { |
|
748 | 754 | $returl = $glossary_returl; |
749 | 755 | } |
750 | 756 | ?> |
@@ -808,15 +814,13 @@ discard block |
||
808 | 814 | else { |
809 | 815 | $letters[] = "<li class=\"on\">" . $letter . "</li>"; |
810 | 816 | } |
811 | - } |
|
812 | - elseif (!empty($GLOSSARY->alphabet[$letter])) { |
|
817 | + } elseif (!empty($GLOSSARY->alphabet[$letter])) { |
|
813 | 818 | $URL = new \MySociety\TheyWorkForYou\Url('glossary'); |
814 | 819 | $URL->insert(array('az' => $letter)); |
815 | 820 | $letter_link = $URL->generate('url'); |
816 | 821 | |
817 | 822 | $letters[] = "<li><a href=\"" . $letter_link . "\">" . $letter . "</a></li>"; |
818 | - } |
|
819 | - else { |
|
823 | + } else { |
|
820 | 824 | $letters[] = '<li>' . $letter . '</li>'; |
821 | 825 | } |
822 | 826 | } |
@@ -856,8 +860,7 @@ discard block |
||
856 | 860 | $URL->insert(array("delete_confirm" => $term['glossary_id'])); |
857 | 861 | $delete_url = $URL->generate(); |
858 | 862 | $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>"; |
859 | - } |
|
860 | - else { |
|
863 | + } else { |
|
861 | 864 | $admin_links = ""; |
862 | 865 | } |
863 | 866 | |
@@ -867,8 +870,7 @@ discard block |
||
867 | 870 | $user_link = $URL->generate('url'); |
868 | 871 | |
869 | 872 | $user_details = "\t\t\t\t<p><small>contributed by user <a href=\"" . $user_link . "\">" . $term['firstname'] . " " . $term['lastname'] . "</a></small>" . $admin_links . "</p>\n"; |
870 | - } |
|
871 | - else { |
|
873 | + } else { |
|
872 | 874 | $user_details = ""; |
873 | 875 | } |
874 | 876 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public $within_stripe_sidebar = false; |
20 | 20 | |
21 | 21 | public function page_start() { |
22 | - if ( !$this->page_started() ) { |
|
22 | + if (!$this->page_started()) { |
|
23 | 23 | $this->checkForAdmin(); |
24 | 24 | $this->displayHeader(); |
25 | 25 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $data = $h->data; |
34 | 34 | $data = array_merge($u->data, $data); |
35 | - if ( isset($page_errors) ) { |
|
35 | + if (isset($page_errors)) { |
|
36 | 36 | $data['page_errors'] = $page_errors; |
37 | 37 | } |
38 | 38 | $data['banner_text'] = ''; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $THISPAGE = new \MySociety\TheyWorkForYou\Url($this_page); |
53 | 53 | |
54 | 54 | $LOGINURL = new \MySociety\TheyWorkForYou\Url('userlogin'); |
55 | - $LOGINURL->insert(array('ret' => $THISPAGE->generate('none') )); |
|
55 | + $LOGINURL->insert(array('ret' => $THISPAGE->generate('none'))); |
|
56 | 56 | |
57 | 57 | $text = "<a href=\"" . $LOGINURL->generate() . "\">You'd better sign in!</a>"; |
58 | 58 | } else { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public function page_end() { |
70 | - if ( !$this->page_started() ) { |
|
70 | + if (!$this->page_started()) { |
|
71 | 71 | $this->page_start(); |
72 | 72 | } |
73 | 73 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - public function stripe_start($type='side', $id='', $extra_class = '') { |
|
104 | + public function stripe_start($type = 'side', $id = '', $extra_class = '') { |
|
105 | 105 | // $type is one of: |
106 | 106 | // 'full' - a full width div |
107 | 107 | // 'side' - a white stripe with a coloured sidebar. |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - public function stripe_end ($contents = array(), $extra = '') { |
|
134 | + public function stripe_end($contents = array(), $extra = '') { |
|
135 | 135 | // $contents is an array containing 0 or more hashes. |
136 | 136 | // Each hash has two values, 'type' and 'content'. |
137 | 137 | // 'Type' could be one of these: |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | public function include_sidebar_template($sidebarname) { |
235 | 235 | global $this_page, $DATA; |
236 | 236 | |
237 | - $sidebarpath = INCLUDESPATH.'easyparliament/sidebars/'.$sidebarname.'.php'; |
|
237 | + $sidebarpath = INCLUDESPATH . 'easyparliament/sidebars/' . $sidebarname . '.php'; |
|
238 | 238 | |
239 | 239 | if (file_exists($sidebarpath)) { |
240 | 240 | include $sidebarpath; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | |
245 | - public function block_start($data=array()) { |
|
245 | + public function block_start($data = array()) { |
|
246 | 246 | // Starts a 'block' div, used mostly on the home page, |
247 | 247 | // on the MP page, and in the sidebars. |
248 | 248 | // $data is a hash like this: |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | if (is_string($message)) { |
390 | 390 | // Sometimes we're just sending a single line to this function |
391 | 391 | // rather like the bigger array... |
392 | - $message = array ( |
|
392 | + $message = array( |
|
393 | 393 | 'text' => $message |
394 | 394 | ); |
395 | 395 | } |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | // if the page has started then we're most likely in an old school page |
398 | 398 | // so we should just print out the error, otherwise stick it in the error |
399 | 399 | // global which will then be displayed by the header template |
400 | - if ( $this->page_started() ) { |
|
400 | + if ($this->page_started()) { |
|
401 | 401 | $this->message($message, 'error'); |
402 | 402 | } else { |
403 | - if ( !isset($page_errors) ) { |
|
403 | + if (!isset($page_errors)) { |
|
404 | 404 | $page_errors = array(); |
405 | 405 | } |
406 | - $page_errors[] = $message; |
|
406 | + $page_errors[] = $message; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if ($fatal) { |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | |
423 | - public function message($message, $class='') { |
|
423 | + public function message($message, $class = '') { |
|
424 | 424 | // Generates a very simple but common page content. |
425 | 425 | // Used for when a user logs out, or votes, or any simple thing |
426 | 426 | // where there's a little message and probably a link elsewhere. |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | if ($page_title != '') { |
499 | 499 | $page_title .= ': '; |
500 | 500 | } |
501 | - $page_title .= format_date ($info['date'], SHORTDATEFORMAT); |
|
501 | + $page_title .= format_date($info['date'], SHORTDATEFORMAT); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | if ($page_title != '') { |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | if (isset($nextprev['up'])) { |
555 | 555 | |
556 | - $uplink = '<span class="up"><a href="' . $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>'; |
|
556 | + $uplink = '<span class="up"><a href="' . $nextprev['up']['url'] . '" title="' . $nextprev['up']['title'] . '">' . $nextprev['up']['body'] . '</a>'; |
|
557 | 557 | if (get_http_var('s')) { |
558 | 558 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
559 | 559 | $uplink .= '<br><a href="' . $URL->generate() . '">Remove highlighting</a>'; |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | $next = $nextprev['next']; |
569 | 569 | |
570 | 570 | if (isset($next['url'])) { |
571 | - $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' »</a>'; |
|
571 | + $nextlink = '<a href="' . $next['url'] . '" title="' . $next['title'] . '" class="linkbutton">' . $next['body'] . ' »</a>'; |
|
572 | 572 | } else { |
573 | 573 | $nextlink = $next['body'] . ' »'; |
574 | 574 | } |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | } |
586 | 586 | |
587 | 587 | |
588 | - public function search_form($value='') { |
|
588 | + public function search_form($value = '') { |
|
589 | 589 | global $SEARCHENGINE; |
590 | 590 | // Search box on the search page. |
591 | 591 | // If $value is set then it will be displayed in the form. |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | |
617 | 617 | echo '<div class="mainsearchbox">'; |
618 | - if ($wtt<2) { |
|
618 | + if ($wtt < 2) { |
|
619 | 619 | echo '<form action="', $URL->generate(), '" method="get">'; |
620 | 620 | if (get_http_var('o')) { |
621 | 621 | echo '<input type="hidden" name="o" value="', _htmlentities(get_http_var('o')), '">'; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | echo '<input type="hidden" name="house" value="', _htmlentities(get_http_var('house')), '">'; |
625 | 625 | } |
626 | 626 | echo '<input type="text" name="q" value="', _htmlentities($value), '" size="50"> '; |
627 | - echo '<input type="submit" value=" ', ($wtt?'Modify search':'Search'), ' ">'; |
|
627 | + echo '<input type="submit" value=" ', ($wtt ? 'Modify search' : 'Search'), ' ">'; |
|
628 | 628 | $URL = new \MySociety\TheyWorkForYou\Url('search'); |
629 | 629 | $URL->insert(array('adv' => 1)); |
630 | 630 | echo ' <a href="' . $URL->generate() . '">More options</a>'; |
@@ -646,16 +646,16 @@ discard block |
||
646 | 646 | $ordering = 'd'; |
647 | 647 | } |
648 | 648 | |
649 | - if ($ordering=='r') { |
|
649 | + if ($ordering == 'r') { |
|
650 | 650 | print '<strong>Sorted by relevance</strong>'; |
651 | 651 | } else { |
652 | 652 | printf("<a href='%s'>Sort by relevance</a>", $orderUrl->generate('html', array('o'=>'r'))); |
653 | 653 | } |
654 | 654 | |
655 | 655 | print " | "; |
656 | - if ($ordering=='d') { |
|
656 | + if ($ordering == 'd') { |
|
657 | 657 | print '<strong>Sorted by date: newest</strong> / <a href="' . $orderUrl->generate('html', array('o'=>'o')) . '">oldest</a>'; |
658 | - } elseif ($ordering=='o') { |
|
658 | + } elseif ($ordering == 'o') { |
|
659 | 659 | print '<strong>Sorted by date:</strong> <a href="' . $orderUrl->generate('html', array('o'=>'d')) . '">newest</a> / <strong>oldest</strong>'; |
660 | 660 | } else { |
661 | 661 | printf("Sort by date: <a href='%s'>newest</a> / <a href='%s'>oldest</a>", |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | } |
664 | 664 | |
665 | 665 | print " | "; |
666 | - if ($ordering=='p') { |
|
666 | + if ($ordering == 'p') { |
|
667 | 667 | print '<strong>Use by person</strong>'; |
668 | 668 | } else { |
669 | 669 | printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o'=>'p'))); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | include_once INCLUDESPATH . 'easyparliament/templates/html/search_advanced.php'; |
688 | 688 | } |
689 | 689 | |
690 | - public function login_form ($errors = array()) { |
|
690 | + public function login_form($errors = array()) { |
|
691 | 691 | // Used for /user/login/ and /user/prompt/ |
692 | 692 | // $errors is a hash of potential errors from a previous log in attempt. |
693 | 693 | ?> |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | public function glossary_atoz(&$GLOSSARY) { |
792 | 792 | // Print out a nice list of lettered links to glossary pages |
793 | 793 | |
794 | - $letters = array (); |
|
794 | + $letters = array(); |
|
795 | 795 | |
796 | 796 | foreach ($GLOSSARY->alphabet as $letter => $eps) { |
797 | 797 | // if we're writing out the current letter (list or item) |
@@ -824,14 +824,14 @@ discard block |
||
824 | 824 | <div class="letters"> |
825 | 825 | <ul> |
826 | 826 | <?php |
827 | - for ($n=0; $n<13; $n++) { |
|
827 | + for ($n = 0; $n < 13; $n++) { |
|
828 | 828 | print $letters[$n]; |
829 | 829 | } |
830 | 830 | ?> |
831 | 831 | </ul> |
832 | 832 | <ul> |
833 | 833 | <?php |
834 | - for ($n=13; $n<26; $n++) { |
|
834 | + for ($n = 13; $n < 26; $n++) { |
|
835 | 835 | print $letters[$n]; |
836 | 836 | } |
837 | 837 | ?> |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | |
851 | 851 | // add some extra controls for the administrators |
852 | 852 | if ($this_page == "admin_glossary") { |
853 | - print "<a id=\"gl".$term['glossary_id']."\"></a>"; |
|
853 | + print "<a id=\"gl" . $term['glossary_id'] . "\"></a>"; |
|
854 | 854 | print "<h3>" . $term['title'] . "</h3>"; |
855 | 855 | $URL = new \MySociety\TheyWorkForYou\Url('admin_glossary'); |
856 | 856 | $URL->insert(array("delete_confirm" => $term['glossary_id'])); |
857 | 857 | $delete_url = $URL->generate(); |
858 | - $admin_links = "<br><small><a href=\"".$delete_url."\">delete</a></small>"; |
|
858 | + $admin_links = "<br><small><a href=\"" . $delete_url . "\">delete</a></small>"; |
|
859 | 859 | } |
860 | 860 | else { |
861 | 861 | $admin_links = ""; |
@@ -878,9 +878,9 @@ discard block |
||
878 | 878 | // Add a direct search link for current glossary item |
879 | 879 | $URL = new \MySociety\TheyWorkForYou\Url('search'); |
880 | 880 | // remember to quote the term for phrase matching in search |
881 | - $URL->insert(array('s' => '"'.$term['title'].'"')); |
|
881 | + $URL->insert(array('s' => '"' . $term['title'] . '"')); |
|
882 | 882 | $search_url = $URL->generate(); |
883 | - printf ("\t\t\t\t<p>Search hansard for \"<a href=\"%s\" title=\"View search results for this glossary item\">%s</a>\"</p>", $search_url, $term['title']); |
|
883 | + printf("\t\t\t\t<p>Search hansard for \"<a href=\"%s\" title=\"View search results for this glossary item\">%s</a>\"</p>", $search_url, $term['title']); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | |
956 | 956 | // Generate all the page links. |
957 | 957 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
958 | - $URL->insert( array('wtt' => get_http_var('wtt')) ); |
|
958 | + $URL->insert(array('wtt' => get_http_var('wtt'))); |
|
959 | 959 | if (isset($pagedata['s'])) { |
960 | 960 | # XXX: Should be taken out in *one* place, not here + search_form etc. |
961 | 961 | $value = $pagedata['s']; |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | |
1094 | 1094 | $body = trim_characters($report['body'], 0, 40); |
1095 | 1095 | |
1096 | - $tabledata['rows'][] = array ( |
|
1096 | + $tabledata['rows'][] = array( |
|
1097 | 1097 | _htmlentities($report['firstname'] . ' ' . $report['lastname']), |
1098 | 1098 | _htmlentities($body), |
1099 | 1099 | $report['reported'], |
@@ -1124,13 +1124,13 @@ discard block |
||
1124 | 1124 | // $page is the name of the page the dates should link to. |
1125 | 1125 | |
1126 | 1126 | // Create array containing abbreviations of days of week. |
1127 | - $daysOfWeek = array('Mon','Tue','Wed','Thu','Fri','Sat','Sun'); |
|
1127 | + $daysOfWeek = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); |
|
1128 | 1128 | |
1129 | 1129 | // What is the first day of the month in question? |
1130 | - $firstDayOfMonth = mktime(0,0,0,$month,1,$year); |
|
1130 | + $firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year); |
|
1131 | 1131 | |
1132 | 1132 | // How many days does this month contain? |
1133 | - $numberDays = date('t',$firstDayOfMonth); |
|
1133 | + $numberDays = date('t', $firstDayOfMonth); |
|
1134 | 1134 | |
1135 | 1135 | // Retrieve some information about the first day of the |
1136 | 1136 | // month in question. |
@@ -1211,7 +1211,7 @@ discard block |
||
1211 | 1211 | |
1212 | 1212 | // Is the $currentDay a member of $dateArray? If so, |
1213 | 1213 | // the day should be linked. |
1214 | - if (in_array($currentDay,$dateArray)) { |
|
1214 | + if (in_array($currentDay, $dateArray)) { |
|
1215 | 1215 | |
1216 | 1216 | $date = sprintf("%04d-%02d-%02d", $year, $month, $currentDay); |
1217 | 1217 | |
@@ -1312,7 +1312,7 @@ discard block |
||
1312 | 1312 | // Returns HTML suitable for putting in the sidebar on Admin pages. |
1313 | 1313 | global $this_page, $DATA; |
1314 | 1314 | |
1315 | - $pages = array ('admin_home', |
|
1315 | + $pages = array('admin_home', |
|
1316 | 1316 | 'admin_comments', 'admin_searchlogs', 'admin_popularsearches', 'admin_failedsearches', |
1317 | 1317 | 'alert_stats', 'admin_statistics', 'admin_reportstats', |
1318 | 1318 | 'admin_commentreports', 'admin_glossary', 'admin_glossary_pending', 'admin_badusers', |
@@ -18,10 +18,13 @@ |
||
18 | 18 | # Content goes here |
19 | 19 | foreach ($data['dates'] as $date => $day_events) { |
20 | 20 | foreach ($order as $i => $chamber) { |
21 | - if (!array_key_exists($chamber, $day_events)) |
|
22 | - continue; |
|
21 | + if (!array_key_exists($chamber, $day_events)) { |
|
22 | + continue; |
|
23 | + } |
|
23 | 24 | $events = $day_events[$chamber]; |
24 | - if ($plural[$i]) $chamber .= 's'; |
|
25 | + if ($plural[$i]) { |
|
26 | + $chamber .= 's'; |
|
27 | + } |
|
25 | 28 | print "<h2 class='calendar'>$chamber"; |
26 | 29 | if (in_array($major[$i], $data['majors'])) { |
27 | 30 | $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']); |
@@ -25,7 +25,7 @@ |
||
25 | 25 | print "<h2 class='calendar'>$chamber"; |
26 | 26 | if (in_array($major[$i], $data['majors'])) { |
27 | 27 | $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$major[$i]]['page_all']); |
28 | - $URL->insert( array( 'd' => $date ) ); |
|
28 | + $URL->insert(array('d' => $date)); |
|
29 | 29 | print ' <a href="' . $URL->generate() . '">See this day →</a>'; |
30 | 30 | } |
31 | 31 | print "</h2>\n"; |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | } |
19 | 19 | $PAGE->block_start(array('id'=>'recentcomments', 'title'=>$title)); |
20 | 20 | |
21 | - if ($this_page != 'home') $PAGE->page_links($data); |
|
21 | + if ($this_page != 'home') { |
|
22 | + $PAGE->page_links($data); |
|
23 | + } |
|
22 | 24 | $USERURL = new \MySociety\TheyWorkForYou\Url('userview'); |
23 | 25 | ?> |
24 | 26 | <ul> |
@@ -50,7 +52,9 @@ discard block |
||
50 | 52 | <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p> |
51 | 53 | <?php |
52 | 54 | } |
53 | - if ($this_page != 'home') $PAGE->page_links($data); |
|
55 | + if ($this_page != 'home') { |
|
56 | + $PAGE->page_links($data); |
|
57 | + } |
|
54 | 58 | $PAGE->block_end(); |
55 | 59 | } |
56 | 60 | ?> |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $date = format_date($date, SHORTDATEFORMAT); |
34 | 34 | $time = format_time($time, TIMEFORMAT); |
35 | 35 | |
36 | - $count = $n+1; |
|
36 | + $count = $n + 1; |
|
37 | 37 | |
38 | 38 | $USERURL->insert(array('u'=>$comment['user_id'])); |
39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if ($this_page == 'home') { |
48 | 48 | $MOREURL = new \MySociety\TheyWorkForYou\Url('comments_recent'); |
49 | 49 | ?> |
50 | - <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments'])+1; ?>">See more annotations posted recently</a></p> |
|
50 | + <p><a href="<?php echo $MOREURL->generate(); ?>#c<?php echo count($data['comments']) + 1; ?>">See more annotations posted recently</a></p> |
|
51 | 51 | <?php |
52 | 52 | } |
53 | 53 | if ($this_page != 'home') $PAGE->page_links($data); |
@@ -156,8 +156,9 @@ |
||
156 | 156 | foreach ($var as $v) { |
157 | 157 | $url_args[] = "$key=" . urlencode(stripslashes($v)); |
158 | 158 | } |
159 | - } elseif ($var != null) |
|
160 | - $url_args[] = "$key=" . urlencode(stripslashes($var)); |
|
159 | + } elseif ($var != null) { |
|
160 | + $url_args[] = "$key=" . urlencode(stripslashes($var)); |
|
161 | + } |
|
161 | 162 | } |
162 | 163 | |
163 | 164 | $page_url = WEBPATH . $DATA->page_metadata($this->destinationpage, "url"); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | // These stores an associative array of key/value pairs that |
44 | 44 | // we'll want passed on to other pages. |
45 | - $this->session_vars = array (); |
|
45 | + $this->session_vars = array(); |
|
46 | 46 | |
47 | 47 | // Prevent things using $DATA running if it hasn't been set, ie in testing |
48 | 48 | if (isset($DATA)) { |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | public function reset() { |
95 | 95 | // Call this to remove all the session_vars. |
96 | - $this->session_vars = array (); |
|
96 | + $this->session_vars = array(); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * override just one or two of them. |
163 | 163 | */ |
164 | 164 | |
165 | - public function generate($encode = "html", $overrideVars=array()) { |
|
165 | + public function generate($encode = "html", $overrideVars = array()) { |
|
166 | 166 | |
167 | 167 | global $DATA; |
168 | 168 | |
169 | - $url_args = array (); |
|
169 | + $url_args = array(); |
|
170 | 170 | |
171 | 171 | foreach (array_merge($this->session_vars, $overrideVars) as $key => $var) { |
172 | 172 | if (is_array($var)) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | protected function getSearchSections() { |
34 | 34 | return array( |
35 | - array( 'section' => 'ni' ) |
|
35 | + array('section' => 'ni') |
|
36 | 36 | ); |
37 | 37 | } |
38 | 38 | |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none'); |
54 | 54 | $MOREURL = new \MySociety\TheyWorkForYou\Url('nidebatesfront'); |
55 | - $MOREURL->insert( array( 'more' => 1 ) ); |
|
55 | + $MOREURL->insert(array('more' => 1)); |
|
56 | 56 | |
57 | 57 | // this makes sure that we don't repeat this debate in the list below |
58 | 58 | $random_debate = NULL; |
59 | - if ( isset($debates['data']) && count($debates['data']) ) { |
|
59 | + if (isset($debates['data']) && count($debates['data'])) { |
|
60 | 60 | $random_debate = $debates['data'][0]; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $recent = array(); |
64 | - if ( isset($debates['data']) && count($debates['data']) ) { |
|
64 | + if (isset($debates['data']) && count($debates['data'])) { |
|
65 | 65 | // at the start of a session there may be less than 6 |
66 | 66 | // debates |
67 | 67 | $max = 6; |
68 | - if ( count($debates['data']) < 6 ) { |
|
68 | + if (count($debates['data']) < 6) { |
|
69 | 69 | $max = count($debates['data']); |
70 | 70 | } |
71 | - for ( $i = 1; $i < $max; $i++ ) { |
|
71 | + for ($i = 1; $i < $max; $i++) { |
|
72 | 72 | $debate = $debates['data'][$i]; |
73 | 73 | $debate['desc'] = "Northern Ireland Assembly debates"; |
74 | 74 | $debate['more_url'] = $MOREURL->generate(); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | $featured = array(); |
80 | - if ( $random_debate ) { |
|
80 | + if ($random_debate) { |
|
81 | 81 | $featured = $random_debate; |
82 | 82 | $featured['more_url'] = $MOREURL->generate(); |
83 | 83 | $featured['desc'] = 'Northern Ireland Assembly debate'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | $data['featured'] = $featured; |
89 | - $data['debates'] = array( 'recent' => $recent); |
|
89 | + $data['debates'] = array('recent' => $recent); |
|
90 | 90 | |
91 | 91 | $data['regional'] = $this->getMLAList(); |
92 | 92 | $data['template'] = 'ni/index'; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $data = array(); |
44 | 44 | |
45 | - $data['popular_searches'] = NULL; |
|
45 | + $data['popular_searches'] = null; |
|
46 | 46 | |
47 | 47 | |
48 | 48 | $data['urls'] = $this->getURLs($data); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $MOREURL->insert( array( 'more' => 1 ) ); |
55 | 55 | |
56 | 56 | // this makes sure that we don't repeat this debate in the list below |
57 | - $random_debate = NULL; |
|
57 | + $random_debate = null; |
|
58 | 58 | if ( isset($debates['data']) && count($debates['data']) ) { |
59 | 59 | $random_debate = $debates['data'][0]; |
60 | 60 | } |