@@ -13,91 +13,91 @@ |
||
| 13 | 13 | |
| 14 | 14 | class BlacklistHelper implements IBlacklistHelper |
| 15 | 15 | { |
| 16 | - /** @var HttpHelper */ |
|
| 17 | - private $httpHelper; |
|
| 18 | - /** |
|
| 19 | - * Cache of previously requested usernames |
|
| 20 | - * @var array |
|
| 21 | - */ |
|
| 22 | - private $cache = array(); |
|
| 23 | - /** @var string */ |
|
| 24 | - private $mediawikiWebServiceEndpoint; |
|
| 16 | + /** @var HttpHelper */ |
|
| 17 | + private $httpHelper; |
|
| 18 | + /** |
|
| 19 | + * Cache of previously requested usernames |
|
| 20 | + * @var array |
|
| 21 | + */ |
|
| 22 | + private $cache = array(); |
|
| 23 | + /** @var string */ |
|
| 24 | + private $mediawikiWebServiceEndpoint; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * BlacklistHelper constructor. |
|
| 28 | - * |
|
| 29 | - * @param HttpHelper $httpHelper |
|
| 30 | - * @param string $mediawikiWebServiceEndpoint |
|
| 31 | - */ |
|
| 32 | - public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint) |
|
| 33 | - { |
|
| 34 | - $this->httpHelper = $httpHelper; |
|
| 35 | - $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
| 36 | - } |
|
| 26 | + /** |
|
| 27 | + * BlacklistHelper constructor. |
|
| 28 | + * |
|
| 29 | + * @param HttpHelper $httpHelper |
|
| 30 | + * @param string $mediawikiWebServiceEndpoint |
|
| 31 | + */ |
|
| 32 | + public function __construct(HttpHelper $httpHelper, $mediawikiWebServiceEndpoint) |
|
| 33 | + { |
|
| 34 | + $this->httpHelper = $httpHelper; |
|
| 35 | + $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 40 | - * |
|
| 41 | - * @param string $username |
|
| 42 | - * |
|
| 43 | - * @return false|string False if the username is not blacklisted, else the blacklist entry. |
|
| 44 | - */ |
|
| 45 | - public function isBlacklisted($username) |
|
| 46 | - { |
|
| 47 | - if (isset($this->cache[$username])) { |
|
| 48 | - $result = $this->cache[$username]; |
|
| 49 | - if ($result === false) { |
|
| 50 | - return false; |
|
| 51 | - } |
|
| 38 | + /** |
|
| 39 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 40 | + * |
|
| 41 | + * @param string $username |
|
| 42 | + * |
|
| 43 | + * @return false|string False if the username is not blacklisted, else the blacklist entry. |
|
| 44 | + */ |
|
| 45 | + public function isBlacklisted($username) |
|
| 46 | + { |
|
| 47 | + if (isset($this->cache[$username])) { |
|
| 48 | + $result = $this->cache[$username]; |
|
| 49 | + if ($result === false) { |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - return $result['line']; |
|
| 54 | - } |
|
| 53 | + return $result['line']; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - try { |
|
| 57 | - $result = $this->performWikiLookup($username); |
|
| 58 | - } |
|
| 59 | - catch (CurlException $ex) { |
|
| 60 | - // LOGME log this, but fail gracefully. |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 56 | + try { |
|
| 57 | + $result = $this->performWikiLookup($username); |
|
| 58 | + } |
|
| 59 | + catch (CurlException $ex) { |
|
| 60 | + // LOGME log this, but fail gracefully. |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if ($result['result'] === 'ok') { |
|
| 65 | - // not blacklisted |
|
| 66 | - $this->cache[$username] = false; |
|
| 64 | + if ($result['result'] === 'ok') { |
|
| 65 | + // not blacklisted |
|
| 66 | + $this->cache[$username] = false; |
|
| 67 | 67 | |
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - else { |
|
| 71 | - $this->cache[$username] = $result; |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + else { |
|
| 71 | + $this->cache[$username] = $result; |
|
| 72 | 72 | |
| 73 | - return $result['line']; |
|
| 74 | - } |
|
| 75 | - } |
|
| 73 | + return $result['line']; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Performs a fetch to MediaWiki for the relevant title blacklist entry |
|
| 79 | - * |
|
| 80 | - * @param string $username The username to look up |
|
| 81 | - * |
|
| 82 | - * @return array |
|
| 83 | - * @throws CurlException |
|
| 84 | - */ |
|
| 85 | - private function performWikiLookup($username) |
|
| 86 | - { |
|
| 87 | - $endpoint = $this->mediawikiWebServiceEndpoint; |
|
| 77 | + /** |
|
| 78 | + * Performs a fetch to MediaWiki for the relevant title blacklist entry |
|
| 79 | + * |
|
| 80 | + * @param string $username The username to look up |
|
| 81 | + * |
|
| 82 | + * @return array |
|
| 83 | + * @throws CurlException |
|
| 84 | + */ |
|
| 85 | + private function performWikiLookup($username) |
|
| 86 | + { |
|
| 87 | + $endpoint = $this->mediawikiWebServiceEndpoint; |
|
| 88 | 88 | |
| 89 | - $parameters = array( |
|
| 90 | - 'action' => 'titleblacklist', |
|
| 91 | - 'format' => 'php', |
|
| 92 | - 'tbtitle' => $username, |
|
| 93 | - 'tbaction' => 'new-account', |
|
| 94 | - 'tbnooverride' => true, |
|
| 95 | - ); |
|
| 89 | + $parameters = array( |
|
| 90 | + 'action' => 'titleblacklist', |
|
| 91 | + 'format' => 'php', |
|
| 92 | + 'tbtitle' => $username, |
|
| 93 | + 'tbaction' => 'new-account', |
|
| 94 | + 'tbnooverride' => true, |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - $apiResult = $this->httpHelper->get($endpoint, $parameters); |
|
| 97 | + $apiResult = $this->httpHelper->get($endpoint, $parameters); |
|
| 98 | 98 | |
| 99 | - $data = unserialize($apiResult); |
|
| 99 | + $data = unserialize($apiResult); |
|
| 100 | 100 | |
| 101 | - return $data['titleblacklist']; |
|
| 102 | - } |
|
| 101 | + return $data['titleblacklist']; |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | \ No newline at end of file |
@@ -12,16 +12,16 @@ |
||
| 12 | 12 | |
| 13 | 13 | class FakeBlacklistHelper implements IBlacklistHelper |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 17 | - * |
|
| 18 | - * @param string $username |
|
| 19 | - * |
|
| 20 | - * @return bool |
|
| 21 | - */ |
|
| 22 | - public function isBlacklisted($username) |
|
| 23 | - { |
|
| 24 | - // Short-circuit |
|
| 25 | - return false; |
|
| 26 | - } |
|
| 15 | + /** |
|
| 16 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 17 | + * |
|
| 18 | + * @param string $username |
|
| 19 | + * |
|
| 20 | + * @return bool |
|
| 21 | + */ |
|
| 22 | + public function isBlacklisted($username) |
|
| 23 | + { |
|
| 24 | + // Short-circuit |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -12,21 +12,21 @@ |
||
| 12 | 12 | |
| 13 | 13 | class EmailHelper implements IEmailHelper |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @param string $to |
|
| 17 | - * @param string $subject |
|
| 18 | - * @param string $content |
|
| 19 | - * @param array $headers Extra headers to include |
|
| 20 | - */ |
|
| 21 | - public function sendMail($to, $subject, $content, $headers = array()) |
|
| 22 | - { |
|
| 23 | - $headers['From'] = '[email protected]'; |
|
| 24 | - $headerString = ''; |
|
| 15 | + /** |
|
| 16 | + * @param string $to |
|
| 17 | + * @param string $subject |
|
| 18 | + * @param string $content |
|
| 19 | + * @param array $headers Extra headers to include |
|
| 20 | + */ |
|
| 21 | + public function sendMail($to, $subject, $content, $headers = array()) |
|
| 22 | + { |
|
| 23 | + $headers['From'] = '[email protected]'; |
|
| 24 | + $headerString = ''; |
|
| 25 | 25 | |
| 26 | - foreach ($headers as $header => $headerValue) { |
|
| 27 | - $headerString .= $header . ': ' . $headerValue . "\r\n"; |
|
| 28 | - } |
|
| 26 | + foreach ($headers as $header => $headerValue) { |
|
| 27 | + $headerString .= $header . ': ' . $headerValue . "\r\n"; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - mail($to, $subject, $content, $headerString); |
|
| 31 | - } |
|
| 30 | + mail($to, $subject, $content, $headerString); |
|
| 31 | + } |
|
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | $headerString = ''; |
| 25 | 25 | |
| 26 | 26 | foreach ($headers as $header => $headerValue) { |
| 27 | - $headerString .= $header . ': ' . $headerValue . "\r\n"; |
|
| 27 | + $headerString .= $header.': '.$headerValue."\r\n"; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | mail($to, $subject, $content, $headerString); |
@@ -12,30 +12,30 @@ |
||
| 12 | 12 | |
| 13 | 13 | interface IBanHelper |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Summary of nameIsBanned |
|
| 17 | - * |
|
| 18 | - * @param string $name The name to test if is banned. |
|
| 19 | - * |
|
| 20 | - * @return Ban |
|
| 21 | - */ |
|
| 22 | - public function nameIsBanned($name); |
|
| 15 | + /** |
|
| 16 | + * Summary of nameIsBanned |
|
| 17 | + * |
|
| 18 | + * @param string $name The name to test if is banned. |
|
| 19 | + * |
|
| 20 | + * @return Ban |
|
| 21 | + */ |
|
| 22 | + public function nameIsBanned($name); |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Summary of emailIsBanned |
|
| 26 | - * |
|
| 27 | - * @param string $email |
|
| 28 | - * |
|
| 29 | - * @return Ban |
|
| 30 | - */ |
|
| 31 | - public function emailIsBanned($email); |
|
| 24 | + /** |
|
| 25 | + * Summary of emailIsBanned |
|
| 26 | + * |
|
| 27 | + * @param string $email |
|
| 28 | + * |
|
| 29 | + * @return Ban |
|
| 30 | + */ |
|
| 31 | + public function emailIsBanned($email); |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Summary of ipIsBanned |
|
| 35 | - * |
|
| 36 | - * @param string $ip |
|
| 37 | - * |
|
| 38 | - * @return Ban |
|
| 39 | - */ |
|
| 40 | - public function ipIsBanned($ip); |
|
| 33 | + /** |
|
| 34 | + * Summary of ipIsBanned |
|
| 35 | + * |
|
| 36 | + * @param string $ip |
|
| 37 | + * |
|
| 38 | + * @return Ban |
|
| 39 | + */ |
|
| 40 | + public function ipIsBanned($ip); |
|
| 41 | 41 | } |
@@ -17,15 +17,15 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | interface IEmailHelper |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Sends an email to the specified email address. |
|
| 22 | - * |
|
| 23 | - * @param string $to |
|
| 24 | - * @param string $subject |
|
| 25 | - * @param string $content |
|
| 26 | - * @param array $headers Extra headers to include |
|
| 27 | - * |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function sendMail($to, $subject, $content, $headers = array()); |
|
| 20 | + /** |
|
| 21 | + * Sends an email to the specified email address. |
|
| 22 | + * |
|
| 23 | + * @param string $to |
|
| 24 | + * @param string $subject |
|
| 25 | + * @param string $content |
|
| 26 | + * @param array $headers Extra headers to include |
|
| 27 | + * |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function sendMail($to, $subject, $content, $headers = array()); |
|
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -10,12 +10,12 @@ |
||
| 10 | 10 | |
| 11 | 11 | interface IBlacklistHelper |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 15 | - * |
|
| 16 | - * @param string $username |
|
| 17 | - * |
|
| 18 | - * @return bool |
|
| 19 | - */ |
|
| 20 | - public function isBlacklisted($username); |
|
| 13 | + /** |
|
| 14 | + * Returns a value indicating whether the provided username is blacklisted by the on-wiki title blacklist |
|
| 15 | + * |
|
| 16 | + * @param string $username |
|
| 17 | + * |
|
| 18 | + * @return bool |
|
| 19 | + */ |
|
| 20 | + public function isBlacklisted($username); |
|
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -10,16 +10,16 @@ |
||
| 10 | 10 | |
| 11 | 11 | interface ITypeAheadHelper |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @param string $class CSS class to apply this typeahead to. |
|
| 15 | - * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 16 | - * |
|
| 17 | - * @return void |
|
| 18 | - */ |
|
| 19 | - public function defineTypeAheadSource($class, callable $generator); |
|
| 13 | + /** |
|
| 14 | + * @param string $class CSS class to apply this typeahead to. |
|
| 15 | + * @param callable $generator Generator function taking no arguments to return an array of strings. |
|
| 16 | + * |
|
| 17 | + * @return void |
|
| 18 | + */ |
|
| 19 | + public function defineTypeAheadSource($class, callable $generator); |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @return string HTML fragment containing a JS block for typeaheads. |
|
| 23 | - */ |
|
| 24 | - public function getTypeAheadScriptBlock(); |
|
| 21 | + /** |
|
| 22 | + * @return string HTML fragment containing a JS block for typeaheads. |
|
| 23 | + */ |
|
| 24 | + public function getTypeAheadScriptBlock(); |
|
| 25 | 25 | } |
| 26 | 26 | \ No newline at end of file |
@@ -22,73 +22,73 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Notification extends DataObject |
| 24 | 24 | { |
| 25 | - private $date; |
|
| 26 | - private $type; |
|
| 27 | - private $text; |
|
| 25 | + private $date; |
|
| 26 | + private $type; |
|
| 27 | + private $text; |
|
| 28 | 28 | |
| 29 | - public function delete() |
|
| 30 | - { |
|
| 31 | - throw new Exception("You shouldn't be doing this..."); |
|
| 32 | - } |
|
| 29 | + public function delete() |
|
| 30 | + { |
|
| 31 | + throw new Exception("You shouldn't be doing this..."); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function save() |
|
| 35 | - { |
|
| 36 | - if ($this->isNew()) { |
|
| 37 | - // insert |
|
| 38 | - $statement = $this->dbObject->prepare("INSERT INTO notification ( type, text ) VALUES ( :type, :text );"); |
|
| 39 | - $statement->bindValue(":type", $this->type); |
|
| 40 | - $statement->bindValue(":text", $this->text); |
|
| 34 | + public function save() |
|
| 35 | + { |
|
| 36 | + if ($this->isNew()) { |
|
| 37 | + // insert |
|
| 38 | + $statement = $this->dbObject->prepare("INSERT INTO notification ( type, text ) VALUES ( :type, :text );"); |
|
| 39 | + $statement->bindValue(":type", $this->type); |
|
| 40 | + $statement->bindValue(":text", $this->text); |
|
| 41 | 41 | |
| 42 | - if ($statement->execute()) { |
|
| 43 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 44 | - } |
|
| 45 | - else { |
|
| 46 | - throw new Exception($statement->errorInfo()); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - else { |
|
| 50 | - throw new Exception("You shouldn't be doing this..."); |
|
| 51 | - } |
|
| 52 | - } |
|
| 42 | + if ($statement->execute()) { |
|
| 43 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 44 | + } |
|
| 45 | + else { |
|
| 46 | + throw new Exception($statement->errorInfo()); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + else { |
|
| 50 | + throw new Exception("You shouldn't be doing this..."); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getDate() |
|
| 55 | - { |
|
| 56 | - return new DateTimeImmutable($this->date); |
|
| 57 | - } |
|
| 54 | + public function getDate() |
|
| 55 | + { |
|
| 56 | + return new DateTimeImmutable($this->date); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @return int |
|
| 61 | - */ |
|
| 62 | - public function getType() |
|
| 63 | - { |
|
| 64 | - return $this->type; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * @return int |
|
| 61 | + */ |
|
| 62 | + public function getType() |
|
| 63 | + { |
|
| 64 | + return $this->type; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @return string |
|
| 69 | - */ |
|
| 70 | - public function getText() |
|
| 71 | - { |
|
| 72 | - return $this->text; |
|
| 73 | - } |
|
| 67 | + /** |
|
| 68 | + * @return string |
|
| 69 | + */ |
|
| 70 | + public function getText() |
|
| 71 | + { |
|
| 72 | + return $this->text; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Summary of setType |
|
| 77 | - * |
|
| 78 | - * @param int $type |
|
| 79 | - */ |
|
| 80 | - public function setType($type) |
|
| 81 | - { |
|
| 82 | - $this->type = $type; |
|
| 83 | - } |
|
| 75 | + /** |
|
| 76 | + * Summary of setType |
|
| 77 | + * |
|
| 78 | + * @param int $type |
|
| 79 | + */ |
|
| 80 | + public function setType($type) |
|
| 81 | + { |
|
| 82 | + $this->type = $type; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Summary of setText |
|
| 87 | - * |
|
| 88 | - * @param string $text |
|
| 89 | - */ |
|
| 90 | - public function setText($text) |
|
| 91 | - { |
|
| 92 | - $this->text = $text; |
|
| 93 | - } |
|
| 85 | + /** |
|
| 86 | + * Summary of setText |
|
| 87 | + * |
|
| 88 | + * @param string $text |
|
| 89 | + */ |
|
| 90 | + public function setText($text) |
|
| 91 | + { |
|
| 92 | + $this->text = $text; |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -404,11 +404,11 @@ |
||
| 404 | 404 | public function getRevealHash() |
| 405 | 405 | { |
| 406 | 406 | $data = $this->id // unique per request |
| 407 | - . '|' . $this->ip // } |
|
| 408 | - . '|' . $this->forwardedip // } private data not known to those without access |
|
| 409 | - . '|' . $this->useragent // } |
|
| 410 | - . '|' . $this->email // } |
|
| 411 | - . '|' . $this->status; // to rudimentarily invalidate the token on status change |
|
| 407 | + . '|'.$this->ip // } |
|
| 408 | + . '|'.$this->forwardedip // } private data not known to those without access |
|
| 409 | + . '|'.$this->useragent // } |
|
| 410 | + . '|'.$this->email // } |
|
| 411 | + . '|'.$this->status; // to rudimentarily invalidate the token on status change |
|
| 412 | 412 | |
| 413 | 413 | return hash('sha256', $data); |
| 414 | 414 | } |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Request extends DataObject |
| 23 | 23 | { |
| 24 | - private $email; |
|
| 25 | - private $ip; |
|
| 26 | - private $name; |
|
| 27 | - /** @var string|null */ |
|
| 28 | - private $comment; |
|
| 29 | - private $status = "Open"; |
|
| 30 | - private $date; |
|
| 31 | - private $emailsent = 0; |
|
| 32 | - private $emailconfirm; |
|
| 33 | - /** @var int|null */ |
|
| 34 | - private $reserved = null; |
|
| 35 | - private $useragent; |
|
| 36 | - private $forwardedip; |
|
| 37 | - private $hasComments = false; |
|
| 38 | - private $hasCommentsResolved = false; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @throws Exception |
|
| 42 | - */ |
|
| 43 | - public function save() |
|
| 44 | - { |
|
| 45 | - if ($this->isNew()) { |
|
| 46 | - // insert |
|
| 47 | - $statement = $this->dbObject->prepare(<<<SQL |
|
| 24 | + private $email; |
|
| 25 | + private $ip; |
|
| 26 | + private $name; |
|
| 27 | + /** @var string|null */ |
|
| 28 | + private $comment; |
|
| 29 | + private $status = "Open"; |
|
| 30 | + private $date; |
|
| 31 | + private $emailsent = 0; |
|
| 32 | + private $emailconfirm; |
|
| 33 | + /** @var int|null */ |
|
| 34 | + private $reserved = null; |
|
| 35 | + private $useragent; |
|
| 36 | + private $forwardedip; |
|
| 37 | + private $hasComments = false; |
|
| 38 | + private $hasCommentsResolved = false; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @throws Exception |
|
| 42 | + */ |
|
| 43 | + public function save() |
|
| 44 | + { |
|
| 45 | + if ($this->isNew()) { |
|
| 46 | + // insert |
|
| 47 | + $statement = $this->dbObject->prepare(<<<SQL |
|
| 48 | 48 | INSERT INTO `request` ( |
| 49 | 49 | email, ip, name, comment, status, date, emailsent, |
| 50 | 50 | emailconfirm, reserved, useragent, forwardedip |
@@ -53,28 +53,28 @@ discard block |
||
| 53 | 53 | :emailconfirm, :reserved, :useragent, :forwardedip |
| 54 | 54 | ); |
| 55 | 55 | SQL |
| 56 | - ); |
|
| 57 | - $statement->bindValue(':email', $this->email); |
|
| 58 | - $statement->bindValue(':ip', $this->ip); |
|
| 59 | - $statement->bindValue(':name', $this->name); |
|
| 60 | - $statement->bindValue(':comment', $this->comment); |
|
| 61 | - $statement->bindValue(':status', $this->status); |
|
| 62 | - $statement->bindValue(':emailsent', $this->emailsent); |
|
| 63 | - $statement->bindValue(':emailconfirm', $this->emailconfirm); |
|
| 64 | - $statement->bindValue(':reserved', $this->reserved); |
|
| 65 | - $statement->bindValue(':useragent', $this->useragent); |
|
| 66 | - $statement->bindValue(':forwardedip', $this->forwardedip); |
|
| 67 | - |
|
| 68 | - if ($statement->execute()) { |
|
| 69 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 70 | - } |
|
| 71 | - else { |
|
| 72 | - throw new Exception($statement->errorInfo()); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - else { |
|
| 76 | - // update |
|
| 77 | - $statement = $this->dbObject->prepare(<<<SQL |
|
| 56 | + ); |
|
| 57 | + $statement->bindValue(':email', $this->email); |
|
| 58 | + $statement->bindValue(':ip', $this->ip); |
|
| 59 | + $statement->bindValue(':name', $this->name); |
|
| 60 | + $statement->bindValue(':comment', $this->comment); |
|
| 61 | + $statement->bindValue(':status', $this->status); |
|
| 62 | + $statement->bindValue(':emailsent', $this->emailsent); |
|
| 63 | + $statement->bindValue(':emailconfirm', $this->emailconfirm); |
|
| 64 | + $statement->bindValue(':reserved', $this->reserved); |
|
| 65 | + $statement->bindValue(':useragent', $this->useragent); |
|
| 66 | + $statement->bindValue(':forwardedip', $this->forwardedip); |
|
| 67 | + |
|
| 68 | + if ($statement->execute()) { |
|
| 69 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
| 70 | + } |
|
| 71 | + else { |
|
| 72 | + throw new Exception($statement->errorInfo()); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + else { |
|
| 76 | + // update |
|
| 77 | + $statement = $this->dbObject->prepare(<<<SQL |
|
| 78 | 78 | UPDATE `request` SET |
| 79 | 79 | status = :status, |
| 80 | 80 | emailsent = :emailsent, |
@@ -83,163 +83,163 @@ discard block |
||
| 83 | 83 | updateversion = updateversion + 1 |
| 84 | 84 | WHERE id = :id AND updateversion = :updateversion; |
| 85 | 85 | SQL |
| 86 | - ); |
|
| 87 | - |
|
| 88 | - $statement->bindValue(':id', $this->id); |
|
| 89 | - $statement->bindValue(':updateversion', $this->updateversion); |
|
| 90 | - |
|
| 91 | - $statement->bindValue(':status', $this->status); |
|
| 92 | - $statement->bindValue(':emailsent', $this->emailsent); |
|
| 93 | - $statement->bindValue(':emailconfirm', $this->emailconfirm); |
|
| 94 | - $statement->bindValue(':reserved', $this->reserved); |
|
| 95 | - |
|
| 96 | - if (!$statement->execute()) { |
|
| 97 | - throw new Exception($statement->errorInfo()); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - if ($statement->rowCount() !== 1) { |
|
| 101 | - throw new OptimisticLockFailedException(); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - $this->updateversion++; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public function getIp() |
|
| 112 | - { |
|
| 113 | - return $this->ip; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @param string $ip |
|
| 118 | - */ |
|
| 119 | - public function setIp($ip) |
|
| 120 | - { |
|
| 121 | - $this->ip = $ip; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @return string |
|
| 126 | - */ |
|
| 127 | - public function getName() |
|
| 128 | - { |
|
| 129 | - return $this->name; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @param string $name |
|
| 134 | - */ |
|
| 135 | - public function setName($name) |
|
| 136 | - { |
|
| 137 | - $this->name = $name; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return string|null |
|
| 142 | - */ |
|
| 143 | - public function getComment() |
|
| 144 | - { |
|
| 145 | - return $this->comment; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param string $comment |
|
| 150 | - */ |
|
| 151 | - public function setComment($comment) |
|
| 152 | - { |
|
| 153 | - $this->comment = $comment; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @return string |
|
| 158 | - */ |
|
| 159 | - public function getStatus() |
|
| 160 | - { |
|
| 161 | - return $this->status; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @param string $status |
|
| 166 | - */ |
|
| 167 | - public function setStatus($status) |
|
| 168 | - { |
|
| 169 | - $this->status = $status; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * Returns the time the request was first submitted |
|
| 174 | - * |
|
| 175 | - * @return DateTimeImmutable |
|
| 176 | - */ |
|
| 177 | - public function getDate() |
|
| 178 | - { |
|
| 179 | - return new DateTimeImmutable($this->date); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * @return bool |
|
| 184 | - */ |
|
| 185 | - public function getEmailSent() |
|
| 186 | - { |
|
| 187 | - return $this->emailsent == "1"; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * @param bool $emailSent |
|
| 192 | - */ |
|
| 193 | - public function setEmailSent($emailSent) |
|
| 194 | - { |
|
| 195 | - $this->emailsent = $emailSent ? 1 : 0; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * @return int|null |
|
| 200 | - */ |
|
| 201 | - public function getReserved() |
|
| 202 | - { |
|
| 203 | - return $this->reserved; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @param int|null $reserved |
|
| 208 | - */ |
|
| 209 | - public function setReserved($reserved) |
|
| 210 | - { |
|
| 211 | - $this->reserved = $reserved; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * @return string |
|
| 216 | - */ |
|
| 217 | - public function getUserAgent() |
|
| 218 | - { |
|
| 219 | - return $this->useragent; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * @param string $useragent |
|
| 224 | - */ |
|
| 225 | - public function setUserAgent($useragent) |
|
| 226 | - { |
|
| 227 | - $this->useragent = $useragent; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * @return string|null |
|
| 232 | - */ |
|
| 233 | - public function getForwardedIp() |
|
| 234 | - { |
|
| 235 | - return $this->forwardedip; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * @param string|null $forwardedip |
|
| 240 | - */ |
|
| 241 | - public function setForwardedIp($forwardedip) |
|
| 242 | - { |
|
| 86 | + ); |
|
| 87 | + |
|
| 88 | + $statement->bindValue(':id', $this->id); |
|
| 89 | + $statement->bindValue(':updateversion', $this->updateversion); |
|
| 90 | + |
|
| 91 | + $statement->bindValue(':status', $this->status); |
|
| 92 | + $statement->bindValue(':emailsent', $this->emailsent); |
|
| 93 | + $statement->bindValue(':emailconfirm', $this->emailconfirm); |
|
| 94 | + $statement->bindValue(':reserved', $this->reserved); |
|
| 95 | + |
|
| 96 | + if (!$statement->execute()) { |
|
| 97 | + throw new Exception($statement->errorInfo()); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + if ($statement->rowCount() !== 1) { |
|
| 101 | + throw new OptimisticLockFailedException(); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + $this->updateversion++; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public function getIp() |
|
| 112 | + { |
|
| 113 | + return $this->ip; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @param string $ip |
|
| 118 | + */ |
|
| 119 | + public function setIp($ip) |
|
| 120 | + { |
|
| 121 | + $this->ip = $ip; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @return string |
|
| 126 | + */ |
|
| 127 | + public function getName() |
|
| 128 | + { |
|
| 129 | + return $this->name; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @param string $name |
|
| 134 | + */ |
|
| 135 | + public function setName($name) |
|
| 136 | + { |
|
| 137 | + $this->name = $name; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return string|null |
|
| 142 | + */ |
|
| 143 | + public function getComment() |
|
| 144 | + { |
|
| 145 | + return $this->comment; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @param string $comment |
|
| 150 | + */ |
|
| 151 | + public function setComment($comment) |
|
| 152 | + { |
|
| 153 | + $this->comment = $comment; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @return string |
|
| 158 | + */ |
|
| 159 | + public function getStatus() |
|
| 160 | + { |
|
| 161 | + return $this->status; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @param string $status |
|
| 166 | + */ |
|
| 167 | + public function setStatus($status) |
|
| 168 | + { |
|
| 169 | + $this->status = $status; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * Returns the time the request was first submitted |
|
| 174 | + * |
|
| 175 | + * @return DateTimeImmutable |
|
| 176 | + */ |
|
| 177 | + public function getDate() |
|
| 178 | + { |
|
| 179 | + return new DateTimeImmutable($this->date); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * @return bool |
|
| 184 | + */ |
|
| 185 | + public function getEmailSent() |
|
| 186 | + { |
|
| 187 | + return $this->emailsent == "1"; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * @param bool $emailSent |
|
| 192 | + */ |
|
| 193 | + public function setEmailSent($emailSent) |
|
| 194 | + { |
|
| 195 | + $this->emailsent = $emailSent ? 1 : 0; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * @return int|null |
|
| 200 | + */ |
|
| 201 | + public function getReserved() |
|
| 202 | + { |
|
| 203 | + return $this->reserved; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @param int|null $reserved |
|
| 208 | + */ |
|
| 209 | + public function setReserved($reserved) |
|
| 210 | + { |
|
| 211 | + $this->reserved = $reserved; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * @return string |
|
| 216 | + */ |
|
| 217 | + public function getUserAgent() |
|
| 218 | + { |
|
| 219 | + return $this->useragent; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * @param string $useragent |
|
| 224 | + */ |
|
| 225 | + public function setUserAgent($useragent) |
|
| 226 | + { |
|
| 227 | + $this->useragent = $useragent; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * @return string|null |
|
| 232 | + */ |
|
| 233 | + public function getForwardedIp() |
|
| 234 | + { |
|
| 235 | + return $this->forwardedip; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * @param string|null $forwardedip |
|
| 240 | + */ |
|
| 241 | + public function setForwardedIp($forwardedip) |
|
| 242 | + { |
|
| 243 | 243 | // Verify that the XFF chain only contains valid IP addresses, and silently discard anything that isn't. |
| 244 | 244 | |
| 245 | 245 | $xff = explode(',', $forwardedip); |
@@ -253,83 +253,83 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | $this->forwardedip = implode(", ", $valid); |
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * @return bool |
|
| 260 | - */ |
|
| 261 | - public function hasComments() |
|
| 262 | - { |
|
| 263 | - if ($this->hasCommentsResolved) { |
|
| 264 | - return $this->hasComments; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if ($this->comment != "") { |
|
| 268 | - $this->hasComments = true; |
|
| 269 | - $this->hasCommentsResolved = true; |
|
| 270 | - |
|
| 271 | - return true; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - $commentsQuery = $this->dbObject->prepare("SELECT COUNT(*) AS num FROM comment WHERE request = :id;"); |
|
| 275 | - $commentsQuery->bindValue(":id", $this->id); |
|
| 276 | - |
|
| 277 | - $commentsQuery->execute(); |
|
| 278 | - |
|
| 279 | - $this->hasComments = ($commentsQuery->fetchColumn() != 0); |
|
| 280 | - $this->hasCommentsResolved = true; |
|
| 281 | - |
|
| 282 | - return $this->hasComments; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * @return string |
|
| 287 | - */ |
|
| 288 | - public function getEmailConfirm() |
|
| 289 | - { |
|
| 290 | - return $this->emailconfirm; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @param string $emailconfirm |
|
| 295 | - */ |
|
| 296 | - public function setEmailConfirm($emailconfirm) |
|
| 297 | - { |
|
| 298 | - $this->emailconfirm = $emailconfirm; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - public function generateEmailConfirmationHash() |
|
| 302 | - { |
|
| 303 | - $this->emailconfirm = bin2hex(openssl_random_pseudo_bytes(16)); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * @return string|null |
|
| 308 | - */ |
|
| 309 | - public function getEmail() |
|
| 310 | - { |
|
| 311 | - return $this->email; |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * @param string|null $email |
|
| 316 | - */ |
|
| 317 | - public function setEmail($email) |
|
| 318 | - { |
|
| 319 | - $this->email = $email; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * @return string |
|
| 324 | - * @throws Exception |
|
| 325 | - */ |
|
| 326 | - public function getClosureReason() |
|
| 327 | - { |
|
| 328 | - if ($this->status != 'Closed') { |
|
| 329 | - throw new Exception("Can't get closure reason for open request."); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - $statement = $this->dbObject->prepare(<<<SQL |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * @return bool |
|
| 260 | + */ |
|
| 261 | + public function hasComments() |
|
| 262 | + { |
|
| 263 | + if ($this->hasCommentsResolved) { |
|
| 264 | + return $this->hasComments; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if ($this->comment != "") { |
|
| 268 | + $this->hasComments = true; |
|
| 269 | + $this->hasCommentsResolved = true; |
|
| 270 | + |
|
| 271 | + return true; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + $commentsQuery = $this->dbObject->prepare("SELECT COUNT(*) AS num FROM comment WHERE request = :id;"); |
|
| 275 | + $commentsQuery->bindValue(":id", $this->id); |
|
| 276 | + |
|
| 277 | + $commentsQuery->execute(); |
|
| 278 | + |
|
| 279 | + $this->hasComments = ($commentsQuery->fetchColumn() != 0); |
|
| 280 | + $this->hasCommentsResolved = true; |
|
| 281 | + |
|
| 282 | + return $this->hasComments; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * @return string |
|
| 287 | + */ |
|
| 288 | + public function getEmailConfirm() |
|
| 289 | + { |
|
| 290 | + return $this->emailconfirm; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @param string $emailconfirm |
|
| 295 | + */ |
|
| 296 | + public function setEmailConfirm($emailconfirm) |
|
| 297 | + { |
|
| 298 | + $this->emailconfirm = $emailconfirm; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + public function generateEmailConfirmationHash() |
|
| 302 | + { |
|
| 303 | + $this->emailconfirm = bin2hex(openssl_random_pseudo_bytes(16)); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * @return string|null |
|
| 308 | + */ |
|
| 309 | + public function getEmail() |
|
| 310 | + { |
|
| 311 | + return $this->email; |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * @param string|null $email |
|
| 316 | + */ |
|
| 317 | + public function setEmail($email) |
|
| 318 | + { |
|
| 319 | + $this->email = $email; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * @return string |
|
| 324 | + * @throws Exception |
|
| 325 | + */ |
|
| 326 | + public function getClosureReason() |
|
| 327 | + { |
|
| 328 | + if ($this->status != 'Closed') { |
|
| 329 | + throw new Exception("Can't get closure reason for open request."); |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + $statement = $this->dbObject->prepare(<<<SQL |
|
| 333 | 333 | SELECT closes.mail_desc |
| 334 | 334 | FROM log |
| 335 | 335 | INNER JOIN closes ON log.action = closes.closes |
@@ -339,25 +339,25 @@ discard block |
||
| 339 | 339 | ORDER BY log.timestamp DESC |
| 340 | 340 | LIMIT 1; |
| 341 | 341 | SQL |
| 342 | - ); |
|
| 343 | - |
|
| 344 | - $statement->bindValue(":requestId", $this->id); |
|
| 345 | - $statement->execute(); |
|
| 346 | - $reason = $statement->fetchColumn(); |
|
| 347 | - |
|
| 348 | - return $reason; |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * Gets a value indicating whether the request was closed as created or not. |
|
| 353 | - */ |
|
| 354 | - public function getWasCreated() |
|
| 355 | - { |
|
| 356 | - if ($this->status != 'Closed') { |
|
| 357 | - throw new Exception("Can't get closure reason for open request."); |
|
| 358 | - } |
|
| 342 | + ); |
|
| 343 | + |
|
| 344 | + $statement->bindValue(":requestId", $this->id); |
|
| 345 | + $statement->execute(); |
|
| 346 | + $reason = $statement->fetchColumn(); |
|
| 347 | + |
|
| 348 | + return $reason; |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * Gets a value indicating whether the request was closed as created or not. |
|
| 353 | + */ |
|
| 354 | + public function getWasCreated() |
|
| 355 | + { |
|
| 356 | + if ($this->status != 'Closed') { |
|
| 357 | + throw new Exception("Can't get closure reason for open request."); |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - $statement = $this->dbObject->prepare(<<<SQL |
|
| 360 | + $statement = $this->dbObject->prepare(<<<SQL |
|
| 361 | 361 | SELECT emailtemplate.oncreated, log.action |
| 362 | 362 | FROM log |
| 363 | 363 | LEFT JOIN emailtemplate ON CONCAT('Closed ', emailtemplate.id) = log.action |
@@ -367,60 +367,60 @@ discard block |
||
| 367 | 367 | ORDER BY log.timestamp DESC |
| 368 | 368 | LIMIT 1; |
| 369 | 369 | SQL |
| 370 | - ); |
|
| 371 | - |
|
| 372 | - $statement->bindValue(":requestId", $this->id); |
|
| 373 | - $statement->execute(); |
|
| 374 | - $onCreated = $statement->fetchColumn(0); |
|
| 375 | - $logAction = $statement->fetchColumn(1); |
|
| 376 | - $statement->closeCursor(); |
|
| 377 | - |
|
| 378 | - if ($onCreated === null) { |
|
| 379 | - return $logAction === "Closed custom-y"; |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - return (bool)$onCreated; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * @return DateTime |
|
| 387 | - */ |
|
| 388 | - public function getClosureDate() |
|
| 389 | - { |
|
| 390 | - $logQuery = $this->dbObject->prepare(<<<SQL |
|
| 370 | + ); |
|
| 371 | + |
|
| 372 | + $statement->bindValue(":requestId", $this->id); |
|
| 373 | + $statement->execute(); |
|
| 374 | + $onCreated = $statement->fetchColumn(0); |
|
| 375 | + $logAction = $statement->fetchColumn(1); |
|
| 376 | + $statement->closeCursor(); |
|
| 377 | + |
|
| 378 | + if ($onCreated === null) { |
|
| 379 | + return $logAction === "Closed custom-y"; |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + return (bool)$onCreated; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * @return DateTime |
|
| 387 | + */ |
|
| 388 | + public function getClosureDate() |
|
| 389 | + { |
|
| 390 | + $logQuery = $this->dbObject->prepare(<<<SQL |
|
| 391 | 391 | SELECT timestamp FROM log |
| 392 | 392 | WHERE objectid = :request AND objecttype = 'Request' AND action LIKE 'Closed%' |
| 393 | 393 | ORDER BY timestamp DESC LIMIT 1; |
| 394 | 394 | SQL |
| 395 | - ); |
|
| 396 | - $logQuery->bindValue(":request", $this->getId()); |
|
| 397 | - $logQuery->execute(); |
|
| 398 | - $logTime = $logQuery->fetchColumn(); |
|
| 399 | - $logQuery->closeCursor(); |
|
| 400 | - |
|
| 401 | - return new DateTime($logTime); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * Returns a hash based on data within this request which can be generated easily from the data to be used to reveal |
|
| 406 | - * data to unauthorised* users. |
|
| 407 | - * |
|
| 408 | - * *:Not tool admins, check users, or the reserving user. |
|
| 409 | - * |
|
| 410 | - * @return string |
|
| 411 | - * |
|
| 412 | - * @todo future work to make invalidation better. Possibly move to the database and invalidate on relevant events? |
|
| 413 | - * Maybe depend on the last logged action timestamp? |
|
| 414 | - */ |
|
| 415 | - public function getRevealHash() |
|
| 416 | - { |
|
| 417 | - $data = $this->id // unique per request |
|
| 418 | - . '|' . $this->ip // } |
|
| 419 | - . '|' . $this->forwardedip // } private data not known to those without access |
|
| 420 | - . '|' . $this->useragent // } |
|
| 421 | - . '|' . $this->email // } |
|
| 422 | - . '|' . $this->status; // to rudimentarily invalidate the token on status change |
|
| 423 | - |
|
| 424 | - return hash('sha256', $data); |
|
| 425 | - } |
|
| 395 | + ); |
|
| 396 | + $logQuery->bindValue(":request", $this->getId()); |
|
| 397 | + $logQuery->execute(); |
|
| 398 | + $logTime = $logQuery->fetchColumn(); |
|
| 399 | + $logQuery->closeCursor(); |
|
| 400 | + |
|
| 401 | + return new DateTime($logTime); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * Returns a hash based on data within this request which can be generated easily from the data to be used to reveal |
|
| 406 | + * data to unauthorised* users. |
|
| 407 | + * |
|
| 408 | + * *:Not tool admins, check users, or the reserving user. |
|
| 409 | + * |
|
| 410 | + * @return string |
|
| 411 | + * |
|
| 412 | + * @todo future work to make invalidation better. Possibly move to the database and invalidate on relevant events? |
|
| 413 | + * Maybe depend on the last logged action timestamp? |
|
| 414 | + */ |
|
| 415 | + public function getRevealHash() |
|
| 416 | + { |
|
| 417 | + $data = $this->id // unique per request |
|
| 418 | + . '|' . $this->ip // } |
|
| 419 | + . '|' . $this->forwardedip // } private data not known to those without access |
|
| 420 | + . '|' . $this->useragent // } |
|
| 421 | + . '|' . $this->email // } |
|
| 422 | + . '|' . $this->status; // to rudimentarily invalidate the token on status change |
|
| 423 | + |
|
| 424 | + return hash('sha256', $data); |
|
| 425 | + } |
|
| 426 | 426 | } |