@@ -22,233 +22,233 @@ |
||
22 | 22 | |
23 | 23 | class OAuthProtocolHelper implements IOAuthProtocolHelper |
24 | 24 | { |
25 | - private $oauthConsumer; |
|
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - private $oauthEndpoint; |
|
30 | - /** |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - private $consumerToken; |
|
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - private $consumerSecret; |
|
38 | - /** |
|
39 | - * @var HttpHelper |
|
40 | - */ |
|
41 | - private $httpHelper; |
|
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - private $mediawikiWebServiceEndpoint; |
|
46 | - |
|
47 | - /** |
|
48 | - * OAuthHelper constructor. |
|
49 | - * |
|
50 | - * @param string $oauthEndpoint |
|
51 | - * @param string $consumerKey |
|
52 | - * @param string $consumerSecret |
|
53 | - * @param HttpHelper $httpHelper |
|
54 | - * @param string $mediawikiWebServiceEndpoint |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - $oauthEndpoint, |
|
58 | - $consumerKey, |
|
59 | - $consumerSecret, |
|
60 | - HttpHelper $httpHelper, |
|
61 | - $mediawikiWebServiceEndpoint |
|
62 | - ) { |
|
63 | - $this->oauthEndpoint = $oauthEndpoint; |
|
64 | - $this->consumerToken = $consumerKey; |
|
65 | - $this->consumerSecret = $consumerSecret; |
|
66 | - $this->httpHelper = $httpHelper; |
|
67 | - |
|
68 | - $this->oauthConsumer = new OAuthConsumer($this->consumerToken, $this->consumerSecret); |
|
69 | - $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * @return stdClass |
|
74 | - * |
|
75 | - * @throws Exception |
|
76 | - * @throws CurlException |
|
77 | - */ |
|
78 | - public function getRequestToken() |
|
79 | - { |
|
80 | - $endpoint = $this->oauthEndpoint . '/initiate&format=json&oauth_callback=oob'; |
|
81 | - |
|
82 | - $parsedUrl = parse_url($endpoint); |
|
83 | - $urlParameters = array(); |
|
84 | - parse_str($parsedUrl['query'], $urlParameters); |
|
85 | - |
|
86 | - $req_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, null, 'GET', $endpoint, $urlParameters); |
|
87 | - $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
88 | - $req_req->sign_request($hmac_method, $this->oauthConsumer, null); |
|
89 | - |
|
90 | - $targetUrl = (string)$req_req; |
|
91 | - |
|
92 | - $data = $this->httpHelper->get($targetUrl, null); |
|
93 | - |
|
94 | - if ($data === false) { |
|
95 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
96 | - } |
|
97 | - |
|
98 | - $token = json_decode($data); |
|
99 | - |
|
100 | - if (!isset($token)) { |
|
101 | - throw new OAuthException('Unknown error encountered getting request token while decoding json data.'); |
|
102 | - } |
|
103 | - |
|
104 | - if (isset($token->error)) { |
|
105 | - throw new OAuthException('Error encountered while getting request token: ' . $token->error); |
|
106 | - } |
|
107 | - |
|
108 | - return $token; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $requestToken |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public function getAuthoriseUrl($requestToken) |
|
117 | - { |
|
118 | - return "{$this->oauthEndpoint}/authorize&oauth_token={$requestToken}&oauth_consumer_key={$this->consumerToken}"; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @param string $oauthRequestToken |
|
123 | - * @param string $oauthRequestSecret |
|
124 | - * @param string $oauthVerifier |
|
125 | - * |
|
126 | - * @return stdClass |
|
127 | - * @throws CurlException |
|
128 | - * @throws Exception |
|
129 | - */ |
|
130 | - public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier) |
|
131 | - { |
|
132 | - $endpoint = $this->oauthEndpoint . '/token&format=json'; |
|
133 | - |
|
134 | - $requestConsumer = new OAuthConsumer($oauthRequestToken, $oauthRequestSecret); |
|
135 | - |
|
136 | - $parsedUrl = parse_url($endpoint); |
|
137 | - parse_str($parsedUrl['query'], $urlParameters); |
|
138 | - $urlParameters['oauth_verifier'] = trim($oauthVerifier); |
|
139 | - |
|
140 | - $acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $requestConsumer, 'GET', $endpoint, |
|
141 | - $urlParameters); |
|
142 | - $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
143 | - $acc_req->sign_request($hmac_method, $this->oauthConsumer, $requestConsumer); |
|
144 | - |
|
145 | - $targetUrl = (string)$acc_req; |
|
146 | - |
|
147 | - $data = $this->httpHelper->get($targetUrl, null); |
|
148 | - |
|
149 | - if ($data === false) { |
|
150 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
151 | - } |
|
152 | - |
|
153 | - $token = json_decode($data); |
|
154 | - |
|
155 | - if (!isset($token)) { |
|
156 | - throw new OAuthException('Unknown error encountered getting access token while decoding json data.'); |
|
157 | - } |
|
158 | - |
|
159 | - if (isset($token->error)) { |
|
160 | - throw new OAuthException('Error encountered while getting access token: ' . $token->error); |
|
161 | - } |
|
162 | - |
|
163 | - return $token; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * @param string $oauthAccessToken |
|
168 | - * @param string $oauthAccessSecret |
|
169 | - * |
|
170 | - * @return stdClass |
|
171 | - * @throws CurlException |
|
172 | - * @throws Exception |
|
173 | - */ |
|
174 | - public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret) |
|
175 | - { |
|
176 | - $endpoint = $this->oauthEndpoint . '/identify&format=json'; |
|
177 | - |
|
178 | - $oauthToken = new OAuthToken($oauthAccessToken, $oauthAccessSecret); |
|
179 | - |
|
180 | - $parsedUrl = parse_url($endpoint); |
|
181 | - parse_str($parsedUrl['query'], $urlParameters); |
|
182 | - |
|
183 | - $acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $oauthToken, 'GET', $endpoint, |
|
184 | - $urlParameters); |
|
185 | - $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
186 | - $acc_req->sign_request($hmac_method, $this->oauthConsumer, $oauthToken); |
|
187 | - |
|
188 | - $targetUrl = (string)$acc_req; |
|
189 | - |
|
190 | - $data = $this->httpHelper->get($targetUrl, null); |
|
191 | - |
|
192 | - if ($data === false) { |
|
193 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
194 | - } |
|
195 | - |
|
196 | - $decodedData = json_decode($data); |
|
197 | - |
|
198 | - if (isset($decodedData->error)) { |
|
199 | - throw new OAuthException($decodedData->error); |
|
200 | - } |
|
201 | - |
|
202 | - $identity = JWT::decode($data, $this->consumerSecret); |
|
203 | - |
|
204 | - return $identity; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * @param array $apiParams array of parameters to send to the API |
|
209 | - * @param string $accessToken user's access token |
|
210 | - * @param string $accessSecret user's secret |
|
211 | - * @param string $method HTTP method |
|
212 | - * |
|
213 | - * @return stdClass |
|
214 | - * @throws ApplicationLogicException |
|
215 | - * @throws CurlException |
|
216 | - * @throws Exception |
|
217 | - */ |
|
218 | - public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET') |
|
219 | - { |
|
220 | - $userToken = new OAuthToken($accessToken, $accessSecret); |
|
221 | - |
|
222 | - $apiParams['format'] = 'json'; |
|
223 | - |
|
224 | - $api_req = OAuthRequest::from_consumer_and_token( |
|
225 | - $this->oauthConsumer, // Consumer |
|
226 | - $userToken, // User Access Token |
|
227 | - $method, // HTTP Method |
|
228 | - $this->mediawikiWebServiceEndpoint, // Endpoint url |
|
229 | - $apiParams // Extra signed parameters |
|
230 | - ); |
|
25 | + private $oauthConsumer; |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + private $oauthEndpoint; |
|
30 | + /** |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + private $consumerToken; |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + private $consumerSecret; |
|
38 | + /** |
|
39 | + * @var HttpHelper |
|
40 | + */ |
|
41 | + private $httpHelper; |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + private $mediawikiWebServiceEndpoint; |
|
46 | + |
|
47 | + /** |
|
48 | + * OAuthHelper constructor. |
|
49 | + * |
|
50 | + * @param string $oauthEndpoint |
|
51 | + * @param string $consumerKey |
|
52 | + * @param string $consumerSecret |
|
53 | + * @param HttpHelper $httpHelper |
|
54 | + * @param string $mediawikiWebServiceEndpoint |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + $oauthEndpoint, |
|
58 | + $consumerKey, |
|
59 | + $consumerSecret, |
|
60 | + HttpHelper $httpHelper, |
|
61 | + $mediawikiWebServiceEndpoint |
|
62 | + ) { |
|
63 | + $this->oauthEndpoint = $oauthEndpoint; |
|
64 | + $this->consumerToken = $consumerKey; |
|
65 | + $this->consumerSecret = $consumerSecret; |
|
66 | + $this->httpHelper = $httpHelper; |
|
67 | + |
|
68 | + $this->oauthConsumer = new OAuthConsumer($this->consumerToken, $this->consumerSecret); |
|
69 | + $this->mediawikiWebServiceEndpoint = $mediawikiWebServiceEndpoint; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * @return stdClass |
|
74 | + * |
|
75 | + * @throws Exception |
|
76 | + * @throws CurlException |
|
77 | + */ |
|
78 | + public function getRequestToken() |
|
79 | + { |
|
80 | + $endpoint = $this->oauthEndpoint . '/initiate&format=json&oauth_callback=oob'; |
|
81 | + |
|
82 | + $parsedUrl = parse_url($endpoint); |
|
83 | + $urlParameters = array(); |
|
84 | + parse_str($parsedUrl['query'], $urlParameters); |
|
85 | + |
|
86 | + $req_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, null, 'GET', $endpoint, $urlParameters); |
|
87 | + $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
88 | + $req_req->sign_request($hmac_method, $this->oauthConsumer, null); |
|
89 | + |
|
90 | + $targetUrl = (string)$req_req; |
|
91 | + |
|
92 | + $data = $this->httpHelper->get($targetUrl, null); |
|
93 | + |
|
94 | + if ($data === false) { |
|
95 | + throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
96 | + } |
|
97 | + |
|
98 | + $token = json_decode($data); |
|
99 | + |
|
100 | + if (!isset($token)) { |
|
101 | + throw new OAuthException('Unknown error encountered getting request token while decoding json data.'); |
|
102 | + } |
|
103 | + |
|
104 | + if (isset($token->error)) { |
|
105 | + throw new OAuthException('Error encountered while getting request token: ' . $token->error); |
|
106 | + } |
|
107 | + |
|
108 | + return $token; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $requestToken |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public function getAuthoriseUrl($requestToken) |
|
117 | + { |
|
118 | + return "{$this->oauthEndpoint}/authorize&oauth_token={$requestToken}&oauth_consumer_key={$this->consumerToken}"; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @param string $oauthRequestToken |
|
123 | + * @param string $oauthRequestSecret |
|
124 | + * @param string $oauthVerifier |
|
125 | + * |
|
126 | + * @return stdClass |
|
127 | + * @throws CurlException |
|
128 | + * @throws Exception |
|
129 | + */ |
|
130 | + public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier) |
|
131 | + { |
|
132 | + $endpoint = $this->oauthEndpoint . '/token&format=json'; |
|
133 | + |
|
134 | + $requestConsumer = new OAuthConsumer($oauthRequestToken, $oauthRequestSecret); |
|
135 | + |
|
136 | + $parsedUrl = parse_url($endpoint); |
|
137 | + parse_str($parsedUrl['query'], $urlParameters); |
|
138 | + $urlParameters['oauth_verifier'] = trim($oauthVerifier); |
|
139 | + |
|
140 | + $acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $requestConsumer, 'GET', $endpoint, |
|
141 | + $urlParameters); |
|
142 | + $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
143 | + $acc_req->sign_request($hmac_method, $this->oauthConsumer, $requestConsumer); |
|
144 | + |
|
145 | + $targetUrl = (string)$acc_req; |
|
146 | + |
|
147 | + $data = $this->httpHelper->get($targetUrl, null); |
|
148 | + |
|
149 | + if ($data === false) { |
|
150 | + throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
151 | + } |
|
152 | + |
|
153 | + $token = json_decode($data); |
|
154 | + |
|
155 | + if (!isset($token)) { |
|
156 | + throw new OAuthException('Unknown error encountered getting access token while decoding json data.'); |
|
157 | + } |
|
158 | + |
|
159 | + if (isset($token->error)) { |
|
160 | + throw new OAuthException('Error encountered while getting access token: ' . $token->error); |
|
161 | + } |
|
162 | + |
|
163 | + return $token; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * @param string $oauthAccessToken |
|
168 | + * @param string $oauthAccessSecret |
|
169 | + * |
|
170 | + * @return stdClass |
|
171 | + * @throws CurlException |
|
172 | + * @throws Exception |
|
173 | + */ |
|
174 | + public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret) |
|
175 | + { |
|
176 | + $endpoint = $this->oauthEndpoint . '/identify&format=json'; |
|
177 | + |
|
178 | + $oauthToken = new OAuthToken($oauthAccessToken, $oauthAccessSecret); |
|
179 | + |
|
180 | + $parsedUrl = parse_url($endpoint); |
|
181 | + parse_str($parsedUrl['query'], $urlParameters); |
|
182 | + |
|
183 | + $acc_req = OAuthRequest::from_consumer_and_token($this->oauthConsumer, $oauthToken, 'GET', $endpoint, |
|
184 | + $urlParameters); |
|
185 | + $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
186 | + $acc_req->sign_request($hmac_method, $this->oauthConsumer, $oauthToken); |
|
187 | + |
|
188 | + $targetUrl = (string)$acc_req; |
|
189 | + |
|
190 | + $data = $this->httpHelper->get($targetUrl, null); |
|
191 | + |
|
192 | + if ($data === false) { |
|
193 | + throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
194 | + } |
|
195 | + |
|
196 | + $decodedData = json_decode($data); |
|
197 | + |
|
198 | + if (isset($decodedData->error)) { |
|
199 | + throw new OAuthException($decodedData->error); |
|
200 | + } |
|
201 | + |
|
202 | + $identity = JWT::decode($data, $this->consumerSecret); |
|
203 | + |
|
204 | + return $identity; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * @param array $apiParams array of parameters to send to the API |
|
209 | + * @param string $accessToken user's access token |
|
210 | + * @param string $accessSecret user's secret |
|
211 | + * @param string $method HTTP method |
|
212 | + * |
|
213 | + * @return stdClass |
|
214 | + * @throws ApplicationLogicException |
|
215 | + * @throws CurlException |
|
216 | + * @throws Exception |
|
217 | + */ |
|
218 | + public function apiCall($apiParams, $accessToken, $accessSecret, $method = 'GET') |
|
219 | + { |
|
220 | + $userToken = new OAuthToken($accessToken, $accessSecret); |
|
221 | + |
|
222 | + $apiParams['format'] = 'json'; |
|
223 | + |
|
224 | + $api_req = OAuthRequest::from_consumer_and_token( |
|
225 | + $this->oauthConsumer, // Consumer |
|
226 | + $userToken, // User Access Token |
|
227 | + $method, // HTTP Method |
|
228 | + $this->mediawikiWebServiceEndpoint, // Endpoint url |
|
229 | + $apiParams // Extra signed parameters |
|
230 | + ); |
|
231 | 231 | |
232 | - $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
232 | + $hmac_method = new OAuthSignatureMethod_HMAC_SHA1(); |
|
233 | 233 | |
234 | - $api_req->sign_request($hmac_method, $this->oauthConsumer, $userToken); |
|
234 | + $api_req->sign_request($hmac_method, $this->oauthConsumer, $userToken); |
|
235 | 235 | |
236 | - $headers = array($api_req->to_header()); |
|
237 | - |
|
238 | - if ($method == 'GET') { |
|
239 | - $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams, $headers); |
|
240 | - } |
|
241 | - elseif ($method == 'POST') { |
|
242 | - $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams, $headers); |
|
243 | - } |
|
244 | - else { |
|
245 | - throw new ApplicationLogicException('Unsupported HTTP Method'); |
|
246 | - } |
|
247 | - |
|
248 | - if ($data === false) { |
|
249 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
250 | - } |
|
251 | - |
|
252 | - return json_decode($data); |
|
253 | - } |
|
236 | + $headers = array($api_req->to_header()); |
|
237 | + |
|
238 | + if ($method == 'GET') { |
|
239 | + $data = $this->httpHelper->get($this->mediawikiWebServiceEndpoint, $apiParams, $headers); |
|
240 | + } |
|
241 | + elseif ($method == 'POST') { |
|
242 | + $data = $this->httpHelper->post($this->mediawikiWebServiceEndpoint, $apiParams, $headers); |
|
243 | + } |
|
244 | + else { |
|
245 | + throw new ApplicationLogicException('Unsupported HTTP Method'); |
|
246 | + } |
|
247 | + |
|
248 | + if ($data === false) { |
|
249 | + throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
250 | + } |
|
251 | + |
|
252 | + return json_decode($data); |
|
253 | + } |
|
254 | 254 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getRequestToken() |
79 | 79 | { |
80 | - $endpoint = $this->oauthEndpoint . '/initiate&format=json&oauth_callback=oob'; |
|
80 | + $endpoint = $this->oauthEndpoint.'/initiate&format=json&oauth_callback=oob'; |
|
81 | 81 | |
82 | 82 | $parsedUrl = parse_url($endpoint); |
83 | 83 | $urlParameters = array(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $data = $this->httpHelper->get($targetUrl, null); |
93 | 93 | |
94 | 94 | if ($data === false) { |
95 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
95 | + throw new CurlException('Curl error: '.$this->httpHelper->getError()); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $token = json_decode($data); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | if (isset($token->error)) { |
105 | - throw new OAuthException('Error encountered while getting request token: ' . $token->error); |
|
105 | + throw new OAuthException('Error encountered while getting request token: '.$token->error); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $token; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function callbackCompleted($oauthRequestToken, $oauthRequestSecret, $oauthVerifier) |
131 | 131 | { |
132 | - $endpoint = $this->oauthEndpoint . '/token&format=json'; |
|
132 | + $endpoint = $this->oauthEndpoint.'/token&format=json'; |
|
133 | 133 | |
134 | 134 | $requestConsumer = new OAuthConsumer($oauthRequestToken, $oauthRequestSecret); |
135 | 135 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $data = $this->httpHelper->get($targetUrl, null); |
148 | 148 | |
149 | 149 | if ($data === false) { |
150 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
150 | + throw new CurlException('Curl error: '.$this->httpHelper->getError()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $token = json_decode($data); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | if (isset($token->error)) { |
160 | - throw new OAuthException('Error encountered while getting access token: ' . $token->error); |
|
160 | + throw new OAuthException('Error encountered while getting access token: '.$token->error); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return $token; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function getIdentityTicket($oauthAccessToken, $oauthAccessSecret) |
175 | 175 | { |
176 | - $endpoint = $this->oauthEndpoint . '/identify&format=json'; |
|
176 | + $endpoint = $this->oauthEndpoint.'/identify&format=json'; |
|
177 | 177 | |
178 | 178 | $oauthToken = new OAuthToken($oauthAccessToken, $oauthAccessSecret); |
179 | 179 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $data = $this->httpHelper->get($targetUrl, null); |
191 | 191 | |
192 | 192 | if ($data === false) { |
193 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
193 | + throw new CurlException('Curl error: '.$this->httpHelper->getError()); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $decodedData = json_decode($data); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | |
248 | 248 | if ($data === false) { |
249 | - throw new CurlException('Curl error: ' . $this->httpHelper->getError()); |
|
249 | + throw new CurlException('Curl error: '.$this->httpHelper->getError()); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return json_decode($data); |
@@ -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 |
@@ -16,16 +16,16 @@ |
||
16 | 16 | |
17 | 17 | class BotCreationTask extends CreationTaskBase |
18 | 18 | { |
19 | - /** |
|
20 | - * @return IMediaWikiClient |
|
21 | - */ |
|
22 | - protected function getMediaWikiClient() |
|
23 | - { |
|
24 | - return new BotMediaWikiClient($this->getSiteConfiguration()); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @return IMediaWikiClient |
|
21 | + */ |
|
22 | + protected function getMediaWikiClient() |
|
23 | + { |
|
24 | + return new BotMediaWikiClient($this->getSiteConfiguration()); |
|
25 | + } |
|
26 | 26 | |
27 | - protected function getCreationReason(Request $request, User $user) |
|
28 | - { |
|
29 | - return parent::getCreationReason($request, $user) . ', on behalf of [[User:' . $user->getOnWikiName() . ']]'; |
|
30 | - } |
|
27 | + protected function getCreationReason(Request $request, User $user) |
|
28 | + { |
|
29 | + return parent::getCreationReason($request, $user) . ', on behalf of [[User:' . $user->getOnWikiName() . ']]'; |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -26,6 +26,6 @@ |
||
26 | 26 | |
27 | 27 | protected function getCreationReason(Request $request, User $user) |
28 | 28 | { |
29 | - return parent::getCreationReason($request, $user) . ', on behalf of [[User:' . $user->getOnWikiName() . ']]'; |
|
29 | + return parent::getCreationReason($request, $user).', on behalf of [[User:'.$user->getOnWikiName().']]'; |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -14,14 +14,14 @@ |
||
14 | 14 | |
15 | 15 | class UserCreationTask extends CreationTaskBase |
16 | 16 | { |
17 | - /** |
|
18 | - * @return IMediaWikiClient |
|
19 | - */ |
|
20 | - protected function getMediaWikiClient() |
|
21 | - { |
|
22 | - $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
23 | - $this->getSiteConfiguration()); |
|
17 | + /** |
|
18 | + * @return IMediaWikiClient |
|
19 | + */ |
|
20 | + protected function getMediaWikiClient() |
|
21 | + { |
|
22 | + $oauth = new OAuthUserHelper($this->getTriggerUser(), $this->getDatabase(), $this->getOauthProtocolHelper(), |
|
23 | + $this->getSiteConfiguration()); |
|
24 | 24 | |
25 | - return $oauth; |
|
26 | - } |
|
25 | + return $oauth; |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | \ No newline at end of file |
@@ -20,73 +20,73 @@ |
||
20 | 20 | |
21 | 21 | class WelcomeUserTask extends BackgroundTaskBase |
22 | 22 | { |
23 | - public static function enqueue(User $triggerUser, Request $request, PdoDatabase $database) |
|
24 | - { |
|
25 | - $job = new JobQueue(); |
|
26 | - $job->setDatabase($database); |
|
27 | - $job->setTask(WelcomeUserTask::class); |
|
28 | - $job->setRequest($request->getId()); |
|
29 | - $job->setTriggerUserId($triggerUser->getId()); |
|
30 | - $job->save(); |
|
31 | - } |
|
32 | - |
|
33 | - public function execute() |
|
34 | - { |
|
35 | - $database = $this->getDatabase(); |
|
36 | - $request = $this->getRequest(); |
|
37 | - $user = $this->getTriggerUser(); |
|
38 | - |
|
39 | - if ($user->getWelcomeTemplate() === null) { |
|
40 | - $this->markFailed('Welcome template not specified'); |
|
41 | - |
|
42 | - return; |
|
43 | - } |
|
44 | - |
|
45 | - /** @var WelcomeTemplate $template */ |
|
46 | - $template = WelcomeTemplate::getById($user->getWelcomeTemplate(), $database); |
|
47 | - |
|
48 | - if ($template === false) { |
|
49 | - $this->markFailed('Welcome template missing'); |
|
50 | - |
|
51 | - return; |
|
52 | - } |
|
53 | - |
|
54 | - $oauth = new OAuthUserHelper($user, $database, $this->getOauthProtocolHelper(), |
|
55 | - $this->getSiteConfiguration()); |
|
56 | - $mediaWikiHelper = new MediaWikiHelper($oauth, $this->getSiteConfiguration()); |
|
57 | - |
|
58 | - if ($request->getStatus() !== RequestStatus::CLOSED) { |
|
59 | - $this->markFailed('Request is currently open'); |
|
60 | - |
|
61 | - return; |
|
62 | - } |
|
63 | - |
|
64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
65 | - $this->markFailed('Account does not exist!'); |
|
66 | - |
|
67 | - return; |
|
68 | - } |
|
69 | - |
|
70 | - $this->performWelcome($template, $request, $mediaWikiHelper); |
|
71 | - $this->markComplete(); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Performs the welcome |
|
76 | - * |
|
77 | - * @param WelcomeTemplate $template |
|
78 | - * @param Request $request |
|
79 | - * @param MediaWikiHelper $mediaWikiHelper |
|
80 | - */ |
|
81 | - private function performWelcome( |
|
82 | - WelcomeTemplate $template, |
|
83 | - Request $request, |
|
84 | - MediaWikiHelper $mediaWikiHelper |
|
85 | - ) { |
|
86 | - $templateText = $template->getBotCode(); |
|
87 | - $templateText = str_replace('$signature', '~~~~', $templateText); |
|
88 | - $templateText = str_replace('$username', $request->getName(), $templateText); |
|
89 | - |
|
90 | - $mediaWikiHelper->addTalkPageMessage($request->getName(), 'Welcome!', 'Welcoming user created through [[WP:ACC]]', $templateText); |
|
91 | - } |
|
23 | + public static function enqueue(User $triggerUser, Request $request, PdoDatabase $database) |
|
24 | + { |
|
25 | + $job = new JobQueue(); |
|
26 | + $job->setDatabase($database); |
|
27 | + $job->setTask(WelcomeUserTask::class); |
|
28 | + $job->setRequest($request->getId()); |
|
29 | + $job->setTriggerUserId($triggerUser->getId()); |
|
30 | + $job->save(); |
|
31 | + } |
|
32 | + |
|
33 | + public function execute() |
|
34 | + { |
|
35 | + $database = $this->getDatabase(); |
|
36 | + $request = $this->getRequest(); |
|
37 | + $user = $this->getTriggerUser(); |
|
38 | + |
|
39 | + if ($user->getWelcomeTemplate() === null) { |
|
40 | + $this->markFailed('Welcome template not specified'); |
|
41 | + |
|
42 | + return; |
|
43 | + } |
|
44 | + |
|
45 | + /** @var WelcomeTemplate $template */ |
|
46 | + $template = WelcomeTemplate::getById($user->getWelcomeTemplate(), $database); |
|
47 | + |
|
48 | + if ($template === false) { |
|
49 | + $this->markFailed('Welcome template missing'); |
|
50 | + |
|
51 | + return; |
|
52 | + } |
|
53 | + |
|
54 | + $oauth = new OAuthUserHelper($user, $database, $this->getOauthProtocolHelper(), |
|
55 | + $this->getSiteConfiguration()); |
|
56 | + $mediaWikiHelper = new MediaWikiHelper($oauth, $this->getSiteConfiguration()); |
|
57 | + |
|
58 | + if ($request->getStatus() !== RequestStatus::CLOSED) { |
|
59 | + $this->markFailed('Request is currently open'); |
|
60 | + |
|
61 | + return; |
|
62 | + } |
|
63 | + |
|
64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
65 | + $this->markFailed('Account does not exist!'); |
|
66 | + |
|
67 | + return; |
|
68 | + } |
|
69 | + |
|
70 | + $this->performWelcome($template, $request, $mediaWikiHelper); |
|
71 | + $this->markComplete(); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Performs the welcome |
|
76 | + * |
|
77 | + * @param WelcomeTemplate $template |
|
78 | + * @param Request $request |
|
79 | + * @param MediaWikiHelper $mediaWikiHelper |
|
80 | + */ |
|
81 | + private function performWelcome( |
|
82 | + WelcomeTemplate $template, |
|
83 | + Request $request, |
|
84 | + MediaWikiHelper $mediaWikiHelper |
|
85 | + ) { |
|
86 | + $templateText = $template->getBotCode(); |
|
87 | + $templateText = str_replace('$signature', '~~~~', $templateText); |
|
88 | + $templateText = str_replace('$username', $request->getName(), $templateText); |
|
89 | + |
|
90 | + $mediaWikiHelper->addTalkPageMessage($request->getName(), 'Welcome!', 'Welcoming user created through [[WP:ACC]]', $templateText); |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -61,7 +61,7 @@ |
||
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())) { |
|
65 | 65 | $this->markFailed('Account does not exist!'); |
66 | 66 | |
67 | 67 | return; |
@@ -61,7 +61,7 @@ |
||
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - if (!$mediaWikiHelper->checkAccountExists($request->getName())){ |
|
64 | + if (!$mediaWikiHelper->checkAccountExists($request->getName())) { |
|
65 | 65 | $this->markFailed('Account does not exist!'); |
66 | 66 | |
67 | 67 | return; |
@@ -30,224 +30,224 @@ |
||
30 | 30 | */ |
31 | 31 | class WebStart extends ApplicationBase |
32 | 32 | { |
33 | - /** |
|
34 | - * @var IRequestRouter $requestRouter The request router to use. Note that different entry points have different |
|
35 | - * routers and hence different URL mappings |
|
36 | - */ |
|
37 | - private $requestRouter; |
|
38 | - /** |
|
39 | - * @var bool $isPublic Determines whether to use public interface objects or internal interface objects |
|
40 | - */ |
|
41 | - private $isPublic = false; |
|
42 | - |
|
43 | - /** |
|
44 | - * WebStart constructor. |
|
45 | - * |
|
46 | - * @param SiteConfiguration $configuration The site configuration |
|
47 | - * @param IRequestRouter $router The request router to use |
|
48 | - */ |
|
49 | - public function __construct(SiteConfiguration $configuration, IRequestRouter $router) |
|
50 | - { |
|
51 | - parent::__construct($configuration); |
|
52 | - |
|
53 | - $this->requestRouter = $router; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @param ITask $page |
|
58 | - * @param SiteConfiguration $siteConfiguration |
|
59 | - * @param PdoDatabase $database |
|
60 | - * @param PdoDatabase $notificationsDatabase |
|
61 | - * |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - protected function setupHelpers( |
|
65 | - ITask $page, |
|
66 | - SiteConfiguration $siteConfiguration, |
|
67 | - PdoDatabase $database, |
|
68 | - PdoDatabase $notificationsDatabase = null |
|
69 | - ) { |
|
70 | - parent::setupHelpers($page, $siteConfiguration, $database, $notificationsDatabase); |
|
71 | - |
|
72 | - if ($page instanceof PageBase) { |
|
73 | - $page->setTokenManager(new TokenManager()); |
|
74 | - |
|
75 | - if ($page instanceof InternalPageBase) { |
|
76 | - $page->setTypeAheadHelper(new TypeAheadHelper()); |
|
77 | - |
|
78 | - $identificationVerifier = new IdentificationVerifier($page->getHttpHelper(), $siteConfiguration, |
|
79 | - $database); |
|
80 | - $page->setIdentificationVerifier($identificationVerifier); |
|
81 | - |
|
82 | - $page->setSecurityManager(new SecurityManager($identificationVerifier, new RoleConfiguration())); |
|
83 | - |
|
84 | - if ($siteConfiguration->getTitleBlacklistEnabled()) { |
|
85 | - $page->setBlacklistHelper(new FakeBlacklistHelper()); |
|
86 | - } |
|
87 | - else { |
|
88 | - $page->setBlacklistHelper(new BlacklistHelper($page->getHttpHelper(), |
|
89 | - $siteConfiguration->getMediawikiWebServiceEndpoint())); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Application entry point. |
|
97 | - * |
|
98 | - * Sets up the environment and runs the application, performing any global cleanup operations when done. |
|
99 | - */ |
|
100 | - public function run() |
|
101 | - { |
|
102 | - try { |
|
103 | - if ($this->setupEnvironment()) { |
|
104 | - $this->main(); |
|
105 | - } |
|
106 | - } |
|
107 | - catch (EnvironmentException $ex) { |
|
108 | - ob_end_clean(); |
|
109 | - print Offline::getOfflineMessage($this->isPublic(), $ex->getMessage()); |
|
110 | - } |
|
111 | - catch (ReadableException $ex) { |
|
112 | - ob_end_clean(); |
|
113 | - print $ex->getReadableError(); |
|
114 | - } |
|
115 | - finally { |
|
116 | - $this->cleanupEnvironment(); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Environment setup |
|
122 | - * |
|
123 | - * This method initialises the tool environment. If the tool cannot be initialised correctly, it will return false |
|
124 | - * and shut down prematurely. |
|
125 | - * |
|
126 | - * @return bool |
|
127 | - * @throws EnvironmentException |
|
128 | - */ |
|
129 | - protected function setupEnvironment() |
|
130 | - { |
|
131 | - // initialise global exception handler |
|
132 | - set_exception_handler(array(ExceptionHandler::class, 'exceptionHandler')); |
|
133 | - set_error_handler(array(ExceptionHandler::class, 'errorHandler'), E_RECOVERABLE_ERROR); |
|
134 | - |
|
135 | - // start output buffering if necessary |
|
136 | - if (ob_get_level() === 0) { |
|
137 | - ob_start(); |
|
138 | - } |
|
139 | - |
|
140 | - // initialise super-global providers |
|
141 | - WebRequest::setGlobalStateProvider(new GlobalStateProvider()); |
|
142 | - |
|
143 | - if (Offline::isOffline()) { |
|
144 | - print Offline::getOfflineMessage($this->isPublic()); |
|
145 | - ob_end_flush(); |
|
146 | - |
|
147 | - return false; |
|
148 | - } |
|
149 | - |
|
150 | - // Call parent setup |
|
151 | - if (!parent::setupEnvironment()) { |
|
152 | - return false; |
|
153 | - } |
|
154 | - |
|
155 | - // Start up sessions |
|
156 | - Session::start(); |
|
157 | - |
|
158 | - // Check the user is allowed to be logged in still. This must be before we call any user-loading functions and |
|
159 | - // get the current user cached. |
|
160 | - // I'm not sure if this function call being here is particularly a good thing, but it's part of starting up a |
|
161 | - // session I suppose. |
|
162 | - $this->checkForceLogout(); |
|
163 | - |
|
164 | - // environment initialised! |
|
165 | - return true; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Main application logic |
|
170 | - */ |
|
171 | - protected function main() |
|
172 | - { |
|
173 | - // Get the right route for the request |
|
174 | - $page = $this->requestRouter->route(); |
|
175 | - |
|
176 | - $siteConfiguration = $this->getConfiguration(); |
|
177 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
178 | - |
|
179 | - if ($siteConfiguration->getIrcNotificationsEnabled()) { |
|
180 | - $notificationsDatabase = PdoDatabase::getDatabaseConnection('notifications'); |
|
181 | - } |
|
182 | - else { |
|
183 | - // @todo federated table here? |
|
184 | - $notificationsDatabase = $database; |
|
185 | - } |
|
186 | - |
|
187 | - $this->setupHelpers($page, $siteConfiguration, $database, $notificationsDatabase); |
|
188 | - |
|
189 | - /* @todo Remove this global statement! It's here for User.php, which does far more than it should. */ |
|
190 | - global $oauthProtocolHelper; |
|
191 | - $oauthProtocolHelper = $page->getOAuthProtocolHelper(); |
|
192 | - |
|
193 | - /* @todo Remove this global statement! It's here for Request.php, which does far more than it should. */ |
|
194 | - global $globalXffTrustProvider; |
|
195 | - $globalXffTrustProvider = $page->getXffTrustProvider(); |
|
196 | - |
|
197 | - // run the route code for the request. |
|
198 | - $page->execute(); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Any cleanup tasks should go here |
|
203 | - * |
|
204 | - * Note that we need to be very careful here, as exceptions may have been thrown and handled. |
|
205 | - * This should *only* be for cleaning up, no logic should go here. |
|
206 | - */ |
|
207 | - protected function cleanupEnvironment() |
|
208 | - { |
|
209 | - // Clean up anything we splurged after sending the page. |
|
210 | - if (ob_get_level() > 0) { |
|
211 | - for ($i = ob_get_level(); $i > 0; $i--) { |
|
212 | - ob_end_clean(); |
|
213 | - } |
|
214 | - } |
|
215 | - } |
|
216 | - |
|
217 | - private function checkForceLogout() |
|
218 | - { |
|
219 | - $database = PdoDatabase::getDatabaseConnection('acc'); |
|
220 | - |
|
221 | - $sessionUserId = WebRequest::getSessionUserId(); |
|
222 | - iF ($sessionUserId === null) { |
|
223 | - return; |
|
224 | - } |
|
225 | - |
|
226 | - // Note, User::getCurrent() caches it's result, which we *really* don't want to trigger. |
|
227 | - $currentUser = User::getById($sessionUserId, $database); |
|
228 | - |
|
229 | - if ($currentUser === false) { |
|
230 | - // Umm... this user has a session cookie with a userId set, but no user exists... |
|
231 | - Session::restart(); |
|
232 | - |
|
233 | - $currentUser = User::getCurrent($database); |
|
234 | - } |
|
235 | - |
|
236 | - if ($currentUser->getForceLogout()) { |
|
237 | - Session::restart(); |
|
238 | - |
|
239 | - $currentUser->setForceLogout(false); |
|
240 | - $currentUser->save(); |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - public function isPublic() |
|
245 | - { |
|
246 | - return $this->isPublic; |
|
247 | - } |
|
248 | - |
|
249 | - public function setPublic($isPublic) |
|
250 | - { |
|
251 | - $this->isPublic = $isPublic; |
|
252 | - } |
|
33 | + /** |
|
34 | + * @var IRequestRouter $requestRouter The request router to use. Note that different entry points have different |
|
35 | + * routers and hence different URL mappings |
|
36 | + */ |
|
37 | + private $requestRouter; |
|
38 | + /** |
|
39 | + * @var bool $isPublic Determines whether to use public interface objects or internal interface objects |
|
40 | + */ |
|
41 | + private $isPublic = false; |
|
42 | + |
|
43 | + /** |
|
44 | + * WebStart constructor. |
|
45 | + * |
|
46 | + * @param SiteConfiguration $configuration The site configuration |
|
47 | + * @param IRequestRouter $router The request router to use |
|
48 | + */ |
|
49 | + public function __construct(SiteConfiguration $configuration, IRequestRouter $router) |
|
50 | + { |
|
51 | + parent::__construct($configuration); |
|
52 | + |
|
53 | + $this->requestRouter = $router; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @param ITask $page |
|
58 | + * @param SiteConfiguration $siteConfiguration |
|
59 | + * @param PdoDatabase $database |
|
60 | + * @param PdoDatabase $notificationsDatabase |
|
61 | + * |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + protected function setupHelpers( |
|
65 | + ITask $page, |
|
66 | + SiteConfiguration $siteConfiguration, |
|
67 | + PdoDatabase $database, |
|
68 | + PdoDatabase $notificationsDatabase = null |
|
69 | + ) { |
|
70 | + parent::setupHelpers($page, $siteConfiguration, $database, $notificationsDatabase); |
|
71 | + |
|
72 | + if ($page instanceof PageBase) { |
|
73 | + $page->setTokenManager(new TokenManager()); |
|
74 | + |
|
75 | + if ($page instanceof InternalPageBase) { |
|
76 | + $page->setTypeAheadHelper(new TypeAheadHelper()); |
|
77 | + |
|
78 | + $identificationVerifier = new IdentificationVerifier($page->getHttpHelper(), $siteConfiguration, |
|
79 | + $database); |
|
80 | + $page->setIdentificationVerifier($identificationVerifier); |
|
81 | + |
|
82 | + $page->setSecurityManager(new SecurityManager($identificationVerifier, new RoleConfiguration())); |
|
83 | + |
|
84 | + if ($siteConfiguration->getTitleBlacklistEnabled()) { |
|
85 | + $page->setBlacklistHelper(new FakeBlacklistHelper()); |
|
86 | + } |
|
87 | + else { |
|
88 | + $page->setBlacklistHelper(new BlacklistHelper($page->getHttpHelper(), |
|
89 | + $siteConfiguration->getMediawikiWebServiceEndpoint())); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Application entry point. |
|
97 | + * |
|
98 | + * Sets up the environment and runs the application, performing any global cleanup operations when done. |
|
99 | + */ |
|
100 | + public function run() |
|
101 | + { |
|
102 | + try { |
|
103 | + if ($this->setupEnvironment()) { |
|
104 | + $this->main(); |
|
105 | + } |
|
106 | + } |
|
107 | + catch (EnvironmentException $ex) { |
|
108 | + ob_end_clean(); |
|
109 | + print Offline::getOfflineMessage($this->isPublic(), $ex->getMessage()); |
|
110 | + } |
|
111 | + catch (ReadableException $ex) { |
|
112 | + ob_end_clean(); |
|
113 | + print $ex->getReadableError(); |
|
114 | + } |
|
115 | + finally { |
|
116 | + $this->cleanupEnvironment(); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Environment setup |
|
122 | + * |
|
123 | + * This method initialises the tool environment. If the tool cannot be initialised correctly, it will return false |
|
124 | + * and shut down prematurely. |
|
125 | + * |
|
126 | + * @return bool |
|
127 | + * @throws EnvironmentException |
|
128 | + */ |
|
129 | + protected function setupEnvironment() |
|
130 | + { |
|
131 | + // initialise global exception handler |
|
132 | + set_exception_handler(array(ExceptionHandler::class, 'exceptionHandler')); |
|
133 | + set_error_handler(array(ExceptionHandler::class, 'errorHandler'), E_RECOVERABLE_ERROR); |
|
134 | + |
|
135 | + // start output buffering if necessary |
|
136 | + if (ob_get_level() === 0) { |
|
137 | + ob_start(); |
|
138 | + } |
|
139 | + |
|
140 | + // initialise super-global providers |
|
141 | + WebRequest::setGlobalStateProvider(new GlobalStateProvider()); |
|
142 | + |
|
143 | + if (Offline::isOffline()) { |
|
144 | + print Offline::getOfflineMessage($this->isPublic()); |
|
145 | + ob_end_flush(); |
|
146 | + |
|
147 | + return false; |
|
148 | + } |
|
149 | + |
|
150 | + // Call parent setup |
|
151 | + if (!parent::setupEnvironment()) { |
|
152 | + return false; |
|
153 | + } |
|
154 | + |
|
155 | + // Start up sessions |
|
156 | + Session::start(); |
|
157 | + |
|
158 | + // Check the user is allowed to be logged in still. This must be before we call any user-loading functions and |
|
159 | + // get the current user cached. |
|
160 | + // I'm not sure if this function call being here is particularly a good thing, but it's part of starting up a |
|
161 | + // session I suppose. |
|
162 | + $this->checkForceLogout(); |
|
163 | + |
|
164 | + // environment initialised! |
|
165 | + return true; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Main application logic |
|
170 | + */ |
|
171 | + protected function main() |
|
172 | + { |
|
173 | + // Get the right route for the request |
|
174 | + $page = $this->requestRouter->route(); |
|
175 | + |
|
176 | + $siteConfiguration = $this->getConfiguration(); |
|
177 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
178 | + |
|
179 | + if ($siteConfiguration->getIrcNotificationsEnabled()) { |
|
180 | + $notificationsDatabase = PdoDatabase::getDatabaseConnection('notifications'); |
|
181 | + } |
|
182 | + else { |
|
183 | + // @todo federated table here? |
|
184 | + $notificationsDatabase = $database; |
|
185 | + } |
|
186 | + |
|
187 | + $this->setupHelpers($page, $siteConfiguration, $database, $notificationsDatabase); |
|
188 | + |
|
189 | + /* @todo Remove this global statement! It's here for User.php, which does far more than it should. */ |
|
190 | + global $oauthProtocolHelper; |
|
191 | + $oauthProtocolHelper = $page->getOAuthProtocolHelper(); |
|
192 | + |
|
193 | + /* @todo Remove this global statement! It's here for Request.php, which does far more than it should. */ |
|
194 | + global $globalXffTrustProvider; |
|
195 | + $globalXffTrustProvider = $page->getXffTrustProvider(); |
|
196 | + |
|
197 | + // run the route code for the request. |
|
198 | + $page->execute(); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Any cleanup tasks should go here |
|
203 | + * |
|
204 | + * Note that we need to be very careful here, as exceptions may have been thrown and handled. |
|
205 | + * This should *only* be for cleaning up, no logic should go here. |
|
206 | + */ |
|
207 | + protected function cleanupEnvironment() |
|
208 | + { |
|
209 | + // Clean up anything we splurged after sending the page. |
|
210 | + if (ob_get_level() > 0) { |
|
211 | + for ($i = ob_get_level(); $i > 0; $i--) { |
|
212 | + ob_end_clean(); |
|
213 | + } |
|
214 | + } |
|
215 | + } |
|
216 | + |
|
217 | + private function checkForceLogout() |
|
218 | + { |
|
219 | + $database = PdoDatabase::getDatabaseConnection('acc'); |
|
220 | + |
|
221 | + $sessionUserId = WebRequest::getSessionUserId(); |
|
222 | + iF ($sessionUserId === null) { |
|
223 | + return; |
|
224 | + } |
|
225 | + |
|
226 | + // Note, User::getCurrent() caches it's result, which we *really* don't want to trigger. |
|
227 | + $currentUser = User::getById($sessionUserId, $database); |
|
228 | + |
|
229 | + if ($currentUser === false) { |
|
230 | + // Umm... this user has a session cookie with a userId set, but no user exists... |
|
231 | + Session::restart(); |
|
232 | + |
|
233 | + $currentUser = User::getCurrent($database); |
|
234 | + } |
|
235 | + |
|
236 | + if ($currentUser->getForceLogout()) { |
|
237 | + Session::restart(); |
|
238 | + |
|
239 | + $currentUser->setForceLogout(false); |
|
240 | + $currentUser->save(); |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + public function isPublic() |
|
245 | + { |
|
246 | + return $this->isPublic; |
|
247 | + } |
|
248 | + |
|
249 | + public function setPublic($isPublic) |
|
250 | + { |
|
251 | + $this->isPublic = $isPublic; |
|
252 | + } |
|
253 | 253 | } |
@@ -13,22 +13,22 @@ discard block |
||
13 | 13 | |
14 | 14 | class ExceptionHandler |
15 | 15 | { |
16 | - /** |
|
17 | - * Global exception handler |
|
18 | - * |
|
19 | - * Smarty would be nice to use, but it COULD BE smarty that throws the errors. |
|
20 | - * Let's build something ourselves, and hope it works. |
|
21 | - * |
|
22 | - * @param $exception |
|
23 | - * |
|
24 | - * @category Security-Critical - has the potential to leak data when exception is thrown. |
|
25 | - */ |
|
26 | - public static function exceptionHandler(Exception $exception) |
|
27 | - { |
|
28 | - /** @global $siteConfiguration SiteConfiguration */ |
|
29 | - global $siteConfiguration; |
|
30 | - |
|
31 | - $errorDocument = <<<HTML |
|
16 | + /** |
|
17 | + * Global exception handler |
|
18 | + * |
|
19 | + * Smarty would be nice to use, but it COULD BE smarty that throws the errors. |
|
20 | + * Let's build something ourselves, and hope it works. |
|
21 | + * |
|
22 | + * @param $exception |
|
23 | + * |
|
24 | + * @category Security-Critical - has the potential to leak data when exception is thrown. |
|
25 | + */ |
|
26 | + public static function exceptionHandler(Exception $exception) |
|
27 | + { |
|
28 | + /** @global $siteConfiguration SiteConfiguration */ |
|
29 | + global $siteConfiguration; |
|
30 | + |
|
31 | + $errorDocument = <<<HTML |
|
32 | 32 | <!DOCTYPE html> |
33 | 33 | <html lang="en"><head> |
34 | 34 | <meta charset="utf-8"> |
@@ -49,77 +49,77 @@ discard block |
||
49 | 49 | </div></body></html> |
50 | 50 | HTML; |
51 | 51 | |
52 | - $errorData = self::getExceptionData($exception); |
|
53 | - $errorData['server'] = $_SERVER; |
|
54 | - $errorData['get'] = $_GET; |
|
55 | - $errorData['post'] = $_POST; |
|
56 | - |
|
57 | - $state = serialize($errorData); |
|
58 | - $errorId = sha1($state); |
|
59 | - |
|
60 | - // Save the error for later analysis |
|
61 | - file_put_contents($siteConfiguration->getErrorLog() . '/' . $errorId . '.log', $state); |
|
62 | - |
|
63 | - // clear and discard any content that's been saved to the output buffer |
|
64 | - if (ob_get_level() > 0) { |
|
65 | - ob_end_clean(); |
|
66 | - } |
|
67 | - |
|
68 | - // push error ID into the document. |
|
69 | - $message = str_replace('$1$', $errorId, $errorDocument); |
|
70 | - |
|
71 | - if ($siteConfiguration->getDebuggingTraceEnabled()) { |
|
72 | - ob_start(); |
|
73 | - var_dump($errorData); |
|
74 | - $textErrorData = ob_get_contents(); |
|
75 | - ob_end_clean(); |
|
76 | - |
|
77 | - $message = str_replace('$2$', $textErrorData, $message); |
|
78 | - } |
|
79 | - else { |
|
80 | - $message = str_replace('$2$', "", $message); |
|
81 | - } |
|
82 | - |
|
83 | - // While we *shouldn't* have sent headers by now due to the output buffering, PHPUnit does weird things. |
|
84 | - // This is "only" needed for the tests, but it's a good idea to wrap this anyway. |
|
85 | - if (!headers_sent()) { |
|
86 | - header('HTTP/1.1 500 Internal Server Error'); |
|
87 | - } |
|
88 | - |
|
89 | - // output the document |
|
90 | - print $message; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param int $errorSeverity The severity level of the exception. |
|
95 | - * @param string $errorMessage The Exception message to throw. |
|
96 | - * @param string $errorFile The filename where the exception is thrown. |
|
97 | - * @param int $errorLine The line number where the exception is thrown. |
|
98 | - * |
|
99 | - * @throws ErrorException |
|
100 | - */ |
|
101 | - public static function errorHandler($errorSeverity, $errorMessage, $errorFile, $errorLine) |
|
102 | - { |
|
103 | - // call into the main exception handler above |
|
104 | - throw new ErrorException($errorMessage, 0, $errorSeverity, $errorFile, $errorLine); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param Exception $exception |
|
109 | - * |
|
110 | - * @return null|array |
|
111 | - */ |
|
112 | - public static function getExceptionData($exception) |
|
113 | - { |
|
114 | - if ($exception == null) { |
|
115 | - return null; |
|
116 | - } |
|
117 | - |
|
118 | - return array( |
|
119 | - 'exception' => get_class($exception), |
|
120 | - 'message' => $exception->getMessage(), |
|
121 | - 'stack' => $exception->getTraceAsString(), |
|
122 | - 'previous' => self::getExceptionData($exception->getPrevious()), |
|
123 | - ); |
|
124 | - } |
|
52 | + $errorData = self::getExceptionData($exception); |
|
53 | + $errorData['server'] = $_SERVER; |
|
54 | + $errorData['get'] = $_GET; |
|
55 | + $errorData['post'] = $_POST; |
|
56 | + |
|
57 | + $state = serialize($errorData); |
|
58 | + $errorId = sha1($state); |
|
59 | + |
|
60 | + // Save the error for later analysis |
|
61 | + file_put_contents($siteConfiguration->getErrorLog() . '/' . $errorId . '.log', $state); |
|
62 | + |
|
63 | + // clear and discard any content that's been saved to the output buffer |
|
64 | + if (ob_get_level() > 0) { |
|
65 | + ob_end_clean(); |
|
66 | + } |
|
67 | + |
|
68 | + // push error ID into the document. |
|
69 | + $message = str_replace('$1$', $errorId, $errorDocument); |
|
70 | + |
|
71 | + if ($siteConfiguration->getDebuggingTraceEnabled()) { |
|
72 | + ob_start(); |
|
73 | + var_dump($errorData); |
|
74 | + $textErrorData = ob_get_contents(); |
|
75 | + ob_end_clean(); |
|
76 | + |
|
77 | + $message = str_replace('$2$', $textErrorData, $message); |
|
78 | + } |
|
79 | + else { |
|
80 | + $message = str_replace('$2$', "", $message); |
|
81 | + } |
|
82 | + |
|
83 | + // While we *shouldn't* have sent headers by now due to the output buffering, PHPUnit does weird things. |
|
84 | + // This is "only" needed for the tests, but it's a good idea to wrap this anyway. |
|
85 | + if (!headers_sent()) { |
|
86 | + header('HTTP/1.1 500 Internal Server Error'); |
|
87 | + } |
|
88 | + |
|
89 | + // output the document |
|
90 | + print $message; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param int $errorSeverity The severity level of the exception. |
|
95 | + * @param string $errorMessage The Exception message to throw. |
|
96 | + * @param string $errorFile The filename where the exception is thrown. |
|
97 | + * @param int $errorLine The line number where the exception is thrown. |
|
98 | + * |
|
99 | + * @throws ErrorException |
|
100 | + */ |
|
101 | + public static function errorHandler($errorSeverity, $errorMessage, $errorFile, $errorLine) |
|
102 | + { |
|
103 | + // call into the main exception handler above |
|
104 | + throw new ErrorException($errorMessage, 0, $errorSeverity, $errorFile, $errorLine); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param Exception $exception |
|
109 | + * |
|
110 | + * @return null|array |
|
111 | + */ |
|
112 | + public static function getExceptionData($exception) |
|
113 | + { |
|
114 | + if ($exception == null) { |
|
115 | + return null; |
|
116 | + } |
|
117 | + |
|
118 | + return array( |
|
119 | + 'exception' => get_class($exception), |
|
120 | + 'message' => $exception->getMessage(), |
|
121 | + 'stack' => $exception->getTraceAsString(), |
|
122 | + 'previous' => self::getExceptionData($exception->getPrevious()), |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | \ No newline at end of file |
@@ -25,48 +25,48 @@ |
||
25 | 25 | |
26 | 26 | trait NavigationMenuAccessControl |
27 | 27 | { |
28 | - protected abstract function assign($name, $value); |
|
28 | + protected abstract function assign($name, $value); |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return SecurityManager |
|
32 | - */ |
|
33 | - protected abstract function getSecurityManager(); |
|
30 | + /** |
|
31 | + * @return SecurityManager |
|
32 | + */ |
|
33 | + protected abstract function getSecurityManager(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param $currentUser |
|
37 | - */ |
|
38 | - protected function setupNavMenuAccess($currentUser) |
|
39 | - { |
|
40 | - $this->assign('nav__canRequests', $this->getSecurityManager() |
|
41 | - ->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
35 | + /** |
|
36 | + * @param $currentUser |
|
37 | + */ |
|
38 | + protected function setupNavMenuAccess($currentUser) |
|
39 | + { |
|
40 | + $this->assign('nav__canRequests', $this->getSecurityManager() |
|
41 | + ->allows(PageMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
42 | 42 | |
43 | - $this->assign('nav__canLogs', $this->getSecurityManager() |
|
44 | - ->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
45 | - $this->assign('nav__canUsers', $this->getSecurityManager() |
|
46 | - ->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
47 | - $this->assign('nav__canSearch', $this->getSecurityManager() |
|
48 | - ->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
49 | - $this->assign('nav__canStats', $this->getSecurityManager() |
|
50 | - ->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
43 | + $this->assign('nav__canLogs', $this->getSecurityManager() |
|
44 | + ->allows(PageLog::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
45 | + $this->assign('nav__canUsers', $this->getSecurityManager() |
|
46 | + ->allows(StatsUsers::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
47 | + $this->assign('nav__canSearch', $this->getSecurityManager() |
|
48 | + ->allows(PageSearch::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
49 | + $this->assign('nav__canStats', $this->getSecurityManager() |
|
50 | + ->allows(StatsMain::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
51 | 51 | |
52 | - $this->assign('nav__canBan', $this->getSecurityManager() |
|
53 | - ->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
54 | - $this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
55 | - ->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
56 | - $currentUser) === SecurityManager::ALLOWED); |
|
57 | - $this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
58 | - ->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
59 | - $currentUser) === SecurityManager::ALLOWED); |
|
60 | - $this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
61 | - ->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
62 | - $this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
63 | - ->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
64 | - $currentUser) === SecurityManager::ALLOWED); |
|
65 | - $this->assign('nav__canJobQueue', $this->getSecurityManager() |
|
66 | - ->allows(PageJobQueue::class, RoleConfiguration::MAIN, |
|
67 | - $currentUser) === SecurityManager::ALLOWED); |
|
52 | + $this->assign('nav__canBan', $this->getSecurityManager() |
|
53 | + ->allows(PageBan::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
54 | + $this->assign('nav__canEmailMgmt', $this->getSecurityManager() |
|
55 | + ->allows(PageEmailManagement::class, RoleConfiguration::MAIN, |
|
56 | + $currentUser) === SecurityManager::ALLOWED); |
|
57 | + $this->assign('nav__canWelcomeMgmt', $this->getSecurityManager() |
|
58 | + ->allows(PageWelcomeTemplateManagement::class, RoleConfiguration::MAIN, |
|
59 | + $currentUser) === SecurityManager::ALLOWED); |
|
60 | + $this->assign('nav__canSiteNoticeMgmt', $this->getSecurityManager() |
|
61 | + ->allows(PageSiteNotice::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
62 | + $this->assign('nav__canUserMgmt', $this->getSecurityManager() |
|
63 | + ->allows(PageUserManagement::class, RoleConfiguration::MAIN, |
|
64 | + $currentUser) === SecurityManager::ALLOWED); |
|
65 | + $this->assign('nav__canJobQueue', $this->getSecurityManager() |
|
66 | + ->allows(PageJobQueue::class, RoleConfiguration::MAIN, |
|
67 | + $currentUser) === SecurityManager::ALLOWED); |
|
68 | 68 | |
69 | - $this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
70 | - ->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
71 | - } |
|
69 | + $this->assign('nav__canViewRequest', $this->getSecurityManager() |
|
70 | + ->allows(PageViewRequest::class, RoleConfiguration::MAIN, $currentUser) === SecurityManager::ALLOWED); |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | \ No newline at end of file |
@@ -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 | } |