@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | public $body = ''; |
32 | 32 | public $posted = ''; |
33 | 33 | public $visible = false; |
34 | - public $modflagged = NULL; // Is a datetime when set. |
|
35 | - public $firstname = ''; // Of the person who posted it. |
|
34 | + public $modflagged = NULL; // Is a datetime when set. |
|
35 | + public $firstname = ''; // Of the person who posted it. |
|
36 | 36 | public $lastname = ''; |
37 | 37 | public $url = ''; |
38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public $exists = false; |
42 | 42 | |
43 | 43 | |
44 | - public function __construct($comment_id='') { |
|
44 | + public function __construct($comment_id = '') { |
|
45 | 45 | |
46 | 46 | $this->db = new ParlDB; |
47 | 47 | |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | if ($q->rows() > 0) { |
70 | 70 | |
71 | 71 | $this->comment_id = $comment_id; |
72 | - $this->user_id = $q->field(0, 'user_id'); |
|
72 | + $this->user_id = $q->field(0, 'user_id'); |
|
73 | 73 | $this->epobject_id = $q->field(0, 'epobject_id'); |
74 | - $this->body = $q->field(0, 'body'); |
|
75 | - $this->posted = $q->field(0, 'posted'); |
|
76 | - $this->visible = $q->field(0, 'visible'); |
|
77 | - $this->modflagged = $q->field(0, 'modflagged'); |
|
74 | + $this->body = $q->field(0, 'body'); |
|
75 | + $this->posted = $q->field(0, 'posted'); |
|
76 | + $this->visible = $q->field(0, 'visible'); |
|
77 | + $this->modflagged = $q->field(0, 'modflagged'); |
|
78 | 78 | |
79 | 79 | // Sets the URL and username for this comment. Duh. |
80 | 80 | $this->_set_url(); |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | public function comments_enabled() { return $this->comments_enabled; } |
105 | 105 | |
106 | 106 | |
107 | - public function display($format='html', $template='comments') { |
|
107 | + public function display($format = 'html', $template = 'comments') { |
|
108 | 108 | |
109 | - $data['comments'][0] = array ( |
|
109 | + $data['comments'][0] = array( |
|
110 | 110 | 'comment_id' => $this->comment_id, |
111 | 111 | 'user_id' => $this->user_id, |
112 | 112 | 'epobject_id' => $this->epobject_id, |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | $flag = 'NULL'; |
143 | 143 | |
144 | 144 | } else { |
145 | - $PAGE->error_message ("Why are you trying to switch this comment's modflag to '" . _htmlentities($switch) . "'!"); |
|
145 | + $PAGE->error_message("Why are you trying to switch this comment's modflag to '"._htmlentities($switch)."'!"); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $q = $this->db->query("UPDATE comments |
149 | 149 | SET modflagged = $flag |
150 | - WHERE comment_id = '" . $this->comment_id . "' |
|
150 | + WHERE comment_id = '".$this->comment_id."' |
|
151 | 151 | "); |
152 | 152 | |
153 | 153 | if ($q->success()) { |
154 | 154 | $this->modflagged = $date; |
155 | 155 | return true; |
156 | 156 | } else { |
157 | - $message = array ( |
|
157 | + $message = array( |
|
158 | 158 | 'title' => 'Sorry', |
159 | 159 | 'text' => "We couldn't update the annotation's modflag." |
160 | 160 | ); |
@@ -171,12 +171,12 @@ discard block |
||
171 | 171 | global $THEUSER, $PAGE; |
172 | 172 | |
173 | 173 | if ($THEUSER->is_able_to('deletecomment')) { |
174 | - $q = $this->db->query("UPDATE comments SET visible = '0' WHERE comment_id = '" . $this->comment_id . "'"); |
|
174 | + $q = $this->db->query("UPDATE comments SET visible = '0' WHERE comment_id = '".$this->comment_id."'"); |
|
175 | 175 | |
176 | 176 | if ($q->success()) { |
177 | 177 | return true; |
178 | 178 | } else { |
179 | - $message = array ( |
|
179 | + $message = array( |
|
180 | 180 | 'title' => 'Sorry', |
181 | 181 | 'text' => "We were unable to delete the annotation." |
182 | 182 | ); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | } else { |
188 | - $message = array ( |
|
188 | + $message = array( |
|
189 | 189 | 'title' => 'Sorry', |
190 | 190 | 'text' => "You are not authorised to delete annotations." |
191 | 191 | ); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | $URL = new \MySociety\TheyWorkForYou\Url($page); |
222 | 222 | $URL->insert(array('id'=>$gid)); |
223 | - $this->url = $URL->generate() . '#c' . $this->comment_id; |
|
223 | + $this->url = $URL->generate().'#c'.$this->comment_id; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
@@ -56,22 +56,22 @@ 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 | - public $emailpublic = ""; // boolean - can other users see this user's email? |
|
64 | + public $emailpublic = ""; // boolean - can other users see this user's email? |
|
65 | 65 | public $postcode = ""; |
66 | 66 | public $url = ""; |
67 | - public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT). |
|
67 | + public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT). |
|
68 | 68 | public $registrationtime = ""; // When they registered (GMT). |
69 | - public $registrationip = ""; // Where they registered from. |
|
70 | - public $optin = ""; // boolean - Do they want emails from us? |
|
71 | - public $deleted = ""; // User can't log in or have their info displayed. |
|
72 | - public $confirmed = ''; // boolean - Has the user confirmed via email? |
|
73 | - public $facebook_id = ''; // Facebook ID for users who login with FB |
|
74 | - public $facebook_token = ''; // Facebook token for users who login with FB |
|
69 | + public $registrationip = ""; // Where they registered from. |
|
70 | + public $optin = ""; // boolean - Do they want emails from us? |
|
71 | + public $deleted = ""; // User can't log in or have their info displayed. |
|
72 | + public $confirmed = ''; // boolean - Has the user confirmed via email? |
|
73 | + public $facebook_id = ''; // Facebook ID for users who login with FB |
|
74 | + public $facebook_token = ''; // Facebook token for users who login with FB |
|
75 | 75 | // Don't use the status to check access privileges - use the is_able_to() function. |
76 | 76 | public $status = "Viewer"; |
77 | 77 | |
@@ -118,23 +118,23 @@ discard block |
||
118 | 118 | // We've got a user, so set them up. |
119 | 119 | |
120 | 120 | $this->user_id = $user_id; |
121 | - $this->firstname = $q->field(0,"firstname"); |
|
122 | - $this->lastname = $q->field(0,"lastname"); |
|
123 | - $this->password = $q->field(0,"password"); |
|
124 | - $this->email = $q->field(0,"email"); |
|
125 | - $this->emailpublic = $q->field(0,"emailpublic") == 1 ? true : false; |
|
126 | - $this->postcode = $q->field(0,"postcode"); |
|
127 | - $this->facebook_id = $q->field(0,"facebook_id"); |
|
128 | - $this->facebook_token = $q->field(0,"facebook_token"); |
|
129 | - $this->url = $q->field(0,"url"); |
|
130 | - $this->lastvisit = $q->field(0,"lastvisit"); |
|
121 | + $this->firstname = $q->field(0, "firstname"); |
|
122 | + $this->lastname = $q->field(0, "lastname"); |
|
123 | + $this->password = $q->field(0, "password"); |
|
124 | + $this->email = $q->field(0, "email"); |
|
125 | + $this->emailpublic = $q->field(0, "emailpublic") == 1 ? true : false; |
|
126 | + $this->postcode = $q->field(0, "postcode"); |
|
127 | + $this->facebook_id = $q->field(0, "facebook_id"); |
|
128 | + $this->facebook_token = $q->field(0, "facebook_token"); |
|
129 | + $this->url = $q->field(0, "url"); |
|
130 | + $this->lastvisit = $q->field(0, "lastvisit"); |
|
131 | 131 | $this->registrationtoken = $q->field(0, 'registrationtoken'); |
132 | - $this->registrationtime = $q->field(0,"registrationtime"); |
|
133 | - $this->registrationip = $q->field(0,"registrationip"); |
|
134 | - $this->optin = $q->field(0,"optin") == 1 ? true : false; |
|
135 | - $this->status = $q->field(0,"status"); |
|
136 | - $this->deleted = $q->field(0,"deleted") == 1 ? true : false; |
|
137 | - $this->confirmed = $q->field(0,"confirmed") == 1 ? true : false; |
|
132 | + $this->registrationtime = $q->field(0, "registrationtime"); |
|
133 | + $this->registrationip = $q->field(0, "registrationip"); |
|
134 | + $this->optin = $q->field(0, "optin") == 1 ? true : false; |
|
135 | + $this->status = $q->field(0, "status"); |
|
136 | + $this->deleted = $q->field(0, "deleted") == 1 ? true : false; |
|
137 | + $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false; |
|
138 | 138 | |
139 | 139 | return true; |
140 | 140 | |
@@ -143,16 +143,16 @@ discard block |
||
143 | 143 | // we're going to show an error too, just in case. |
144 | 144 | // *Should* never happen... |
145 | 145 | return false; |
146 | - twfy_debug("USER", "There is more than one user with an id of '" . _htmlentities($user_id) . "'"); |
|
146 | + twfy_debug("USER", "There is more than one user with an id of '"._htmlentities($user_id)."'"); |
|
147 | 147 | |
148 | 148 | } else { |
149 | 149 | return false; |
150 | - twfy_debug("USER", "There is no user with an id of '" . _htmlentities($user_id) . "'"); |
|
150 | + twfy_debug("USER", "There is no user with an id of '"._htmlentities($user_id)."'"); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | } |
154 | 154 | |
155 | - public function add($details, $confirmation_required=true) { |
|
155 | + public function add($details, $confirmation_required = true) { |
|
156 | 156 | // Adds a new user's info into the db. |
157 | 157 | // Then optionally (and usually) calls another function to |
158 | 158 | // send them a confirmation email. |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // This will be sent to them via email, so we can confirm they exist. |
240 | 240 | // The token will be the first 16 characters of a hash. |
241 | 241 | |
242 | - $token = substr( password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16 ); |
|
242 | + $token = substr(password_hash($details["email"].microtime(), PASSWORD_BCRYPT), 29, 16); |
|
243 | 243 | |
244 | 244 | // Full stops don't work well at the end of URLs in emails, |
245 | 245 | // so replace them. We won't be doing anything clever with the hash |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $r = $this->db->query("UPDATE users |
252 | 252 | SET registrationtoken = :registrationtoken |
253 | 253 | WHERE user_id = :user_id |
254 | - ", array ( |
|
254 | + ", array( |
|
255 | 255 | ':registrationtoken' => $this->registrationtoken, |
256 | 256 | ':user_id' => $this->user_id |
257 | 257 | )); |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | } |
299 | 299 | |
300 | 300 | public function add_facebook_id($facebook_id) { |
301 | - $q = $this->db->query ("UPDATE users SET facebook_id = :facebook_id WHERE email = :email", |
|
301 | + $q = $this->db->query("UPDATE users SET facebook_id = :facebook_id WHERE email = :email", |
|
302 | 302 | array( |
303 | 303 | ':facebook_id' => $facebook_id, |
304 | 304 | ':email' => $this->email |
@@ -319,24 +319,24 @@ discard block |
||
319 | 319 | !isset($details['email']) || |
320 | 320 | $details['email'] == '' || |
321 | 321 | !isset($details['token']) || |
322 | - $details['token'] == '' ) { |
|
322 | + $details['token'] == '') { |
|
323 | 323 | return false; |
324 | 324 | } |
325 | 325 | |
326 | 326 | // We prefix the registration token with the user's id and '-'. |
327 | 327 | // Not for any particularly good reason, but we do. |
328 | 328 | |
329 | - $urltoken = $this->user_id . '-' . $details['token']; |
|
329 | + $urltoken = $this->user_id.'-'.$details['token']; |
|
330 | 330 | |
331 | - $confirmurl = 'https://' . DOMAIN . '/E/' . $urltoken; |
|
331 | + $confirmurl = 'https://'.DOMAIN.'/E/'.$urltoken; |
|
332 | 332 | |
333 | 333 | // Arrays we need to send a templated email. |
334 | - $data = array ( |
|
334 | + $data = array( |
|
335 | 335 | 'to' => $details['email'], |
336 | 336 | 'template' => 'email_confirmation' |
337 | 337 | ); |
338 | 338 | |
339 | - $merge = array ( |
|
339 | + $merge = array( |
|
340 | 340 | 'FIRSTNAME' => $details['firstname'], |
341 | 341 | 'LASTNAME' => $details['lastname'], |
342 | 342 | 'CONFIRMURL' => $confirmurl |
@@ -368,17 +368,17 @@ discard block |
||
368 | 368 | // We prefix the registration token with the user's id and '-'. |
369 | 369 | // Not for any particularly good reason, but we do. |
370 | 370 | |
371 | - $urltoken = $this->user_id . '-' . $this->registrationtoken; |
|
371 | + $urltoken = $this->user_id.'-'.$this->registrationtoken; |
|
372 | 372 | |
373 | - $confirmurl = 'https://' . DOMAIN . '/U/' . $urltoken; |
|
373 | + $confirmurl = 'https://'.DOMAIN.'/U/'.$urltoken; |
|
374 | 374 | |
375 | 375 | // Arrays we need to send a templated email. |
376 | - $data = array ( |
|
376 | + $data = array( |
|
377 | 377 | 'to' => $details['email'], |
378 | 378 | 'template' => 'join_confirmation' |
379 | 379 | ); |
380 | 380 | |
381 | - $merge = array ( |
|
381 | + $merge = array( |
|
382 | 382 | 'FIRSTNAME' => $details['firstname'], |
383 | 383 | 'LASTNAME' => $details['lastname'], |
384 | 384 | 'CONFIRMURL' => $confirmurl |
@@ -440,23 +440,23 @@ discard block |
||
440 | 440 | $this->email = $email; |
441 | 441 | for (;;) { |
442 | 442 | |
443 | - $pwd=null; |
|
444 | - $o=null; |
|
443 | + $pwd = null; |
|
444 | + $o = null; |
|
445 | 445 | |
446 | 446 | // Generates the password .... |
447 | - for ($x=0; $x < 6;) { |
|
448 | - $y = rand(1,1000); |
|
449 | - if($y>350 && $y<601) $d=chr(rand(48,57)); |
|
450 | - if($y<351) $d=chr(rand(65,90)); |
|
451 | - if($y>600) $d=chr(rand(97,122)); |
|
452 | - if ($d!=$o && !preg_match('#[O01lI]#', $d)) { |
|
453 | - $o=$d; $pwd.=$d; $x++; |
|
447 | + for ($x = 0; $x < 6;) { |
|
448 | + $y = rand(1, 1000); |
|
449 | + if ($y > 350 && $y < 601) $d = chr(rand(48, 57)); |
|
450 | + if ($y < 351) $d = chr(rand(65, 90)); |
|
451 | + if ($y > 600) $d = chr(rand(97, 122)); |
|
452 | + if ($d != $o && !preg_match('#[O01lI]#', $d)) { |
|
453 | + $o = $d; $pwd .= $d; $x++; |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
457 | 457 | // If the PW fits your purpose (e.g. this regexpression) return it, else make a new one |
458 | 458 | // (You can change this regular-expression how you want ....) |
459 | - if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/",$pwd)) { |
|
459 | + if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/", $pwd)) { |
|
460 | 460 | break; |
461 | 461 | } |
462 | 462 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | $passwordforDB = password_hash($pwd, PASSWORD_BCRYPT); |
476 | 476 | |
477 | - $q = $this->db->query ("UPDATE users SET password = :password WHERE email = :email", |
|
477 | + $q = $this->db->query("UPDATE users SET password = :password WHERE email = :email", |
|
478 | 478 | array( |
479 | 479 | ':password' => $passwordforDB, |
480 | 480 | ':email' => $email |
@@ -502,16 +502,16 @@ discard block |
||
502 | 502 | return false; |
503 | 503 | } |
504 | 504 | |
505 | - $data = array ( |
|
505 | + $data = array( |
|
506 | 506 | 'to' => $this->email(), |
507 | 507 | 'template' => 'new_password' |
508 | 508 | ); |
509 | 509 | |
510 | 510 | $URL = new \MySociety\TheyWorkForYou\Url("userlogin"); |
511 | 511 | |
512 | - $merge = array ( |
|
512 | + $merge = array( |
|
513 | 513 | 'EMAIL' => $this->email(), |
514 | - 'LOGINURL' => "https://" . DOMAIN . $URL->generate(), |
|
514 | + 'LOGINURL' => "https://".DOMAIN.$URL->generate(), |
|
515 | 515 | 'PASSWORD' => $this->password() |
516 | 516 | ); |
517 | 517 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | public function facebook_id_exists($id, $return_id = false) { |
569 | 569 | // Returns true if there's a user with this facebook id. |
570 | 570 | |
571 | - if ($id!= "") { |
|
571 | + if ($id != "") { |
|
572 | 572 | $q = $this->db->query("SELECT user_id FROM users WHERE facebook_id = :id", array(':id' => $id)); |
573 | 573 | if ($q->rows() > 0) { |
574 | 574 | if ($return_id) { |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | /* Everyone */ return true; |
648 | 648 | |
649 | 649 | default: |
650 | - $PAGE->error_message ("You need to set permissions for '$action'!"); |
|
650 | + $PAGE->error_message("You need to set permissions for '$action'!"); |
|
651 | 651 | |
652 | 652 | return false; |
653 | 653 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | // Maybe there's a way of fetching these from the DB, |
666 | 666 | // so we don't duplicate them here...? |
667 | 667 | |
668 | - $statuses = array ("Viewer", "User", "Moderator", "Administrator", "Superuser"); |
|
668 | + $statuses = array("Viewer", "User", "Moderator", "Administrator", "Superuser"); |
|
669 | 669 | |
670 | 670 | return $statuses; |
671 | 671 | |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | . $deletedsql |
804 | 804 | . $confirmedsql |
805 | 805 | . $emailsql |
806 | - . $statussql . " |
|
806 | + . $statussql." |
|
807 | 807 | optin = :optin |
808 | 808 | WHERE user_id = :user_id |
809 | 809 | ", array_merge($params, array( |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | return $details; |
824 | 824 | |
825 | 825 | } else { |
826 | - $PAGE->error_message ("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'"); |
|
826 | + $PAGE->error_message("Sorry, we were unable to update user id '"._htmlentities($details["user_id"])."'"); |
|
827 | 827 | |
828 | 828 | return false; |
829 | 829 | } |
@@ -896,13 +896,13 @@ discard block |
||
896 | 896 | |
897 | 897 | if ($this->facebook_user) { |
898 | 898 | if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) { |
899 | - twfy_debug ("THEUSER", "init SUCCESS: setting as logged in"); |
|
899 | + twfy_debug("THEUSER", "init SUCCESS: setting as logged in"); |
|
900 | 900 | $this->loggedin = true; |
901 | - } elseif (md5 ($this->facebook_token()) != $matches[2]) { |
|
902 | - twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
901 | + } elseif (md5($this->facebook_token()) != $matches[2]) { |
|
902 | + twfy_debug("THEUSER", "init FAILED: Facebook token doesn't match cookie"); |
|
903 | 903 | $this->loggedin = false; |
904 | 904 | } else { |
905 | - twfy_debug ("THEUSER", "init FAILED: User is deleted"); |
|
905 | + twfy_debug("THEUSER", "init FAILED: User is deleted"); |
|
906 | 906 | $this->loggedin = false; |
907 | 907 | } |
908 | 908 | } else { |
@@ -915,30 +915,30 @@ discard block |
||
915 | 915 | // to need. Their preferences and saved things or something. |
916 | 916 | |
917 | 917 | |
918 | - twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in"); |
|
918 | + twfy_debug("THEUSER init SUCCEEDED", "setting as logged in"); |
|
919 | 919 | $this->loggedin = true; |
920 | 920 | |
921 | - } elseif (md5 ($this->password()) != $matches[2]) { |
|
922 | - twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie"); |
|
921 | + } elseif (md5($this->password()) != $matches[2]) { |
|
922 | + twfy_debug("THEUSER init FAILED", "Password doesn't match cookie"); |
|
923 | 923 | $this->loggedin = false; |
924 | 924 | } else { |
925 | - twfy_debug ("THEUSER init FAILED", "User is deleted"); |
|
925 | + twfy_debug("THEUSER init FAILED", "User is deleted"); |
|
926 | 926 | $this->loggedin = false; |
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
930 | 930 | } else { |
931 | - twfy_debug ("THEUSER init FAILED", "didn't get 1 row from db"); |
|
931 | + twfy_debug("THEUSER init FAILED", "didn't get 1 row from db"); |
|
932 | 932 | $this->loggedin = false; |
933 | 933 | } |
934 | 934 | |
935 | 935 | } else { |
936 | - twfy_debug ("THEUSER init FAILED", "cookie's user_id is not numeric"); |
|
936 | + twfy_debug("THEUSER init FAILED", "cookie's user_id is not numeric"); |
|
937 | 937 | $this->loggedin = false; |
938 | 938 | } |
939 | 939 | |
940 | 940 | } else { |
941 | - twfy_debug ("THEUSER init FAILED", "cookie is not of the correct form"); |
|
941 | + twfy_debug("THEUSER init FAILED", "cookie is not of the correct form"); |
|
942 | 942 | $this->loggedin = false; |
943 | 943 | } |
944 | 944 | |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | $date_now = gmdate("Y-m-d H:i:s"); |
966 | 966 | $q = $this->db->query("UPDATE users |
967 | 967 | SET lastvisit = '$date_now' |
968 | - WHERE user_id = '" . $this->user_id() . "'"); |
|
968 | + WHERE user_id = '".$this->user_id()."'"); |
|
969 | 969 | |
970 | 970 | $this->lastvisit = $date_now; |
971 | 971 | } |
@@ -1004,83 +1004,83 @@ discard block |
||
1004 | 1004 | // This error string is shared between both email and password errors to |
1005 | 1005 | // prevent leaking of account existence. |
1006 | 1006 | |
1007 | - $error_string = 'There is no user registered with an email of ' . _htmlentities($email) . ', or the given password is incorrect. If you are subscribed to email alerts, you are not necessarily registered on the website. If you register, you will be able to manage your email alerts, as well as leave annotations.'; |
|
1007 | + $error_string = 'There is no user registered with an email of '._htmlentities($email).', or the given password is incorrect. If you are subscribed to email alerts, you are not necessarily registered on the website. If you register, you will be able to manage your email alerts, as well as leave annotations.'; |
|
1008 | 1008 | |
1009 | 1009 | $q = $this->db->query("SELECT user_id, password, deleted, confirmed FROM users WHERE email = :email", array(':email' => $email)); |
1010 | 1010 | |
1011 | 1011 | if ($q->rows() == 1) { |
1012 | 1012 | // OK. |
1013 | - $dbpassword = $q->field(0,"password"); |
|
1013 | + $dbpassword = $q->field(0, "password"); |
|
1014 | 1014 | if (password_verify($userenteredpassword, $dbpassword)) { |
1015 | - $this->user_id = $q->field(0,"user_id"); |
|
1015 | + $this->user_id = $q->field(0, "user_id"); |
|
1016 | 1016 | $this->password = $dbpassword; |
1017 | 1017 | // We'll need these when we're going to log in. |
1018 | - $this->deleted = $q->field(0,"deleted") == 1 ? true : false; |
|
1019 | - $this->confirmed = $q->field(0,"confirmed") == 1 ? true : false; |
|
1018 | + $this->deleted = $q->field(0, "deleted") == 1 ? true : false; |
|
1019 | + $this->confirmed = $q->field(0, "confirmed") == 1 ? true : false; |
|
1020 | 1020 | |
1021 | 1021 | return true; |
1022 | 1022 | |
1023 | 1023 | } else { |
1024 | 1024 | // Failed. |
1025 | - return array ("invalidemail" => $error_string); |
|
1025 | + return array("invalidemail" => $error_string); |
|
1026 | 1026 | |
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | } else { |
1030 | 1030 | // Failed. |
1031 | - return array ("invalidemail" => $error_string); |
|
1031 | + return array("invalidemail" => $error_string); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | public function has_postcode() { |
1037 | 1037 | $has_postcode = false; |
1038 | - if ( $this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set() ) { |
|
1038 | + if ($this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set()) { |
|
1039 | 1039 | $has_postcode = true; |
1040 | 1040 | } |
1041 | 1041 | return $has_postcode; |
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | |
1045 | - public function facebook_login($returl="", $expire, $accessToken) { |
|
1045 | + public function facebook_login($returl = "", $expire, $accessToken) { |
|
1046 | 1046 | global $PAGE; |
1047 | 1047 | |
1048 | - twfy_debug("THEUSER", "Faceook login, user_id " . $this->user_id); |
|
1049 | - twfy_debug("THEUSER", "Faceook login, facebook_id " . $this->facebook_id); |
|
1050 | - twfy_debug("THEUSER", "Faceook login, email" . $this->email); |
|
1048 | + twfy_debug("THEUSER", "Faceook login, user_id ".$this->user_id); |
|
1049 | + twfy_debug("THEUSER", "Faceook login, facebook_id ".$this->facebook_id); |
|
1050 | + twfy_debug("THEUSER", "Faceook login, email".$this->email); |
|
1051 | 1051 | if ($this->facebook_id() == "") { |
1052 | - $PAGE->error_message ("We don't have a facebook id for this user.", true); |
|
1052 | + $PAGE->error_message("We don't have a facebook id for this user.", true); |
|
1053 | 1053 | |
1054 | 1054 | return; |
1055 | 1055 | } |
1056 | 1056 | |
1057 | - twfy_debug("THEUSER", "Faceook login, facebook_token: " . $accessToken); |
|
1057 | + twfy_debug("THEUSER", "Faceook login, facebook_token: ".$accessToken); |
|
1058 | 1058 | |
1059 | - $q = $this->db->query ("UPDATE users SET facebook_token = :token WHERE email = :email", |
|
1059 | + $q = $this->db->query("UPDATE users SET facebook_token = :token WHERE email = :email", |
|
1060 | 1060 | array( |
1061 | 1061 | ':token' => $accessToken, |
1062 | 1062 | ':email' => $this->email |
1063 | 1063 | )); |
1064 | 1064 | |
1065 | 1065 | if (!$q->success()) { |
1066 | - $PAGE->error_message ("There was a problem logging you in", true); |
|
1066 | + $PAGE->error_message("There was a problem logging you in", true); |
|
1067 | 1067 | twfy_debug("THEUSER", "Faceook login, failed to set accessToken"); |
1068 | 1068 | |
1069 | 1069 | return false; |
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | // facebook login users probably don't have a password |
1073 | - $cookie = $this->user_id() . "." . md5 ($accessToken); |
|
1074 | - twfy_debug("THEUSER", "Faceook login, cookie: " . $cookie); |
|
1073 | + $cookie = $this->user_id().".".md5($accessToken); |
|
1074 | + twfy_debug("THEUSER", "Faceook login, cookie: ".$cookie); |
|
1075 | 1075 | |
1076 | - twfy_debug("USER", "logging in user from facebook " . $this->user_id); |
|
1076 | + twfy_debug("USER", "logging in user from facebook ".$this->user_id); |
|
1077 | 1077 | |
1078 | 1078 | $this->loggedin = True; |
1079 | 1079 | $this->_login($returl, $expire, $cookie, 'facebook_id'); |
1080 | 1080 | return true; |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - public function login($returl="", $expire) { |
|
1083 | + public function login($returl = "", $expire) { |
|
1084 | 1084 | |
1085 | 1085 | // This is used to log the user in. Duh. |
1086 | 1086 | // You should already have checked the user's email and password using |
@@ -1102,21 +1102,21 @@ discard block |
||
1102 | 1102 | |
1103 | 1103 | // Various checks about the user - if they fail, we exit. |
1104 | 1104 | if ($this->user_id() == "" || $this->password == "") { |
1105 | - $PAGE->error_message ("We don't have the user_id or password to make the cookie.", true); |
|
1105 | + $PAGE->error_message("We don't have the user_id or password to make the cookie.", true); |
|
1106 | 1106 | |
1107 | 1107 | return; |
1108 | 1108 | } elseif ($this->deleted) { |
1109 | - $PAGE->error_message ("This user has been deleted.", true); |
|
1109 | + $PAGE->error_message("This user has been deleted.", true); |
|
1110 | 1110 | |
1111 | 1111 | return; |
1112 | 1112 | } elseif (!$this->confirmed) { |
1113 | - $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); |
|
1113 | + $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); |
|
1114 | 1114 | |
1115 | 1115 | return; |
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | // Reminder: $this->password is actually a hashed version of the plaintext pw. |
1119 | - $cookie = $this->user_id() . "." . md5 ($this->password()); |
|
1119 | + $cookie = $this->user_id().".".md5($this->password()); |
|
1120 | 1120 | |
1121 | 1121 | $this->_login($returl, $expire, $cookie); |
1122 | 1122 | } |
@@ -1127,14 +1127,14 @@ discard block |
||
1127 | 1127 | // user. We don't want it hanging around as it causes confusion. |
1128 | 1128 | $this->unset_postcode_cookie(); |
1129 | 1129 | |
1130 | - twfy_debug("THEUSER", "expire is " . $expire); |
|
1130 | + twfy_debug("THEUSER", "expire is ".$expire); |
|
1131 | 1131 | |
1132 | 1132 | $cookie_expires = 0; |
1133 | 1133 | if ($expire == 'never') { |
1134 | 1134 | twfy_debug("THEUSER", "cookie never expires"); |
1135 | - $cookie_expires = time()+86400*365*20; |
|
1135 | + $cookie_expires = time() + 86400 * 365 * 20; |
|
1136 | 1136 | } elseif (is_int($expire) && $expire > time()) { |
1137 | - twfy_debug("THEUSER", "cookie expires at " . $expire); |
|
1137 | + twfy_debug("THEUSER", "cookie expires at ".$expire); |
|
1138 | 1138 | $cookie_expires = $expire; |
1139 | 1139 | } else { |
1140 | 1140 | twfy_debug("THEUSER", "cookie expires with session"); |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - public function confirm_email($token, $redirect=true) { |
|
1173 | + public function confirm_email($token, $redirect = true) { |
|
1174 | 1174 | $arg = ''; |
1175 | 1175 | if (strstr($token, '::')) $arg = '::'; |
1176 | 1176 | if (strstr($token, '-')) $arg = '-'; |
@@ -1183,24 +1183,24 @@ discard block |
||
1183 | 1183 | FROM tokens |
1184 | 1184 | WHERE token = :token |
1185 | 1185 | AND type = 'E' |
1186 | - ", array (':token' => $registrationtoken)); |
|
1186 | + ", array(':token' => $registrationtoken)); |
|
1187 | 1187 | |
1188 | 1188 | if ($q->rows() == 1) { |
1189 | 1189 | $expires = $q->field(0, 'expires'); |
1190 | 1190 | $expire_time = strtotime($expires); |
1191 | - if ( $expire_time < time() ) { |
|
1191 | + if ($expire_time < time()) { |
|
1192 | 1192 | global $PAGE; |
1193 | 1193 | if ($PAGE && $redirect) { |
1194 | - $PAGE->error_message ("Sorry, that token seems to have expired"); |
|
1194 | + $PAGE->error_message("Sorry, that token seems to have expired"); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | return false; |
1198 | 1198 | } |
1199 | 1199 | |
1200 | - list( $user_id, $email ) = explode('::', $q->field(0, 'data')); |
|
1200 | + list($user_id, $email) = explode('::', $q->field(0, 'data')); |
|
1201 | 1201 | |
1202 | 1202 | // if we are logged in as someone else don't change the email |
1203 | - if ( $this->user_id() != 0 && $this->user_id() != $user_id ) { |
|
1203 | + if ($this->user_id() != 0 && $this->user_id() != $user_id) { |
|
1204 | 1204 | return false; |
1205 | 1205 | } |
1206 | 1206 | |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | # This should probably be in the ALERT class |
1293 | 1293 | $this->db->query('update alerts set confirmed=1 where email = :email and criteria = :criteria', array( |
1294 | 1294 | ':email' => $this->email, |
1295 | - ':criteria' => 'speaker:' . $pid |
|
1295 | + ':criteria' => 'speaker:'.$pid |
|
1296 | 1296 | )); |
1297 | 1297 | } catch (MySociety\TheyWorkForYou\MemberException $e) { |
1298 | 1298 | } |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | // |
1329 | 1329 | // Note that this doesn't login or redirect the user. |
1330 | 1330 | |
1331 | - twfy_debug("THEUSER", "Confirming user without token: " . $this->user_id()); |
|
1331 | + twfy_debug("THEUSER", "Confirming user without token: ".$this->user_id()); |
|
1332 | 1332 | $q = $this->db->query("SELECT email, password, postcode |
1333 | 1333 | FROM users |
1334 | 1334 | WHERE user_id = :user_id |
@@ -1338,9 +1338,9 @@ discard block |
||
1338 | 1338 | |
1339 | 1339 | if ($q->rows() == 1) { |
1340 | 1340 | |
1341 | - twfy_debug("THEUSER", "User with ID found to confirm: " . $this->user_id()); |
|
1341 | + twfy_debug("THEUSER", "User with ID found to confirm: ".$this->user_id()); |
|
1342 | 1342 | // We'll need these to be set before logging the user in. |
1343 | - $this->email = $q->field(0, 'email'); |
|
1343 | + $this->email = $q->field(0, 'email'); |
|
1344 | 1344 | |
1345 | 1345 | // Set that they're confirmed in the DB. |
1346 | 1346 | $r = $this->db->query("UPDATE users |
@@ -1355,18 +1355,18 @@ discard block |
||
1355 | 1355 | # This should probably be in the ALERT class |
1356 | 1356 | $this->db->query('update alerts set confirmed=1 where email = :email and criteria = :criteria', array( |
1357 | 1357 | ':email' => $this->email, |
1358 | - ':criteria' => 'speaker:' . $pid |
|
1358 | + ':criteria' => 'speaker:'.$pid |
|
1359 | 1359 | )); |
1360 | 1360 | } catch (MySociety\TheyWorkForYou\MemberException $e) { |
1361 | 1361 | } |
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | if ($r->success()) { |
1365 | - twfy_debug("THEUSER", "User with ID confirmed: " . $this->user_id()); |
|
1365 | + twfy_debug("THEUSER", "User with ID confirmed: ".$this->user_id()); |
|
1366 | 1366 | $this->confirmed = true; |
1367 | 1367 | return true; |
1368 | 1368 | } else { |
1369 | - twfy_debug("THEUSER", "User with ID not confirmed: " . $this->user_id()); |
|
1369 | + twfy_debug("THEUSER", "User with ID not confirmed: ".$this->user_id()); |
|
1370 | 1370 | // Couldn't set them as confirmed in the DB. |
1371 | 1371 | return false; |
1372 | 1372 | } |
@@ -1374,7 +1374,7 @@ discard block |
||
1374 | 1374 | } else { |
1375 | 1375 | // Couldn't find this user in the DB. Maybe the token was |
1376 | 1376 | // wrong or incomplete? |
1377 | - twfy_debug("THEUSER", "User with ID not found to confirm: " . $this->user_id()); |
|
1377 | + twfy_debug("THEUSER", "User with ID not found to confirm: ".$this->user_id()); |
|
1378 | 1378 | return false; |
1379 | 1379 | } |
1380 | 1380 | } |
@@ -1387,14 +1387,14 @@ discard block |
||
1387 | 1387 | |
1388 | 1388 | $this->postcode = $pc; |
1389 | 1389 | if (!headers_sent()) // if in debug mode |
1390 | - setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN); |
|
1390 | + setcookie(POSTCODE_COOKIE, $pc, time() + 7 * 86400, "/", COOKIEDOMAIN); |
|
1391 | 1391 | |
1392 | - twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain"); |
|
1392 | + twfy_debug('USER', "Set the cookie named '".POSTCODE_COOKIE." to '$pc' for ".COOKIEDOMAIN." domain"); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | public function unset_postcode_cookie() { |
1396 | 1396 | if (!headers_sent()) // if in debug mode |
1397 | - setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
|
1397 | + setcookie(POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN); |
|
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | // mostly here for updating from facebook where we do not need |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | |
1408 | 1408 | // this is checked elsewhere but just in case we check here and |
1409 | 1409 | // bail out to be on the safe side |
1410 | - if ( isset($details['email'] ) ) { |
|
1411 | - if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) { |
|
1410 | + if (isset($details['email'])) { |
|
1411 | + if ($details['email'] != $this->email() && $this->email_exists($details['email'])) { |
|
1412 | 1412 | return false; |
1413 | 1413 | } |
1414 | 1414 | } |
@@ -1457,8 +1457,8 @@ discard block |
||
1457 | 1457 | // this is checked elsewhere but just in case we check here and |
1458 | 1458 | // bail out to be on the safe side |
1459 | 1459 | $email = ''; |
1460 | - if ( isset($details['email'] ) ) { |
|
1461 | - if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) { |
|
1460 | + if (isset($details['email'])) { |
|
1461 | + if ($details['email'] != $this->email() && $this->email_exists($details['email'])) { |
|
1462 | 1462 | return false; |
1463 | 1463 | } |
1464 | 1464 | $email = $details['email']; |
@@ -1486,8 +1486,8 @@ discard block |
||
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | if ($email && $email != $this->email) { |
1489 | - $token = substr( password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16 ); |
|
1490 | - $data = $this->user_id() . '::' . $email; |
|
1489 | + $token = substr(password_hash($email.microtime(), PASSWORD_BCRYPT), 29, 16); |
|
1490 | + $data = $this->user_id().'::'.$email; |
|
1491 | 1491 | $r = $this->db->query("INSERT INTO tokens |
1492 | 1492 | ( expires, token, type, data ) |
1493 | 1493 | VALUES |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | )); |
1504 | 1504 | |
1505 | 1505 | // send confirmation email here |
1506 | - if ( $r->success() ) { |
|
1506 | + if ($r->success()) { |
|
1507 | 1507 | $newdetails['email'] = $email; |
1508 | 1508 | $newdetails['token'] = $token; |
1509 | 1509 | if ($confirm_email) { |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | $url = $ARCHIVEURL->generate(); |
6 | 6 | |
7 | 7 | $this->block_start(array('title'=>'News Archives', 'url'=>$url)); |
8 | -include BASEDIR . '/news/sidebar_archives.php'; |
|
8 | +include BASEDIR.'/news/sidebar_archives.php'; |
|
9 | 9 | $this->block_end(); |
10 | 10 | |
11 | 11 | $this->block_start(array('title'=>'RSS/XML')); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $rssurl = $RSSURL->generate(); |
14 | 14 | |
15 | 15 | $HELPURL = new \MySociety\TheyWorkForYou\Url('help'); |
16 | -$helpurl = $HELPURL->generate() . '#rss'; |
|
16 | +$helpurl = $HELPURL->generate().'#rss'; |
|
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <p><a href="<?php echo $rssurl; ?>">RSS feed of recent posts</a> (<a href="<?php echo $helpurl; ?>">?</a>)</p> |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | * |
11 | 11 | */ |
12 | 12 | |
13 | -include_once INCLUDESPATH . "easyparliament/init.php"; |
|
14 | -require_once INCLUDESPATH . "../../commonlib/phplib/random.php"; |
|
15 | -require_once INCLUDESPATH . "../../commonlib/phplib/auth.php"; |
|
13 | +include_once INCLUDESPATH."easyparliament/init.php"; |
|
14 | +require_once INCLUDESPATH."../../commonlib/phplib/random.php"; |
|
15 | +require_once INCLUDESPATH."../../commonlib/phplib/auth.php"; |
|
16 | 16 | |
17 | 17 | // increment this each time you change the question so |
18 | 18 | // the cookie magic works |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | if ($hide_question) { |
34 | 34 | $always_ask = 0; |
35 | 35 | $show_survey_qn = $current_question; |
36 | - setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
|
36 | + setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/'); |
|
37 | 37 | } elseif ($has_answered_question == $current_question && !$always_ask) { |
38 | 38 | $show_survey_qn = $current_question; |
39 | - setcookie('survey', $current_question, time()+60*60*24*365, '/'); |
|
39 | + setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/'); |
|
40 | 40 | } elseif (isset($_COOKIE['survey'])) { |
41 | 41 | $show_survey_qn = $_COOKIE['survey']; |
42 | 42 | } |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | if ($show_survey_qn < $current_question && !$has_answered_question) { |
50 | 50 | $page_url = ''; |
51 | 51 | $hide_url = ''; |
52 | - if ( in_array( $this_page, array('mp', 'peer', 'msp', 'mla', 'royal') ) ) { |
|
52 | + if (in_array($this_page, array('mp', 'peer', 'msp', 'mla', 'royal'))) { |
|
53 | 53 | global $MEMBER; |
54 | - $page_url = $MEMBER->url(true) . "?answered_survey=$current_question"; |
|
55 | - $hide_url = $MEMBER->url() . "?hide_survey=$current_question"; |
|
54 | + $page_url = $MEMBER->url(true)."?answered_survey=$current_question"; |
|
55 | + $hide_url = $MEMBER->url()."?hide_survey=$current_question"; |
|
56 | 56 | } else { |
57 | 57 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
58 | - $URL->insert(array('answered_survey' => $current_question )); |
|
59 | - $page_url = 'https://' . DOMAIN . $URL->generate(); |
|
58 | + $URL->insert(array('answered_survey' => $current_question)); |
|
59 | + $page_url = 'https://'.DOMAIN.$URL->generate(); |
|
60 | 60 | $URL = new \MySociety\TheyWorkForYou\Url($this_page); |
61 | - $URL->insert(array('hide_survey' => $current_question )); |
|
61 | + $URL->insert(array('hide_survey' => $current_question)); |
|
62 | 62 | $hide_url = $URL->generate(); |
63 | 63 | } |
64 | 64 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - public function display ($view, $args=array(), $format='html') { |
|
45 | + public function display($view, $args = array(), $format = 'html') { |
|
46 | 46 | // $view is what we're viewing by: |
47 | 47 | // 'ep' is all the comments attached to an epobject. |
48 | 48 | // 'user' is all the comments written by a user. |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | } else { |
68 | 68 | // Don't have a valid $view; |
69 | - $PAGE->error_message ("You haven't specified a view type."); |
|
69 | + $PAGE->error_message("You haven't specified a view type."); |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | |
88 | - public function render($data, $format='html', $template='comments') { |
|
88 | + public function render($data, $format = 'html', $template = 'comments') { |
|
89 | 89 | include (INCLUDESPATH."easyparliament/templates/$format/$template.php"); |
90 | 90 | } |
91 | 91 | |
@@ -93,21 +93,21 @@ discard block |
||
93 | 93 | // Get all the data attached to an epobject. |
94 | 94 | global $PAGE; |
95 | 95 | |
96 | - twfy_debug (get_class($this), "getting data by epobject"); |
|
96 | + twfy_debug(get_class($this), "getting data by epobject"); |
|
97 | 97 | |
98 | 98 | // What we return. |
99 | 99 | $data = array(); |
100 | 100 | if (!is_numeric($args['epobject_id'])) { |
101 | - $PAGE->error_message ("Sorry, we don't have a valid epobject id"); |
|
101 | + $PAGE->error_message("Sorry, we don't have a valid epobject id"); |
|
102 | 102 | return $data; |
103 | 103 | } |
104 | 104 | |
105 | 105 | // For getting the data. |
106 | - $input = array ( |
|
107 | - 'amount' => array ( |
|
106 | + $input = array( |
|
107 | + 'amount' => array( |
|
108 | 108 | 'user' => true |
109 | 109 | ), |
110 | - 'where' => array ( |
|
110 | + 'where' => array( |
|
111 | 111 | 'comments.epobject_id=' => $args['epobject_id'], |
112 | 112 | #'visible=' => '1' |
113 | 113 | ), |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | // comments by things in $args? |
136 | 136 | global $PAGE; |
137 | 137 | |
138 | - twfy_debug (get_class($this), "getting data by user"); |
|
138 | + twfy_debug(get_class($this), "getting data by user"); |
|
139 | 139 | |
140 | 140 | // What we return. |
141 | 141 | $data = array(); |
142 | 142 | |
143 | 143 | if (!is_numeric($args['user_id'])) { |
144 | - $PAGE->error_message ("Sorry, we don't have a valid user id"); |
|
144 | + $PAGE->error_message("Sorry, we don't have a valid user id"); |
|
145 | 145 | return $data; |
146 | 146 | } |
147 | 147 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | $num = 10; |
152 | 152 | } |
153 | 153 | |
154 | - if (isset($args['page']) && is_numeric($args['page']) && $args['page']>1) { |
|
154 | + if (isset($args['page']) && is_numeric($args['page']) && $args['page'] > 1) { |
|
155 | 155 | $page = $args['page']; |
156 | 156 | } else { |
157 | 157 | $page = 1; |
158 | 158 | } |
159 | 159 | |
160 | - $limit = $num*($page-1) . ',' . $num; |
|
160 | + $limit = $num * ($page - 1).','.$num; |
|
161 | 161 | |
162 | 162 | // We're getting the most recent comments posted to epobjects. |
163 | 163 | // We're grouping them by epobject so we can just link to each hansard thing once. |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | |
194 | 194 | if ($q->rows() > 0) { |
195 | 195 | |
196 | - for ($n=0; $n<$q->rows(); $n++) { |
|
196 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
197 | 197 | |
198 | 198 | // All the basic stuff... |
199 | - $comments[$n] = array ( |
|
199 | + $comments[$n] = array( |
|
200 | 200 | 'comment_id' => $q->field($n, 'comment_id'), |
201 | 201 | 'posted' => $q->field($n, 'posted'), |
202 | 202 | 'total_comments' => $q->field($n, 'total_comments'), |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Add the URL... |
211 | - $urldata = array ( |
|
211 | + $urldata = array( |
|
212 | 212 | 'major' => $q->field($n, 'major'), |
213 | 213 | 'gid' => $q->field($n, 'gid'), |
214 | 214 | 'comment_id' => $q->field($n, 'comment_id'), |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | |
235 | 235 | $commentbodies = array(); |
236 | 236 | |
237 | - for ($n=0; $n<$r->rows(); $n++) { |
|
238 | - $commentbodies[ $r->field($n, 'comment_id') ] = $r->field($n, 'body'); |
|
237 | + for ($n = 0; $n < $r->rows(); $n++) { |
|
238 | + $commentbodies[$r->field($n, 'comment_id')] = $r->field($n, 'body'); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // This does rely on both this and the previous query returning |
242 | 242 | // stuff in the same order... |
243 | 243 | foreach ($comments as $n => $commentdata) { |
244 | - $comments[$n]['body'] = $commentbodies[ $comments[$n]['comment_id'] ]; |
|
244 | + $comments[$n]['body'] = $commentbodies[$comments[$n]['comment_id']]; |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $data['comments'] = $comments; |
250 | 250 | $data['results_per_page'] = $num; |
251 | 251 | $data['page'] = $page; |
252 | - $q = $this->db->query('SELECT COUNT(DISTINCT(epobject_id)) AS count FROM comments WHERE visible=1 AND user_id=' . $args['user_id']); |
|
252 | + $q = $this->db->query('SELECT COUNT(DISTINCT(epobject_id)) AS count FROM comments WHERE visible=1 AND user_id='.$args['user_id']); |
|
253 | 253 | $data['total_results'] = $q->field(0, 'count'); |
254 | 254 | return $data; |
255 | 255 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // $args should contain 'num', indicating how many to get. |
262 | 262 | // and perhaps pid too, for a particular person |
263 | 263 | |
264 | - twfy_debug (get_class($this), "getting data by recent"); |
|
264 | + twfy_debug(get_class($this), "getting data by recent"); |
|
265 | 265 | |
266 | 266 | // What we return. |
267 | 267 | $data = array(); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $page = 1; |
279 | 279 | } |
280 | 280 | |
281 | - $limit = $num*($page-1) . ',' . $num; |
|
281 | + $limit = $num * ($page - 1).','.$num; |
|
282 | 282 | |
283 | 283 | $where = array( |
284 | 284 | 'visible=' => '1' |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | if (isset($args['pid']) && is_numeric($args['pid'])) { |
287 | 287 | $where['person_id='] = $args['pid']; |
288 | 288 | } |
289 | - $input = array ( |
|
290 | - 'amount' => array ( |
|
289 | + $input = array( |
|
290 | + 'amount' => array( |
|
291 | 291 | 'user' => true |
292 | 292 | ), |
293 | 293 | 'where' => $where, |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $data['pid'] = $args['pid']; |
306 | 306 | $q = 'SELECT title, given_name, family_name, lordofname, house FROM member m, person_names p WHERE m.person_id=p.person_id AND p.type="name" AND left_house="9999-12-31" AND m.person_id = :pid'; |
307 | 307 | $q = $this->db->query($q, array(':pid' => $args['pid'])); |
308 | - $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0,'lordofname')); |
|
308 | + $data['full_name'] = member_full_name($q->field(0, 'house'), $q->field(0, 'title'), $q->field(0, 'given_name'), $q->field(0, 'family_name'), $q->field(0, 'lordofname')); |
|
309 | 309 | $q = 'SELECT COUNT(*) AS count FROM comments,hansard WHERE visible=1 AND comments.epobject_id = hansard.epobject_id and hansard.person_id = :pid'; |
310 | 310 | $params[':pid'] = $args['pid']; |
311 | 311 | } else { |
@@ -319,15 +319,15 @@ discard block |
||
319 | 319 | public function _get_data_by_dates($args) { |
320 | 320 | // $args should contain start_date and end_date |
321 | 321 | |
322 | - twfy_debug (get_class($this), "getting data by recent"); |
|
322 | + twfy_debug(get_class($this), "getting data by recent"); |
|
323 | 323 | $data = array(); |
324 | 324 | $where = array( |
325 | 325 | 'visible=' => '1', |
326 | 326 | 'date(posted)>=' => $args['start_date'], |
327 | 327 | 'date(posted)<=' => $args['end_date'] |
328 | 328 | ); |
329 | - $input = array ( |
|
330 | - 'amount' => array ( |
|
329 | + $input = array( |
|
330 | + 'amount' => array( |
|
331 | 331 | 'user' => true |
332 | 332 | ), |
333 | 333 | 'where' => $where, |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public function _get_data_by_search($args) { |
342 | 342 | // $args should contain 'num', indicating how many to get. |
343 | 343 | |
344 | - twfy_debug (get_class($this), "getting data by search"); |
|
344 | + twfy_debug(get_class($this), "getting data by search"); |
|
345 | 345 | |
346 | 346 | // What we return. |
347 | 347 | $data = array(); |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | $page = 1; |
359 | 359 | } |
360 | 360 | |
361 | - $limit = $num*($page-1) . ',' . $num; |
|
361 | + $limit = $num * ($page - 1).','.$num; |
|
362 | 362 | |
363 | - $input = array ( |
|
364 | - 'amount' => array ( |
|
363 | + $input = array( |
|
364 | + 'amount' => array( |
|
365 | 365 | 'user'=> true |
366 | 366 | ), |
367 | - 'where' => array ( |
|
367 | + 'where' => array( |
|
368 | 368 | 'comments.body LIKE' => "%$args[s]%" |
369 | 369 | ), |
370 | 370 | 'order' => 'posted DESC', |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | // It returns the URL for the comment. |
392 | 392 | |
393 | 393 | $major = $urldata['major']; |
394 | - $gid = $urldata['gid']; |
|
394 | + $gid = $urldata['gid']; |
|
395 | 395 | $comment_id = $urldata['comment_id']; |
396 | 396 | $user_id = isset($urldata['user_id']) ? $urldata['user_id'] : false; |
397 | 397 | |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | $URL = new \MySociety\TheyWorkForYou\Url($page); |
406 | 406 | |
407 | 407 | $gid = fix_gid_from_db($gid); // In includes/utility.php |
408 | - $URL->insert(array('id' => $gid )); |
|
408 | + $URL->insert(array('id' => $gid)); |
|
409 | 409 | if ($user_id) { |
410 | 410 | $URL->insert(array('u' => $user_id)); |
411 | 411 | } |
412 | - $url = $URL->generate() . '#c' . $comment_id; |
|
412 | + $url = $URL->generate().'#c'.$comment_id; |
|
413 | 413 | |
414 | 414 | return $url; |
415 | 415 | } |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | $limit = isset($input['limit']) ? $input['limit'] : ''; |
484 | 484 | |
485 | 485 | // The fields to fetch from db. 'table' => array ('field1', 'field2'). |
486 | - $fieldsarr = array ( |
|
487 | - 'comments' => array ('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'), |
|
488 | - 'hansard' => array ('major', 'gid') |
|
486 | + $fieldsarr = array( |
|
487 | + 'comments' => array('comment_id', 'user_id', 'epobject_id', 'body', 'posted', 'modflagged', 'visible'), |
|
488 | + 'hansard' => array('major', 'gid') |
|
489 | 489 | ); |
490 | 490 | |
491 | 491 | // Yes, we need the gid of a comment's associated hansard object |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | |
497 | 497 | // Add on the stuff for getting a user's details. |
498 | 498 | if (isset($amount['user']) && $amount['user'] == true) { |
499 | - $fieldsarr['users'] = array ('firstname', 'lastname', 'user_id'); |
|
499 | + $fieldsarr['users'] = array('firstname', 'lastname', 'user_id'); |
|
500 | 500 | // Like doing "FROM comments, users" but it's easier to add |
501 | 501 | // an "INNER JOIN..." automatically to the query. |
502 | 502 | $join .= ' INNER JOIN users ON comments.user_id = users.user_id '; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | $fieldsarr['epobject'] = array('body'); |
508 | 508 | } |
509 | 509 | |
510 | - $fieldsarr2 = array (); |
|
510 | + $fieldsarr2 = array(); |
|
511 | 511 | // Construct the $fields clause. |
512 | 512 | foreach ($fieldsarr as $table => $tablesfields) { |
513 | 513 | foreach ($tablesfields as $n => $field) { |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $fields = implode(', ', $fieldsarr2); |
525 | 525 | |
526 | 526 | |
527 | - $wherearr2 = array (); |
|
527 | + $wherearr2 = array(); |
|
528 | 528 | $params = array(); |
529 | 529 | $i = 0; |
530 | 530 | // Construct the $where clause. |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $params[":where$i"] = $val; |
534 | 534 | $i++; |
535 | 535 | } |
536 | - $where = implode (" AND ", $wherearr2); |
|
536 | + $where = implode(" AND ", $wherearr2); |
|
537 | 537 | |
538 | 538 | if ($order != '') { |
539 | 539 | $order = "ORDER BY $order"; |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | // Finally, do the query! |
547 | - $q = $this->db->query ("SELECT $fields |
|
547 | + $q = $this->db->query("SELECT $fields |
|
548 | 548 | FROM comments |
549 | 549 | $join |
550 | 550 | WHERE $where |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | ", $params); |
554 | 554 | |
555 | 555 | // Format the data into an array for returning. |
556 | - $data = array (); |
|
556 | + $data = array(); |
|
557 | 557 | |
558 | 558 | if ($q->rows() > 0) { |
559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | // We'll generate permalinks for each comment. |
564 | 564 | // Assuming every comment is from the same major... |
565 | 565 | |
566 | - for ($n=0; $n<$q->rows(); $n++) { |
|
566 | + for ($n = 0; $n < $q->rows(); $n++) { |
|
567 | 567 | |
568 | 568 | // Put each row returned into its own array in $data. |
569 | 569 | foreach ($fieldsarr as $table => $tablesfields) { |
@@ -25,8 +25,8 @@ |
||
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 ) ); |
|
29 | - print ' <a href="' . $URL->generate() . '">See this day →</a>'; |
|
28 | + $URL->insert(array('d' => $date)); |
|
29 | + print ' <a href="'.$URL->generate().'">See this day →</a>'; |
|
30 | 30 | } |
31 | 31 | print "</h2>\n"; |
32 | 32 | print $list[$i] ? "<ul class='calendar'>\n" : "<dl class='calendar'>\n"; |
@@ -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']); |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | // Create array containing abbreviations of days of week. |
43 | - $daysOfWeek = array('Mon','Tue','Wed','Thu','Fri','Sat','Sun'); |
|
43 | + $daysOfWeek = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'); |
|
44 | 44 | |
45 | 45 | // What is the first day of the month in question? |
46 | - $firstDayOfMonth = mktime(0,0,0,$month,1,$year); |
|
46 | + $firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year); |
|
47 | 47 | |
48 | 48 | // How many days does this month contain? |
49 | - $numberDays = date('t',$firstDayOfMonth); |
|
49 | + $numberDays = date('t', $firstDayOfMonth); |
|
50 | 50 | |
51 | 51 | // Retrieve some information about the first day of the |
52 | 52 | // month in question. |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | if (isset($data['info']['onday'])) { |
61 | 61 | // 'onday' is like 'yyyy-mm-dd'. |
62 | 62 | $datebits = explode('-', $data['info']['onday']); |
63 | - if (count($datebits)>2 && $datebits[0] == $year && $datebits[1] == $month) { |
|
63 | + if (count($datebits) > 2 && $datebits[0] == $year && $datebits[1] == $month) { |
|
64 | 64 | $toDay = $datebits[2]; |
65 | 65 | } else { |
66 | 66 | $toDay = ''; |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | // sittings - e.g. WH is only Tuesday-Thursday |
150 | 150 | if ($currentDay == $toDay) { |
151 | 151 | print '<td class="on"'; |
152 | - if ($recess[0] && $recess[0]!=1) print ' title="'.$recess[0].'"'; |
|
152 | + if ($recess[0] && $recess[0] != 1) print ' title="'.$recess[0].'"'; |
|
153 | 153 | print '>'; |
154 | 154 | } elseif ($recess[0]) { |
155 | 155 | print '<td class="no"'; |
156 | - if ($recess[0]!=1) print ' title="'.$recess[0].'"'; |
|
156 | + if ($recess[0] != 1) print ' title="'.$recess[0].'"'; |
|
157 | 157 | print '>'; |
158 | 158 | } else { |
159 | 159 | print '<td>'; |
@@ -161,22 +161,22 @@ discard block |
||
161 | 161 | |
162 | 162 | // Is the $currentDay a member of $dates? If so, |
163 | 163 | // the day should be linked. |
164 | - if (in_array($currentDay,$dates)) { |
|
164 | + if (in_array($currentDay, $dates)) { |
|
165 | 165 | |
166 | 166 | $date = sprintf("%04d-%02d-%02d", $year, $month, $currentDay); |
167 | 167 | |
168 | 168 | if ($currentDay == $toDay) { |
169 | - print '<span>' . $currentDay . '</span></td>'; |
|
169 | + print '<span>'.$currentDay.'</span></td>'; |
|
170 | 170 | } else { |
171 | 171 | $DAYURL->insert(array('d'=>$date)); |
172 | - print "<a href=\"" . $DAYURL->generate() . "\">$currentDay</a></td>"; |
|
172 | + print "<a href=\"".$DAYURL->generate()."\">$currentDay</a></td>"; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // $currentDay is not a member of $dates. |
176 | 176 | |
177 | 177 | } else { |
178 | 178 | |
179 | - print '<span>' . $currentDay . '</span></td>'; |
|
179 | + print '<span>'.$currentDay.'</span></td>'; |
|
180 | 180 | } |
181 | 181 | // Increment counters |
182 | 182 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $year = $years[0]; |
210 | 210 | $URL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$data['info']['major']]['page_year']); |
211 | 211 | $URL->insert(array('y'=>$year)); |
212 | - print '<p><a href="' . $URL->generate() . '">See all of ' . $year . '</a></p>'; |
|
212 | + print '<p><a href="'.$URL->generate().'">See all of '.$year.'</a></p>'; |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | } else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $last_result = $info['total_results']; |
45 | 45 | } |
46 | 46 | |
47 | - print "\t\t\t\t<h3 style='font-weight:normal'>Results <strong>" . number_format($info['first_result']) . '-' . number_format($last_result) . '</strong> of ' . number_format($info['total_results']) . " for <strong>" . _htmlentities($searchdescription) . "</strong></h3>\n"; |
|
47 | + print "\t\t\t\t<h3 style='font-weight:normal'>Results <strong>".number_format($info['first_result']).'-'.number_format($last_result).'</strong> of '.number_format($info['total_results'])." for <strong>"._htmlentities($searchdescription)."</strong></h3>\n"; |
|
48 | 48 | |
49 | 49 | } elseif ($info['total_results'] == 0) { |
50 | 50 | echo '<h3 style="font-weight:normal">Your search for <strong>', _htmlentities($searchdescription), '</strong> did not match anything.</h3>'; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $u = new \MySociety\TheyWorkForYou\Url('search'); |
55 | 55 | $u->reset(); |
56 | 56 | $u->insert(array('s' => $info['spelling_correction'])); |
57 | - echo '<p><big>Did you mean: <a href="' . $u->generate(), '">', $info['spelling_correction'] . '</a>?</big></p>'; |
|
57 | + echo '<p><big>Did you mean: <a href="'.$u->generate(), '">', $info['spelling_correction'].'</a>?</big></p>'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($match = get_http_var('match')) { |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | if (isset ($data['rows']) && count($data['rows']) > 0) { |
67 | 67 | |
68 | 68 | echo '<dl id="searchresults">'; |
69 | - for ($i=0; $i<count($data['rows']); $i++) { |
|
69 | + for ($i = 0; $i < count($data['rows']); $i++) { |
|
70 | 70 | |
71 | 71 | $row = $data['rows'][$i]; |
72 | 72 | echo '<dt><a href="', $row['listurl'], '">'; |
73 | 73 | if (isset($row['parent']) && count($row['parent']) > 0) { |
74 | - echo ('<strong>' . $row['parent']['body'] . '</strong>'); |
|
74 | + echo ('<strong>'.$row['parent']['body'].'</strong>'); |
|
75 | 75 | } |
76 | - echo '</a> <small>(' . format_date($row['hdate'], LONGDATEFORMAT) . ')'; |
|
76 | + echo '</a> <small>('.format_date($row['hdate'], LONGDATEFORMAT).')'; |
|
77 | 77 | if (isset($row['video_status']) && ($row['video_status'] == 5 || $row['video_status'] == 7)) { |
78 | 78 | echo ' <em>has video</em> '; |
79 | 79 | } |
80 | 80 | if (isset($row['collapsed']) && $row['collapsed'] && $row['subsection_id']) { |
81 | 81 | $URL = new \MySociety\TheyWorkForYou\Url('search'); |
82 | - $URL->insert(array('s' => $info['s'] . " segment:$row[subsection_id]" )); |
|
82 | + $URL->insert(array('s' => $info['s']." segment:$row[subsection_id]")); |
|
83 | 83 | echo ' <a href="', $URL->generate(), '">See ', $row['collapsed'], |
84 | - ' other result', $row['collapsed']>1?'s':'', ' from this ', |
|
84 | + ' other result', $row['collapsed'] > 1 ? 's' : '', ' from this ', |
|
85 | 85 | $hansardmajors[$row['major']]['singular'], '</a>'; |
86 | 86 | } |
87 | 87 | echo '</small>'; |
88 | 88 | if ($match = get_http_var('match')) { |
89 | - echo ' – <a href="/search/record.php?result=', $row['gid'] , '&match=', _htmlspecialchars($match), '">This is the correct match</a>'; |
|
89 | + echo ' – <a href="/search/record.php?result=', $row['gid'], '&match=', _htmlspecialchars($match), '">This is the correct match</a>'; |
|
90 | 90 | } |
91 | 91 | echo '</dt> <dd><p>'; |
92 | 92 | if (isset($row['speaker']) && count($row['speaker'])) { |
93 | - echo "<em>" . ucfirst($row['speaker']['name']) . "</em>"; |
|
93 | + echo "<em>".ucfirst($row['speaker']['name'])."</em>"; |
|
94 | 94 | if ($row['extract']) echo ": "; |
95 | 95 | } |
96 | 96 | |
97 | - echo $row['extract'] . "</p></dd>\n"; |
|
97 | + echo $row['extract']."</p></dd>\n"; |
|
98 | 98 | |
99 | 99 | } |
100 | 100 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | if (isset($data['comments']) && count($data['comments']) > 0) { |
15 | 15 | $title = 'Most recent annotations'; |
16 | 16 | if (isset($data['full_name'])) { |
17 | - $title .= ' on things by ' . $data['full_name']; |
|
17 | + $title .= ' on things by '.$data['full_name']; |
|
18 | 18 | } |
19 | 19 | $PAGE->block_start(array('id'=>'recentcomments', 'title'=>$title)); |
20 | 20 | |
@@ -33,11 +33,11 @@ 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 | |
40 | - ?><a name="c<?php echo $count; ?>"></a><strong><?php echo _htmlentities($comment['firstname'] . ' ' . $comment['lastname']); ?>:</strong> <?php echo $commenttext; ?> <small>(<?php echo relative_time($comment['posted']); ?>)</small><br><a href="<?php echo $comment['url']; ?>">Read annotation</a> | <a href="<?php echo $USERURL->generate(); ?>" title="See more information about this user">All by this user</a> </li> |
|
40 | + ?><a name="c<?php echo $count; ?>"></a><strong><?php echo _htmlentities($comment['firstname'].' '.$comment['lastname']); ?>:</strong> <?php echo $commenttext; ?> <small>(<?php echo relative_time($comment['posted']); ?>)</small><br><a href="<?php echo $comment['url']; ?>">Read annotation</a> | <a href="<?php echo $USERURL->generate(); ?>" title="See more information about this user">All by this user</a> </li> |
|
41 | 41 | <?php |
42 | 42 | } |
43 | 43 | ?> |
@@ -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); |
@@ -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 | ?> |