@@ -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 | } |
@@ -18,101 +18,101 @@ |
||
18 | 18 | */ |
19 | 19 | class AntiSpoofCache extends DataObject |
20 | 20 | { |
21 | - /** @var string */ |
|
22 | - protected $username; |
|
23 | - /** @var string */ |
|
24 | - protected $data; |
|
25 | - /** @var string */ |
|
26 | - protected $timestamp; |
|
27 | - |
|
28 | - /** |
|
29 | - * @param string $username |
|
30 | - * @param PdoDatabase $database |
|
31 | - * |
|
32 | - * @return AntiSpoofCache|false |
|
33 | - */ |
|
34 | - public static function getByUsername($username, PdoDatabase $database) |
|
35 | - { |
|
36 | - $statement = $database->prepare(<<<SQL |
|
21 | + /** @var string */ |
|
22 | + protected $username; |
|
23 | + /** @var string */ |
|
24 | + protected $data; |
|
25 | + /** @var string */ |
|
26 | + protected $timestamp; |
|
27 | + |
|
28 | + /** |
|
29 | + * @param string $username |
|
30 | + * @param PdoDatabase $database |
|
31 | + * |
|
32 | + * @return AntiSpoofCache|false |
|
33 | + */ |
|
34 | + public static function getByUsername($username, PdoDatabase $database) |
|
35 | + { |
|
36 | + $statement = $database->prepare(<<<SQL |
|
37 | 37 | SELECT * |
38 | 38 | FROM antispoofcache |
39 | 39 | WHERE username = :id AND timestamp > date_sub(now(), INTERVAL 3 HOUR) |
40 | 40 | LIMIT 1 |
41 | 41 | SQL |
42 | - ); |
|
43 | - $statement->bindValue(":id", $username); |
|
44 | - |
|
45 | - $statement->execute(); |
|
46 | - |
|
47 | - $resultObject = $statement->fetchObject(get_called_class()); |
|
48 | - |
|
49 | - if ($resultObject != false) { |
|
50 | - $resultObject->setDatabase($database); |
|
51 | - } |
|
52 | - |
|
53 | - return $resultObject; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getUsername() |
|
60 | - { |
|
61 | - return $this->username; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param string $username |
|
66 | - */ |
|
67 | - public function setUsername($username) |
|
68 | - { |
|
69 | - $this->username = $username; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function getData() |
|
76 | - { |
|
77 | - return $this->data; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $data |
|
82 | - */ |
|
83 | - public function setData($data) |
|
84 | - { |
|
85 | - $this->data = $data; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @return DateTimeImmutable |
|
90 | - */ |
|
91 | - public function getTimestamp() |
|
92 | - { |
|
93 | - return new DateTimeImmutable($this->timestamp); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @throws Exception |
|
98 | - */ |
|
99 | - public function save() |
|
100 | - { |
|
101 | - if ($this->isNew()) { |
|
102 | - // insert |
|
103 | - // clear old data first |
|
104 | - $this->dbObject->exec("DELETE FROM antispoofcache WHERE timestamp < date_sub(now(), INTERVAL 3 HOUR);"); |
|
105 | - |
|
106 | - $statement = $this->dbObject->prepare("INSERT INTO antispoofcache (username, data) VALUES (:username, :data);"); |
|
107 | - $statement->bindValue(":username", $this->username); |
|
108 | - $statement->bindValue(":data", $this->data); |
|
109 | - |
|
110 | - if ($statement->execute()) { |
|
111 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
112 | - } |
|
113 | - else { |
|
114 | - throw new Exception($statement->errorInfo()); |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
42 | + ); |
|
43 | + $statement->bindValue(":id", $username); |
|
44 | + |
|
45 | + $statement->execute(); |
|
46 | + |
|
47 | + $resultObject = $statement->fetchObject(get_called_class()); |
|
48 | + |
|
49 | + if ($resultObject != false) { |
|
50 | + $resultObject->setDatabase($database); |
|
51 | + } |
|
52 | + |
|
53 | + return $resultObject; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getUsername() |
|
60 | + { |
|
61 | + return $this->username; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param string $username |
|
66 | + */ |
|
67 | + public function setUsername($username) |
|
68 | + { |
|
69 | + $this->username = $username; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function getData() |
|
76 | + { |
|
77 | + return $this->data; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $data |
|
82 | + */ |
|
83 | + public function setData($data) |
|
84 | + { |
|
85 | + $this->data = $data; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @return DateTimeImmutable |
|
90 | + */ |
|
91 | + public function getTimestamp() |
|
92 | + { |
|
93 | + return new DateTimeImmutable($this->timestamp); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @throws Exception |
|
98 | + */ |
|
99 | + public function save() |
|
100 | + { |
|
101 | + if ($this->isNew()) { |
|
102 | + // insert |
|
103 | + // clear old data first |
|
104 | + $this->dbObject->exec("DELETE FROM antispoofcache WHERE timestamp < date_sub(now(), INTERVAL 3 HOUR);"); |
|
105 | + |
|
106 | + $statement = $this->dbObject->prepare("INSERT INTO antispoofcache (username, data) VALUES (:username, :data);"); |
|
107 | + $statement->bindValue(":username", $this->username); |
|
108 | + $statement->bindValue(":data", $this->data); |
|
109 | + |
|
110 | + if ($statement->execute()) { |
|
111 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
112 | + } |
|
113 | + else { |
|
114 | + throw new Exception($statement->errorInfo()); |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | 118 | } |
@@ -17,151 +17,151 @@ |
||
17 | 17 | */ |
18 | 18 | class Log extends DataObject |
19 | 19 | { |
20 | - /** @var int */ |
|
21 | - private $objectid; |
|
22 | - /** @var string */ |
|
23 | - private $objecttype; |
|
24 | - /** @var int */ |
|
25 | - private $user; |
|
26 | - /** @var string */ |
|
27 | - private $action; |
|
28 | - private $timestamp; |
|
29 | - /** @var string|null */ |
|
30 | - private $comment; |
|
31 | - |
|
32 | - /** |
|
33 | - * @throws Exception |
|
34 | - */ |
|
35 | - public function save() |
|
36 | - { |
|
37 | - if ($this->isNew()) { |
|
38 | - $statement = $this->dbObject->prepare(<<<SQL |
|
20 | + /** @var int */ |
|
21 | + private $objectid; |
|
22 | + /** @var string */ |
|
23 | + private $objecttype; |
|
24 | + /** @var int */ |
|
25 | + private $user; |
|
26 | + /** @var string */ |
|
27 | + private $action; |
|
28 | + private $timestamp; |
|
29 | + /** @var string|null */ |
|
30 | + private $comment; |
|
31 | + |
|
32 | + /** |
|
33 | + * @throws Exception |
|
34 | + */ |
|
35 | + public function save() |
|
36 | + { |
|
37 | + if ($this->isNew()) { |
|
38 | + $statement = $this->dbObject->prepare(<<<SQL |
|
39 | 39 | INSERT INTO log (objectid, objecttype, user, action, timestamp, comment) |
40 | 40 | VALUES (:id, :type, :user, :action, CURRENT_TIMESTAMP(), :comment); |
41 | 41 | SQL |
42 | - ); |
|
43 | - |
|
44 | - $statement->bindValue(":id", $this->objectid); |
|
45 | - $statement->bindValue(":type", $this->objecttype); |
|
46 | - $statement->bindValue(":user", $this->user); |
|
47 | - $statement->bindValue(":action", $this->action); |
|
48 | - $statement->bindValue(":comment", $this->comment); |
|
49 | - |
|
50 | - if ($statement->execute()) { |
|
51 | - $this->id = (int)$this->dbObject->lastInsertId(); |
|
52 | - } |
|
53 | - else { |
|
54 | - throw new Exception($statement->errorInfo()); |
|
55 | - } |
|
56 | - } |
|
57 | - else { |
|
58 | - throw new Exception("Updating logs is not available"); |
|
59 | - } |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @throws Exception |
|
64 | - */ |
|
65 | - public function delete() |
|
66 | - { |
|
67 | - throw new Exception("Deleting logs is not available."); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @return int |
|
72 | - */ |
|
73 | - public function getObjectId() |
|
74 | - { |
|
75 | - return $this->objectid; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Summary of setObjectId |
|
80 | - * |
|
81 | - * @param int $objectId |
|
82 | - */ |
|
83 | - public function setObjectId($objectId) |
|
84 | - { |
|
85 | - $this->objectid = $objectId; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function getObjectType() |
|
92 | - { |
|
93 | - return $this->objecttype; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Summary of setObjectType |
|
98 | - * |
|
99 | - * @param string $objectType |
|
100 | - */ |
|
101 | - public function setObjectType($objectType) |
|
102 | - { |
|
103 | - $this->objecttype = $objectType; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @return int |
|
108 | - */ |
|
109 | - public function getUser() |
|
110 | - { |
|
111 | - return $this->user; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Summary of setUser |
|
116 | - * |
|
117 | - * @param User $user |
|
118 | - */ |
|
119 | - public function setUser(User $user) |
|
120 | - { |
|
121 | - $this->user = $user->getId(); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function getAction() |
|
128 | - { |
|
129 | - return $this->action; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Summary of setAction |
|
134 | - * |
|
135 | - * @param string $action |
|
136 | - */ |
|
137 | - public function setAction($action) |
|
138 | - { |
|
139 | - $this->action = $action; |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * @return DateTimeImmutable |
|
144 | - */ |
|
145 | - public function getTimestamp() |
|
146 | - { |
|
147 | - return new DateTimeImmutable($this->timestamp); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return string|null |
|
152 | - */ |
|
153 | - public function getComment() |
|
154 | - { |
|
155 | - return $this->comment; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Summary of setComment |
|
160 | - * |
|
161 | - * @param string $comment |
|
162 | - */ |
|
163 | - public function setComment($comment) |
|
164 | - { |
|
165 | - $this->comment = $comment; |
|
166 | - } |
|
42 | + ); |
|
43 | + |
|
44 | + $statement->bindValue(":id", $this->objectid); |
|
45 | + $statement->bindValue(":type", $this->objecttype); |
|
46 | + $statement->bindValue(":user", $this->user); |
|
47 | + $statement->bindValue(":action", $this->action); |
|
48 | + $statement->bindValue(":comment", $this->comment); |
|
49 | + |
|
50 | + if ($statement->execute()) { |
|
51 | + $this->id = (int)$this->dbObject->lastInsertId(); |
|
52 | + } |
|
53 | + else { |
|
54 | + throw new Exception($statement->errorInfo()); |
|
55 | + } |
|
56 | + } |
|
57 | + else { |
|
58 | + throw new Exception("Updating logs is not available"); |
|
59 | + } |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @throws Exception |
|
64 | + */ |
|
65 | + public function delete() |
|
66 | + { |
|
67 | + throw new Exception("Deleting logs is not available."); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @return int |
|
72 | + */ |
|
73 | + public function getObjectId() |
|
74 | + { |
|
75 | + return $this->objectid; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Summary of setObjectId |
|
80 | + * |
|
81 | + * @param int $objectId |
|
82 | + */ |
|
83 | + public function setObjectId($objectId) |
|
84 | + { |
|
85 | + $this->objectid = $objectId; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function getObjectType() |
|
92 | + { |
|
93 | + return $this->objecttype; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Summary of setObjectType |
|
98 | + * |
|
99 | + * @param string $objectType |
|
100 | + */ |
|
101 | + public function setObjectType($objectType) |
|
102 | + { |
|
103 | + $this->objecttype = $objectType; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @return int |
|
108 | + */ |
|
109 | + public function getUser() |
|
110 | + { |
|
111 | + return $this->user; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Summary of setUser |
|
116 | + * |
|
117 | + * @param User $user |
|
118 | + */ |
|
119 | + public function setUser(User $user) |
|
120 | + { |
|
121 | + $this->user = $user->getId(); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function getAction() |
|
128 | + { |
|
129 | + return $this->action; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Summary of setAction |
|
134 | + * |
|
135 | + * @param string $action |
|
136 | + */ |
|
137 | + public function setAction($action) |
|
138 | + { |
|
139 | + $this->action = $action; |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * @return DateTimeImmutable |
|
144 | + */ |
|
145 | + public function getTimestamp() |
|
146 | + { |
|
147 | + return new DateTimeImmutable($this->timestamp); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return string|null |
|
152 | + */ |
|
153 | + public function getComment() |
|
154 | + { |
|
155 | + return $this->comment; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Summary of setComment |
|
160 | + * |
|
161 | + * @param string $comment |
|
162 | + */ |
|
163 | + public function setComment($comment) |
|
164 | + { |
|
165 | + $this->comment = $comment; |
|
166 | + } |
|
167 | 167 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | final protected function setUpSmarty() |
55 | 55 | { |
56 | 56 | $this->smarty = new Smarty(); |
57 | - $this->smarty->addPluginsDir($this->getSiteConfiguration()->getFilePath() . '/smarty-plugins'); |
|
57 | + $this->smarty->addPluginsDir($this->getSiteConfiguration()->getFilePath().'/smarty-plugins'); |
|
58 | 58 | |
59 | 59 | $this->assign('currentUser', User::getCommunity()); |
60 | 60 | $this->assign('loggedIn', false); |
@@ -15,89 +15,89 @@ |
||
15 | 15 | |
16 | 16 | trait TemplateOutput |
17 | 17 | { |
18 | - /** @var Smarty */ |
|
19 | - private $smarty; |
|
20 | - /** @var string Extra JavaScript to include at the end of the page's execution */ |
|
21 | - private $tailScript; |
|
18 | + /** @var Smarty */ |
|
19 | + private $smarty; |
|
20 | + /** @var string Extra JavaScript to include at the end of the page's execution */ |
|
21 | + private $tailScript; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return SiteConfiguration |
|
25 | - */ |
|
26 | - protected abstract function getSiteConfiguration(); |
|
23 | + /** |
|
24 | + * @return SiteConfiguration |
|
25 | + */ |
|
26 | + protected abstract function getSiteConfiguration(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Include extra JavaScript at the end of the page's execution |
|
30 | - * |
|
31 | - * @param $script string JavaScript to include at the end of the page |
|
32 | - */ |
|
33 | - final protected function setTailScript($script) |
|
34 | - { |
|
35 | - $this->tailScript = $script; |
|
36 | - } |
|
28 | + /** |
|
29 | + * Include extra JavaScript at the end of the page's execution |
|
30 | + * |
|
31 | + * @param $script string JavaScript to include at the end of the page |
|
32 | + */ |
|
33 | + final protected function setTailScript($script) |
|
34 | + { |
|
35 | + $this->tailScript = $script; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Assigns a Smarty variable |
|
40 | - * |
|
41 | - * @param array|string $name the template variable name(s) |
|
42 | - * @param mixed $value the value to assign |
|
43 | - */ |
|
44 | - final protected function assign($name, $value) |
|
45 | - { |
|
46 | - $this->smarty->assign($name, $value); |
|
47 | - } |
|
38 | + /** |
|
39 | + * Assigns a Smarty variable |
|
40 | + * |
|
41 | + * @param array|string $name the template variable name(s) |
|
42 | + * @param mixed $value the value to assign |
|
43 | + */ |
|
44 | + final protected function assign($name, $value) |
|
45 | + { |
|
46 | + $this->smarty->assign($name, $value); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Sets up the variables used by the main Smarty base template. |
|
51 | - * |
|
52 | - * This list is getting kinda long. |
|
53 | - */ |
|
54 | - final protected function setUpSmarty() |
|
55 | - { |
|
56 | - $this->smarty = new Smarty(); |
|
57 | - $this->smarty->addPluginsDir($this->getSiteConfiguration()->getFilePath() . '/smarty-plugins'); |
|
49 | + /** |
|
50 | + * Sets up the variables used by the main Smarty base template. |
|
51 | + * |
|
52 | + * This list is getting kinda long. |
|
53 | + */ |
|
54 | + final protected function setUpSmarty() |
|
55 | + { |
|
56 | + $this->smarty = new Smarty(); |
|
57 | + $this->smarty->addPluginsDir($this->getSiteConfiguration()->getFilePath() . '/smarty-plugins'); |
|
58 | 58 | |
59 | - $this->assign('currentUser', User::getCommunity()); |
|
60 | - $this->assign('loggedIn', false); |
|
61 | - $this->assign('baseurl', $this->getSiteConfiguration()->getBaseUrl()); |
|
62 | - $this->assign('mediawikiScriptPath', $this->getSiteConfiguration()->getMediawikiScriptPath()); |
|
59 | + $this->assign('currentUser', User::getCommunity()); |
|
60 | + $this->assign('loggedIn', false); |
|
61 | + $this->assign('baseurl', $this->getSiteConfiguration()->getBaseUrl()); |
|
62 | + $this->assign('mediawikiScriptPath', $this->getSiteConfiguration()->getMediawikiScriptPath()); |
|
63 | 63 | |
64 | - $this->assign('siteNoticeText', ''); |
|
65 | - $this->assign('toolversion', Environment::getToolVersion()); |
|
64 | + $this->assign('siteNoticeText', ''); |
|
65 | + $this->assign('toolversion', Environment::getToolVersion()); |
|
66 | 66 | |
67 | - // default these |
|
68 | - $this->assign('onlineusers', array()); |
|
69 | - $this->assign('typeAheadBlock', ''); |
|
70 | - $this->assign('extraJs', array()); |
|
71 | - $this->assign('extraCss', array()); |
|
67 | + // default these |
|
68 | + $this->assign('onlineusers', array()); |
|
69 | + $this->assign('typeAheadBlock', ''); |
|
70 | + $this->assign('extraJs', array()); |
|
71 | + $this->assign('extraCss', array()); |
|
72 | 72 | |
73 | - // nav menu access control |
|
74 | - $this->assign('nav__canRequests', false); |
|
75 | - $this->assign('nav__canLogs', false); |
|
76 | - $this->assign('nav__canUsers', false); |
|
77 | - $this->assign('nav__canSearch', false); |
|
78 | - $this->assign('nav__canStats', false); |
|
79 | - $this->assign('nav__canBan', false); |
|
80 | - $this->assign('nav__canEmailMgmt', false); |
|
81 | - $this->assign('nav__canWelcomeMgmt', false); |
|
82 | - $this->assign('nav__canSiteNoticeMgmt', false); |
|
83 | - $this->assign('nav__canUserMgmt', false); |
|
84 | - $this->assign('nav__canViewRequest', false); |
|
85 | - $this->assign('nav__canJobQueue', false); |
|
73 | + // nav menu access control |
|
74 | + $this->assign('nav__canRequests', false); |
|
75 | + $this->assign('nav__canLogs', false); |
|
76 | + $this->assign('nav__canUsers', false); |
|
77 | + $this->assign('nav__canSearch', false); |
|
78 | + $this->assign('nav__canStats', false); |
|
79 | + $this->assign('nav__canBan', false); |
|
80 | + $this->assign('nav__canEmailMgmt', false); |
|
81 | + $this->assign('nav__canWelcomeMgmt', false); |
|
82 | + $this->assign('nav__canSiteNoticeMgmt', false); |
|
83 | + $this->assign('nav__canUserMgmt', false); |
|
84 | + $this->assign('nav__canViewRequest', false); |
|
85 | + $this->assign('nav__canJobQueue', false); |
|
86 | 86 | |
87 | - $this->assign('page', $this); |
|
88 | - } |
|
87 | + $this->assign('page', $this); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Fetches a rendered Smarty template |
|
92 | - * |
|
93 | - * @param $template string Template file path, relative to /templates/ |
|
94 | - * |
|
95 | - * @return string Templated HTML |
|
96 | - */ |
|
97 | - final protected function fetchTemplate($template) |
|
98 | - { |
|
99 | - $this->assign("tailScript", $this->tailScript); |
|
90 | + /** |
|
91 | + * Fetches a rendered Smarty template |
|
92 | + * |
|
93 | + * @param $template string Template file path, relative to /templates/ |
|
94 | + * |
|
95 | + * @return string Templated HTML |
|
96 | + */ |
|
97 | + final protected function fetchTemplate($template) |
|
98 | + { |
|
99 | + $this->assign("tailScript", $this->tailScript); |
|
100 | 100 | |
101 | - return $this->smarty->fetch($template); |
|
102 | - } |
|
101 | + return $this->smarty->fetch($template); |
|
102 | + } |
|
103 | 103 | } |
@@ -17,25 +17,25 @@ |
||
17 | 17 | */ |
18 | 18 | class Session |
19 | 19 | { |
20 | - public static function start() |
|
21 | - { |
|
22 | - ini_set('session.cookie_httponly', 1); |
|
20 | + public static function start() |
|
21 | + { |
|
22 | + ini_set('session.cookie_httponly', 1); |
|
23 | 23 | |
24 | - if (WebRequest::isHttps()) { |
|
25 | - ini_set('session.cookie_secure', 1); |
|
26 | - } |
|
24 | + if (WebRequest::isHttps()) { |
|
25 | + ini_set('session.cookie_secure', 1); |
|
26 | + } |
|
27 | 27 | |
28 | - session_start(); |
|
29 | - } |
|
28 | + session_start(); |
|
29 | + } |
|
30 | 30 | |
31 | - public static function destroy() |
|
32 | - { |
|
33 | - session_destroy(); |
|
34 | - } |
|
31 | + public static function destroy() |
|
32 | + { |
|
33 | + session_destroy(); |
|
34 | + } |
|
35 | 35 | |
36 | - public static function restart() |
|
37 | - { |
|
38 | - self::destroy(); |
|
39 | - self::start(); |
|
40 | - } |
|
36 | + public static function restart() |
|
37 | + { |
|
38 | + self::destroy(); |
|
39 | + self::start(); |
|
40 | + } |
|
41 | 41 | } |
@@ -21,141 +21,141 @@ |
||
21 | 21 | */ |
22 | 22 | class SessionAlert |
23 | 23 | { |
24 | - private $message; |
|
25 | - private $title; |
|
26 | - private $type; |
|
27 | - private $closable; |
|
28 | - private $block; |
|
29 | - |
|
30 | - /** |
|
31 | - * @param string $message |
|
32 | - * @param string $title |
|
33 | - * @param string $type |
|
34 | - * @param bool $closable |
|
35 | - * @param bool $block |
|
36 | - */ |
|
37 | - public function __construct($message, $title, $type = "alert-info", $closable = true, $block = true) |
|
38 | - { |
|
39 | - $this->message = $message; |
|
40 | - $this->title = $title; |
|
41 | - $this->type = $type; |
|
42 | - $this->closable = $closable; |
|
43 | - $this->block = $block; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Shows a quick one-liner message |
|
48 | - * |
|
49 | - * @param string $message |
|
50 | - * @param string $type |
|
51 | - */ |
|
52 | - public static function quick($message, $type = "alert-info") |
|
53 | - { |
|
54 | - self::append(new SessionAlert($message, "", $type, true, false)); |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param SessionAlert $alert |
|
59 | - */ |
|
60 | - public static function append(SessionAlert $alert) |
|
61 | - { |
|
62 | - $data = WebRequest::getSessionAlertData(); |
|
63 | - $data[] = serialize($alert); |
|
64 | - WebRequest::setSessionAlertData($data); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Shows a quick one-liner success message |
|
69 | - * |
|
70 | - * @param string $message |
|
71 | - */ |
|
72 | - public static function success($message) |
|
73 | - { |
|
74 | - self::append(new SessionAlert($message, "", "alert-success", true, true)); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Shows a quick one-liner warning message |
|
79 | - * |
|
80 | - * @param string $message |
|
81 | - * @param string $title |
|
82 | - */ |
|
83 | - public static function warning($message, $title = "Warning!") |
|
84 | - { |
|
85 | - self::append(new SessionAlert($message, $title, "alert-warning", true, true)); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Shows a quick one-liner error message |
|
90 | - * |
|
91 | - * @param string $message |
|
92 | - * @param string $title |
|
93 | - */ |
|
94 | - public static function error($message, $title = "Error!") |
|
95 | - { |
|
96 | - self::append(new SessionAlert($message, $title, "alert-error", true, true)); |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Retrieves the alerts which have been saved to the session |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - public static function getAlerts() |
|
104 | - { |
|
105 | - $alertData = array(); |
|
106 | - |
|
107 | - foreach (WebRequest::getSessionAlertData() as $a) { |
|
108 | - $alertData[] = unserialize($a); |
|
109 | - } |
|
110 | - |
|
111 | - return $alertData; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Clears the alerts from the session |
|
116 | - */ |
|
117 | - public static function clearAlerts() |
|
118 | - { |
|
119 | - WebRequest::clearSessionAlertData(); |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return boolean |
|
124 | - */ |
|
125 | - public function isBlock() |
|
126 | - { |
|
127 | - return $this->block; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return boolean |
|
132 | - */ |
|
133 | - public function isClosable() |
|
134 | - { |
|
135 | - return $this->closable; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public function getType() |
|
142 | - { |
|
143 | - return $this->type; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function getTitle() |
|
150 | - { |
|
151 | - return $this->title; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return string |
|
156 | - */ |
|
157 | - public function getMessage() |
|
158 | - { |
|
159 | - return $this->message; |
|
160 | - } |
|
24 | + private $message; |
|
25 | + private $title; |
|
26 | + private $type; |
|
27 | + private $closable; |
|
28 | + private $block; |
|
29 | + |
|
30 | + /** |
|
31 | + * @param string $message |
|
32 | + * @param string $title |
|
33 | + * @param string $type |
|
34 | + * @param bool $closable |
|
35 | + * @param bool $block |
|
36 | + */ |
|
37 | + public function __construct($message, $title, $type = "alert-info", $closable = true, $block = true) |
|
38 | + { |
|
39 | + $this->message = $message; |
|
40 | + $this->title = $title; |
|
41 | + $this->type = $type; |
|
42 | + $this->closable = $closable; |
|
43 | + $this->block = $block; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Shows a quick one-liner message |
|
48 | + * |
|
49 | + * @param string $message |
|
50 | + * @param string $type |
|
51 | + */ |
|
52 | + public static function quick($message, $type = "alert-info") |
|
53 | + { |
|
54 | + self::append(new SessionAlert($message, "", $type, true, false)); |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param SessionAlert $alert |
|
59 | + */ |
|
60 | + public static function append(SessionAlert $alert) |
|
61 | + { |
|
62 | + $data = WebRequest::getSessionAlertData(); |
|
63 | + $data[] = serialize($alert); |
|
64 | + WebRequest::setSessionAlertData($data); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Shows a quick one-liner success message |
|
69 | + * |
|
70 | + * @param string $message |
|
71 | + */ |
|
72 | + public static function success($message) |
|
73 | + { |
|
74 | + self::append(new SessionAlert($message, "", "alert-success", true, true)); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Shows a quick one-liner warning message |
|
79 | + * |
|
80 | + * @param string $message |
|
81 | + * @param string $title |
|
82 | + */ |
|
83 | + public static function warning($message, $title = "Warning!") |
|
84 | + { |
|
85 | + self::append(new SessionAlert($message, $title, "alert-warning", true, true)); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Shows a quick one-liner error message |
|
90 | + * |
|
91 | + * @param string $message |
|
92 | + * @param string $title |
|
93 | + */ |
|
94 | + public static function error($message, $title = "Error!") |
|
95 | + { |
|
96 | + self::append(new SessionAlert($message, $title, "alert-error", true, true)); |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Retrieves the alerts which have been saved to the session |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + public static function getAlerts() |
|
104 | + { |
|
105 | + $alertData = array(); |
|
106 | + |
|
107 | + foreach (WebRequest::getSessionAlertData() as $a) { |
|
108 | + $alertData[] = unserialize($a); |
|
109 | + } |
|
110 | + |
|
111 | + return $alertData; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Clears the alerts from the session |
|
116 | + */ |
|
117 | + public static function clearAlerts() |
|
118 | + { |
|
119 | + WebRequest::clearSessionAlertData(); |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @return boolean |
|
124 | + */ |
|
125 | + public function isBlock() |
|
126 | + { |
|
127 | + return $this->block; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return boolean |
|
132 | + */ |
|
133 | + public function isClosable() |
|
134 | + { |
|
135 | + return $this->closable; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public function getType() |
|
142 | + { |
|
143 | + return $this->type; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function getTitle() |
|
150 | + { |
|
151 | + return $this->title; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return string |
|
156 | + */ |
|
157 | + public function getMessage() |
|
158 | + { |
|
159 | + return $this->message; |
|
160 | + } |
|
161 | 161 | } |