@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | * @licence http://www.gnu.org/licenses/gpl.txt |
27 | 27 | */ |
28 | 28 | |
29 | -require_once __DIR__ . '/pens_controller.php'; |
|
30 | -require_once __DIR__ . '/pens_package_handler.php'; |
|
31 | -require_once __DIR__ . '/pens_exception.php'; |
|
32 | -require_once __DIR__ . '/pens_response.php'; |
|
29 | +require_once __DIR__.'/pens_controller.php'; |
|
30 | +require_once __DIR__.'/pens_package_handler.php'; |
|
31 | +require_once __DIR__.'/pens_exception.php'; |
|
32 | +require_once __DIR__.'/pens_response.php'; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * PENSServer |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * Singleton method |
65 | 65 | */ |
66 | 66 | public static function singleton() { |
67 | - if(!isset(self::$_instance)) { |
|
67 | + if (!isset(self::$_instance)) { |
|
68 | 68 | $c = __CLASS__; |
69 | 69 | self::$_instance = new $c; |
70 | 70 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param PENSPackageHandler Package handler |
89 | 89 | */ |
90 | 90 | public function setPackageHandler($package_handler) { |
91 | - if($package_handler instanceof PENSPackageHandler) { |
|
91 | + if ($package_handler instanceof PENSPackageHandler) { |
|
92 | 92 | $this->_package_handler = $package_handler; |
93 | 93 | } |
94 | 94 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | try { |
102 | 102 | // First, try to parse the request |
103 | 103 | $request = $this->parseRequest(); |
104 | - if($request->getCommand() == "collect") { |
|
105 | - if(isset($_REQUEST['process'])) { |
|
104 | + if ($request->getCommand() == "collect") { |
|
105 | + if (isset($_REQUEST['process'])) { |
|
106 | 106 | // Collect the package and process it |
107 | 107 | $receipt = null; |
108 | 108 | $path_to_package = null; |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | // Collect the package |
111 | 111 | $path_to_package = $this->collectPackage($request); |
112 | 112 | $receipt = new PENSResponse(0, "package successfully collected"); |
113 | - } catch(PENSException $e) { |
|
113 | + } catch (PENSException $e) { |
|
114 | 114 | $receipt = new PENSResponse($e); |
115 | 115 | } |
116 | 116 | // Send receipt |
117 | 117 | $response = $this->sendReceipt($request, $receipt); |
118 | - if(!is_null($response) && !is_null($path_to_package)) { |
|
119 | - if($response->getError() === 0) { |
|
118 | + if (!is_null($response) && !is_null($path_to_package)) { |
|
119 | + if ($response->getError() === 0) { |
|
120 | 120 | // Process package |
121 | 121 | $this->processPackage($request, $path_to_package); |
122 | 122 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $params = $_REQUEST; |
130 | 130 | $params['process'] = 1; |
131 | 131 | $scheme = "http"; |
132 | - if(!empty($_SERVER['HTTPS'])) { |
|
132 | + if (!empty($_SERVER['HTTPS'])) { |
|
133 | 133 | $scheme = "https"; |
134 | 134 | } |
135 | 135 | $ch = curl_init(); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - } catch(PENSException $e) { |
|
144 | + } catch (PENSException $e) { |
|
145 | 145 | // If we could not parse the request, send the error back to the client |
146 | 146 | $this->sendResponse(new PENSResponse($e)); |
147 | 147 | } |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | */ |
157 | 157 | protected function collectPackage($request) { |
158 | 158 | $supported_package_types = $this->_package_handler->getSupportedPackageTypes(); |
159 | - if(!in_array($request->getPackageType(), $supported_package_types)) { |
|
159 | + if (!in_array($request->getPackageType(), $supported_package_types)) { |
|
160 | 160 | throw new PENSException(1430); |
161 | 161 | } |
162 | 162 | $supported_package_formats = $this->_package_handler->getSupportedPackageFormats(); |
163 | - if(!in_array($request->getPackageFormat(), $supported_package_formats)) { |
|
163 | + if (!in_array($request->getPackageFormat(), $supported_package_formats)) { |
|
164 | 164 | throw new PENSException(1431); |
165 | 165 | } |
166 | - if(!$this->isExpiryDateValid($request->getPackageUrlExpiry())) { |
|
166 | + if (!$this->isExpiryDateValid($request->getPackageUrlExpiry())) { |
|
167 | 167 | throw new PENSException(1322); |
168 | 168 | } |
169 | 169 | |
170 | 170 | // Try to download the package in the temporary directory |
171 | 171 | $tmp = null; |
172 | - if(function_exists("sys_get_temp_dir")) { |
|
172 | + if (function_exists("sys_get_temp_dir")) { |
|
173 | 173 | $tmp = sys_get_temp_dir(); |
174 | 174 | } else { |
175 | 175 | $tmp = "/tmp"; |
@@ -180,14 +180,14 @@ discard block |
||
180 | 180 | curl_setopt($ch, CURLOPT_URL, $request->getPackageUrl()); |
181 | 181 | curl_setopt($ch, CURLOPT_HEADER, false); |
182 | 182 | curl_setopt($ch, CURLOPT_FILE, $fp); |
183 | - if(!is_null($request->getPackageUrlUserId())) { |
|
183 | + if (!is_null($request->getPackageUrlUserId())) { |
|
184 | 184 | curl_setopt($ch, CURLOPT_USERPWD, $request->getPackageUrlUserId().":".$request->getPackageUrlPassword()); |
185 | 185 | } |
186 | - if(curl_exec($ch) === false) { |
|
186 | + if (curl_exec($ch) === false) { |
|
187 | 187 | $errno = curl_errno($ch); |
188 | 188 | curl_close($ch); |
189 | 189 | // Error occured. Throw an exception |
190 | - switch($errno) { |
|
190 | + switch ($errno) { |
|
191 | 191 | case CURLE_UNSUPPORTED_PROTOCOL: |
192 | 192 | throw new PENSException(1301); |
193 | 193 | break; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | date_default_timezone_set('UTC'); |
224 | 224 | $current_time = time(); |
225 | 225 | $expiry_time = strtotime($expiry->format(DateTime::ISO8601)); |
226 | - if($current_time > $expiry_time) { |
|
226 | + if ($current_time > $expiry_time) { |
|
227 | 227 | return false; |
228 | 228 | } else { |
229 | 229 | return true; |
@@ -239,17 +239,17 @@ discard block |
||
239 | 239 | * @return PENSResponse Response |
240 | 240 | */ |
241 | 241 | protected function sendAlertOrReceipt($request, $response, $mode) { |
242 | - if($mode == "alert") { |
|
242 | + if ($mode == "alert") { |
|
243 | 243 | $url = $request->getAlerts(); |
244 | 244 | } else { |
245 | 245 | $url = $request->getReceipt(); |
246 | 246 | } |
247 | - if(!empty($url)) { |
|
247 | + if (!empty($url)) { |
|
248 | 248 | $url_components = parse_url($url); |
249 | 249 | $scheme = $url_components["scheme"]; |
250 | - if($scheme == "mailto") { |
|
250 | + if ($scheme == "mailto") { |
|
251 | 251 | $to = $url_components["path"]; |
252 | - if($mode == "alert") { |
|
252 | + if ($mode == "alert") { |
|
253 | 253 | $subject = "PENS Alert for ".$request->getPackageId(); |
254 | 254 | } else { |
255 | 255 | $subject = "PENS Receipt for ".$request->getPackageId(); |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | $message = $response->__toString(); |
258 | 258 | mail($to, $subject, $message); |
259 | 259 | return new PENSResponse(0, ""); |
260 | - } else if($scheme == "http" || $scheme == "https") { |
|
261 | - if($mode == "alert") { |
|
260 | + } else if ($scheme == "http" || $scheme == "https") { |
|
261 | + if ($mode == "alert") { |
|
262 | 262 | $params = array_merge($request->getSendAlertArray(), $response->getArray()); |
263 | 263 | } else { |
264 | 264 | $params = array_merge($request->getSendReceiptArray(), $response->getArray()); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
270 | 270 | $data = curl_exec($ch); |
271 | 271 | curl_close($ch); |
272 | - if($data === false) { |
|
272 | + if ($data === false) { |
|
273 | 273 | return null; |
274 | 274 | } else { |
275 | 275 | return new PENSResponse($data); |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @licence http://www.gnu.org/licenses/gpl.txt |
28 | 28 | */ |
29 | 29 | |
30 | -require_once __DIR__ . '/pens_exception.php'; |
|
31 | -require_once __DIR__ . '/pens_request_receipt.php'; |
|
32 | -require_once __DIR__ . '/pens_request_collect.php'; |
|
33 | -require_once __DIR__ . '/pens_request_alert.php'; |
|
30 | +require_once __DIR__.'/pens_exception.php'; |
|
31 | +require_once __DIR__.'/pens_request_receipt.php'; |
|
32 | +require_once __DIR__.'/pens_request_collect.php'; |
|
33 | +require_once __DIR__.'/pens_request_alert.php'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * PENSRequestFactory |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function createPENSRequest($arguments) { |
57 | 57 | $command = $arguments["command"]; |
58 | - if($command == "alert") { |
|
58 | + if ($command == "alert") { |
|
59 | 59 | return new PENSRequestAlert($arguments); |
60 | - } else if($command == "collect") { |
|
60 | + } else if ($command == "collect") { |
|
61 | 61 | return new PENSRequestCollect($arguments); |
62 | - } else if($command == "receipt") { |
|
62 | + } else if ($command == "receipt") { |
|
63 | 63 | return new PENSRequestReceipt($arguments); |
64 | 64 | } else { |
65 | 65 | throw new PENSException(2002); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @throws PENSException with code 2001 if invalid |
187 | 187 | */ |
188 | 188 | public function setPensVersion($pens_version) { |
189 | - if($pens_version == PENSConfig::$version) { |
|
189 | + if ($pens_version == PENSConfig::$version) { |
|
190 | 190 | $this->_pens_version = $pens_version; |
191 | 191 | } else { |
192 | 192 | throw new PENSException(2001); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @throws PENSException with code 2002 if invalid |
206 | 206 | */ |
207 | 207 | protected function setCommand($command) { |
208 | - if(in_array($command, PENSConfig::$allowed_commands)) { |
|
208 | + if (in_array($command, PENSConfig::$allowed_commands)) { |
|
209 | 209 | $this->_command = $command; |
210 | 210 | } else { |
211 | 211 | throw new PENSException(2002); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @throws PENSException with code 2003 if invalid |
225 | 225 | */ |
226 | 226 | public function setPackageType($package_type) { |
227 | - if(in_array($package_type, PENSConfig::$allowed_package_types)) { |
|
227 | + if (in_array($package_type, PENSConfig::$allowed_package_types)) { |
|
228 | 228 | $this->_package_type = $package_type; |
229 | 229 | } else { |
230 | 230 | throw new PENSException(2003); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @throws PENSException with code 2004 if invalid |
244 | 244 | */ |
245 | 245 | public function setPackageTypeVersion($package_type_version) { |
246 | - if(empty($package_type_version)) { |
|
246 | + if (empty($package_type_version)) { |
|
247 | 247 | throw new PENSException(2004); |
248 | 248 | } else { |
249 | 249 | $this->_package_type_version = $package_type_version; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @throws PENSException with code 2005 if invalid |
263 | 263 | */ |
264 | 264 | public function setPackageFormat($package_format) { |
265 | - if(in_array($package_format, PENSConfig::$allowed_package_formats)) { |
|
265 | + if (in_array($package_format, PENSConfig::$allowed_package_formats)) { |
|
266 | 266 | $this->_package_format = $package_format; |
267 | 267 | } else { |
268 | 268 | throw new PENSException(2005); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | } |
317 | 317 | |
318 | 318 | public function setPackageUrlUserId($package_url_user_id) { |
319 | - if(!empty($package_url_user_id)) { |
|
319 | + if (!empty($package_url_user_id)) { |
|
320 | 320 | $this->_package_url_user_id = $package_url_user_id; |
321 | 321 | } |
322 | 322 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | public function setPackageUrlAccount($package_url_account) { |
329 | - if(!empty($package_url_account)) { |
|
329 | + if (!empty($package_url_account)) { |
|
330 | 330 | $this->_package_url_account = $package_url_account; |
331 | 331 | } |
332 | 332 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | public function setPackageUrlPassword($package_url_password) { |
339 | - if(!empty($package_url_password)) { |
|
339 | + if (!empty($package_url_password)) { |
|
340 | 340 | $this->_package_url_password = $package_url_password; |
341 | 341 | } |
342 | 342 | } |
@@ -354,13 +354,13 @@ discard block |
||
354 | 354 | * @todo Perform a better validation of the date |
355 | 355 | */ |
356 | 356 | public function setPackageUrlExpiry($package_url_expiry) { |
357 | - if(empty($package_url_expiry)) { |
|
357 | + if (empty($package_url_expiry)) { |
|
358 | 358 | throw new PENSException(2009); |
359 | 359 | } else { |
360 | 360 | try { |
361 | 361 | $expiry = new DateTime($package_url_expiry, new DateTimeZone('UTC')); |
362 | 362 | $this->_package_url_expiry = $expiry; |
363 | - } catch(Exception $e) { |
|
363 | + } catch (Exception $e) { |
|
364 | 364 | throw new PENSException(2009); |
365 | 365 | } |
366 | 366 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @throws PENSException with code 2010 if invalid |
379 | 379 | */ |
380 | 380 | public function setClient($client) { |
381 | - if(!empty($client)) { |
|
381 | + if (!empty($client)) { |
|
382 | 382 | $this->_client = $client; |
383 | 383 | } else { |
384 | 384 | throw new PENSException(2010); |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | |
392 | 392 | public function setSystemUserId($system_user_id) { |
393 | - if(!empty($system_user_id)) { |
|
393 | + if (!empty($system_user_id)) { |
|
394 | 394 | $this->_system_user_id = $system_user_id; |
395 | 395 | } |
396 | 396 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | } |
401 | 401 | |
402 | 402 | public function setSystemPassword($system_password) { |
403 | - if(!empty($system_password)) { |
|
403 | + if (!empty($system_password)) { |
|
404 | 404 | $this->_system_password = $system_password; |
405 | 405 | } |
406 | 406 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @throws PENSException with code 2011 if invalid |
418 | 418 | */ |
419 | 419 | public function setReceipt($receipt) { |
420 | - if($this instanceof PENSRequestCollect) { |
|
420 | + if ($this instanceof PENSRequestCollect) { |
|
421 | 421 | if (preg_match('/'.ABSOLUTEURI_2396.'/', $receipt)) { |
422 | 422 | $this->_receipt = $receipt; |
423 | 423 | } else { |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | public function setAlerts($alerts) { |
434 | - if(!empty($alerts)) { |
|
435 | - if(preg_match('/'.ABSOLUTEURI_2396.'/', $alerts)) { |
|
434 | + if (!empty($alerts)) { |
|
435 | + if (preg_match('/'.ABSOLUTEURI_2396.'/', $alerts)) { |
|
436 | 436 | $this->_alerts = $alerts; |
437 | 437 | } else { |
438 | 438 | throw new PENSException(1201); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | } |
446 | 446 | |
447 | 447 | public function setVendorData($vendor_data) { |
448 | - if(!empty($vendor_data)) { |
|
448 | + if (!empty($vendor_data)) { |
|
449 | 449 | $this->_vendor_data = $vendor_data; |
450 | 450 | } |
451 | 451 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @licence http://www.gnu.org/licenses/gpl.txt |
27 | 27 | */ |
28 | 28 | |
29 | -require_once __DIR__ . '/pens_config.php'; |
|
30 | -require_once __DIR__ . '/pens_message.php'; |
|
31 | -require_once __DIR__ . '/pens_exception.php'; |
|
29 | +require_once __DIR__.'/pens_config.php'; |
|
30 | +require_once __DIR__.'/pens_message.php'; |
|
31 | +require_once __DIR__.'/pens_exception.php'; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * PENSResponse |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function __construct($error, $error_text = null, $pens_data = null) { |
75 | 75 | $this->_pens_version = PENSConfig::$version; |
76 | - if($error instanceof PENSException) { |
|
76 | + if ($error instanceof PENSException) { |
|
77 | 77 | $this->_error = $error->getCode(); |
78 | 78 | $this->_error_text = $error->getMessage(); |
79 | - } else if(is_string($error)){ |
|
79 | + } else if (is_string($error)) { |
|
80 | 80 | // Parse the string |
81 | 81 | $this->parseResponse($error); |
82 | - } else if(is_array($error)) { |
|
82 | + } else if (is_array($error)) { |
|
83 | 83 | // Try to build from array |
84 | 84 | $this->_error = $error["error"]; |
85 | 85 | $this->_error_text = $error["error-text"]; |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | protected function parseResponse($response) { |
101 | 101 | $lines = explode(PENSConfig::$eol, $response); |
102 | 102 | $i = 1; |
103 | - foreach($lines as $line) { |
|
104 | - if($i < 5) { |
|
103 | + foreach ($lines as $line) { |
|
104 | + if ($i < 5) { |
|
105 | 105 | $pair = explode("=", $line); |
106 | - if($pair[0] == "error") { |
|
106 | + if ($pair[0] == "error") { |
|
107 | 107 | $this->_error = intval($pair[1]); |
108 | - } else if($pair[0] == "error-text") { |
|
108 | + } else if ($pair[0] == "error-text") { |
|
109 | 109 | $this->_error_text = $pair[1]; |
110 | - } else if($pair[0] == "version") { |
|
110 | + } else if ($pair[0] == "version") { |
|
111 | 111 | $this->_pens_version = $pair[1]; |
112 | - } else if($pair[0] == "pens-data") { |
|
113 | - if(!empty($pair[1])) { |
|
112 | + } else if ($pair[0] == "pens-data") { |
|
113 | + if (!empty($pair[1])) { |
|
114 | 114 | $this->_pens_data = $pair[1].PENSConfig::$eol; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | } else { |
118 | - if(!empty($line)) { |
|
118 | + if (!empty($line)) { |
|
119 | 119 | $this->_pens_data .= $line.PENSConfig::$eol; |
120 | 120 | } |
121 | 121 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . '/pens/pens_request_factory.php'; |
|
4 | -require_once __DIR__ . '/pens/pens_response.php'; |
|
5 | -require_once __DIR__ . '/pens/pens_package_handler.php'; |
|
6 | -require_once __DIR__ . '/pens/pens_server.php'; |
|
7 | -require_once __DIR__ . '/pens/pens_client.php'; |
|
3 | +require_once __DIR__.'/pens/pens_request_factory.php'; |
|
4 | +require_once __DIR__.'/pens/pens_response.php'; |
|
5 | +require_once __DIR__.'/pens/pens_package_handler.php'; |
|
6 | +require_once __DIR__.'/pens/pens_server.php'; |
|
7 | +require_once __DIR__.'/pens/pens_client.php'; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @licence http://www.gnu.org/licenses/gpl.txt |
24 | 24 | */ |
25 | 25 | |
26 | -require_once __DIR__ . '/pens.php'; |
|
26 | +require_once __DIR__.'/pens.php'; |
|
27 | 27 | |
28 | 28 | class MyPackageHandler extends PENSPackageHandler { |
29 | 29 | public function processPackage($request, $path_to_package) { |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | public function exceptionTestForValue($key, $value, $code) { |
80 | 80 | try { |
81 | 81 | $myargs = $this->args; |
82 | - if($value === null) { |
|
82 | + if ($value === null) { |
|
83 | 83 | unset($myargs[$key]); |
84 | 84 | } else { |
85 | 85 | $myargs[$key] = $value; |
86 | 86 | } |
87 | 87 | $object = $this->createObject($myargs); |
88 | 88 | $this->fail(); |
89 | - } catch(PENSException $e) { |
|
89 | + } catch (PENSException $e) { |
|
90 | 90 | $this->assertEqual($e->getCode(), $code); |
91 | 91 | } |
92 | 92 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $myargs["receipt"] = "mailto:[email protected],[email protected]"; |
179 | 179 | $object = $this->createObject($myargs); |
180 | 180 | $this->pass(); |
181 | - } catch(PENSException $e) { |
|
181 | + } catch (PENSException $e) { |
|
182 | 182 | $this->fail(); |
183 | 183 | } |
184 | 184 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $this->assertEqual($object->getAlerts(), "http://myurl.com/alerts"); |
205 | 205 | $this->assertEqual($object->getVendorData(), "here are my data"); |
206 | 206 | |
207 | - } catch(PENSException $e) { |
|
207 | + } catch (PENSException $e) { |
|
208 | 208 | $this->fail(); |
209 | 209 | } |
210 | 210 | } |
@@ -8,8 +8,8 @@ |
||
8 | 8 | /** |
9 | 9 | * Init |
10 | 10 | */ |
11 | -require_once __DIR__ . '/../../../main/inc/global.inc.php'; |
|
12 | -require_once __DIR__ . '/../config.php'; |
|
11 | +require_once __DIR__.'/../../../main/inc/global.inc.php'; |
|
12 | +require_once __DIR__.'/../config.php'; |
|
13 | 13 | |
14 | 14 | if (!api_is_anonymous()) { |
15 | 15 | $currentPageClass = isset($_POST['page_class']) ? $_POST['page_class'] : ''; |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | { |
107 | 107 | $advancedSubscriptionQueueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE); |
108 | 108 | |
109 | - $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (" . |
|
110 | - "id int UNSIGNED NOT NULL AUTO_INCREMENT, " . |
|
111 | - "session_id int UNSIGNED NOT NULL, " . |
|
112 | - "user_id int UNSIGNED NOT NULL, " . |
|
113 | - "status int UNSIGNED NOT NULL, " . |
|
114 | - "last_message_id int UNSIGNED NOT NULL, " . |
|
115 | - "created_at datetime NOT NULL, " . |
|
116 | - "updated_at datetime NULL, " . |
|
117 | - "PRIMARY KEY PK_advanced_subscription_queue (id), " . |
|
109 | + $sql = "CREATE TABLE IF NOT EXISTS $advancedSubscriptionQueueTable (". |
|
110 | + "id int UNSIGNED NOT NULL AUTO_INCREMENT, ". |
|
111 | + "session_id int UNSIGNED NOT NULL, ". |
|
112 | + "user_id int UNSIGNED NOT NULL, ". |
|
113 | + "status int UNSIGNED NOT NULL, ". |
|
114 | + "last_message_id int UNSIGNED NOT NULL, ". |
|
115 | + "created_at datetime NOT NULL, ". |
|
116 | + "updated_at datetime NULL, ". |
|
117 | + "PRIMARY KEY PK_advanced_subscription_queue (id), ". |
|
118 | 118 | "UNIQUE KEY UK_advanced_subscription_queue (user_id, session_id)); "; |
119 | 119 | Database::query($sql); |
120 | 120 | } |
@@ -265,11 +265,10 @@ discard block |
||
265 | 265 | $now = new DateTime(api_get_utc_datetime()); |
266 | 266 | $newYearDate = $plugin->get('course_session_credit_year_start_date'); |
267 | 267 | $newYearDate = !empty($newYearDate) ? |
268 | - new \DateTime($newYearDate . $now->format('/Y')) : |
|
269 | - $now; |
|
268 | + new \DateTime($newYearDate.$now->format('/Y')) : $now; |
|
270 | 269 | $extra = new ExtraFieldValue('session'); |
271 | - $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER) . ' su INNER JOIN ' . |
|
272 | - Database::get_main_table(TABLE_MAIN_SESSION) . ' s ON s.id = su.session_id'; |
|
270 | + $joinSessionTable = Database::get_main_table(TABLE_MAIN_SESSION_USER).' su INNER JOIN '. |
|
271 | + Database::get_main_table(TABLE_MAIN_SESSION).' s ON s.id = su.session_id'; |
|
273 | 272 | $whereSessionParams = 'su.relation_type = ? AND s.access_start_date >= ? AND su.user_id = ?'; |
274 | 273 | $whereSessionParamsValues = array( |
275 | 274 | 0, |
@@ -734,14 +733,14 @@ discard block |
||
734 | 733 | $tpl->assign('termsContent', $termsAndConditions); |
735 | 734 | $termsAndConditions = $tpl->fetch('/advanced_subscription/views/terms_and_conditions_to_pdf.tpl'); |
736 | 735 | $pdf = new PDF(); |
737 | - $filename = 'terms' . sha1(rand(0,99999)); |
|
736 | + $filename = 'terms'.sha1(rand(0, 99999)); |
|
738 | 737 | $pdf->content_to_pdf($termsAndConditions, null, $filename, null, 'F'); |
739 | 738 | $fileAttachments['file'][] = array( |
740 | - 'name' => $filename . '.pdf', |
|
741 | - 'application/pdf' => $filename . '.pdf', |
|
742 | - 'tmp_name' => api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf', |
|
739 | + 'name' => $filename.'.pdf', |
|
740 | + 'application/pdf' => $filename.'.pdf', |
|
741 | + 'tmp_name' => api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf', |
|
743 | 742 | 'error' => UPLOAD_ERR_OK, |
744 | - 'size' => filesize(api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf'), |
|
743 | + 'size' => filesize(api_get_path(SYS_ARCHIVE_PATH).$filename.'.pdf'), |
|
745 | 744 | ); |
746 | 745 | $fileAttachments['comments'][] = get_lang('TermsAndConditions'); |
747 | 746 | } |
@@ -1032,7 +1031,7 @@ discard block |
||
1032 | 1031 | |
1033 | 1032 | $mergedArray = array_merge(array($sessionId), array_keys($fields)); |
1034 | 1033 | |
1035 | - $sql = "SELECT * FROM " . Database::get_main_table(TABLE_EXTRA_FIELD_VALUES) ." |
|
1034 | + $sql = "SELECT * FROM ".Database::get_main_table(TABLE_EXTRA_FIELD_VALUES)." |
|
1036 | 1035 | WHERE item_id = %d AND field_id IN (%d, %d, %d, %d, %d, %d, %d)"; |
1037 | 1036 | $sql = vsprintf($sql, $mergedArray); |
1038 | 1037 | $sessionFieldValueList = Database::query($sql); |
@@ -1048,10 +1047,10 @@ discard block |
||
1048 | 1047 | $sessionArray['description'] = SessionManager::getDescriptionFromSessionId($sessionId); |
1049 | 1048 | |
1050 | 1049 | if (isset($sessionArray['brochure'])) { |
1051 | - $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['brochure']; |
|
1050 | + $sessionArray['brochure'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['brochure']; |
|
1052 | 1051 | } |
1053 | 1052 | if (isset($sessionArray['banner'])) { |
1054 | - $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH) . $sessionArray['banner']; |
|
1053 | + $sessionArray['banner'] = api_get_path(WEB_UPLOAD_PATH).$sessionArray['banner']; |
|
1055 | 1054 | } |
1056 | 1055 | |
1057 | 1056 | return $sessionArray; |
@@ -1108,7 +1107,7 @@ discard block |
||
1108 | 1107 | */ |
1109 | 1108 | public function getSessionUrl($sessionId) |
1110 | 1109 | { |
1111 | - $url = api_get_path(WEB_CODE_PATH) . 'session/?session_id=' . intval($sessionId); |
|
1110 | + $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.intval($sessionId); |
|
1112 | 1111 | |
1113 | 1112 | return $url; |
1114 | 1113 | } |
@@ -1157,16 +1156,16 @@ discard block |
||
1157 | 1156 | */ |
1158 | 1157 | public function getQueueUrl($params) |
1159 | 1158 | { |
1160 | - $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/ajax/advanced_subscription.ajax.php?' . |
|
1161 | - 'a=' . Security::remove_XSS($params['action']) . '&' . |
|
1162 | - 's=' . intval($params['sessionId']) . '&' . |
|
1163 | - 'current_user_id=' . intval($params['currentUserId']) . '&' . |
|
1164 | - 'e=' . intval($params['newStatus']) . '&' . |
|
1165 | - 'u=' . intval($params['studentUserId']) . '&' . |
|
1166 | - 'q=' . intval($params['queueId']) . '&' . |
|
1167 | - 'is_connected=' . 1 . '&' . |
|
1168 | - 'profile_completed=' . intval($params['profile_completed']) . '&' . |
|
1169 | - 'v=' . $this->generateHash($params); |
|
1159 | + $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/ajax/advanced_subscription.ajax.php?'. |
|
1160 | + 'a='.Security::remove_XSS($params['action']).'&'. |
|
1161 | + 's='.intval($params['sessionId']).'&'. |
|
1162 | + 'current_user_id='.intval($params['currentUserId']).'&'. |
|
1163 | + 'e='.intval($params['newStatus']).'&'. |
|
1164 | + 'u='.intval($params['studentUserId']).'&'. |
|
1165 | + 'q='.intval($params['queueId']).'&'. |
|
1166 | + 'is_connected='.1.'&'. |
|
1167 | + 'profile_completed='.intval($params['profile_completed']).'&'. |
|
1168 | + 'v='.$this->generateHash($params); |
|
1170 | 1169 | |
1171 | 1170 | return $url; |
1172 | 1171 | } |
@@ -1219,7 +1218,7 @@ discard block |
||
1219 | 1218 | } |
1220 | 1219 | $queueTable = Database::get_main_table(TABLE_ADVANCED_SUBSCRIPTION_QUEUE); |
1221 | 1220 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
1222 | - $userJoinTable = $queueTable . ' q INNER JOIN ' . $userTable . ' u ON q.user_id = u.user_id'; |
|
1221 | + $userJoinTable = $queueTable.' q INNER JOIN '.$userTable.' u ON q.user_id = u.user_id'; |
|
1223 | 1222 | $where = array( |
1224 | 1223 | 'where' => array( |
1225 | 1224 | 'q.session_id = ?' => array( |
@@ -1232,7 +1231,7 @@ discard block |
||
1232 | 1231 | $students = Database::select($select, $userJoinTable, $where); |
1233 | 1232 | foreach ($students as &$student) { |
1234 | 1233 | $status = intval($student['status']); |
1235 | - switch($status) { |
|
1234 | + switch ($status) { |
|
1236 | 1235 | case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE: |
1237 | 1236 | case ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START: |
1238 | 1237 | $student['validation'] = ''; |
@@ -1246,7 +1245,7 @@ discard block |
||
1246 | 1245 | $student['validation'] = 'Yes'; |
1247 | 1246 | break; |
1248 | 1247 | default: |
1249 | - error_log(__FILE__ . ' ' . __FUNCTION__ . ' Student status no detected'); |
|
1248 | + error_log(__FILE__.' '.__FUNCTION__.' Student status no detected'); |
|
1250 | 1249 | } |
1251 | 1250 | } |
1252 | 1251 | $return = array( |
@@ -1295,7 +1294,7 @@ discard block |
||
1295 | 1294 | $dataPrepared['queueId'] = intval($data['queueId']); |
1296 | 1295 | $dataPrepared['newStatus'] = intval($data['newStatus']); |
1297 | 1296 | $dataPrepared = serialize($dataPrepared); |
1298 | - return sha1($dataPrepared . $key); |
|
1297 | + return sha1($dataPrepared.$key); |
|
1299 | 1298 | } |
1300 | 1299 | |
1301 | 1300 | /** |
@@ -1350,12 +1349,12 @@ discard block |
||
1350 | 1349 | break; |
1351 | 1350 | } |
1352 | 1351 | |
1353 | - $url = api_get_path(WEB_PLUGIN_PATH) . "advanced_subscription/src/terms_and_conditions.php?"; |
|
1352 | + $url = api_get_path(WEB_PLUGIN_PATH)."advanced_subscription/src/terms_and_conditions.php?"; |
|
1354 | 1353 | $url .= http_build_query($urlParams); |
1355 | 1354 | |
1356 | 1355 | // Launch popup |
1357 | 1356 | if ($mode == ADVANCED_SUBSCRIPTION_TERMS_MODE_POPUP) { |
1358 | - $url = 'javascript:void(window.open(\'' . $url .'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))'; |
|
1357 | + $url = 'javascript:void(window.open(\''.$url.'\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,height=600px\', \'100\' ))'; |
|
1359 | 1358 | } |
1360 | 1359 | return $url; |
1361 | 1360 | } |
@@ -1367,9 +1366,9 @@ discard block |
||
1367 | 1366 | */ |
1368 | 1367 | public function getRenderMailUrl($params) |
1369 | 1368 | { |
1370 | - $url = api_get_path(WEB_PLUGIN_PATH) . 'advanced_subscription/src/render_mail.php?' . |
|
1371 | - 'q=' . $params['queueId'] . '&' . |
|
1372 | - 'v=' . $this->generateHash($params); |
|
1369 | + $url = api_get_path(WEB_PLUGIN_PATH).'advanced_subscription/src/render_mail.php?'. |
|
1370 | + 'q='.$params['queueId'].'&'. |
|
1371 | + 'v='.$this->generateHash($params); |
|
1373 | 1372 | return $url; |
1374 | 1373 | } |
1375 | 1374 | |
@@ -1440,7 +1439,7 @@ discard block |
||
1440 | 1439 | sf.extra_field_type = $extraFieldType AND |
1441 | 1440 | sf.variable = 'is_induction_session' AND |
1442 | 1441 | su.relation_type = 0 AND |
1443 | - su.user_id = " . intval($userId); |
|
1442 | + su.user_id = ".intval($userId); |
|
1444 | 1443 | |
1445 | 1444 | $result = Database::query($sql); |
1446 | 1445 |