@@ -23,65 +23,65 @@ |
||
23 | 23 | */ |
24 | 24 | class MonitorAction extends XmlApiPageBase implements IXmlApiAction |
25 | 25 | { |
26 | - /** |
|
27 | - * @param DOMElement $apiDocument |
|
28 | - * |
|
29 | - * @return DOMElement |
|
30 | - */ |
|
31 | - public function executeApiAction(DOMElement $apiDocument) |
|
32 | - { |
|
33 | - $now = new DateTime(); |
|
26 | + /** |
|
27 | + * @param DOMElement $apiDocument |
|
28 | + * |
|
29 | + * @return DOMElement |
|
30 | + */ |
|
31 | + public function executeApiAction(DOMElement $apiDocument) |
|
32 | + { |
|
33 | + $now = new DateTime(); |
|
34 | 34 | |
35 | - $old = $this->getOldest(); |
|
36 | - $oldest = new DateTime($old); |
|
35 | + $old = $this->getOldest(); |
|
36 | + $oldest = new DateTime($old); |
|
37 | 37 | |
38 | - $new = $this->getNewest(); |
|
39 | - $newest = new DateTime($new); |
|
38 | + $new = $this->getNewest(); |
|
39 | + $newest = new DateTime($new); |
|
40 | 40 | |
41 | - $monitoringElement = $this->document->createElement("data"); |
|
42 | - $monitoringElement->setAttribute("date", $now->format('c')); |
|
43 | - $monitoringElement->setAttribute("oldest", $old === null ? null : $oldest->format('c')); |
|
44 | - $monitoringElement->setAttribute("newest", $new === null ? null : $newest->format('c')); |
|
45 | - $apiDocument->appendChild($monitoringElement); |
|
41 | + $monitoringElement = $this->document->createElement("data"); |
|
42 | + $monitoringElement->setAttribute("date", $now->format('c')); |
|
43 | + $monitoringElement->setAttribute("oldest", $old === null ? null : $oldest->format('c')); |
|
44 | + $monitoringElement->setAttribute("newest", $new === null ? null : $newest->format('c')); |
|
45 | + $apiDocument->appendChild($monitoringElement); |
|
46 | 46 | |
47 | - return $apiDocument; |
|
48 | - } |
|
47 | + return $apiDocument; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return string|null |
|
52 | - */ |
|
53 | - private function getOldest() |
|
54 | - { |
|
55 | - $statement = $this->getDatabase() |
|
56 | - ->prepare("SELECT min(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
57 | - $successful = $statement->execute(array( |
|
58 | - ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
59 | - ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
60 | - )); |
|
50 | + /** |
|
51 | + * @return string|null |
|
52 | + */ |
|
53 | + private function getOldest() |
|
54 | + { |
|
55 | + $statement = $this->getDatabase() |
|
56 | + ->prepare("SELECT min(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
57 | + $successful = $statement->execute(array( |
|
58 | + ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
59 | + ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
60 | + )); |
|
61 | 61 | |
62 | - if (!$successful) { |
|
63 | - return null; |
|
64 | - } |
|
62 | + if (!$successful) { |
|
63 | + return null; |
|
64 | + } |
|
65 | 65 | |
66 | - $result = $statement->fetchColumn(); |
|
66 | + $result = $statement->fetchColumn(); |
|
67 | 67 | |
68 | - return $result; |
|
69 | - } |
|
68 | + return $result; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - private function getNewest() |
|
75 | - { |
|
76 | - $statement = $this->getDatabase() |
|
77 | - ->prepare("SELECT max(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
78 | - $statement->execute(array( |
|
79 | - ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
80 | - ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
81 | - )); |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + private function getNewest() |
|
75 | + { |
|
76 | + $statement = $this->getDatabase() |
|
77 | + ->prepare("SELECT max(date) FROM request WHERE email != :email AND ip != :ip;"); |
|
78 | + $statement->execute(array( |
|
79 | + ':email' => $this->getSiteConfiguration()->getDataClearEmail(), |
|
80 | + ':ip' => $this->getSiteConfiguration()->getDataClearIp(), |
|
81 | + )); |
|
82 | 82 | |
83 | - $result = $statement->fetchColumn(0); |
|
83 | + $result = $statement->fetchColumn(0); |
|
84 | 84 | |
85 | - return $result; |
|
86 | - } |
|
85 | + return $result; |
|
86 | + } |
|
87 | 87 | } |
@@ -17,67 +17,67 @@ |
||
17 | 17 | */ |
18 | 18 | class StatusAction extends XmlApiPageBase implements IXmlApiAction |
19 | 19 | { |
20 | - public function executeApiAction(DOMElement $apiDocument) |
|
21 | - { |
|
22 | - $statusElement = $this->document->createElement("status"); |
|
23 | - $apiDocument->appendChild($statusElement); |
|
20 | + public function executeApiAction(DOMElement $apiDocument) |
|
21 | + { |
|
22 | + $statusElement = $this->document->createElement("status"); |
|
23 | + $apiDocument->appendChild($statusElement); |
|
24 | 24 | |
25 | - $query = $this->getDatabase()->prepare(<<<SQL |
|
25 | + $query = $this->getDatabase()->prepare(<<<SQL |
|
26 | 26 | SELECT /* Api/StatusAction */ COUNT(*) AS count |
27 | 27 | FROM request |
28 | 28 | WHERE |
29 | 29 | status = :pstatus |
30 | 30 | AND emailconfirm = 'Confirmed'; |
31 | 31 | SQL |
32 | - ); |
|
32 | + ); |
|
33 | 33 | |
34 | - $availableRequestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
34 | + $availableRequestStates = $this->getSiteConfiguration()->getRequestStates(); |
|
35 | 35 | |
36 | - foreach ($availableRequestStates as $key => $value) { |
|
37 | - $query->bindValue(":pstatus", $key); |
|
38 | - $query->execute(); |
|
39 | - $sus = $query->fetchColumn(); |
|
40 | - $statusElement->setAttribute($value['api'], $sus); |
|
41 | - $query->closeCursor(); |
|
42 | - } |
|
36 | + foreach ($availableRequestStates as $key => $value) { |
|
37 | + $query->bindValue(":pstatus", $key); |
|
38 | + $query->execute(); |
|
39 | + $sus = $query->fetchColumn(); |
|
40 | + $statusElement->setAttribute($value['api'], $sus); |
|
41 | + $query->closeCursor(); |
|
42 | + } |
|
43 | 43 | |
44 | - $query = $this->getDatabase()->prepare(<<<SQL |
|
44 | + $query = $this->getDatabase()->prepare(<<<SQL |
|
45 | 45 | SELECT /* Api/StatusAction */ COUNT(*) AS count |
46 | 46 | FROM ban |
47 | 47 | WHERE |
48 | 48 | (duration > UNIX_TIMESTAMP() OR duration = -1) |
49 | 49 | AND active = 1; |
50 | 50 | SQL |
51 | - ); |
|
51 | + ); |
|
52 | 52 | |
53 | - $query->execute(); |
|
54 | - $sus = $query->fetchColumn(); |
|
55 | - $statusElement->setAttribute("bans", $sus); |
|
56 | - $query->closeCursor(); |
|
53 | + $query->execute(); |
|
54 | + $sus = $query->fetchColumn(); |
|
55 | + $statusElement->setAttribute("bans", $sus); |
|
56 | + $query->closeCursor(); |
|
57 | 57 | |
58 | - $query = $this->getDatabase()->prepare(<<<SQL |
|
58 | + $query = $this->getDatabase()->prepare(<<<SQL |
|
59 | 59 | SELECT /* Api/StatusAction */ COUNT(*) AS count |
60 | 60 | FROM user WHERE status = :ulevel; |
61 | 61 | SQL |
62 | - ); |
|
63 | - $query->bindValue(":ulevel", "Admin"); |
|
64 | - $query->execute(); |
|
65 | - $sus = $query->fetchColumn(); |
|
66 | - $statusElement->setAttribute("useradmin", $sus); |
|
67 | - $query->closeCursor(); |
|
62 | + ); |
|
63 | + $query->bindValue(":ulevel", "Admin"); |
|
64 | + $query->execute(); |
|
65 | + $sus = $query->fetchColumn(); |
|
66 | + $statusElement->setAttribute("useradmin", $sus); |
|
67 | + $query->closeCursor(); |
|
68 | 68 | |
69 | - $query->bindValue(":ulevel", "User"); |
|
70 | - $query->execute(); |
|
71 | - $sus = $query->fetchColumn(); |
|
72 | - $statusElement->setAttribute("user", $sus); |
|
73 | - $query->closeCursor(); |
|
69 | + $query->bindValue(":ulevel", "User"); |
|
70 | + $query->execute(); |
|
71 | + $sus = $query->fetchColumn(); |
|
72 | + $statusElement->setAttribute("user", $sus); |
|
73 | + $query->closeCursor(); |
|
74 | 74 | |
75 | - $query->bindValue(":ulevel", "New"); |
|
76 | - $query->execute(); |
|
77 | - $sus = $query->fetchColumn(); |
|
78 | - $statusElement->setAttribute("usernew", $sus); |
|
79 | - $query->closeCursor(); |
|
75 | + $query->bindValue(":ulevel", "New"); |
|
76 | + $query->execute(); |
|
77 | + $sus = $query->fetchColumn(); |
|
78 | + $statusElement->setAttribute("usernew", $sus); |
|
79 | + $query->closeCursor(); |
|
80 | 80 | |
81 | - return $apiDocument; |
|
82 | - } |
|
81 | + return $apiDocument; |
|
82 | + } |
|
83 | 83 | } |
@@ -20,47 +20,47 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class CountAction extends XmlApiPageBase implements IXmlApiAction |
22 | 22 | { |
23 | - /** |
|
24 | - * The target user |
|
25 | - * @var User $user |
|
26 | - */ |
|
27 | - private $user; |
|
23 | + /** |
|
24 | + * The target user |
|
25 | + * @var User $user |
|
26 | + */ |
|
27 | + private $user; |
|
28 | 28 | |
29 | - public function executeApiAction(DOMElement $apiDocument) |
|
30 | - { |
|
31 | - $username = WebRequest::getString('user'); |
|
32 | - if ($username === null) { |
|
33 | - throw new ApiException("Please specify a username"); |
|
34 | - } |
|
29 | + public function executeApiAction(DOMElement $apiDocument) |
|
30 | + { |
|
31 | + $username = WebRequest::getString('user'); |
|
32 | + if ($username === null) { |
|
33 | + throw new ApiException("Please specify a username"); |
|
34 | + } |
|
35 | 35 | |
36 | - $userElement = $this->document->createElement("user"); |
|
37 | - $userElement->setAttribute("name", $username); |
|
38 | - $apiDocument->appendChild($userElement); |
|
36 | + $userElement = $this->document->createElement("user"); |
|
37 | + $userElement->setAttribute("name", $username); |
|
38 | + $apiDocument->appendChild($userElement); |
|
39 | 39 | |
40 | - $user = User::getByUsername($username, $this->getDatabase()); |
|
40 | + $user = User::getByUsername($username, $this->getDatabase()); |
|
41 | 41 | |
42 | - if ($user === false) { |
|
43 | - $userElement->setAttribute("missing", "true"); |
|
42 | + if ($user === false) { |
|
43 | + $userElement->setAttribute("missing", "true"); |
|
44 | 44 | |
45 | - return $apiDocument; |
|
46 | - } |
|
45 | + return $apiDocument; |
|
46 | + } |
|
47 | 47 | |
48 | - $this->user = $user; |
|
48 | + $this->user = $user; |
|
49 | 49 | |
50 | - $userElement->setAttribute("level", $this->user->getStatus()); |
|
51 | - $userElement->setAttribute("created", $this->getAccountsCreated()); |
|
50 | + $userElement->setAttribute("level", $this->user->getStatus()); |
|
51 | + $userElement->setAttribute("created", $this->getAccountsCreated()); |
|
52 | 52 | |
53 | - $userElement->setAttribute("today", $this->getToday()); |
|
53 | + $userElement->setAttribute("today", $this->getToday()); |
|
54 | 54 | |
55 | - // Let the IRC bot handle the result of this. |
|
56 | - $this->fetchAdminData($userElement); |
|
55 | + // Let the IRC bot handle the result of this. |
|
56 | + $this->fetchAdminData($userElement); |
|
57 | 57 | |
58 | - return $apiDocument; |
|
59 | - } |
|
58 | + return $apiDocument; |
|
59 | + } |
|
60 | 60 | |
61 | - private function getAccountsCreated() |
|
62 | - { |
|
63 | - $query = <<<QUERY |
|
61 | + private function getAccountsCreated() |
|
62 | + { |
|
63 | + $query = <<<QUERY |
|
64 | 64 | SELECT COUNT(*) AS count |
65 | 65 | FROM log |
66 | 66 | LEFT JOIN emailtemplate ON concat('Closed ', emailtemplate.id) = log.action |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | AND user.username = :username; |
72 | 72 | QUERY; |
73 | 73 | |
74 | - $statement = $this->getDatabase()->prepare($query); |
|
75 | - $statement->execute(array(":username" => $this->user->getUsername())); |
|
76 | - $result = $statement->fetchColumn(); |
|
77 | - $statement->closeCursor(); |
|
74 | + $statement = $this->getDatabase()->prepare($query); |
|
75 | + $statement->execute(array(":username" => $this->user->getUsername())); |
|
76 | + $result = $statement->fetchColumn(); |
|
77 | + $statement->closeCursor(); |
|
78 | 78 | |
79 | - return $result; |
|
80 | - } |
|
79 | + return $result; |
|
80 | + } |
|
81 | 81 | |
82 | - private function getToday() |
|
83 | - { |
|
84 | - $query = <<<QUERY |
|
82 | + private function getToday() |
|
83 | + { |
|
84 | + $query = <<<QUERY |
|
85 | 85 | SELECT |
86 | 86 | COUNT(*) AS count |
87 | 87 | FROM log |
@@ -93,99 +93,99 @@ discard block |
||
93 | 93 | AND user.username = :username; |
94 | 94 | QUERY; |
95 | 95 | |
96 | - $statement = $this->getDatabase()->prepare($query); |
|
97 | - $statement->bindValue(":username", $this->user->getUsername()); |
|
98 | - $statement->bindValue(":date", date('Y-m-d') . "%"); |
|
99 | - $statement->execute(); |
|
100 | - $today = $statement->fetchColumn(); |
|
101 | - $statement->closeCursor(); |
|
102 | - |
|
103 | - return $today; |
|
104 | - } |
|
105 | - |
|
106 | - private function fetchAdminData(DOMElement $userElement) |
|
107 | - { |
|
108 | - $query = "SELECT COUNT(*) AS count FROM log WHERE log.user = :userid AND log.action = :action;"; |
|
109 | - |
|
110 | - $statement = $this->getDatabase()->prepare($query); |
|
111 | - $statement->bindValue(":userid", $this->user->getId()); |
|
112 | - $statement->bindValue(":action", "Suspended"); |
|
113 | - $statement->execute(); |
|
114 | - $sus = $statement->fetchColumn(); |
|
115 | - $userElement->setAttribute("suspended", $sus); |
|
116 | - $statement->closeCursor(); |
|
117 | - |
|
118 | - $statement->bindValue(":action", "Promoted"); |
|
119 | - $statement->execute(); |
|
120 | - $pro = $statement->fetchColumn(); |
|
121 | - $userElement->setAttribute("promoted", $pro); |
|
122 | - $statement->closeCursor(); |
|
123 | - |
|
124 | - $statement->bindValue(":action", "Approved"); |
|
125 | - $statement->execute(); |
|
126 | - $app = $statement->fetchColumn(); |
|
127 | - $userElement->setAttribute("approved", $app); |
|
128 | - $statement->closeCursor(); |
|
129 | - |
|
130 | - $statement->bindValue(":action", "Demoted"); |
|
131 | - $statement->execute(); |
|
132 | - $dem = $statement->fetchColumn(); |
|
133 | - $userElement->setAttribute("demoted", $dem); |
|
134 | - $statement->closeCursor(); |
|
135 | - |
|
136 | - $statement->bindValue(":action", "Declined"); |
|
137 | - $statement->execute(); |
|
138 | - $dec = $statement->fetchColumn(); |
|
139 | - $userElement->setAttribute("declined", $dec); |
|
140 | - $statement->closeCursor(); |
|
141 | - |
|
142 | - $statement->bindValue(":action", "Renamed"); |
|
143 | - $statement->execute(); |
|
144 | - $rnc = $statement->fetchColumn(); |
|
145 | - $userElement->setAttribute("renamed", $rnc); |
|
146 | - $statement->closeCursor(); |
|
147 | - |
|
148 | - $statement->bindValue(":action", "Edited"); |
|
149 | - $statement->execute(); |
|
150 | - $mec = $statement->fetchColumn(); |
|
151 | - $userElement->setAttribute("edited", $mec); |
|
152 | - $statement->closeCursor(); |
|
153 | - |
|
154 | - $statement->bindValue(":action", "Prefchange"); |
|
155 | - $statement->execute(); |
|
156 | - $pcc = $statement->fetchColumn(); |
|
157 | - $userElement->setAttribute("prefchange", $pcc); |
|
158 | - $statement->closeCursor(); |
|
159 | - |
|
160 | - // Combine all three actions affecting Welcome templates into one count. |
|
161 | - $combinedquery = $this->getDatabase()->prepare(<<<SQL |
|
96 | + $statement = $this->getDatabase()->prepare($query); |
|
97 | + $statement->bindValue(":username", $this->user->getUsername()); |
|
98 | + $statement->bindValue(":date", date('Y-m-d') . "%"); |
|
99 | + $statement->execute(); |
|
100 | + $today = $statement->fetchColumn(); |
|
101 | + $statement->closeCursor(); |
|
102 | + |
|
103 | + return $today; |
|
104 | + } |
|
105 | + |
|
106 | + private function fetchAdminData(DOMElement $userElement) |
|
107 | + { |
|
108 | + $query = "SELECT COUNT(*) AS count FROM log WHERE log.user = :userid AND log.action = :action;"; |
|
109 | + |
|
110 | + $statement = $this->getDatabase()->prepare($query); |
|
111 | + $statement->bindValue(":userid", $this->user->getId()); |
|
112 | + $statement->bindValue(":action", "Suspended"); |
|
113 | + $statement->execute(); |
|
114 | + $sus = $statement->fetchColumn(); |
|
115 | + $userElement->setAttribute("suspended", $sus); |
|
116 | + $statement->closeCursor(); |
|
117 | + |
|
118 | + $statement->bindValue(":action", "Promoted"); |
|
119 | + $statement->execute(); |
|
120 | + $pro = $statement->fetchColumn(); |
|
121 | + $userElement->setAttribute("promoted", $pro); |
|
122 | + $statement->closeCursor(); |
|
123 | + |
|
124 | + $statement->bindValue(":action", "Approved"); |
|
125 | + $statement->execute(); |
|
126 | + $app = $statement->fetchColumn(); |
|
127 | + $userElement->setAttribute("approved", $app); |
|
128 | + $statement->closeCursor(); |
|
129 | + |
|
130 | + $statement->bindValue(":action", "Demoted"); |
|
131 | + $statement->execute(); |
|
132 | + $dem = $statement->fetchColumn(); |
|
133 | + $userElement->setAttribute("demoted", $dem); |
|
134 | + $statement->closeCursor(); |
|
135 | + |
|
136 | + $statement->bindValue(":action", "Declined"); |
|
137 | + $statement->execute(); |
|
138 | + $dec = $statement->fetchColumn(); |
|
139 | + $userElement->setAttribute("declined", $dec); |
|
140 | + $statement->closeCursor(); |
|
141 | + |
|
142 | + $statement->bindValue(":action", "Renamed"); |
|
143 | + $statement->execute(); |
|
144 | + $rnc = $statement->fetchColumn(); |
|
145 | + $userElement->setAttribute("renamed", $rnc); |
|
146 | + $statement->closeCursor(); |
|
147 | + |
|
148 | + $statement->bindValue(":action", "Edited"); |
|
149 | + $statement->execute(); |
|
150 | + $mec = $statement->fetchColumn(); |
|
151 | + $userElement->setAttribute("edited", $mec); |
|
152 | + $statement->closeCursor(); |
|
153 | + |
|
154 | + $statement->bindValue(":action", "Prefchange"); |
|
155 | + $statement->execute(); |
|
156 | + $pcc = $statement->fetchColumn(); |
|
157 | + $userElement->setAttribute("prefchange", $pcc); |
|
158 | + $statement->closeCursor(); |
|
159 | + |
|
160 | + // Combine all three actions affecting Welcome templates into one count. |
|
161 | + $combinedquery = $this->getDatabase()->prepare(<<<SQL |
|
162 | 162 | SELECT |
163 | 163 | COUNT(*) AS count |
164 | 164 | FROM log |
165 | 165 | WHERE log.user = :userid |
166 | 166 | AND log.action IN ('CreatedTemplate', 'EditedTemplate', 'DeletedTemplate'); |
167 | 167 | SQL |
168 | - ); |
|
168 | + ); |
|
169 | 169 | |
170 | - $combinedquery->bindValue(":userid", $this->user->getId()); |
|
171 | - $combinedquery->execute(); |
|
172 | - $dtc = $combinedquery->fetchColumn(); |
|
173 | - $userElement->setAttribute("welctempchange", $dtc); |
|
174 | - $combinedquery->closeCursor(); |
|
170 | + $combinedquery->bindValue(":userid", $this->user->getId()); |
|
171 | + $combinedquery->execute(); |
|
172 | + $dtc = $combinedquery->fetchColumn(); |
|
173 | + $userElement->setAttribute("welctempchange", $dtc); |
|
174 | + $combinedquery->closeCursor(); |
|
175 | 175 | |
176 | - // Combine both actions affecting Email templates into one count. |
|
177 | - $combinedquery = $this->getDatabase()->prepare(<<<SQL |
|
176 | + // Combine both actions affecting Email templates into one count. |
|
177 | + $combinedquery = $this->getDatabase()->prepare(<<<SQL |
|
178 | 178 | SELECT COUNT(*) AS count |
179 | 179 | FROM log |
180 | 180 | WHERE log.user = :userid |
181 | 181 | AND log.action IN ('CreatedEmail', 'EditedEmail'); |
182 | 182 | SQL |
183 | - ); |
|
184 | - |
|
185 | - $combinedquery->bindValue(":userid", $this->user->getId()); |
|
186 | - $combinedquery->execute(); |
|
187 | - $cec = $combinedquery->fetchColumn(); |
|
188 | - $userElement->setAttribute("emailtempchange", $cec); |
|
189 | - $combinedquery->closeCursor(); |
|
190 | - } |
|
183 | + ); |
|
184 | + |
|
185 | + $combinedquery->bindValue(":userid", $this->user->getId()); |
|
186 | + $combinedquery->execute(); |
|
187 | + $cec = $combinedquery->fetchColumn(); |
|
188 | + $userElement->setAttribute("emailtempchange", $cec); |
|
189 | + $combinedquery->closeCursor(); |
|
190 | + } |
|
191 | 191 | } |
@@ -15,8 +15,8 @@ |
||
15 | 15 | */ |
16 | 16 | interface IApiAction extends IRoutedTask |
17 | 17 | { |
18 | - /** |
|
19 | - * @return string the XML, or false if an error occurred. |
|
20 | - */ |
|
21 | - public function runApiPage(); |
|
18 | + /** |
|
19 | + * @return string the XML, or false if an error occurred. |
|
20 | + */ |
|
21 | + public function runApiPage(); |
|
22 | 22 | } |
@@ -24,88 +24,88 @@ |
||
24 | 24 | */ |
25 | 25 | class AccessDeniedException extends ReadableException |
26 | 26 | { |
27 | - use NavigationMenuAccessControl; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var SecurityManager |
|
31 | - */ |
|
32 | - private $securityManager; |
|
33 | - |
|
34 | - /** |
|
35 | - * AccessDeniedException constructor. |
|
36 | - * |
|
37 | - * @param SecurityManager $securityManager |
|
38 | - */ |
|
39 | - public function __construct(SecurityManager $securityManager = null) |
|
40 | - { |
|
41 | - $this->securityManager = $securityManager; |
|
42 | - } |
|
43 | - |
|
44 | - public function getReadableError() |
|
45 | - { |
|
46 | - if (!headers_sent()) { |
|
47 | - header("HTTP/1.1 403 Forbidden"); |
|
48 | - } |
|
49 | - |
|
50 | - $this->setUpSmarty(); |
|
51 | - |
|
52 | - // uck. We should still be able to access the database in this situation though. |
|
53 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
54 | - $currentUser = User::getCurrent($database); |
|
55 | - $this->assign('currentUser', $currentUser); |
|
56 | - |
|
57 | - if($this->securityManager !== null) { |
|
58 | - $this->setupNavMenuAccess($currentUser); |
|
59 | - } |
|
60 | - |
|
61 | - if ($currentUser->isDeclined()) { |
|
62 | - $this->assign('htmlTitle', 'Account Declined'); |
|
63 | - $this->assign('declineReason', $this->getLogEntry('Declined', $currentUser, $database)); |
|
64 | - |
|
65 | - return $this->fetchTemplate("exception/account-declined.tpl"); |
|
66 | - } |
|
67 | - |
|
68 | - if ($currentUser->isSuspended()) { |
|
69 | - $this->assign('htmlTitle', 'Account Suspended'); |
|
70 | - $this->assign('suspendReason', $this->getLogEntry('Suspended', $currentUser, $database)); |
|
71 | - |
|
72 | - return $this->fetchTemplate("exception/account-suspended.tpl"); |
|
73 | - } |
|
74 | - |
|
75 | - if ($currentUser->isNewUser()) { |
|
76 | - $this->assign('htmlTitle', 'Account Pending'); |
|
77 | - |
|
78 | - return $this->fetchTemplate("exception/account-new.tpl"); |
|
79 | - } |
|
80 | - |
|
81 | - return $this->fetchTemplate("exception/access-denied.tpl"); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $action |
|
86 | - * @param User $user |
|
87 | - * @param PdoDatabase $database |
|
88 | - * |
|
89 | - * @return null|string |
|
90 | - */ |
|
91 | - private function getLogEntry($action, User $user, PdoDatabase $database) |
|
92 | - { |
|
93 | - /** @var Log[] $logs */ |
|
94 | - $logs = LogSearchHelper::get($database) |
|
95 | - ->byAction($action) |
|
96 | - ->byObjectType('User') |
|
97 | - ->byObjectId($user->getId()) |
|
98 | - ->limit(1) |
|
99 | - ->fetch(); |
|
100 | - |
|
101 | - return $logs[0]->getComment(); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @return SecurityManager |
|
106 | - */ |
|
107 | - protected function getSecurityManager() |
|
108 | - { |
|
109 | - return $this->securityManager; |
|
110 | - } |
|
27 | + use NavigationMenuAccessControl; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var SecurityManager |
|
31 | + */ |
|
32 | + private $securityManager; |
|
33 | + |
|
34 | + /** |
|
35 | + * AccessDeniedException constructor. |
|
36 | + * |
|
37 | + * @param SecurityManager $securityManager |
|
38 | + */ |
|
39 | + public function __construct(SecurityManager $securityManager = null) |
|
40 | + { |
|
41 | + $this->securityManager = $securityManager; |
|
42 | + } |
|
43 | + |
|
44 | + public function getReadableError() |
|
45 | + { |
|
46 | + if (!headers_sent()) { |
|
47 | + header("HTTP/1.1 403 Forbidden"); |
|
48 | + } |
|
49 | + |
|
50 | + $this->setUpSmarty(); |
|
51 | + |
|
52 | + // uck. We should still be able to access the database in this situation though. |
|
53 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
54 | + $currentUser = User::getCurrent($database); |
|
55 | + $this->assign('currentUser', $currentUser); |
|
56 | + |
|
57 | + if($this->securityManager !== null) { |
|
58 | + $this->setupNavMenuAccess($currentUser); |
|
59 | + } |
|
60 | + |
|
61 | + if ($currentUser->isDeclined()) { |
|
62 | + $this->assign('htmlTitle', 'Account Declined'); |
|
63 | + $this->assign('declineReason', $this->getLogEntry('Declined', $currentUser, $database)); |
|
64 | + |
|
65 | + return $this->fetchTemplate("exception/account-declined.tpl"); |
|
66 | + } |
|
67 | + |
|
68 | + if ($currentUser->isSuspended()) { |
|
69 | + $this->assign('htmlTitle', 'Account Suspended'); |
|
70 | + $this->assign('suspendReason', $this->getLogEntry('Suspended', $currentUser, $database)); |
|
71 | + |
|
72 | + return $this->fetchTemplate("exception/account-suspended.tpl"); |
|
73 | + } |
|
74 | + |
|
75 | + if ($currentUser->isNewUser()) { |
|
76 | + $this->assign('htmlTitle', 'Account Pending'); |
|
77 | + |
|
78 | + return $this->fetchTemplate("exception/account-new.tpl"); |
|
79 | + } |
|
80 | + |
|
81 | + return $this->fetchTemplate("exception/access-denied.tpl"); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $action |
|
86 | + * @param User $user |
|
87 | + * @param PdoDatabase $database |
|
88 | + * |
|
89 | + * @return null|string |
|
90 | + */ |
|
91 | + private function getLogEntry($action, User $user, PdoDatabase $database) |
|
92 | + { |
|
93 | + /** @var Log[] $logs */ |
|
94 | + $logs = LogSearchHelper::get($database) |
|
95 | + ->byAction($action) |
|
96 | + ->byObjectType('User') |
|
97 | + ->byObjectId($user->getId()) |
|
98 | + ->limit(1) |
|
99 | + ->fetch(); |
|
100 | + |
|
101 | + return $logs[0]->getComment(); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @return SecurityManager |
|
106 | + */ |
|
107 | + protected function getSecurityManager() |
|
108 | + { |
|
109 | + return $this->securityManager; |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | \ No newline at end of file |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $currentUser = User::getCurrent($database); |
55 | 55 | $this->assign('currentUser', $currentUser); |
56 | 56 | |
57 | - if($this->securityManager !== null) { |
|
57 | + if ($this->securityManager !== null) { |
|
58 | 58 | $this->setupNavMenuAccess($currentUser); |
59 | 59 | } |
60 | 60 |
@@ -15,51 +15,51 @@ |
||
15 | 15 | |
16 | 16 | class NotIdentifiedException extends ReadableException |
17 | 17 | { |
18 | - use NavigationMenuAccessControl; |
|
19 | - /** |
|
20 | - * @var SecurityManager |
|
21 | - */ |
|
22 | - private $securityManager; |
|
18 | + use NavigationMenuAccessControl; |
|
19 | + /** |
|
20 | + * @var SecurityManager |
|
21 | + */ |
|
22 | + private $securityManager; |
|
23 | 23 | |
24 | - /** |
|
25 | - * NotIdentifiedException constructor. |
|
26 | - * |
|
27 | - * @param SecurityManager $securityManager |
|
28 | - */ |
|
29 | - public function __construct(SecurityManager $securityManager = null) |
|
30 | - { |
|
31 | - $this->securityManager = $securityManager; |
|
32 | - } |
|
24 | + /** |
|
25 | + * NotIdentifiedException constructor. |
|
26 | + * |
|
27 | + * @param SecurityManager $securityManager |
|
28 | + */ |
|
29 | + public function __construct(SecurityManager $securityManager = null) |
|
30 | + { |
|
31 | + $this->securityManager = $securityManager; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Returns a readable HTML error message that's displayable to the user using templates. |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getReadableError() |
|
39 | - { |
|
40 | - if (!headers_sent()) { |
|
41 | - header("HTTP/1.1 403 Forbidden"); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Returns a readable HTML error message that's displayable to the user using templates. |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getReadableError() |
|
39 | + { |
|
40 | + if (!headers_sent()) { |
|
41 | + header("HTTP/1.1 403 Forbidden"); |
|
42 | + } |
|
43 | 43 | |
44 | - $this->setUpSmarty(); |
|
44 | + $this->setUpSmarty(); |
|
45 | 45 | |
46 | - // uck. We should still be able to access the database in this situation though. |
|
47 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
48 | - $currentUser = User::getCurrent($database); |
|
49 | - $this->assign('currentUser', $currentUser); |
|
46 | + // uck. We should still be able to access the database in this situation though. |
|
47 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
48 | + $currentUser = User::getCurrent($database); |
|
49 | + $this->assign('currentUser', $currentUser); |
|
50 | 50 | |
51 | - if($this->securityManager !== null) { |
|
52 | - $this->setupNavMenuAccess($currentUser); |
|
53 | - } |
|
51 | + if($this->securityManager !== null) { |
|
52 | + $this->setupNavMenuAccess($currentUser); |
|
53 | + } |
|
54 | 54 | |
55 | - return $this->fetchTemplate("exception/not-identified.tpl"); |
|
56 | - } |
|
55 | + return $this->fetchTemplate("exception/not-identified.tpl"); |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * @return SecurityManager |
|
60 | - */ |
|
61 | - protected function getSecurityManager() |
|
62 | - { |
|
63 | - return $this->securityManager; |
|
64 | - } |
|
58 | + /** |
|
59 | + * @return SecurityManager |
|
60 | + */ |
|
61 | + protected function getSecurityManager() |
|
62 | + { |
|
63 | + return $this->securityManager; |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | \ No newline at end of file |
@@ -54,7 +54,7 @@ |
||
54 | 54 | $currentUser = User::getCurrent($database); |
55 | 55 | $this->assign('currentUser', $currentUser); |
56 | 56 | |
57 | - if($this->securityManager !== null) { |
|
57 | + if ($this->securityManager !== null) { |
|
58 | 58 | $this->setupNavMenuAccess($currentUser); |
59 | 59 | } |
60 | 60 |
@@ -13,37 +13,37 @@ |
||
13 | 13 | */ |
14 | 14 | class AutoLoader |
15 | 15 | { |
16 | - public static function load($class) |
|
17 | - { |
|
18 | - // handle namespaces sensibly |
|
19 | - if (strpos($class, "Waca") !== false) { |
|
20 | - // strip off the initial namespace |
|
21 | - $class = str_replace("Waca\\", "", $class); |
|
16 | + public static function load($class) |
|
17 | + { |
|
18 | + // handle namespaces sensibly |
|
19 | + if (strpos($class, "Waca") !== false) { |
|
20 | + // strip off the initial namespace |
|
21 | + $class = str_replace("Waca\\", "", $class); |
|
22 | 22 | |
23 | - // swap backslashes for forward slashes to map to directory names |
|
24 | - $class = str_replace("\\", "/", $class); |
|
25 | - } |
|
23 | + // swap backslashes for forward slashes to map to directory names |
|
24 | + $class = str_replace("\\", "/", $class); |
|
25 | + } |
|
26 | 26 | |
27 | - $paths = array( |
|
28 | - __DIR__ . '/' . $class . ".php", |
|
29 | - __DIR__ . '/DataObjects/' . $class . ".php", |
|
30 | - __DIR__ . '/Providers/' . $class . ".php", |
|
31 | - __DIR__ . '/Providers/Interfaces/' . $class . ".php", |
|
32 | - __DIR__ . '/Validation/' . $class . ".php", |
|
33 | - __DIR__ . '/Helpers/' . $class . ".php", |
|
34 | - __DIR__ . '/Helpers/Interfaces/' . $class . ".php", |
|
35 | - __DIR__ . '/' . $class . ".php", |
|
36 | - ); |
|
27 | + $paths = array( |
|
28 | + __DIR__ . '/' . $class . ".php", |
|
29 | + __DIR__ . '/DataObjects/' . $class . ".php", |
|
30 | + __DIR__ . '/Providers/' . $class . ".php", |
|
31 | + __DIR__ . '/Providers/Interfaces/' . $class . ".php", |
|
32 | + __DIR__ . '/Validation/' . $class . ".php", |
|
33 | + __DIR__ . '/Helpers/' . $class . ".php", |
|
34 | + __DIR__ . '/Helpers/Interfaces/' . $class . ".php", |
|
35 | + __DIR__ . '/' . $class . ".php", |
|
36 | + ); |
|
37 | 37 | |
38 | - foreach ($paths as $file) { |
|
39 | - if (file_exists($file)) { |
|
40 | - /** @noinspection PhpIncludeInspection */ |
|
41 | - require_once($file); |
|
42 | - } |
|
38 | + foreach ($paths as $file) { |
|
39 | + if (file_exists($file)) { |
|
40 | + /** @noinspection PhpIncludeInspection */ |
|
41 | + require_once($file); |
|
42 | + } |
|
43 | 43 | |
44 | - if (class_exists($class)) { |
|
45 | - return; |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
44 | + if (class_exists($class)) { |
|
45 | + return; |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | class RequestStatus |
12 | 12 | { |
13 | - const HOSPITAL = 'Hospital'; |
|
14 | - const JOBQUEUE = 'JobQueue'; |
|
15 | - const CLOSED = 'Closed'; |
|
13 | + const HOSPITAL = 'Hospital'; |
|
14 | + const JOBQUEUE = 'JobQueue'; |
|
15 | + const CLOSED = 'Closed'; |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -18,71 +18,71 @@ |
||
18 | 18 | |
19 | 19 | trait RequestListData |
20 | 20 | { |
21 | - // function imports from InternalPageBase etc. |
|
22 | - protected abstract function getDatabase(); |
|
23 | - |
|
24 | - protected abstract function getXffTrustProvider(); |
|
25 | - |
|
26 | - protected abstract function getSiteConfiguration(); |
|
27 | - |
|
28 | - protected abstract function barrierTest($action, User $user, $pageName = null); |
|
29 | - |
|
30 | - /** |
|
31 | - * @param Request[] $requests |
|
32 | - * |
|
33 | - * @return RequestList |
|
34 | - */ |
|
35 | - protected function prepareRequestData(array $requests) : RequestList |
|
36 | - { |
|
37 | - $requestList = new RequestList(); |
|
38 | - $requestList->requests = $requests; |
|
39 | - |
|
40 | - $userIds = array_map( |
|
41 | - function(Request $entry) { |
|
42 | - return $entry->getReserved(); |
|
43 | - }, |
|
44 | - $requests |
|
45 | - ); |
|
46 | - |
|
47 | - $requestList->userList = UserSearchHelper::get($this->getDatabase())->inIds($userIds)->fetchMap('username'); |
|
48 | - |
|
49 | - $requestList->requestTrustedIp = []; |
|
50 | - $requestList->relatedIpRequests = []; |
|
51 | - $requestList->relatedEmailRequests = []; |
|
52 | - |
|
53 | - foreach ($requests as $request) { |
|
54 | - $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
55 | - $request->getIp(), |
|
56 | - $request->getForwardedIp() |
|
57 | - ); |
|
58 | - |
|
59 | - RequestSearchHelper::get($this->getDatabase()) |
|
60 | - ->byIp($trustedIp) |
|
61 | - ->withConfirmedEmail() |
|
62 | - ->excludingPurgedData($this->getSiteConfiguration()) |
|
63 | - ->excludingRequest($request->getId()) |
|
64 | - ->getRecordCount($ipCount); |
|
65 | - |
|
66 | - RequestSearchHelper::get($this->getDatabase()) |
|
67 | - ->byEmailAddress($request->getEmail()) |
|
68 | - ->withConfirmedEmail() |
|
69 | - ->excludingPurgedData($this->getSiteConfiguration()) |
|
70 | - ->excludingRequest($request->getId()) |
|
71 | - ->getRecordCount($emailCount); |
|
72 | - |
|
73 | - $requestList->requestTrustedIp[$request->getId()] = $trustedIp; |
|
74 | - $requestList->relatedEmailRequests[$request->getId()] = $emailCount; |
|
75 | - $requestList->relatedIpRequests[$request->getId()] = $ipCount; |
|
76 | - } |
|
77 | - |
|
78 | - $currentUser = User::getCurrent($this->getDatabase()); |
|
79 | - |
|
80 | - $requestList->canBan = $this->barrierTest('set', $currentUser, PageBan::class); |
|
81 | - $requestList->canBreakReservation = $this->barrierTest('force', $currentUser, PageBreakReservation::class); |
|
82 | - $requestList->showPrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData'); |
|
83 | - $requestList->dataClearEmail = $this->getSiteConfiguration()->getDataClearEmail(); |
|
84 | - $requestList->dataClearIp = $this->getSiteConfiguration()->getDataClearIp(); |
|
85 | - |
|
86 | - return $requestList; |
|
87 | - } |
|
21 | + // function imports from InternalPageBase etc. |
|
22 | + protected abstract function getDatabase(); |
|
23 | + |
|
24 | + protected abstract function getXffTrustProvider(); |
|
25 | + |
|
26 | + protected abstract function getSiteConfiguration(); |
|
27 | + |
|
28 | + protected abstract function barrierTest($action, User $user, $pageName = null); |
|
29 | + |
|
30 | + /** |
|
31 | + * @param Request[] $requests |
|
32 | + * |
|
33 | + * @return RequestList |
|
34 | + */ |
|
35 | + protected function prepareRequestData(array $requests) : RequestList |
|
36 | + { |
|
37 | + $requestList = new RequestList(); |
|
38 | + $requestList->requests = $requests; |
|
39 | + |
|
40 | + $userIds = array_map( |
|
41 | + function(Request $entry) { |
|
42 | + return $entry->getReserved(); |
|
43 | + }, |
|
44 | + $requests |
|
45 | + ); |
|
46 | + |
|
47 | + $requestList->userList = UserSearchHelper::get($this->getDatabase())->inIds($userIds)->fetchMap('username'); |
|
48 | + |
|
49 | + $requestList->requestTrustedIp = []; |
|
50 | + $requestList->relatedIpRequests = []; |
|
51 | + $requestList->relatedEmailRequests = []; |
|
52 | + |
|
53 | + foreach ($requests as $request) { |
|
54 | + $trustedIp = $this->getXffTrustProvider()->getTrustedClientIp( |
|
55 | + $request->getIp(), |
|
56 | + $request->getForwardedIp() |
|
57 | + ); |
|
58 | + |
|
59 | + RequestSearchHelper::get($this->getDatabase()) |
|
60 | + ->byIp($trustedIp) |
|
61 | + ->withConfirmedEmail() |
|
62 | + ->excludingPurgedData($this->getSiteConfiguration()) |
|
63 | + ->excludingRequest($request->getId()) |
|
64 | + ->getRecordCount($ipCount); |
|
65 | + |
|
66 | + RequestSearchHelper::get($this->getDatabase()) |
|
67 | + ->byEmailAddress($request->getEmail()) |
|
68 | + ->withConfirmedEmail() |
|
69 | + ->excludingPurgedData($this->getSiteConfiguration()) |
|
70 | + ->excludingRequest($request->getId()) |
|
71 | + ->getRecordCount($emailCount); |
|
72 | + |
|
73 | + $requestList->requestTrustedIp[$request->getId()] = $trustedIp; |
|
74 | + $requestList->relatedEmailRequests[$request->getId()] = $emailCount; |
|
75 | + $requestList->relatedIpRequests[$request->getId()] = $ipCount; |
|
76 | + } |
|
77 | + |
|
78 | + $currentUser = User::getCurrent($this->getDatabase()); |
|
79 | + |
|
80 | + $requestList->canBan = $this->barrierTest('set', $currentUser, PageBan::class); |
|
81 | + $requestList->canBreakReservation = $this->barrierTest('force', $currentUser, PageBreakReservation::class); |
|
82 | + $requestList->showPrivateData = $this->barrierTest('alwaysSeePrivateData', $currentUser, 'RequestData'); |
|
83 | + $requestList->dataClearEmail = $this->getSiteConfiguration()->getDataClearEmail(); |
|
84 | + $requestList->dataClearIp = $this->getSiteConfiguration()->getDataClearIp(); |
|
85 | + |
|
86 | + return $requestList; |
|
87 | + } |
|
88 | 88 | } |
@@ -38,7 +38,8 @@ |
||
38 | 38 | $requestList->requests = $requests; |
39 | 39 | |
40 | 40 | $userIds = array_map( |
41 | - function(Request $entry) { |
|
41 | + function(Request $entry) |
|
42 | + { |
|
42 | 43 | return $entry->getReserved(); |
43 | 44 | }, |
44 | 45 | $requests |