@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | |
| 57 | 57 | class USER { |
| 58 | - public $user_id = "0"; // So we have an ID for non-logged in users reporting comments etc. |
|
| 59 | - public $firstname = "Guest"; // So we have something to print for non-logged in users. |
|
| 58 | + public $user_id = "0"; // So we have an ID for non-logged in users reporting comments etc. |
|
| 59 | + public $firstname = "Guest"; // So we have something to print for non-logged in users. |
|
| 60 | 60 | public $lastname = ""; |
| 61 | - public $password = ""; // This will be a hashed version of a plaintext pw. |
|
| 61 | + public $password = ""; // This will be a hashed version of a plaintext pw. |
|
| 62 | 62 | public $email = ""; |
| 63 | 63 | public $postcode = ""; |
| 64 | 64 | public $url = ""; |
| 65 | - public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT). |
|
| 65 | + public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT). |
|
| 66 | 66 | public $registrationtime = ""; // When they registered (GMT). |
| 67 | - public $registrationip = ""; // Where they registered from. |
|
| 68 | - public $optin = ""; // Int containing multiple binary opt-ins. (See top of User.php) |
|
| 69 | - public $deleted = ""; // User can't log in or have their info displayed. |
|
| 70 | - public $confirmed = ''; // boolean - Has the user confirmed via email? |
|
| 71 | - public $facebook_id = ''; // Facebook ID for users who login with FB |
|
| 72 | - public $facebook_token = ''; // Facebook token for users who login with FB |
|
| 73 | - public $can_annotate = false; // Can the user add annotations |
|
| 74 | - public $organisation = ''; // The organisation the user belongs to |
|
| 67 | + public $registrationip = ""; // Where they registered from. |
|
| 68 | + public $optin = ""; // Int containing multiple binary opt-ins. (See top of User.php) |
|
| 69 | + public $deleted = ""; // User can't log in or have their info displayed. |
|
| 70 | + public $confirmed = ''; // boolean - Has the user confirmed via email? |
|
| 71 | + public $facebook_id = ''; // Facebook ID for users who login with FB |
|
| 72 | + public $facebook_token = ''; // Facebook token for users who login with FB |
|
| 73 | + public $can_annotate = false; // Can the user add annotations |
|
| 74 | + public $organisation = ''; // The organisation the user belongs to |
|
| 75 | 75 | // Don't use the status to check access privileges - use the is_able_to() function. |
| 76 | 76 | public $status = "Viewer"; |
| 77 | 77 | |
@@ -324,12 +324,12 @@ discard block |
||
| 324 | 324 | $confirmurl = 'https://' . DOMAIN . '/E/' . $urltoken; |
| 325 | 325 | |
| 326 | 326 | // Arrays we need to send a templated email. |
| 327 | - $data = [ |
|
| 327 | + $data = [ |
|
| 328 | 328 | 'to' => $details['email'], |
| 329 | 329 | 'template' => 'email_confirmation', |
| 330 | 330 | ]; |
| 331 | 331 | |
| 332 | - $merge = [ |
|
| 332 | + $merge = [ |
|
| 333 | 333 | 'CONFIRMURL' => $confirmurl, |
| 334 | 334 | ]; |
| 335 | 335 | |
@@ -367,12 +367,12 @@ discard block |
||
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | // Arrays we need to send a templated email. |
| 370 | - $data = [ |
|
| 370 | + $data = [ |
|
| 371 | 371 | 'to' => $details['email'], |
| 372 | 372 | 'template' => 'join_confirmation', |
| 373 | 373 | ]; |
| 374 | 374 | |
| 375 | - $merge = [ |
|
| 375 | + $merge = [ |
|
| 376 | 376 | 'CONFIRMURL' => $confirmurl, |
| 377 | 377 | ]; |
| 378 | 378 | |
@@ -438,13 +438,13 @@ discard block |
||
| 438 | 438 | // Generates the password .... |
| 439 | 439 | for ($x = 0; $x < 6;) { |
| 440 | 440 | $y = rand(1, 1000); |
| 441 | - if($y > 350 && $y < 601) { |
|
| 441 | + if ($y > 350 && $y < 601) { |
|
| 442 | 442 | $d = chr(rand(48, 57)); |
| 443 | 443 | } |
| 444 | - if($y < 351) { |
|
| 444 | + if ($y < 351) { |
|
| 445 | 445 | $d = chr(rand(65, 90)); |
| 446 | 446 | } |
| 447 | - if($y > 600) { |
|
| 447 | + if ($y > 600) { |
|
| 448 | 448 | $d = chr(rand(97, 122)); |
| 449 | 449 | } |
| 450 | 450 | if ($d != $o && !preg_match('#[O01lI]#', $d)) { |
@@ -504,14 +504,14 @@ discard block |
||
| 504 | 504 | return false; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $data = [ |
|
| 507 | + $data = [ |
|
| 508 | 508 | 'to' => $this->email(), |
| 509 | 509 | 'template' => 'new_password', |
| 510 | 510 | ]; |
| 511 | 511 | |
| 512 | 512 | $URL = new \MySociety\TheyWorkForYou\Url("userlogin"); |
| 513 | 513 | |
| 514 | - $merge = [ |
|
| 514 | + $merge = [ |
|
| 515 | 515 | 'EMAIL' => $this->email(), |
| 516 | 516 | 'LOGINURL' => "https://" . DOMAIN . $URL->generate(), |
| 517 | 517 | 'PASSWORD' => $this->password(), |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | // Maybe there's a way of fetching these from the DB, |
| 688 | 688 | // so we don't duplicate them here...? |
| 689 | 689 | |
| 690 | - $statuses = ["Viewer", "User", "Moderator", "Administrator", "Superuser"]; |
|
| 690 | + $statuses = ["Viewer", "User", "Moderator", "Administrator", "Superuser"]; |
|
| 691 | 691 | |
| 692 | 692 | return $statuses; |
| 693 | 693 | |
@@ -1031,7 +1031,7 @@ discard block |
||
| 1031 | 1031 | $date_now = gmdate("Y-m-d H:i:s"); |
| 1032 | 1032 | $this->db->query( |
| 1033 | 1033 | "UPDATE users SET lastvisit = :lastvisit WHERE user_id = :user_id", |
| 1034 | - [ ':lastvisit' => $date_now, ':user_id' => $this->user_id() ] |
|
| 1034 | + [':lastvisit' => $date_now, ':user_id' => $this->user_id()] |
|
| 1035 | 1035 | ); |
| 1036 | 1036 | |
| 1037 | 1037 | $this->lastvisit = $date_now; |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | |
| 1428 | 1428 | twfy_debug("THEUSER", "User with ID found to confirm: " . $this->user_id()); |
| 1429 | 1429 | // We'll need these to be set before logging the user in. |
| 1430 | - $this->email = $q['email']; |
|
| 1430 | + $this->email = $q['email']; |
|
| 1431 | 1431 | |
| 1432 | 1432 | // Set that they're confirmed in the DB. |
| 1433 | 1433 | $r = $this->db->query("UPDATE users |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | public $body = ''; |
| 31 | 31 | public $posted = ''; |
| 32 | 32 | public $visible = false; |
| 33 | - public $modflagged = null; // Is a datetime when set. |
|
| 34 | - public $firstname = ''; // Of the person who posted it. |
|
| 33 | + public $modflagged = null; // Is a datetime when set. |
|
| 34 | + public $firstname = ''; // Of the person who posted it. |
|
| 35 | 35 | public $lastname = ''; |
| 36 | 36 | public $url = ''; |
| 37 | 37 | |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | if ($q) { |
| 71 | 71 | |
| 72 | 72 | $this->comment_id = $comment_id; |
| 73 | - $this->user_id = $q['user_id']; |
|
| 73 | + $this->user_id = $q['user_id']; |
|
| 74 | 74 | $this->epobject_id = $q['epobject_id']; |
| 75 | - $this->body = $q['body']; |
|
| 76 | - $this->posted = $q['posted']; |
|
| 77 | - $this->visible = $q['visible']; |
|
| 78 | - $this->modflagged = $q['modflagged']; |
|
| 75 | + $this->body = $q['body']; |
|
| 76 | + $this->posted = $q['posted']; |
|
| 77 | + $this->visible = $q['visible']; |
|
| 78 | + $this->modflagged = $q['modflagged']; |
|
| 79 | 79 | |
| 80 | 80 | // Sets the URL and username for this comment. Duh. |
| 81 | 81 | $this->_set_url(); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if (!$THEUSER->is_able_to('addcomment')) { |
| 145 | - $message = [ |
|
| 145 | + $message = [ |
|
| 146 | 146 | 'title' => 'Sorry', |
| 147 | 147 | 'text' => 'You are not allowed to post annotations.', |
| 148 | 148 | ]; |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | if ($q->success()) { |
| 205 | 205 | // Set the object varibales up. |
| 206 | - $this->comment_id = $q->insert_id(); |
|
| 207 | - $this->user_id = $THEUSER->user_id(); |
|
| 208 | - $this->epobject_id = $data['epobject_id']; |
|
| 209 | - $this->body = $data['body']; |
|
| 210 | - $this->posted = $posted; |
|
| 211 | - $this->visible = 1; |
|
| 206 | + $this->comment_id = $q->insert_id(); |
|
| 207 | + $this->user_id = $THEUSER->user_id(); |
|
| 208 | + $this->epobject_id = $data['epobject_id']; |
|
| 209 | + $this->body = $data['body']; |
|
| 210 | + $this->posted = $posted; |
|
| 211 | + $this->visible = 1; |
|
| 212 | 212 | |
| 213 | 213 | return $this->comment_id(); |
| 214 | 214 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | public function display($format = 'html', $template = 'comments') { |
| 222 | - $data['comments'][0] = [ |
|
| 222 | + $data['comments'][0] = [ |
|
| 223 | 223 | 'comment_id' => $this->comment_id, |
| 224 | 224 | 'user_id' => $this->user_id, |
| 225 | 225 | 'epobject_id' => $this->epobject_id, |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $this->modflagged = $date; |
| 268 | 268 | return true; |
| 269 | 269 | } else { |
| 270 | - $message = [ |
|
| 270 | + $message = [ |
|
| 271 | 271 | 'title' => 'Sorry', |
| 272 | 272 | 'text' => "We couldn't update the annotation's modflag.", |
| 273 | 273 | ]; |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | if ($q->success()) { |
| 290 | 290 | return true; |
| 291 | 291 | } else { |
| 292 | - $message = [ |
|
| 292 | + $message = [ |
|
| 293 | 293 | 'title' => 'Sorry', |
| 294 | 294 | 'text' => "We were unable to delete the annotation.", |
| 295 | 295 | ]; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | } else { |
| 301 | - $message = [ |
|
| 301 | + $message = [ |
|
| 302 | 302 | 'title' => 'Sorry', |
| 303 | 303 | 'text' => "You are not authorised to delete annotations.", |
| 304 | 304 | ]; |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | 'posted' => date('Y-m-d H:i:s', time()), |
| 67 | 67 | 'modflagged' => null, |
| 68 | 68 | 'visible' => 1, |
| 69 | - 'preview' => true, // Extra tag so we know this is just a preview. |
|
| 69 | + 'preview' => true, // Extra tag so we know this is just a preview. |
|
| 70 | 70 | ]; |
| 71 | 71 | |
| 72 | 72 | $COMMENTLIST = new COMMENTLIST(); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $commentId = $comment->create($data); |
| 134 | 134 | |
| 135 | - $page = $this->fetch_page([ 'type' => 'debates', 'id' => '2014-01-01b.1.2' ]); |
|
| 135 | + $page = $this->fetch_page(['type' => 'debates', 'id' => '2014-01-01b.1.2']); |
|
| 136 | 136 | $this->assertStringContainsString('This is a...', $page); |
| 137 | 137 | |
| 138 | 138 | $THEUSER->_update([ |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | 'organisation' => '', |
| 147 | 147 | ]); |
| 148 | 148 | |
| 149 | - $page = $this->fetch_page([ 'type' => 'debates', 'id' => '2014-01-01b.1.2' ]); |
|
| 149 | + $page = $this->fetch_page(['type' => 'debates', 'id' => '2014-01-01b.1.2']); |
|
| 150 | 150 | $this->assertStringNotContainsString('This is a...', $page); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | self::$db->query("UPDATE comments SET user_id = 2 WHERE comment_id = $commentId"); |
| 171 | 171 | |
| 172 | - $page = $this->fetch_page([ 'type' => 'debates', 'id' => '2014-01-01b.1.2' ]); |
|
| 172 | + $page = $this->fetch_page(['type' => 'debates', 'id' => '2014-01-01b.1.2']); |
|
| 173 | 173 | $this->assertStringNotContainsString('This is a...', $page); |
| 174 | 174 | |
| 175 | 175 | self::$db->query("UPDATE comments SET posted = '2024-10-09 12:42:11' WHERE comment_id = $commentId"); |
| 176 | 176 | |
| 177 | - $page = $this->fetch_page([ 'type' => 'debates', 'id' => '2014-01-01b.1.2' ]); |
|
| 177 | + $page = $this->fetch_page(['type' => 'debates', 'id' => '2014-01-01b.1.2']); |
|
| 178 | 178 | $this->assertStringContainsString('This is a...', $page); |
| 179 | 179 | } |
| 180 | 180 | |