@@ -79,6 +79,7 @@ |
||
79 | 79 | * |
80 | 80 | * @param int Exception code |
81 | 81 | * @param string Message to display |
82 | + * @param integer $code |
|
82 | 83 | * @return PENSException Exception created |
83 | 84 | */ |
84 | 85 | public function __construct($code, $message = null) { |
@@ -90,7 +90,7 @@ |
||
90 | 90 | * Sets the message based on the code |
91 | 91 | */ |
92 | 92 | protected function setMessageBasedOnCode() { |
93 | - if(empty($this->message) && !empty(self::$_code_to_messages[$this->code])) { |
|
93 | + if (empty($this->message) && !empty(self::$_code_to_messages[$this->code])) { |
|
94 | 94 | $this->message = self::$_code_to_messages[$this->code]; |
95 | 95 | } |
96 | 96 | } |
@@ -37,62 +37,62 @@ |
||
37 | 37 | */ |
38 | 38 | class PENSException extends Exception { |
39 | 39 | |
40 | - /** |
|
41 | - * Array that provides an association between exception codes and messages |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - protected static $_code_to_messages = array( |
|
45 | - 1101 => "Unable to parse PENS command", |
|
46 | - 1201 => "Attempt to pass an invalid argument", |
|
47 | - 1301 => "Unable to retrieve package", |
|
48 | - 1302 => "Unable to retrieve package via HTTPS", |
|
49 | - 1304 => "Unable to retrieve package via FTP", |
|
50 | - 1306 => "Unable to retrieve package via FTPS", |
|
51 | - 1310 => "Unable to retrieve package at specified URL due to error in URL or lack of response from URL", |
|
52 | - 1312 => "Unable to retrieve package at specified URL due to error with access credential for package URL", |
|
53 | - 1320 => "Expiration date is non-null and in an improper format", |
|
54 | - 1322 => "Current time indicates expiry date has passed", |
|
55 | - 1420 => "PENS version not supported", |
|
56 | - 1421 => "Command not supported", |
|
57 | - 1430 => "Package type not supported", |
|
58 | - // The following error code is not specified in the PENS specification and was added in this implementation |
|
59 | - 1431 => "Package format not supported", |
|
60 | - 1432 => "Internal package error", |
|
61 | - 1440 => "Insufficient host space/storage available", |
|
62 | - 1500 => "Unable to communicate with provided acknowledgement URL", |
|
63 | - 1510 => "Unsupported acknowledgement protocol", |
|
64 | - 1520 => "Unsupported alert protocol", |
|
65 | - 2001 => "PENS version invalid or not specified", |
|
66 | - 2002 => "PENS command invalid or not specified", |
|
67 | - 2003 => "package-type invalid or not specified", |
|
68 | - 2004 => "package-type-version invalid or not specified", |
|
69 | - 2005 => "package-format invalid or not specified", |
|
70 | - 2007 => "package-id invalid or not specified", |
|
71 | - 2008 => "package-url invalid or not specified", |
|
72 | - 2009 => "package-url-expiry date invalid or not specified", |
|
73 | - 2010 => "client submitting package invalid or not specified", |
|
74 | - 2011 => "receipt url invalid or not specified" |
|
75 | - ); |
|
40 | + /** |
|
41 | + * Array that provides an association between exception codes and messages |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + protected static $_code_to_messages = array( |
|
45 | + 1101 => "Unable to parse PENS command", |
|
46 | + 1201 => "Attempt to pass an invalid argument", |
|
47 | + 1301 => "Unable to retrieve package", |
|
48 | + 1302 => "Unable to retrieve package via HTTPS", |
|
49 | + 1304 => "Unable to retrieve package via FTP", |
|
50 | + 1306 => "Unable to retrieve package via FTPS", |
|
51 | + 1310 => "Unable to retrieve package at specified URL due to error in URL or lack of response from URL", |
|
52 | + 1312 => "Unable to retrieve package at specified URL due to error with access credential for package URL", |
|
53 | + 1320 => "Expiration date is non-null and in an improper format", |
|
54 | + 1322 => "Current time indicates expiry date has passed", |
|
55 | + 1420 => "PENS version not supported", |
|
56 | + 1421 => "Command not supported", |
|
57 | + 1430 => "Package type not supported", |
|
58 | + // The following error code is not specified in the PENS specification and was added in this implementation |
|
59 | + 1431 => "Package format not supported", |
|
60 | + 1432 => "Internal package error", |
|
61 | + 1440 => "Insufficient host space/storage available", |
|
62 | + 1500 => "Unable to communicate with provided acknowledgement URL", |
|
63 | + 1510 => "Unsupported acknowledgement protocol", |
|
64 | + 1520 => "Unsupported alert protocol", |
|
65 | + 2001 => "PENS version invalid or not specified", |
|
66 | + 2002 => "PENS command invalid or not specified", |
|
67 | + 2003 => "package-type invalid or not specified", |
|
68 | + 2004 => "package-type-version invalid or not specified", |
|
69 | + 2005 => "package-format invalid or not specified", |
|
70 | + 2007 => "package-id invalid or not specified", |
|
71 | + 2008 => "package-url invalid or not specified", |
|
72 | + 2009 => "package-url-expiry date invalid or not specified", |
|
73 | + 2010 => "client submitting package invalid or not specified", |
|
74 | + 2011 => "receipt url invalid or not specified" |
|
75 | + ); |
|
76 | 76 | |
77 | - /** |
|
78 | - * Redefines the constructor so that code is the first argument |
|
79 | - * |
|
80 | - * @param int Exception code |
|
81 | - * @param string Message to display |
|
82 | - * @return PENSException Exception created |
|
83 | - */ |
|
84 | - public function __construct($code, $message = null) { |
|
85 | - parent::__construct($message, $code); |
|
86 | - $this->setMessageBasedOnCode(); |
|
87 | - } |
|
77 | + /** |
|
78 | + * Redefines the constructor so that code is the first argument |
|
79 | + * |
|
80 | + * @param int Exception code |
|
81 | + * @param string Message to display |
|
82 | + * @return PENSException Exception created |
|
83 | + */ |
|
84 | + public function __construct($code, $message = null) { |
|
85 | + parent::__construct($message, $code); |
|
86 | + $this->setMessageBasedOnCode(); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Sets the message based on the code |
|
91 | - */ |
|
92 | - protected function setMessageBasedOnCode() { |
|
93 | - if(empty($this->message) && !empty(self::$_code_to_messages[$this->code])) { |
|
94 | - $this->message = self::$_code_to_messages[$this->code]; |
|
95 | - } |
|
96 | - } |
|
89 | + /** |
|
90 | + * Sets the message based on the code |
|
91 | + */ |
|
92 | + protected function setMessageBasedOnCode() { |
|
93 | + if(empty($this->message) && !empty(self::$_code_to_messages[$this->code])) { |
|
94 | + $this->message = self::$_code_to_messages[$this->code]; |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | } |
@@ -236,6 +236,7 @@ discard block |
||
236 | 236 | * @param PENSRequest Original collect request |
237 | 237 | * @param PENSResponse Reponse to send in the receipt or the alert |
238 | 238 | * @param string Mode (alert | receipt) |
239 | + * @param string $mode |
|
239 | 240 | * @return PENSResponse Response |
240 | 241 | */ |
241 | 242 | protected function sendAlertOrReceipt($request, $response, $mode) { |
@@ -283,6 +284,7 @@ discard block |
||
283 | 284 | * |
284 | 285 | * @param PENSRequest Original collect request |
285 | 286 | * @param PENSResponse Response to send in the receipt |
287 | + * @param PENSResponse $receipt |
|
286 | 288 | * @return PENSResponse Response |
287 | 289 | */ |
288 | 290 | protected function sendReceipt($request, $receipt) { |
@@ -294,6 +296,7 @@ discard block |
||
294 | 296 | * |
295 | 297 | * @param PENSRequest Original collect request |
296 | 298 | * @param string Path to the package on the hard drive |
299 | + * @param string $path_to_package |
|
297 | 300 | */ |
298 | 301 | protected function processPackage($request, $path_to_package) { |
299 | 302 | return $this->_package_handler->processPackage($request, $path_to_package); |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | * along with php-pens. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | */ |
18 | 18 | |
19 | - /** |
|
20 | - * PENSServer |
|
21 | - * |
|
22 | - * Provides the PENSServer class |
|
23 | - * |
|
24 | - * @package PENS |
|
25 | - * @author Guillaume Viguier-Just <[email protected]> |
|
26 | - * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | - */ |
|
19 | + /** |
|
20 | + * PENSServer |
|
21 | + * |
|
22 | + * Provides the PENSServer class |
|
23 | + * |
|
24 | + * @package PENS |
|
25 | + * @author Guillaume Viguier-Just <[email protected]> |
|
26 | + * @licence http://www.gnu.org/licenses/gpl.txt |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | require_once __DIR__ . '/pens_controller.php'; |
30 | 30 | require_once __DIR__ . '/pens_package_handler.php'; |
@@ -42,272 +42,272 @@ discard block |
||
42 | 42 | */ |
43 | 43 | class PENSServer extends PENSController { |
44 | 44 | |
45 | - /** |
|
46 | - * Instance of the PENSServer |
|
47 | - * @var PENSServer |
|
48 | - */ |
|
49 | - private static $_instance; |
|
45 | + /** |
|
46 | + * Instance of the PENSServer |
|
47 | + * @var PENSServer |
|
48 | + */ |
|
49 | + private static $_instance; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Package handler |
|
53 | - * @var PENSPackageHandler |
|
54 | - */ |
|
55 | - protected $_package_handler = null; |
|
51 | + /** |
|
52 | + * Package handler |
|
53 | + * @var PENSPackageHandler |
|
54 | + */ |
|
55 | + protected $_package_handler = null; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Private constructor |
|
59 | - */ |
|
60 | - private function __construct() { |
|
61 | - } |
|
57 | + /** |
|
58 | + * Private constructor |
|
59 | + */ |
|
60 | + private function __construct() { |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Singleton method |
|
65 | - */ |
|
66 | - public static function singleton() { |
|
67 | - if(!isset(self::$_instance)) { |
|
68 | - $c = __CLASS__; |
|
69 | - self::$_instance = new $c; |
|
70 | - } |
|
71 | - return self::$_instance; |
|
72 | - } |
|
63 | + /** |
|
64 | + * Singleton method |
|
65 | + */ |
|
66 | + public static function singleton() { |
|
67 | + if(!isset(self::$_instance)) { |
|
68 | + $c = __CLASS__; |
|
69 | + self::$_instance = new $c; |
|
70 | + } |
|
71 | + return self::$_instance; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Prevent users to clone the instance |
|
76 | - */ |
|
77 | - public function __clone() { |
|
78 | - trigger_error('Clone is not allowed', E_USER_ERROR); |
|
79 | - } |
|
74 | + /** |
|
75 | + * Prevent users to clone the instance |
|
76 | + */ |
|
77 | + public function __clone() { |
|
78 | + trigger_error('Clone is not allowed', E_USER_ERROR); |
|
79 | + } |
|
80 | 80 | |
81 | - public function getPackageHandler() { |
|
82 | - return $this->_package_handler; |
|
83 | - } |
|
81 | + public function getPackageHandler() { |
|
82 | + return $this->_package_handler; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Sets the package handler. Does nothing if the argument is not an instance of PENSPackageHandler |
|
87 | - * |
|
88 | - * @param PENSPackageHandler Package handler |
|
89 | - */ |
|
90 | - public function setPackageHandler($package_handler) { |
|
91 | - if($package_handler instanceof PENSPackageHandler) { |
|
92 | - $this->_package_handler = $package_handler; |
|
93 | - } |
|
94 | - } |
|
85 | + /** |
|
86 | + * Sets the package handler. Does nothing if the argument is not an instance of PENSPackageHandler |
|
87 | + * |
|
88 | + * @param PENSPackageHandler Package handler |
|
89 | + */ |
|
90 | + public function setPackageHandler($package_handler) { |
|
91 | + if($package_handler instanceof PENSPackageHandler) { |
|
92 | + $this->_package_handler = $package_handler; |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Receives a collect request and treats it |
|
98 | - */ |
|
99 | - public function receiveCollect() { |
|
100 | - $request = null; |
|
101 | - try { |
|
102 | - // First, try to parse the request |
|
103 | - $request = $this->parseRequest(); |
|
104 | - if($request->getCommand() == "collect") { |
|
105 | - if(isset($_REQUEST['process'])) { |
|
106 | - // Collect the package and process it |
|
107 | - $receipt = null; |
|
108 | - $path_to_package = null; |
|
109 | - try { |
|
110 | - // Collect the package |
|
111 | - $path_to_package = $this->collectPackage($request); |
|
112 | - $receipt = new PENSResponse(0, "package successfully collected"); |
|
113 | - } catch(PENSException $e) { |
|
114 | - $receipt = new PENSResponse($e); |
|
115 | - } |
|
116 | - // Send receipt |
|
117 | - $response = $this->sendReceipt($request, $receipt); |
|
118 | - if(!is_null($response) && !is_null($path_to_package)) { |
|
119 | - if($response->getError() === 0) { |
|
120 | - // Process package |
|
121 | - $this->processPackage($request, $path_to_package); |
|
122 | - } |
|
123 | - unlink($path_to_package); |
|
124 | - } |
|
125 | - } else { |
|
126 | - // Then, send a success response to the client |
|
127 | - $this->sendResponse(new PENSResponse(0, "collect command received and understood")); |
|
128 | - // Send a request to process the package: fake multithreading |
|
129 | - $params = $_REQUEST; |
|
130 | - $params['process'] = 1; |
|
131 | - $scheme = "http"; |
|
132 | - if(!empty($_SERVER['HTTPS'])) { |
|
133 | - $scheme = "https"; |
|
134 | - } |
|
135 | - $ch = curl_init(); |
|
136 | - curl_setopt($ch, CURLOPT_URL, $scheme."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
137 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
138 | - curl_setopt($ch, CURLOPT_TIMEOUT, 1); |
|
139 | - curl_exec($ch); |
|
140 | - curl_close($ch); |
|
141 | - } |
|
142 | - } |
|
96 | + /** |
|
97 | + * Receives a collect request and treats it |
|
98 | + */ |
|
99 | + public function receiveCollect() { |
|
100 | + $request = null; |
|
101 | + try { |
|
102 | + // First, try to parse the request |
|
103 | + $request = $this->parseRequest(); |
|
104 | + if($request->getCommand() == "collect") { |
|
105 | + if(isset($_REQUEST['process'])) { |
|
106 | + // Collect the package and process it |
|
107 | + $receipt = null; |
|
108 | + $path_to_package = null; |
|
109 | + try { |
|
110 | + // Collect the package |
|
111 | + $path_to_package = $this->collectPackage($request); |
|
112 | + $receipt = new PENSResponse(0, "package successfully collected"); |
|
113 | + } catch(PENSException $e) { |
|
114 | + $receipt = new PENSResponse($e); |
|
115 | + } |
|
116 | + // Send receipt |
|
117 | + $response = $this->sendReceipt($request, $receipt); |
|
118 | + if(!is_null($response) && !is_null($path_to_package)) { |
|
119 | + if($response->getError() === 0) { |
|
120 | + // Process package |
|
121 | + $this->processPackage($request, $path_to_package); |
|
122 | + } |
|
123 | + unlink($path_to_package); |
|
124 | + } |
|
125 | + } else { |
|
126 | + // Then, send a success response to the client |
|
127 | + $this->sendResponse(new PENSResponse(0, "collect command received and understood")); |
|
128 | + // Send a request to process the package: fake multithreading |
|
129 | + $params = $_REQUEST; |
|
130 | + $params['process'] = 1; |
|
131 | + $scheme = "http"; |
|
132 | + if(!empty($_SERVER['HTTPS'])) { |
|
133 | + $scheme = "https"; |
|
134 | + } |
|
135 | + $ch = curl_init(); |
|
136 | + curl_setopt($ch, CURLOPT_URL, $scheme."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
137 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
138 | + curl_setopt($ch, CURLOPT_TIMEOUT, 1); |
|
139 | + curl_exec($ch); |
|
140 | + curl_close($ch); |
|
141 | + } |
|
142 | + } |
|
143 | 143 | |
144 | - } catch(PENSException $e) { |
|
145 | - // If we could not parse the request, send the error back to the client |
|
146 | - $this->sendResponse(new PENSResponse($e)); |
|
147 | - } |
|
148 | - } |
|
144 | + } catch(PENSException $e) { |
|
145 | + // If we could not parse the request, send the error back to the client |
|
146 | + $this->sendResponse(new PENSResponse($e)); |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Collects the package onto the local server |
|
152 | - * |
|
153 | - * @param PENSRequest request |
|
154 | - * @return string Path to the package on the hard drive |
|
155 | - * @throws PENSException if an exception occured |
|
156 | - */ |
|
157 | - protected function collectPackage($request) { |
|
158 | - $supported_package_types = $this->_package_handler->getSupportedPackageTypes(); |
|
159 | - if(!in_array($request->getPackageType(), $supported_package_types)) { |
|
160 | - throw new PENSException(1430); |
|
161 | - } |
|
162 | - $supported_package_formats = $this->_package_handler->getSupportedPackageFormats(); |
|
163 | - if(!in_array($request->getPackageFormat(), $supported_package_formats)) { |
|
164 | - throw new PENSException(1431); |
|
165 | - } |
|
166 | - if(!$this->isExpiryDateValid($request->getPackageUrlExpiry())) { |
|
167 | - throw new PENSException(1322); |
|
168 | - } |
|
150 | + /** |
|
151 | + * Collects the package onto the local server |
|
152 | + * |
|
153 | + * @param PENSRequest request |
|
154 | + * @return string Path to the package on the hard drive |
|
155 | + * @throws PENSException if an exception occured |
|
156 | + */ |
|
157 | + protected function collectPackage($request) { |
|
158 | + $supported_package_types = $this->_package_handler->getSupportedPackageTypes(); |
|
159 | + if(!in_array($request->getPackageType(), $supported_package_types)) { |
|
160 | + throw new PENSException(1430); |
|
161 | + } |
|
162 | + $supported_package_formats = $this->_package_handler->getSupportedPackageFormats(); |
|
163 | + if(!in_array($request->getPackageFormat(), $supported_package_formats)) { |
|
164 | + throw new PENSException(1431); |
|
165 | + } |
|
166 | + if(!$this->isExpiryDateValid($request->getPackageUrlExpiry())) { |
|
167 | + throw new PENSException(1322); |
|
168 | + } |
|
169 | 169 | |
170 | - // Try to download the package in the temporary directory |
|
171 | - $tmp = null; |
|
172 | - if(function_exists("sys_get_temp_dir")) { |
|
173 | - $tmp = sys_get_temp_dir(); |
|
174 | - } else { |
|
175 | - $tmp = "/tmp"; |
|
176 | - } |
|
177 | - $path_to_file = $tmp."/".$request->getFilename(); |
|
178 | - $fp = fopen($path_to_file, 'w'); |
|
179 | - $ch = curl_init(); |
|
180 | - curl_setopt($ch, CURLOPT_URL, $request->getPackageUrl()); |
|
181 | - curl_setopt($ch, CURLOPT_HEADER, false); |
|
182 | - curl_setopt($ch, CURLOPT_FILE, $fp); |
|
183 | - if(!is_null($request->getPackageUrlUserId())) { |
|
184 | - curl_setopt($ch, CURLOPT_USERPWD, $request->getPackageUrlUserId().":".$request->getPackageUrlPassword()); |
|
185 | - } |
|
186 | - if(curl_exec($ch) === false) { |
|
187 | - $errno = curl_errno($ch); |
|
188 | - curl_close($ch); |
|
189 | - // Error occured. Throw an exception |
|
190 | - switch($errno) { |
|
191 | - case CURLE_UNSUPPORTED_PROTOCOL: |
|
192 | - throw new PENSException(1301); |
|
193 | - break; |
|
194 | - case CURLE_URL_MALFORMAT: |
|
195 | - case CURLE_COULDNT_RESOLVE_PROXY: |
|
196 | - case CURLE_COULDNT_RESOLVE_HOST: |
|
197 | - case CURLE_COULDNT_CONNECT: |
|
198 | - case CURLE_OPERATION_TIMEOUT: |
|
199 | - case CURLE_REMOTE_FILE_NOT_FOUND: |
|
200 | - throw new PENSException(1310); |
|
201 | - break; |
|
202 | - case CURLE_REMOTE_ACCESS_DENIED: |
|
203 | - throw new PENSException(1312); |
|
204 | - break; |
|
205 | - default: |
|
206 | - throw new PENSException(1301); |
|
207 | - break; |
|
208 | - } |
|
209 | - return null; |
|
170 | + // Try to download the package in the temporary directory |
|
171 | + $tmp = null; |
|
172 | + if(function_exists("sys_get_temp_dir")) { |
|
173 | + $tmp = sys_get_temp_dir(); |
|
174 | + } else { |
|
175 | + $tmp = "/tmp"; |
|
176 | + } |
|
177 | + $path_to_file = $tmp."/".$request->getFilename(); |
|
178 | + $fp = fopen($path_to_file, 'w'); |
|
179 | + $ch = curl_init(); |
|
180 | + curl_setopt($ch, CURLOPT_URL, $request->getPackageUrl()); |
|
181 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
182 | + curl_setopt($ch, CURLOPT_FILE, $fp); |
|
183 | + if(!is_null($request->getPackageUrlUserId())) { |
|
184 | + curl_setopt($ch, CURLOPT_USERPWD, $request->getPackageUrlUserId().":".$request->getPackageUrlPassword()); |
|
185 | + } |
|
186 | + if(curl_exec($ch) === false) { |
|
187 | + $errno = curl_errno($ch); |
|
188 | + curl_close($ch); |
|
189 | + // Error occured. Throw an exception |
|
190 | + switch($errno) { |
|
191 | + case CURLE_UNSUPPORTED_PROTOCOL: |
|
192 | + throw new PENSException(1301); |
|
193 | + break; |
|
194 | + case CURLE_URL_MALFORMAT: |
|
195 | + case CURLE_COULDNT_RESOLVE_PROXY: |
|
196 | + case CURLE_COULDNT_RESOLVE_HOST: |
|
197 | + case CURLE_COULDNT_CONNECT: |
|
198 | + case CURLE_OPERATION_TIMEOUT: |
|
199 | + case CURLE_REMOTE_FILE_NOT_FOUND: |
|
200 | + throw new PENSException(1310); |
|
201 | + break; |
|
202 | + case CURLE_REMOTE_ACCESS_DENIED: |
|
203 | + throw new PENSException(1312); |
|
204 | + break; |
|
205 | + default: |
|
206 | + throw new PENSException(1301); |
|
207 | + break; |
|
208 | + } |
|
209 | + return null; |
|
210 | 210 | |
211 | - } else { |
|
212 | - curl_close($ch); |
|
213 | - return $path_to_file; |
|
214 | - } |
|
215 | - } |
|
211 | + } else { |
|
212 | + curl_close($ch); |
|
213 | + return $path_to_file; |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - /** |
|
218 | - * Verifies that the package url is not expired |
|
219 | - * |
|
220 | - * @param DateTime DateTime object to verify against current time |
|
221 | - */ |
|
222 | - protected function isExpiryDateValid($expiry) { |
|
223 | - date_default_timezone_set('UTC'); |
|
224 | - $current_time = time(); |
|
225 | - $expiry_time = strtotime($expiry->format(DateTime::ISO8601)); |
|
226 | - if($current_time > $expiry_time) { |
|
227 | - return false; |
|
228 | - } else { |
|
229 | - return true; |
|
230 | - } |
|
231 | - } |
|
217 | + /** |
|
218 | + * Verifies that the package url is not expired |
|
219 | + * |
|
220 | + * @param DateTime DateTime object to verify against current time |
|
221 | + */ |
|
222 | + protected function isExpiryDateValid($expiry) { |
|
223 | + date_default_timezone_set('UTC'); |
|
224 | + $current_time = time(); |
|
225 | + $expiry_time = strtotime($expiry->format(DateTime::ISO8601)); |
|
226 | + if($current_time > $expiry_time) { |
|
227 | + return false; |
|
228 | + } else { |
|
229 | + return true; |
|
230 | + } |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * Sends an alert or a receipt. Called by sendReceipt and sendAlert |
|
235 | - * |
|
236 | - * @param PENSRequest Original collect request |
|
237 | - * @param PENSResponse Reponse to send in the receipt or the alert |
|
238 | - * @param string Mode (alert | receipt) |
|
239 | - * @return PENSResponse Response |
|
240 | - */ |
|
241 | - protected function sendAlertOrReceipt($request, $response, $mode) { |
|
242 | - if($mode == "alert") { |
|
243 | - $url = $request->getAlerts(); |
|
244 | - } else { |
|
245 | - $url = $request->getReceipt(); |
|
246 | - } |
|
247 | - if(!empty($url)) { |
|
248 | - $url_components = parse_url($url); |
|
249 | - $scheme = $url_components["scheme"]; |
|
250 | - if($scheme == "mailto") { |
|
251 | - $to = $url_components["path"]; |
|
252 | - if($mode == "alert") { |
|
253 | - $subject = "PENS Alert for ".$request->getPackageId(); |
|
254 | - } else { |
|
255 | - $subject = "PENS Receipt for ".$request->getPackageId(); |
|
256 | - } |
|
257 | - $message = $response->__toString(); |
|
258 | - mail($to, $subject, $message); |
|
259 | - return new PENSResponse(0, ""); |
|
260 | - } else if($scheme == "http" || $scheme == "https") { |
|
261 | - if($mode == "alert") { |
|
262 | - $params = array_merge($request->getSendAlertArray(), $response->getArray()); |
|
263 | - } else { |
|
264 | - $params = array_merge($request->getSendReceiptArray(), $response->getArray()); |
|
265 | - } |
|
266 | - $ch = curl_init($url); |
|
267 | - curl_setopt($ch, CURLOPT_POST, true); |
|
268 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
269 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
270 | - $data = curl_exec($ch); |
|
271 | - curl_close($ch); |
|
272 | - if($data === false) { |
|
273 | - return null; |
|
274 | - } else { |
|
275 | - return new PENSResponse($data); |
|
276 | - } |
|
277 | - } |
|
278 | - } |
|
279 | - } |
|
233 | + /** |
|
234 | + * Sends an alert or a receipt. Called by sendReceipt and sendAlert |
|
235 | + * |
|
236 | + * @param PENSRequest Original collect request |
|
237 | + * @param PENSResponse Reponse to send in the receipt or the alert |
|
238 | + * @param string Mode (alert | receipt) |
|
239 | + * @return PENSResponse Response |
|
240 | + */ |
|
241 | + protected function sendAlertOrReceipt($request, $response, $mode) { |
|
242 | + if($mode == "alert") { |
|
243 | + $url = $request->getAlerts(); |
|
244 | + } else { |
|
245 | + $url = $request->getReceipt(); |
|
246 | + } |
|
247 | + if(!empty($url)) { |
|
248 | + $url_components = parse_url($url); |
|
249 | + $scheme = $url_components["scheme"]; |
|
250 | + if($scheme == "mailto") { |
|
251 | + $to = $url_components["path"]; |
|
252 | + if($mode == "alert") { |
|
253 | + $subject = "PENS Alert for ".$request->getPackageId(); |
|
254 | + } else { |
|
255 | + $subject = "PENS Receipt for ".$request->getPackageId(); |
|
256 | + } |
|
257 | + $message = $response->__toString(); |
|
258 | + mail($to, $subject, $message); |
|
259 | + return new PENSResponse(0, ""); |
|
260 | + } else if($scheme == "http" || $scheme == "https") { |
|
261 | + if($mode == "alert") { |
|
262 | + $params = array_merge($request->getSendAlertArray(), $response->getArray()); |
|
263 | + } else { |
|
264 | + $params = array_merge($request->getSendReceiptArray(), $response->getArray()); |
|
265 | + } |
|
266 | + $ch = curl_init($url); |
|
267 | + curl_setopt($ch, CURLOPT_POST, true); |
|
268 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
269 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
270 | + $data = curl_exec($ch); |
|
271 | + curl_close($ch); |
|
272 | + if($data === false) { |
|
273 | + return null; |
|
274 | + } else { |
|
275 | + return new PENSResponse($data); |
|
276 | + } |
|
277 | + } |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Sends a receipt. Returns a PENSResponse in case of success, null if a problem occured |
|
283 | - * |
|
284 | - * @param PENSRequest Original collect request |
|
285 | - * @param PENSResponse Response to send in the receipt |
|
286 | - * @return PENSResponse Response |
|
287 | - */ |
|
288 | - protected function sendReceipt($request, $receipt) { |
|
289 | - return $this->sendAlertOrReceipt($request, $receipt, "receipt"); |
|
290 | - } |
|
281 | + /** |
|
282 | + * Sends a receipt. Returns a PENSResponse in case of success, null if a problem occured |
|
283 | + * |
|
284 | + * @param PENSRequest Original collect request |
|
285 | + * @param PENSResponse Response to send in the receipt |
|
286 | + * @return PENSResponse Response |
|
287 | + */ |
|
288 | + protected function sendReceipt($request, $receipt) { |
|
289 | + return $this->sendAlertOrReceipt($request, $receipt, "receipt"); |
|
290 | + } |
|
291 | 291 | |
292 | - /** |
|
293 | - * Processes the package using the handler provided |
|
294 | - * |
|
295 | - * @param PENSRequest Original collect request |
|
296 | - * @param string Path to the package on the hard drive |
|
297 | - */ |
|
298 | - protected function processPackage($request, $path_to_package) { |
|
299 | - return $this->_package_handler->processPackage($request, $path_to_package); |
|
300 | - } |
|
292 | + /** |
|
293 | + * Processes the package using the handler provided |
|
294 | + * |
|
295 | + * @param PENSRequest Original collect request |
|
296 | + * @param string Path to the package on the hard drive |
|
297 | + */ |
|
298 | + protected function processPackage($request, $path_to_package) { |
|
299 | + return $this->_package_handler->processPackage($request, $path_to_package); |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * Sends an alert to the client. Returns a PENSResponse in case of success, null if a problem occured |
|
304 | - * |
|
305 | - * @param PENSRequest Original collect request |
|
306 | - * @param PENSResponse Response to send in the alert |
|
307 | - * @return PENSResponse Response |
|
308 | - */ |
|
309 | - public function sendAlert($request, $alert) { |
|
310 | - return $this->sendAlertOrReceipt($request, $alert, "alert"); |
|
311 | - } |
|
302 | + /** |
|
303 | + * Sends an alert to the client. Returns a PENSResponse in case of success, null if a problem occured |
|
304 | + * |
|
305 | + * @param PENSRequest Original collect request |
|
306 | + * @param PENSResponse Response to send in the alert |
|
307 | + * @return PENSResponse Response |
|
308 | + */ |
|
309 | + public function sendAlert($request, $alert) { |
|
310 | + return $this->sendAlertOrReceipt($request, $alert, "alert"); |
|
311 | + } |
|
312 | 312 | |
313 | 313 | } |
@@ -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); |
@@ -76,6 +76,11 @@ |
||
76 | 76 | return PENSRequestFactory::createPENSRequest($myargs); |
77 | 77 | } |
78 | 78 | |
79 | + /** |
|
80 | + * @param string $key |
|
81 | + * @param string|null $value |
|
82 | + * @param integer $code |
|
83 | + */ |
|
79 | 84 | public function exceptionTestForValue($key, $value, $code) { |
80 | 85 | try { |
81 | 86 | $myargs = $this->args; |
@@ -44,170 +44,170 @@ |
||
44 | 44 | */ |
45 | 45 | class TestPENSRequest extends UnitTestCase { |
46 | 46 | |
47 | - /** |
|
48 | - * Valid arguments to be used for tests |
|
49 | - * |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - private $args = null; |
|
53 | - |
|
54 | - public function setUp() { |
|
55 | - $this->args = array( |
|
56 | - "pens-version" => "1.0.0", |
|
57 | - "command" => "collect", |
|
58 | - "package-type" => "aicc-pkg", |
|
59 | - "package-type-version" => "1.0", |
|
60 | - "package-format" => "zip", |
|
61 | - "package-id" => "http://myurl.com/12345", |
|
62 | - "package-url" => "http://myurl.com/mypackage.zip", |
|
63 | - "package-url-expiry" => "2006-04-01T06:51:29Z", |
|
64 | - "client" => "Authorware7", |
|
65 | - "receipt" => "mailto:[email protected]", |
|
66 | - "package-url-user-id" => "guillaumev", |
|
67 | - "package-url-account" => "toto", |
|
68 | - "package-url-password" => "12345", |
|
69 | - "system-user-id" => "guillaumev", |
|
70 | - "system-password" => "12345", |
|
71 | - "alerts" => "http://myurl.com/alerts", |
|
72 | - "vendor-data" => "here are my data"); |
|
73 | - } |
|
74 | - |
|
75 | - public function createObject($myargs) { |
|
76 | - return PENSRequestFactory::createPENSRequest($myargs); |
|
77 | - } |
|
78 | - |
|
79 | - public function exceptionTestForValue($key, $value, $code) { |
|
80 | - try { |
|
81 | - $myargs = $this->args; |
|
82 | - if($value === null) { |
|
83 | - unset($myargs[$key]); |
|
84 | - } else { |
|
85 | - $myargs[$key] = $value; |
|
86 | - } |
|
87 | - $object = $this->createObject($myargs); |
|
88 | - $this->fail(); |
|
89 | - } catch(PENSException $e) { |
|
90 | - $this->assertEqual($e->getCode(), $code); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - public function testPensVersionInvalid() { |
|
95 | - $this->exceptionTestForValue("pens-version", "0.8.0", 2001); |
|
96 | - } |
|
97 | - |
|
98 | - public function testPensVersionNull() { |
|
99 | - $this->exceptionTestForValue("pens-version", null, 2001); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - public function testCommandInvalid() { |
|
104 | - $this->exceptionTestForValue("command", "testing", 2002); |
|
105 | - } |
|
106 | - |
|
107 | - public function testCommandNull() { |
|
108 | - $this->exceptionTestForValue("command", null, 2002); |
|
109 | - } |
|
110 | - |
|
111 | - public function testPackageTypeInvalid() { |
|
112 | - $this->exceptionTestForValue("package-type", "testing", 2003); |
|
113 | - } |
|
114 | - |
|
115 | - public function testPackageTypeNull() { |
|
116 | - $this->exceptionTestForValue("package-type", null, 2003); |
|
117 | - } |
|
118 | - |
|
119 | - public function testPackageTypeVersionNull() { |
|
120 | - $this->exceptionTestForValue("package-type-version", null, 2004); |
|
121 | - } |
|
122 | - |
|
123 | - public function testPackageFormatInvalid() { |
|
124 | - $this->exceptionTestForValue("package-format", "testing", 2005); |
|
125 | - } |
|
126 | - |
|
127 | - public function testPackageFormatNull() { |
|
128 | - $this->exceptionTestForValue("package-format", null, 2005); |
|
129 | - } |
|
130 | - |
|
131 | - public function testPackageIdInvalid() { |
|
132 | - $this->exceptionTestForValue("package-id", "testing", 2007); |
|
133 | - } |
|
134 | - |
|
135 | - public function testPackageIdNull() { |
|
136 | - $this->exceptionTestForValue("package-id", null, 2007); |
|
137 | - } |
|
138 | - |
|
139 | - public function testPackageUrlInvalid() { |
|
140 | - $this->exceptionTestForValue("package-url", "testing", 2008); |
|
141 | - } |
|
142 | - |
|
143 | - public function testPackageUrlInvalid2() { |
|
144 | - $this->exceptionTestForValue("package-url", "http://myurl.com/mypackage", 2008); |
|
145 | - } |
|
146 | - |
|
147 | - public function testPackageUrlNull() { |
|
148 | - $this->exceptionTestForValue("package-url", null, 2008); |
|
149 | - } |
|
150 | - |
|
151 | - public function testPackageUrlExpiryNull() { |
|
152 | - $this->exceptionTestForValue("package-url-expiry", null, 2009); |
|
153 | - } |
|
154 | - |
|
155 | - public function testPackageUrlExpiryInvalid() { |
|
156 | - $this->exceptionTestForValue("package-url-expiry", "testing", 2009); |
|
157 | - } |
|
158 | - |
|
159 | - public function testClientNull() { |
|
160 | - $this->exceptionTestForValue("client", null, 2010); |
|
161 | - } |
|
162 | - |
|
163 | - public function testReceiptNull() { |
|
164 | - $this->exceptionTestForValue("receipt", null, 2011); |
|
165 | - } |
|
166 | - |
|
167 | - public function testReceiptInvalid() { |
|
168 | - $this->exceptionTestForValue("receipt", "testing", 2011); |
|
169 | - } |
|
170 | - |
|
171 | - public function testAlertsInvalid() { |
|
172 | - $this->exceptionTestForValue("alerts", "testing", 1201); |
|
173 | - } |
|
174 | - |
|
175 | - public function testReceiptValid() { |
|
176 | - try { |
|
177 | - $myargs = $this->args; |
|
178 | - $myargs["receipt"] = "mailto:[email protected],[email protected]"; |
|
179 | - $object = $this->createObject($myargs); |
|
180 | - $this->pass(); |
|
181 | - } catch(PENSException $e) { |
|
182 | - $this->fail(); |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - public function testValid() { |
|
187 | - try { |
|
188 | - $object = $this->createObject($this->args); |
|
189 | - $this->assertIsA($object, "PENSRequestCollect"); |
|
190 | - $this->assertEqual($object->getPensVersion(), "1.0.0"); |
|
191 | - $this->assertEqual($object->getPackageType(), "aicc-pkg"); |
|
192 | - $this->assertEqual($object->getPackageTypeVersion(), "1.0"); |
|
193 | - $this->assertEqual($object->getPackageFormat(), "zip"); |
|
194 | - $this->assertEqual($object->getPackageId(), "http://myurl.com/12345"); |
|
195 | - $this->assertEqual($object->getPackageUrl(), "http://myurl.com/mypackage.zip"); |
|
196 | - $this->assertIsA($object->getPackageUrlExpiry(), "DateTime"); |
|
197 | - $this->assertEqual($object->getClient(), "Authorware7"); |
|
198 | - $this->assertEqual($object->getReceipt(), "mailto:[email protected]"); |
|
199 | - $this->assertEqual($object->getPackageUrlUserId(), "guillaumev"); |
|
200 | - $this->assertEqual($object->getPackageUrlAccount(), "toto"); |
|
201 | - $this->assertEqual($object->getPackageUrlPassword(), "12345"); |
|
202 | - $this->assertEqual($object->getSystemUserId(), "guillaumev"); |
|
203 | - $this->assertEqual($object->getSystemPassword(), "12345"); |
|
204 | - $this->assertEqual($object->getAlerts(), "http://myurl.com/alerts"); |
|
205 | - $this->assertEqual($object->getVendorData(), "here are my data"); |
|
47 | + /** |
|
48 | + * Valid arguments to be used for tests |
|
49 | + * |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + private $args = null; |
|
53 | + |
|
54 | + public function setUp() { |
|
55 | + $this->args = array( |
|
56 | + "pens-version" => "1.0.0", |
|
57 | + "command" => "collect", |
|
58 | + "package-type" => "aicc-pkg", |
|
59 | + "package-type-version" => "1.0", |
|
60 | + "package-format" => "zip", |
|
61 | + "package-id" => "http://myurl.com/12345", |
|
62 | + "package-url" => "http://myurl.com/mypackage.zip", |
|
63 | + "package-url-expiry" => "2006-04-01T06:51:29Z", |
|
64 | + "client" => "Authorware7", |
|
65 | + "receipt" => "mailto:[email protected]", |
|
66 | + "package-url-user-id" => "guillaumev", |
|
67 | + "package-url-account" => "toto", |
|
68 | + "package-url-password" => "12345", |
|
69 | + "system-user-id" => "guillaumev", |
|
70 | + "system-password" => "12345", |
|
71 | + "alerts" => "http://myurl.com/alerts", |
|
72 | + "vendor-data" => "here are my data"); |
|
73 | + } |
|
74 | + |
|
75 | + public function createObject($myargs) { |
|
76 | + return PENSRequestFactory::createPENSRequest($myargs); |
|
77 | + } |
|
78 | + |
|
79 | + public function exceptionTestForValue($key, $value, $code) { |
|
80 | + try { |
|
81 | + $myargs = $this->args; |
|
82 | + if($value === null) { |
|
83 | + unset($myargs[$key]); |
|
84 | + } else { |
|
85 | + $myargs[$key] = $value; |
|
86 | + } |
|
87 | + $object = $this->createObject($myargs); |
|
88 | + $this->fail(); |
|
89 | + } catch(PENSException $e) { |
|
90 | + $this->assertEqual($e->getCode(), $code); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + public function testPensVersionInvalid() { |
|
95 | + $this->exceptionTestForValue("pens-version", "0.8.0", 2001); |
|
96 | + } |
|
97 | + |
|
98 | + public function testPensVersionNull() { |
|
99 | + $this->exceptionTestForValue("pens-version", null, 2001); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + public function testCommandInvalid() { |
|
104 | + $this->exceptionTestForValue("command", "testing", 2002); |
|
105 | + } |
|
106 | + |
|
107 | + public function testCommandNull() { |
|
108 | + $this->exceptionTestForValue("command", null, 2002); |
|
109 | + } |
|
110 | + |
|
111 | + public function testPackageTypeInvalid() { |
|
112 | + $this->exceptionTestForValue("package-type", "testing", 2003); |
|
113 | + } |
|
114 | + |
|
115 | + public function testPackageTypeNull() { |
|
116 | + $this->exceptionTestForValue("package-type", null, 2003); |
|
117 | + } |
|
118 | + |
|
119 | + public function testPackageTypeVersionNull() { |
|
120 | + $this->exceptionTestForValue("package-type-version", null, 2004); |
|
121 | + } |
|
122 | + |
|
123 | + public function testPackageFormatInvalid() { |
|
124 | + $this->exceptionTestForValue("package-format", "testing", 2005); |
|
125 | + } |
|
126 | + |
|
127 | + public function testPackageFormatNull() { |
|
128 | + $this->exceptionTestForValue("package-format", null, 2005); |
|
129 | + } |
|
130 | + |
|
131 | + public function testPackageIdInvalid() { |
|
132 | + $this->exceptionTestForValue("package-id", "testing", 2007); |
|
133 | + } |
|
134 | + |
|
135 | + public function testPackageIdNull() { |
|
136 | + $this->exceptionTestForValue("package-id", null, 2007); |
|
137 | + } |
|
138 | + |
|
139 | + public function testPackageUrlInvalid() { |
|
140 | + $this->exceptionTestForValue("package-url", "testing", 2008); |
|
141 | + } |
|
142 | + |
|
143 | + public function testPackageUrlInvalid2() { |
|
144 | + $this->exceptionTestForValue("package-url", "http://myurl.com/mypackage", 2008); |
|
145 | + } |
|
146 | + |
|
147 | + public function testPackageUrlNull() { |
|
148 | + $this->exceptionTestForValue("package-url", null, 2008); |
|
149 | + } |
|
150 | + |
|
151 | + public function testPackageUrlExpiryNull() { |
|
152 | + $this->exceptionTestForValue("package-url-expiry", null, 2009); |
|
153 | + } |
|
154 | + |
|
155 | + public function testPackageUrlExpiryInvalid() { |
|
156 | + $this->exceptionTestForValue("package-url-expiry", "testing", 2009); |
|
157 | + } |
|
158 | + |
|
159 | + public function testClientNull() { |
|
160 | + $this->exceptionTestForValue("client", null, 2010); |
|
161 | + } |
|
162 | + |
|
163 | + public function testReceiptNull() { |
|
164 | + $this->exceptionTestForValue("receipt", null, 2011); |
|
165 | + } |
|
166 | + |
|
167 | + public function testReceiptInvalid() { |
|
168 | + $this->exceptionTestForValue("receipt", "testing", 2011); |
|
169 | + } |
|
170 | + |
|
171 | + public function testAlertsInvalid() { |
|
172 | + $this->exceptionTestForValue("alerts", "testing", 1201); |
|
173 | + } |
|
174 | + |
|
175 | + public function testReceiptValid() { |
|
176 | + try { |
|
177 | + $myargs = $this->args; |
|
178 | + $myargs["receipt"] = "mailto:[email protected],[email protected]"; |
|
179 | + $object = $this->createObject($myargs); |
|
180 | + $this->pass(); |
|
181 | + } catch(PENSException $e) { |
|
182 | + $this->fail(); |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + public function testValid() { |
|
187 | + try { |
|
188 | + $object = $this->createObject($this->args); |
|
189 | + $this->assertIsA($object, "PENSRequestCollect"); |
|
190 | + $this->assertEqual($object->getPensVersion(), "1.0.0"); |
|
191 | + $this->assertEqual($object->getPackageType(), "aicc-pkg"); |
|
192 | + $this->assertEqual($object->getPackageTypeVersion(), "1.0"); |
|
193 | + $this->assertEqual($object->getPackageFormat(), "zip"); |
|
194 | + $this->assertEqual($object->getPackageId(), "http://myurl.com/12345"); |
|
195 | + $this->assertEqual($object->getPackageUrl(), "http://myurl.com/mypackage.zip"); |
|
196 | + $this->assertIsA($object->getPackageUrlExpiry(), "DateTime"); |
|
197 | + $this->assertEqual($object->getClient(), "Authorware7"); |
|
198 | + $this->assertEqual($object->getReceipt(), "mailto:[email protected]"); |
|
199 | + $this->assertEqual($object->getPackageUrlUserId(), "guillaumev"); |
|
200 | + $this->assertEqual($object->getPackageUrlAccount(), "toto"); |
|
201 | + $this->assertEqual($object->getPackageUrlPassword(), "12345"); |
|
202 | + $this->assertEqual($object->getSystemUserId(), "guillaumev"); |
|
203 | + $this->assertEqual($object->getSystemPassword(), "12345"); |
|
204 | + $this->assertEqual($object->getAlerts(), "http://myurl.com/alerts"); |
|
205 | + $this->assertEqual($object->getVendorData(), "here are my data"); |
|
206 | 206 | |
207 | - } catch(PENSException $e) { |
|
208 | - $this->fail(); |
|
209 | - } |
|
210 | - } |
|
207 | + } catch(PENSException $e) { |
|
208 | + $this->fail(); |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | 213 | } |
@@ -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 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * Handle the subscribe action. |
59 | 59 | * |
60 | - * @return bool |
|
60 | + * @return null|boolean |
|
61 | 61 | */ |
62 | 62 | function action_subscribe_user() |
63 | 63 | { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | /** |
153 | 153 | * |
154 | - * @param type $course_code |
|
154 | + * @param string $course_code |
|
155 | 155 | * @return type |
156 | 156 | */ |
157 | 157 | function retrieve_course($course_code) |
@@ -40,11 +40,19 @@ |
||
40 | 40 | return isset($_GET[$key]) ? $_GET[$key] : $default; |
41 | 41 | } |
42 | 42 | |
43 | + /** |
|
44 | + * @param string $key |
|
45 | + * |
|
46 | + * @return string |
|
47 | + */ |
|
43 | 48 | public static function server($key, $default = '') |
44 | 49 | { |
45 | 50 | return isset($_SERVER[$key]) ? $_SERVER[$key] : $default; |
46 | 51 | } |
47 | 52 | |
53 | + /** |
|
54 | + * @param string $name |
|
55 | + */ |
|
48 | 56 | public static function get_lang($name) |
49 | 57 | { |
50 | 58 | return SearchCoursePlugin::create()->get_lang($name); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once dirname(__FILE__) . '/register_course_widget.class.php'; |
|
3 | +require_once dirname(__FILE__).'/register_course_widget.class.php'; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Search course widget. |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | $url = self::server('REQUEST_URI'); |
61 | 61 | $url = explode('?', $url); |
62 | 62 | $url = reset($url); |
63 | - $url = self::server('SERVER_NAME') . $url; |
|
63 | + $url = self::server('SERVER_NAME').$url; |
|
64 | 64 | |
65 | 65 | $root = api_get_path('WEB_PATH'); |
66 | 66 | $root = str_replace('https://', '', $root); |
67 | 67 | $root = str_replace('http://', '', $root); |
68 | - $index_url = $root . 'index.php'; |
|
68 | + $index_url = $root.'index.php'; |
|
69 | 69 | |
70 | 70 | return $url == $index_url || $url == $root; |
71 | 71 | } |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | $url = self::server('REQUEST_URI'); |
81 | 81 | $url = explode('?', $url); |
82 | 82 | $url = reset($url); |
83 | - $url = self::server('SERVER_NAME') . $url; |
|
83 | + $url = self::server('SERVER_NAME').$url; |
|
84 | 84 | |
85 | 85 | $root = api_get_path('WEB_PATH'); |
86 | 86 | $root = str_replace('https://', '', $root); |
87 | 87 | $root = str_replace('http://', '', $root); |
88 | - $index_url = $root . 'user_portal.php'; |
|
88 | + $index_url = $root.'user_portal.php'; |
|
89 | 89 | |
90 | 90 | return $url == $index_url || $url == $root; |
91 | 91 | } |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | $parameters[self::PARAM_ACTION] = $action; |
154 | 154 | } |
155 | 155 | $parameters = implode('&', $parameters); |
156 | - $parameters = $parameters ? '?' . $parameters : ''; |
|
157 | - return $self . $parameters; |
|
156 | + $parameters = $parameters ? '?'.$parameters : ''; |
|
157 | + return $self.$parameters; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | $details = implode(' - ', $details); |
242 | 242 | $title = $course['title']; |
243 | 243 | |
244 | - $href = api_get_path(WEB_COURSE_PATH).$course['code'] .'/index.php'; |
|
245 | - echo '<tr><td><b><a href="' . $href . '">' . "$title</a></b><br/>$details</td><td>"; |
|
244 | + $href = api_get_path(WEB_COURSE_PATH).$course['code'].'/index.php'; |
|
245 | + echo '<tr><td><b><a href="'.$href.'">'."$title</a></b><br/>$details</td><td>"; |
|
246 | 246 | if (!api_is_anonymous()) { |
247 | 247 | if ($course['registration_code']) { |
248 | 248 | Display::display_icon( |
@@ -336,13 +336,13 @@ discard block |
||
336 | 336 | |
337 | 337 | if (api_is_anonymous()) |
338 | 338 | { |
339 | - $course_fiter = 'visibility = ' . COURSE_VISIBILITY_OPEN_WORLD; |
|
339 | + $course_fiter = 'visibility = '.COURSE_VISIBILITY_OPEN_WORLD; |
|
340 | 340 | } |
341 | 341 | else |
342 | 342 | { |
343 | - $course_fiter = 'visibility = ' . COURSE_VISIBILITY_OPEN_WORLD . ' OR '; |
|
344 | - $course_fiter .= 'visibility = ' . COURSE_VISIBILITY_OPEN_PLATFORM . ' OR '; |
|
345 | - $course_fiter .= '(visibility = ' . COURSE_VISIBILITY_REGISTERED . ' AND subscribe = 1)'; |
|
343 | + $course_fiter = 'visibility = '.COURSE_VISIBILITY_OPEN_WORLD.' OR '; |
|
344 | + $course_fiter .= 'visibility = '.COURSE_VISIBILITY_OPEN_PLATFORM.' OR '; |
|
345 | + $course_fiter .= '(visibility = '.COURSE_VISIBILITY_REGISTERED.' AND subscribe = 1)'; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | $sql = <<<EOT |
@@ -123,8 +123,7 @@ discard block |
||
123 | 123 | if ($has_content) |
124 | 124 | { |
125 | 125 | echo '<div class="list">'; |
126 | - } |
|
127 | - else |
|
126 | + } else |
|
128 | 127 | { |
129 | 128 | echo '<div>'; |
130 | 129 | } |
@@ -132,8 +131,7 @@ discard block |
||
132 | 131 | if (RegisterCourseWidget::factory()->run()) |
133 | 132 | { |
134 | 133 | $result = true; |
135 | - } |
|
136 | - else |
|
134 | + } else |
|
137 | 135 | { |
138 | 136 | $result = $this->action_display(); |
139 | 137 | } |
@@ -337,8 +335,7 @@ discard block |
||
337 | 335 | if (api_is_anonymous()) |
338 | 336 | { |
339 | 337 | $course_fiter = 'visibility = ' . COURSE_VISIBILITY_OPEN_WORLD; |
340 | - } |
|
341 | - else |
|
338 | + } else |
|
342 | 339 | { |
343 | 340 | $course_fiter = 'visibility = ' . COURSE_VISIBILITY_OPEN_WORLD . ' OR '; |
344 | 341 | $course_fiter .= 'visibility = ' . COURSE_VISIBILITY_OPEN_PLATFORM . ' OR '; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param $category_id |
58 | 58 | * @param $course_id |
59 | 59 | * @param $project_id |
60 | - * @param $other_area |
|
60 | + * @param integer $other_area |
|
61 | 61 | * @param $email |
62 | 62 | * @param $subject |
63 | 63 | * @param $content |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Assign ticket to admin |
243 | - * @param $ticket_id |
|
244 | - * @param $user_id |
|
243 | + * @param string $ticket_id |
|
244 | + * @param integer $user_id |
|
245 | 245 | */ |
246 | 246 | public static function assign_ticket_user($ticket_id, $user_id) |
247 | 247 | { |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Insert message between Users and Admins |
297 | - * @param $ticket_id |
|
298 | - * @param $subject |
|
299 | - * @param $content |
|
297 | + * @param string $ticket_id |
|
298 | + * @param string $subject |
|
299 | + * @param string $content |
|
300 | 300 | * @param $file_attachments |
301 | 301 | * @param $user_id |
302 | 302 | * @param string $status |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * Attachment files when a message is sent |
404 | 404 | * @param $file_attach |
405 | - * @param $ticket_id |
|
406 | - * @param $message_id |
|
407 | - * @param $message_attch_id |
|
405 | + * @param integer $ticket_id |
|
406 | + * @param integer $message_id |
|
407 | + * @param integer $message_attch_id |
|
408 | 408 | * @return array |
409 | 409 | */ |
410 | 410 | public static function save_message_attachment_file( |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public static function get_all_tickets_status() |
43 | 43 | { |
44 | 44 | $table_support_status = Database::get_main_table(TABLE_TICKET_STATUS); |
45 | - $sql = "SELECT * FROM " . $table_support_status; |
|
45 | + $sql = "SELECT * FROM ".$table_support_status; |
|
46 | 46 | $result = Database::query($sql); |
47 | 47 | $types = array(); |
48 | 48 | while ($row = Database::fetch_assoc($result)) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | if ($ticket_id != 0) { |
160 | - $ticket_code = "A" . str_pad( |
|
160 | + $ticket_code = "A".str_pad( |
|
161 | 161 | (int) $ticket_id, 11, "0", STR_PAD_LEFT |
162 | 162 | ); |
163 | 163 | $sql_update_code = "UPDATE $table_support_tickets |
@@ -175,24 +175,24 @@ discard block |
||
175 | 175 | $user = api_get_user_info($request_user); |
176 | 176 | $helpDeskMessage = '<table> |
177 | 177 | <tr> |
178 | - <td width="100px"><b>' . get_lang('User') . '</b></td> |
|
179 | - <td width="400px">' . $user['firstname']. ' ' . $user['lastname'] . '</td> |
|
178 | + <td width="100px"><b>' . get_lang('User').'</b></td> |
|
179 | + <td width="400px">' . $user['firstname'].' '.$user['lastname'].'</td> |
|
180 | 180 | </tr> |
181 | 181 | <tr> |
182 | - <td width="100px"><b>' . get_lang('Username') . '</b></td> |
|
183 | - <td width="400px">' . $user['username'] . '</td> |
|
182 | + <td width="100px"><b>' . get_lang('Username').'</b></td> |
|
183 | + <td width="400px">' . $user['username'].'</td> |
|
184 | 184 | </tr> |
185 | 185 | <tr> |
186 | - <td width="100px"><b>' . get_lang('Date') . '</b></td> |
|
187 | - <td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . '</td> |
|
186 | + <td width="100px"><b>' . get_lang('Date').'</b></td> |
|
187 | + <td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG).'</td> |
|
188 | 188 | </tr> |
189 | 189 | <tr> |
190 | - <td width="100px"><b>' . get_lang('Topic') . '</b></td> |
|
191 | - <td width="400px">' . $subject . '</td> |
|
190 | + <td width="100px"><b>' . get_lang('Topic').'</b></td> |
|
191 | + <td width="400px">' . $subject.'</td> |
|
192 | 192 | </tr> |
193 | 193 | <tr> |
194 | - <td width="100px"><b>' . get_lang('Description') . '</b></td> |
|
195 | - <td width="400px">' . $content . '</td> |
|
194 | + <td width="100px"><b>' . get_lang('Description').'</b></td> |
|
195 | + <td width="400px">' . $content.'</td> |
|
196 | 196 | </tr> |
197 | 197 | </table>'; |
198 | 198 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | if ($insert_id != $user_id) { |
275 | 275 | $info = api_get_user_info($user_id); |
276 | 276 | $sender = api_get_user_info($insert_id); |
277 | - $href = api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/ticket_details.php?ticket_id=' . $ticket_id; |
|
277 | + $href = api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/src/ticket_details.php?ticket_id='.$ticket_id; |
|
278 | 278 | $message = sprintf($plugin->get_lang('TicketAssignedMsg'), $info['complete_name'], $href, $ticket_id); |
279 | 279 | $mailTitle = sprintf($plugin->get_lang('TicketAssignX'), $ticket_id); |
280 | 280 | api_mail_html( |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); |
320 | 320 | $table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS); |
321 | 321 | if ($sendConfirmation) { |
322 | - $form = '<form action="ticket_details.php?ticket_id=' . $ticket_id . '" id="confirmticket" method="POST" > |
|
323 | - <p>' . $plugin->get_lang('TicketWasThisAnswerSatisfying') . '</p> |
|
324 | - <button name="response" id="responseyes" value="1">' . get_lang('Yes') . '</button> |
|
325 | - <button name="response" id="responseno" value="0">' . get_lang('No') . '</button> |
|
322 | + $form = '<form action="ticket_details.php?ticket_id='.$ticket_id.'" id="confirmticket" method="POST" > |
|
323 | + <p>' . $plugin->get_lang('TicketWasThisAnswerSatisfying').'</p> |
|
324 | + <button name="response" id="responseyes" value="1">' . get_lang('Yes').'</button> |
|
325 | + <button name="response" id="responseno" value="0">' . get_lang('No').'</button> |
|
326 | 326 | </form>'; |
327 | 327 | $content .= $form; |
328 | 328 | Database::query( |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | '$message_id', |
354 | 354 | '$subject', |
355 | 355 | '$content', |
356 | - '" . Database::escape_string($_SERVER['REMOTE_ADDR']) . "', |
|
356 | + '".Database::escape_string($_SERVER['REMOTE_ADDR'])."', |
|
357 | 357 | '$user_id', |
358 | - '" . $now . "', |
|
358 | + '".$now."', |
|
359 | 359 | '$user_id', |
360 | - '" . $now . "', |
|
360 | + '".$now."', |
|
361 | 361 | '$status' |
362 | 362 | )"; |
363 | 363 | Database::query($sql_insert_message); |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | } else { |
429 | 429 | $new_file_name = uniqid(''); |
430 | 430 | $path_attachment = api_get_path(SYS_ARCHIVE_PATH); |
431 | - $path_message_attach = $path_attachment . 'plugin_ticket_messageattch/'; |
|
431 | + $path_message_attach = $path_attachment.'plugin_ticket_messageattch/'; |
|
432 | 432 | if (!file_exists($path_message_attach)) { |
433 | 433 | @mkdir($path_message_attach, api_get_permissions_for_new_directories(), true); |
434 | 434 | } |
435 | - $new_path = $path_message_attach . $new_file_name; |
|
435 | + $new_path = $path_message_attach.$new_file_name; |
|
436 | 436 | if (is_uploaded_file($file_attach['tmp_name'])) { |
437 | 437 | @copy($file_attach['tmp_name'], $new_path); |
438 | 438 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | '$ticket_id', |
456 | 456 | '$message_id', |
457 | 457 | '$message_attch_id', |
458 | - '" . $file_attach['size'] . "', |
|
458 | + '".$file_attach['size']."', |
|
459 | 459 | '$user_id', |
460 | 460 | '$now', |
461 | 461 | '$user_id', |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | Database::query($sql); |
465 | 465 | |
466 | 466 | return array( |
467 | - 'path' => $path_message_attach . $safe_new_file_name, |
|
467 | + 'path' => $path_message_attach.$safe_new_file_name, |
|
468 | 468 | 'filename' => $safe_file_name |
469 | 469 | ); |
470 | 470 | } |
@@ -689,14 +689,14 @@ discard block |
||
689 | 689 | $result_unread = Database::query($sql_unread); |
690 | 690 | $unread = Database::fetch_object($result_unread)->unread; |
691 | 691 | $userInfo = api_get_user_info($row['user_id']); |
692 | - $hrefUser = $webPath . 'main/admin/user_information.php?user_id=' . $row['user_id']; |
|
692 | + $hrefUser = $webPath.'main/admin/user_information.php?user_id='.$row['user_id']; |
|
693 | 693 | $name = "<a href='$hrefUser'> {$userInfo['username']} </a>"; |
694 | 694 | $actions = ""; |
695 | 695 | |
696 | 696 | if ($row['responsible'] != 0) { |
697 | 697 | $row['responsible'] = api_get_user_info($row['responsible']); |
698 | 698 | if (!empty($row['responsible'])) { |
699 | - $hrefResp = $webPath . 'main/admin/user_information.php?user_id=' . $row['responsible']['user_id']; |
|
699 | + $hrefResp = $webPath.'main/admin/user_information.php?user_id='.$row['responsible']['user_id']; |
|
700 | 700 | $row['responsible'] = "<a href='$hrefResp'> {$row['responsible']['username']} </a>"; |
701 | 701 | } else { |
702 | 702 | $row['responsible'] = get_lang('UnknownUser'); |
@@ -704,9 +704,9 @@ discard block |
||
704 | 704 | |
705 | 705 | } else { |
706 | 706 | if ($row['status_id'] != 'REE') { |
707 | - $row['responsible'] = '<span style="color:#ff0000;">' . $plugin->get_lang('ToBeAssigned') . '</span>'; |
|
707 | + $row['responsible'] = '<span style="color:#ff0000;">'.$plugin->get_lang('ToBeAssigned').'</span>'; |
|
708 | 708 | } else { |
709 | - $row['responsible'] = '<span style="color:#00ff00;">' . get_lang('MessageResent') . '</span>'; |
|
709 | + $row['responsible'] = '<span style="color:#00ff00;">'.get_lang('MessageResent').'</span>'; |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
@@ -727,17 +727,17 @@ discard block |
||
727 | 727 | $row['col1'] = api_get_local_time($row['col1']); |
728 | 728 | $row['col2'] = api_get_local_time($row['col2']); |
729 | 729 | if ($isAdmin) { |
730 | - $actions .= '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . Display::return_icon( |
|
730 | + $actions .= '<a href="ticket_details.php?ticket_id='.$row['col0'].'">'.Display::return_icon( |
|
731 | 731 | 'synthese_view.gif', get_lang('Info') |
732 | - ) . '</a> '; |
|
732 | + ).'</a> '; |
|
733 | 733 | if ($row['priority_id'] == 'HGH' && $row['status_id'] != 'CLS') { |
734 | - $actions .= '<img src="' . $webCodePath . 'img/exclamation.png" border="0" />'; |
|
734 | + $actions .= '<img src="'.$webCodePath.'img/exclamation.png" border="0" />'; |
|
735 | 735 | } |
736 | 736 | $row['col0'] = Display::return_icon( |
737 | 737 | $img_source, get_lang('Info') |
738 | - ) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['ticket_code'] . '</a>'; |
|
738 | + ).'<a href="ticket_details.php?ticket_id='.$row['col0'].'">'.$row['ticket_code'].'</a>'; |
|
739 | 739 | if ($row['col7'] == 'PENDIENTE') { |
740 | - $row['col7'] = '<span style="color: #f00; font-weight:bold;">' . $row['col7'] . '</span>'; |
|
740 | + $row['col7'] = '<span style="color: #f00; font-weight:bold;">'.$row['col7'].'</span>'; |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | $ticket = array( |
@@ -754,22 +754,22 @@ discard block |
||
754 | 754 | ); |
755 | 755 | } else { |
756 | 756 | $actions = ""; |
757 | - $actions .= '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . Display::return_icon( |
|
757 | + $actions .= '<a href="ticket_details.php?ticket_id='.$row['col0'].'">'.Display::return_icon( |
|
758 | 758 | 'synthese_view.gif', get_lang('Info') |
759 | - ) . '</a> '; |
|
759 | + ).'</a> '; |
|
760 | 760 | $row['col0'] = Display::return_icon( |
761 | 761 | $img_source, get_lang('Info') |
762 | - ) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['ticket_code'] . '</a>'; |
|
762 | + ).'<a href="ticket_details.php?ticket_id='.$row['col0'].'">'.$row['ticket_code'].'</a>'; |
|
763 | 763 | $now = api_strtotime(api_get_utc_datetime()); |
764 | 764 | $last_edit_date = api_strtotime($row['sys_lastedit_datetime']); |
765 | 765 | $dif = $now - $last_edit_date; |
766 | 766 | |
767 | 767 | if ($dif > 172800 && $row['priority_id'] == 'NRM' && $row['status_id'] != 'CLS') { |
768 | - $actions .= '<a href="myticket.php?ticket_id=' . $row['ticket_id'] . '&action=alert"> |
|
769 | - <img src="' . Display::returnIconPath('exclamation.png') . '" border="0" /></a>'; |
|
768 | + $actions .= '<a href="myticket.php?ticket_id='.$row['ticket_id'].'&action=alert"> |
|
769 | + <img src="' . Display::returnIconPath('exclamation.png').'" border="0" /></a>'; |
|
770 | 770 | } |
771 | 771 | if ($row['priority_id'] == 'HGH') { |
772 | - $actions .= '<img src="' . Display::returnIconPath('admin_star.png') . '" border="0" />'; |
|
772 | + $actions .= '<img src="'.Display::returnIconPath('admin_star.png').'" border="0" />'; |
|
773 | 773 | } |
774 | 774 | $ticket = array( |
775 | 775 | $row['col0'], |
@@ -781,14 +781,14 @@ discard block |
||
781 | 781 | ); |
782 | 782 | } |
783 | 783 | if ($unread > 0) { |
784 | - $ticket['0'] = $ticket['0'] . ' (' . $unread . ')<a href="ticket_details.php?ticket_id=' . $row['ticket_id'] . '"> |
|
785 | - <img src="' . Display::returnIconPath('message_new.png') . '" border="0" title="' . $unread . ' ' . get_lang('Messages') . '"/> |
|
784 | + $ticket['0'] = $ticket['0'].' ('.$unread.')<a href="ticket_details.php?ticket_id='.$row['ticket_id'].'"> |
|
785 | + <img src="' . Display::returnIconPath('message_new.png').'" border="0" title="'.$unread.' '.get_lang('Messages').'"/> |
|
786 | 786 | </a>'; |
787 | 787 | } |
788 | 788 | if ($isAdmin) { |
789 | - $ticket['0'] .= ' <a href="javascript:void(0)" onclick="load_history_ticket(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')"> |
|
790 | - <img onclick="load_course_list(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')" onmouseover="clear_course_list (\'div_' . $row['ticket_id'] . '\')" src="' . Display::returnIconPath('history.gif') . '" title="' . get_lang('Historial') . '" alt="' . get_lang('Historial') . '"/> |
|
791 | - <div class="blackboard_hide" id="div_' . $row['ticket_id'] . '"> </div> |
|
789 | + $ticket['0'] .= ' <a href="javascript:void(0)" onclick="load_history_ticket(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')"> |
|
790 | + <img onclick="load_course_list(\'div_' . $row['ticket_id'].'\','.$row['ticket_id'].')" onmouseover="clear_course_list (\'div_'.$row['ticket_id'].'\')" src="'.Display::returnIconPath('history.gif').'" title="'.get_lang('Historial').'" alt="'.get_lang('Historial').'"/> |
|
791 | + <div class="blackboard_hide" id="div_' . $row['ticket_id'].'"> </div> |
|
792 | 792 | </a> '; |
793 | 793 | } |
794 | 794 | $tickets[] = $ticket; |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | $userInfo = api_get_user_info($row['request_user']); |
1029 | - $row['user_url'] = '<a href="' . api_get_path(WEB_PATH) . 'main/admin/user_information.php?user_id=' . $row['request_user'] . '"> |
|
1030 | - ' . api_get_person_name($userInfo['firstname'], $userInfo['lastname']) . '</a>'; |
|
1029 | + $row['user_url'] = '<a href="'.api_get_path(WEB_PATH).'main/admin/user_information.php?user_id='.$row['request_user'].'"> |
|
1030 | + ' . api_get_person_name($userInfo['firstname'], $userInfo['lastname']).'</a>'; |
|
1031 | 1031 | $ticket['usuario'] = $userInfo; |
1032 | 1032 | $ticket['ticket'] = $row; |
1033 | 1033 | } |
@@ -1044,10 +1044,10 @@ discard block |
||
1044 | 1044 | while ($row = Database::fetch_assoc($result)) { |
1045 | 1045 | $message = $row; |
1046 | 1046 | $completeName = api_get_person_name($row['firstname'], $row['lastname']); |
1047 | - $href = $webPath . 'main/admin/user_information.php?user_id=' . $row['user_id']; |
|
1047 | + $href = $webPath.'main/admin/user_information.php?user_id='.$row['user_id']; |
|
1048 | 1048 | //Check if user is an admin |
1049 | 1049 | $sql_admin = "SELECT user_id FROM $admin_table |
1050 | - WHERE user_id = '" . intval($message['user_id']) . "' |
|
1050 | + WHERE user_id = '".intval($message['user_id'])."' |
|
1051 | 1051 | LIMIT 1"; |
1052 | 1052 | $result_admin = Database::query($sql_admin); |
1053 | 1053 | $message['admin'] = false; |
@@ -1059,12 +1059,12 @@ discard block |
||
1059 | 1059 | $sql = "SELECT * |
1060 | 1060 | FROM $table_support_message_attachments |
1061 | 1061 | WHERE |
1062 | - message_id = " . $row['message_id'] . " AND |
|
1062 | + message_id = ".$row['message_id']." AND |
|
1063 | 1063 | ticket_id= '$ticket_id' "; |
1064 | 1064 | $result_attach = Database::query($sql); |
1065 | 1065 | while ($row2 = Database::fetch_assoc($result_attach)) { |
1066 | - $archiveURL = $archiveURL = $webPath . "plugin/" . PLUGIN_NAME . '/src/download.php?ticket_id=' . $ticket_id . '&file='; |
|
1067 | - $row2['attachment_link'] = $attach_icon . ' <a href="' . $archiveURL . $row2['path'] . '&title=' . $row2['filename'] . '">' . $row2['filename'] . '</a> (' . $row2['size'] . ')'; |
|
1066 | + $archiveURL = $archiveURL = $webPath."plugin/".PLUGIN_NAME.'/src/download.php?ticket_id='.$ticket_id.'&file='; |
|
1067 | + $row2['attachment_link'] = $attach_icon.' <a href="'.$archiveURL.$row2['path'].'&title='.$row2['filename'].'">'.$row2['filename'].'</a> ('.$row2['size'].')'; |
|
1068 | 1068 | $message['atachments'][] = $row2; |
1069 | 1069 | } |
1070 | 1070 | $ticket['messages'][] = $message; |
@@ -1088,9 +1088,9 @@ discard block |
||
1088 | 1088 | ); |
1089 | 1089 | $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); |
1090 | 1090 | $now = api_get_utc_datetime(); |
1091 | - $sql = "UPDATE " . $table_support_messages . " |
|
1092 | - SET status = 'LEI', sys_lastedit_user_id ='" . api_get_user_id() . "', |
|
1093 | - sys_lastedit_datetime ='" . $now . "' |
|
1091 | + $sql = "UPDATE ".$table_support_messages." |
|
1092 | + SET status = 'LEI', sys_lastedit_user_id ='" . api_get_user_id()."', |
|
1093 | + sys_lastedit_datetime ='" . $now."' |
|
1094 | 1094 | WHERE ticket_id ='$ticket_id' "; |
1095 | 1095 | |
1096 | 1096 | if (api_is_platform_admin()) { |
@@ -1189,10 +1189,10 @@ discard block |
||
1189 | 1189 | $user_id = intval($user_id); |
1190 | 1190 | |
1191 | 1191 | $now = api_get_utc_datetime(); |
1192 | - $sql = "UPDATE " . $table_support_tickets . " SET |
|
1192 | + $sql = "UPDATE ".$table_support_tickets." SET |
|
1193 | 1193 | status_id = '$status_id', |
1194 | 1194 | sys_lastedit_user_id ='$user_id', |
1195 | - sys_lastedit_datetime ='" . $now . "' |
|
1195 | + sys_lastedit_datetime ='".$now."' |
|
1196 | 1196 | WHERE ticket_id ='$ticket_id'"; |
1197 | 1197 | $result = Database::query($sql); |
1198 | 1198 | |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | $sql = "UPDATE $table_support_tickets SET |
1278 | 1278 | status_id = 'CLS', |
1279 | 1279 | sys_lastedit_user_id ='$user_id', |
1280 | - sys_lastedit_datetime ='" . $now . "', |
|
1280 | + sys_lastedit_datetime ='".$now."', |
|
1281 | 1281 | end_date ='$now' |
1282 | 1282 | WHERE ticket_id ='$ticket_id'"; |
1283 | 1283 | Database::query($sql); |
@@ -1334,8 +1334,8 @@ discard block |
||
1334 | 1334 | $row['assigned_date'] = api_convert_and_format_date( |
1335 | 1335 | api_get_local_time($row['assigned_date']), '%d/%m/%y-%H:%M:%S', _api_get_timezone() |
1336 | 1336 | ); |
1337 | - $row['assignuser'] = ($row['user_id'] != 0) ? ('<a href="' . $webpath . 'main/admin/user_information.php?user_id=' . $row['user_id'] . '" target="_blank">' . $assignuser['username'] . '</a>') : get_lang('Unassign'); |
|
1338 | - $row['insertuser'] = '<a href="' . $webpath . 'main/admin/user_information.php?user_id=' . $row['sys_insert_user_id'] . '" target="_blank">' . $insertuser['username'] . '</a>'; |
|
1337 | + $row['assignuser'] = ($row['user_id'] != 0) ? ('<a href="'.$webpath.'main/admin/user_information.php?user_id='.$row['user_id'].'" target="_blank">'.$assignuser['username'].'</a>') : get_lang('Unassign'); |
|
1338 | + $row['insertuser'] = '<a href="'.$webpath.'main/admin/user_information.php?user_id='.$row['sys_insert_user_id'].'" target="_blank">'.$insertuser['username'].'</a>'; |
|
1339 | 1339 | $history[] = $row; |
1340 | 1340 | } |
1341 | 1341 | return $history; |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | while ($row = Database::fetch_assoc($result)) { |
1532 | 1532 | if ($row['responsable'] != 0) { |
1533 | 1533 | $row['responsable'] = api_get_user_info($row['responsable']); |
1534 | - $row['responsable'] = $row['responsable']['firstname'] . ' ' . $row['responsable']['lastname']; |
|
1534 | + $row['responsable'] = $row['responsable']['firstname'].' '.$row['responsable']['lastname']; |
|
1535 | 1535 | } |
1536 | 1536 | $row['sys_insert_datetime'] = api_format_date( |
1537 | 1537 | $row['sys_insert_datetime'], '%d/%m/%y - %I:%M:%S %p' |
@@ -12,7 +12,7 @@ |
||
12 | 12 | /** |
13 | 13 | * Set the result |
14 | 14 | * @staticvar null $result |
15 | - * @return type |
|
15 | + * @return TicketPlugin |
|
16 | 16 | */ |
17 | 17 | static function create() |
18 | 18 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function install() |
36 | 36 | { |
37 | 37 | // Create database tables and insert a Tab |
38 | - require_once api_get_path(SYS_PLUGIN_PATH) . PLUGIN_NAME . '/database.php'; |
|
38 | + require_once api_get_path(SYS_PLUGIN_PATH).PLUGIN_NAME.'/database.php'; |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $rsTab = $this->deleteTab($plugSetting['comment']); |
85 | 85 | |
86 | 86 | if ($rsTab) { |
87 | - echo "<script>location.href = '" . $_SERVER['REQUEST_URI'] . "';</script>"; |
|
87 | + echo "<script>location.href = '".$_SERVER['REQUEST_URI']."';</script>"; |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @param $courseInfo |
76 | - * @param $weeksCount |
|
76 | + * @param string $weeksCount |
|
77 | 77 | * @param $page |
78 | 78 | * @return array |
79 | 79 | */ |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | /** |
184 | 184 | * @param $datos |
185 | - * @param $pagina |
|
185 | + * @param integer $pagina |
|
186 | 186 | * @return string |
187 | 187 | */ |
188 | 188 | function showStudentResult($datos, $pagina) |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | |
202 | 202 | /** |
203 | 203 | * @param $data |
204 | - * @param $numero_semanas |
|
205 | - * @return array |
|
204 | + * @param integer $numero_semanas |
|
205 | + * @return string[] |
|
206 | 206 | */ |
207 | 207 | function showStudentResultExport($data, $numero_semanas) |
208 | 208 | { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $table_post = Database::get_course_table(TABLE_FORUM_POST); |
22 | 22 | $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION); |
23 | 23 | $course_code = Database::escape_string($course_code); |
24 | - $res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '" . $course_code . "'"); |
|
24 | + $res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '".$course_code."'"); |
|
25 | 25 | $sqlWeeks = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'"; |
26 | 26 | $resWeeks = Database::query($sqlWeeks); |
27 | 27 | $weeks = Database::fetch_object($resWeeks); |
@@ -105,52 +105,52 @@ discard block |
||
105 | 105 | $lineHeaderExport = array(null, null); |
106 | 106 | $lineHeaderExport2 = array(null, ull); |
107 | 107 | while ($rowe = Database::fetch_assoc($resultHeader)) { |
108 | - $lineHeaderExport[] = utf8_decode('Work' . $rowe['week_id']); |
|
109 | - $lineHeaderExport[] = utf8_decode('Forum' . $rowe['week_id']); |
|
108 | + $lineHeaderExport[] = utf8_decode('Work'.$rowe['week_id']); |
|
109 | + $lineHeaderExport[] = utf8_decode('Forum'.$rowe['week_id']); |
|
110 | 110 | //$fila_export_encabezado[] = utf8_decode('Eval'.$rowe['week_id']); |
111 | 111 | //$fila_export_encabezado[] = utf8_decode('PC'.$rowe['week_id']); |
112 | 112 | $lineHeaderExport2[] = utf8_decode($rowe['work_title']); |
113 | 113 | $lineHeaderExport2[] = utf8_decode($rowe['thread_title']); |
114 | 114 | //$fila_export_encabezado2[] = utf8_decode($rowe['eval_title']); |
115 | 115 | //$fila_export_encabezado2[] = utf8_decode($rowe['pc_title']); |
116 | - $fila_export = array('Work' . $rowe['week_id'], 'Forum' . $rowe['week_id'], 'Eval' . $rowe['week_id'], 'PC' . $rowe['week_id']); |
|
116 | + $fila_export = array('Work'.$rowe['week_id'], 'Forum'.$rowe['week_id'], 'Eval'.$rowe['week_id'], 'PC'.$rowe['week_id']); |
|
117 | 117 | if ($rowe['week_id'] > (($page - 1) * 7) && $rowe['week_id'] <= (7 * $page)) { |
118 | 118 | $ids[$rowe['week_id']] = $rowe['id']; |
119 | - $line.='<th> |
|
120 | - <a href="#" onClick="showContent(' . "'tarea" . $rowe['week_id'] . "'" . ');">Work' . $rowe['week_id'] . ' |
|
121 | - <div class="blackboard_hide" id="tarea' . $rowe['week_id'] . '">' . $rowe['work_title'] . '</div> |
|
119 | + $line .= '<th> |
|
120 | + <a href="#" onClick="showContent(' . "'tarea".$rowe['week_id']."'".');">Work'.$rowe['week_id'].' |
|
121 | + <div class="blackboard_hide" id="tarea' . $rowe['week_id'].'">'.$rowe['work_title'].'</div> |
|
122 | 122 | </a></th>'; |
123 | - $line.= '<th> |
|
124 | - <a href="#" onClick="showContent(' . "'foro" . $rowe['week_id'] . "'" . ');">Forum' . $rowe['week_id'] . ' |
|
125 | - <div class="blackboard_hide" id="foro' . $rowe['week_id'] . '">' . $rowe['thread_title'] . '</div> |
|
123 | + $line .= '<th> |
|
124 | + <a href="#" onClick="showContent(' . "'foro".$rowe['week_id']."'".');">Forum'.$rowe['week_id'].' |
|
125 | + <div class="blackboard_hide" id="foro' . $rowe['week_id'].'">'.$rowe['thread_title'].'</div> |
|
126 | 126 | </a> |
127 | 127 | </th>'; |
128 | 128 | } |
129 | 129 | } |
130 | 130 | $tableExport[] = $lineHeaderExport; |
131 | 131 | $tableExport[] = $lineHeaderExport2; |
132 | - $line.= '</tr>'; |
|
132 | + $line .= '</tr>'; |
|
133 | 133 | |
134 | 134 | $html = '<form action="tutor.php" name="semanas" id="semanas" method="POST"> |
135 | 135 | <div class="row"> |
136 | - ' . get_lang('SelectWeeksSpan') . ' |
|
136 | + ' . get_lang('SelectWeeksSpan').' |
|
137 | 137 | <select name="weeksNumber" id="weeksNumber" onChange="submit();"> |
138 | - <option value="7" ' . (($weeksCount == 7) ? 'selected="selected"' : "") . '>7 weeks</option> |
|
139 | - <option value="14" ' . (($weeksCount == 14) ? 'selected="selected"' : "") . '>14 weeks</option> |
|
138 | + <option value="7" ' . (($weeksCount == 7) ? 'selected="selected"' : "").'>7 weeks</option> |
|
139 | + <option value="14" ' . (($weeksCount == 14) ? 'selected="selected"' : "").'>14 weeks</option> |
|
140 | 140 | </select>'; |
141 | 141 | |
142 | 142 | |
143 | 143 | if ($weeksCount == 14) { |
144 | - $html .= '<span style="float:right;"><a href="tutor.php?page=' . (($page == 1) ? 2 : 1) . '">' . (($page == 1) ? "Siguiente" : "Anterior") . '</a></span>'; |
|
144 | + $html .= '<span style="float:right;"><a href="tutor.php?page='.(($page == 1) ? 2 : 1).'">'.(($page == 1) ? "Siguiente" : "Anterior").'</a></span>'; |
|
145 | 145 | } |
146 | - $html .= '<span style="float:right;"><a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '</a></span>'; |
|
146 | + $html .= '<span style="float:right;"><a href="'.api_get_self().'?action=export'.$get_parameter.$get_parameter2.'">'.Display::return_icon('export_excel.png', get_lang('Export'), '', '32').'</a></span>'; |
|
147 | 147 | |
148 | 148 | $html .= '</form>'; |
149 | 149 | $html .= '<table class="reports">'; |
150 | 150 | $html .= '<tr> |
151 | 151 | <th ></th>'; |
152 | 152 | for ($i = (7 * $page - 6); $i <= $page * 7; $i++) { |
153 | - $html .= '<th colspan="2">Week ' . $i . '<a href="assign_tickets.php?id=' . $ids[$i] . '" class="ajax">' . Display::return_icon('edit.png', get_lang('Edit'), array('width' => '16', 'height' => '16'), 22) . '</a></th>'; |
|
153 | + $html .= '<th colspan="2">Week '.$i.'<a href="assign_tickets.php?id='.$ids[$i].'" class="ajax">'.Display::return_icon('edit.png', get_lang('Edit'), array('width' => '16', 'height' => '16'), 22).'</a></th>'; |
|
154 | 154 | } |
155 | 155 | $html .= '</tr>'; |
156 | 156 | $html .= $line; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if ($row['week_id'] > (($page - 1) * 7) && $row['week_id'] <= (7 * $page)) { |
168 | 168 | $results[$row['username']][$row['week_id']] = $row; |
169 | 169 | if (count($results[$row['username']]) == 7) { |
170 | - $html.= showStudentResult($results[$row['username']], $page); |
|
170 | + $html .= showStudentResult($results[$row['username']], $page); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | if (count($resultadose[$row['username']]) == $weeksCount) { |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | $inicio = (7 * $pagina - 6); |
191 | 191 | $fila = '<tr>'; |
192 | 192 | |
193 | - $fila.= '<td><a href="' . api_get_path(WEB_CODE_PATH) . 'user/userInfo.php?' . api_get_cidreq() . '&uInfo=' . $datos[$inicio]['user_id'] . '">' . $datos[$inicio]['username'] . '</a></td>'; |
|
193 | + $fila .= '<td><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&uInfo='.$datos[$inicio]['user_id'].'">'.$datos[$inicio]['username'].'</a></td>'; |
|
194 | 194 | foreach ($datos as $dato) { |
195 | - $fila.= '<td align="center">' . (($dato['work_ok'] == 1) ? Display::return_icon('check.png') : Display::return_icon('aspa.png')) . '</td>'; |
|
196 | - $fila.= '<td align="center">' . (($dato['thread_ok'] == 1) ? Display::return_icon('check.png') : Display::return_icon('aspa.png')) . '</td>'; |
|
195 | + $fila .= '<td align="center">'.(($dato['work_ok'] == 1) ? Display::return_icon('check.png') : Display::return_icon('aspa.png')).'</td>'; |
|
196 | + $fila .= '<td align="center">'.(($dato['thread_ok'] == 1) ? Display::return_icon('check.png') : Display::return_icon('aspa.png')).'</td>'; |
|
197 | 197 | } |
198 | - $fila.= '</tr>'; |
|
198 | + $fila .= '</tr>'; |
|
199 | 199 | return $fila; |
200 | 200 | } |
201 | 201 |
@@ -94,7 +94,7 @@ |
||
94 | 94 | /** |
95 | 95 | * @param array $templates |
96 | 96 | * |
97 | - * @return null |
|
97 | + * @return null|string |
|
98 | 98 | */ |
99 | 99 | public function formatTemplates($templates) |
100 | 100 | { |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | return [[ |
146 | 146 | 'title' => get_lang('EmptyTemplate'), |
147 | 147 | 'description' => null, |
148 | - 'image' => api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/empty.gif', |
|
148 | + 'image' => api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/empty.gif', |
|
149 | 149 | 'html' => ' |
150 | 150 | <!DOCYTPE html> |
151 | 151 | <html> |
152 | 152 | <head> |
153 | - <meta charset="' . api_get_system_encoding() . '" /> |
|
153 | + <meta charset="' . api_get_system_encoding().'" /> |
|
154 | 154 | </head> |
155 | - <body dir="' . api_get_text_direction() . '"> |
|
155 | + <body dir="' . api_get_text_direction().'"> |
|
156 | 156 | <p> |
157 | 157 | <br/> |
158 | 158 | </p> |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $search = array('{CSS}', '{IMG_DIR}', '{REL_PATH}', '{COURSE_DIR}'); |
176 | 176 | $replace = array( |
177 | 177 | '', |
178 | - api_get_path(REL_CODE_PATH) . 'img/', |
|
178 | + api_get_path(REL_CODE_PATH).'img/', |
|
179 | 179 | api_get_path(REL_PATH), |
180 | 180 | api_get_path(REL_DEFAULT_COURSE_DOCUMENT_PATH), |
181 | 181 | api_get_path(REL_DEFAULT_COURSE_DOCUMENT_PATH) |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | foreach ($systemTemplates as $template) { |
187 | 187 | $image = $template->getImage(); |
188 | 188 | $image = !empty($image) ? $image : 'empty.gif'; |
189 | - $image = api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/' . $image; |
|
189 | + $image = api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/'.$image; |
|
190 | 190 | |
191 | 191 | /*$image = $this->urlGenerator->generate( |
192 | 192 | 'get_document_template_action', |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | $templateItem['image'] = api_get_path(WEB_APP_PATH) |
239 | 239 | . 'home/default_platform_document/template_thumb/noimage.gif'; |
240 | 240 | $templateItem['html'] = file_get_contents(api_get_path(SYS_COURSE_PATH) |
241 | - . $courseDirectory . '/document' . $templateData['path']); |
|
241 | + . $courseDirectory.'/document'.$templateData['path']); |
|
242 | 242 | |
243 | 243 | $image = $template->getImage(); |
244 | 244 | if (!empty($image)) { |
245 | 245 | $templateItem['image'] = api_get_path(WEB_COURSE_PATH) |
246 | - . $courseDirectory . '/upload/template_thumbnails/' . $template->getImage(); |
|
246 | + . $courseDirectory.'/upload/template_thumbnails/'.$template->getImage(); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | $templateList[] = $templateItem; |