@@ -52,224 +52,224 @@ discard block |
||
52 | 52 | * @access public |
53 | 53 | */ |
54 | 54 | class nusoap_client_mime extends nusoap_client { |
55 | - /** |
|
56 | - * @var array Each array element in the return is an associative array with keys |
|
57 | - * data, filename, contenttype, cid |
|
58 | - * @access private |
|
59 | - */ |
|
60 | - var $requestAttachments = array(); |
|
61 | - /** |
|
62 | - * @var array Each array element in the return is an associative array with keys |
|
63 | - * data, filename, contenttype, cid |
|
64 | - * @access private |
|
65 | - */ |
|
66 | - var $responseAttachments; |
|
67 | - /** |
|
68 | - * @var string |
|
69 | - * @access private |
|
70 | - */ |
|
71 | - var $mimeContentType; |
|
72 | - |
|
73 | - /** |
|
74 | - * adds a MIME attachment to the current request. |
|
75 | - * |
|
76 | - * If the $data parameter contains an empty string, this method will read |
|
77 | - * the contents of the file named by the $filename parameter. |
|
78 | - * |
|
79 | - * If the $cid parameter is false, this method will generate the cid. |
|
80 | - * |
|
81 | - * @param string $data The data of the attachment |
|
82 | - * @param string $filename The filename of the attachment (default is empty string) |
|
83 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
84 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
85 | - * @return string The content-id (cid) of the attachment |
|
86 | - * @access public |
|
87 | - */ |
|
88 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { |
|
89 | - if (! $cid) { |
|
90 | - $cid = md5(uniqid(time())); |
|
91 | - } |
|
92 | - |
|
93 | - $info['data'] = $data; |
|
94 | - $info['filename'] = $filename; |
|
95 | - $info['contenttype'] = $contenttype; |
|
96 | - $info['cid'] = $cid; |
|
97 | - |
|
98 | - $this->requestAttachments[] = $info; |
|
99 | - |
|
100 | - return $cid; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * clears the MIME attachments for the current request. |
|
105 | - * |
|
106 | - * @access public |
|
107 | - */ |
|
108 | - function clearAttachments() { |
|
109 | - $this->requestAttachments = array(); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * gets the MIME attachments from the current response. |
|
114 | - * |
|
115 | - * Each array element in the return is an associative array with keys |
|
116 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
117 | - * for addAttachment. |
|
118 | - * |
|
119 | - * @return array The attachments. |
|
120 | - * @access public |
|
121 | - */ |
|
122 | - function getAttachments() { |
|
123 | - return $this->responseAttachments; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * gets the HTTP body for the current request. |
|
128 | - * |
|
129 | - * @param string $soapmsg The SOAP payload |
|
130 | - * @return string The HTTP body, which includes the SOAP payload |
|
131 | - * @access private |
|
132 | - */ |
|
133 | - function getHTTPBody($soapmsg) { |
|
134 | - if (count($this->requestAttachments) > 0) { |
|
135 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
136 | - $mimeMessage = new Mail_mimePart('', $params); |
|
137 | - unset($params); |
|
138 | - |
|
139 | - $params['content_type'] = 'text/xml'; |
|
140 | - $params['encoding'] = '8bit'; |
|
141 | - $params['charset'] = $this->soap_defencoding; |
|
142 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
143 | - |
|
144 | - foreach ($this->requestAttachments as $att) { |
|
145 | - unset($params); |
|
146 | - |
|
147 | - $params['content_type'] = $att['contenttype']; |
|
148 | - $params['encoding'] = 'base64'; |
|
149 | - $params['disposition'] = 'attachment'; |
|
150 | - $params['dfilename'] = $att['filename']; |
|
151 | - $params['cid'] = $att['cid']; |
|
152 | - |
|
153 | - if ($att['data'] == '' && $att['filename'] <> '') { |
|
154 | - if ($fd = fopen($att['filename'], 'rb')) { |
|
155 | - $data = fread($fd, filesize($att['filename'])); |
|
156 | - fclose($fd); |
|
157 | - } else { |
|
158 | - $data = ''; |
|
159 | - } |
|
160 | - $mimeMessage->addSubpart($data, $params); |
|
161 | - } else { |
|
162 | - $mimeMessage->addSubpart($att['data'], $params); |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - $output = $mimeMessage->encode(); |
|
167 | - $mimeHeaders = $output['headers']; |
|
168 | - |
|
169 | - foreach ($mimeHeaders as $k => $v) { |
|
170 | - $this->debug("MIME header $k: $v"); |
|
171 | - if (strtolower($k) == 'content-type') { |
|
172 | - // PHP header() seems to strip leading whitespace starting |
|
173 | - // the second line, so force everything to one line |
|
174 | - $this->mimeContentType = str_replace("\r\n", " ", $v); |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - return $output['body']; |
|
179 | - } |
|
180 | - |
|
181 | - return parent::getHTTPBody($soapmsg); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * gets the HTTP content type for the current request. |
|
186 | - * |
|
187 | - * Note: getHTTPBody must be called before this. |
|
188 | - * |
|
189 | - * @return string the HTTP content type for the current request. |
|
190 | - * @access private |
|
191 | - */ |
|
192 | - function getHTTPContentType() { |
|
193 | - if (count($this->requestAttachments) > 0) { |
|
194 | - return $this->mimeContentType; |
|
195 | - } |
|
196 | - return parent::getHTTPContentType(); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * gets the HTTP content type charset for the current request. |
|
201 | - * returns false for non-text content types. |
|
202 | - * |
|
203 | - * Note: getHTTPBody must be called before this. |
|
204 | - * |
|
205 | - * @return string the HTTP content type charset for the current request. |
|
206 | - * @access private |
|
207 | - */ |
|
208 | - function getHTTPContentTypeCharset() { |
|
209 | - if (count($this->requestAttachments) > 0) { |
|
210 | - return false; |
|
211 | - } |
|
212 | - return parent::getHTTPContentTypeCharset(); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * processes SOAP message returned from server |
|
217 | - * |
|
218 | - * @param array $headers The HTTP headers |
|
219 | - * @param string $data unprocessed response data from server |
|
220 | - * @return mixed value of the message, decoded into a PHP type |
|
221 | - * @access private |
|
222 | - */ |
|
55 | + /** |
|
56 | + * @var array Each array element in the return is an associative array with keys |
|
57 | + * data, filename, contenttype, cid |
|
58 | + * @access private |
|
59 | + */ |
|
60 | + var $requestAttachments = array(); |
|
61 | + /** |
|
62 | + * @var array Each array element in the return is an associative array with keys |
|
63 | + * data, filename, contenttype, cid |
|
64 | + * @access private |
|
65 | + */ |
|
66 | + var $responseAttachments; |
|
67 | + /** |
|
68 | + * @var string |
|
69 | + * @access private |
|
70 | + */ |
|
71 | + var $mimeContentType; |
|
72 | + |
|
73 | + /** |
|
74 | + * adds a MIME attachment to the current request. |
|
75 | + * |
|
76 | + * If the $data parameter contains an empty string, this method will read |
|
77 | + * the contents of the file named by the $filename parameter. |
|
78 | + * |
|
79 | + * If the $cid parameter is false, this method will generate the cid. |
|
80 | + * |
|
81 | + * @param string $data The data of the attachment |
|
82 | + * @param string $filename The filename of the attachment (default is empty string) |
|
83 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
84 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
85 | + * @return string The content-id (cid) of the attachment |
|
86 | + * @access public |
|
87 | + */ |
|
88 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { |
|
89 | + if (! $cid) { |
|
90 | + $cid = md5(uniqid(time())); |
|
91 | + } |
|
92 | + |
|
93 | + $info['data'] = $data; |
|
94 | + $info['filename'] = $filename; |
|
95 | + $info['contenttype'] = $contenttype; |
|
96 | + $info['cid'] = $cid; |
|
97 | + |
|
98 | + $this->requestAttachments[] = $info; |
|
99 | + |
|
100 | + return $cid; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * clears the MIME attachments for the current request. |
|
105 | + * |
|
106 | + * @access public |
|
107 | + */ |
|
108 | + function clearAttachments() { |
|
109 | + $this->requestAttachments = array(); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * gets the MIME attachments from the current response. |
|
114 | + * |
|
115 | + * Each array element in the return is an associative array with keys |
|
116 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
117 | + * for addAttachment. |
|
118 | + * |
|
119 | + * @return array The attachments. |
|
120 | + * @access public |
|
121 | + */ |
|
122 | + function getAttachments() { |
|
123 | + return $this->responseAttachments; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * gets the HTTP body for the current request. |
|
128 | + * |
|
129 | + * @param string $soapmsg The SOAP payload |
|
130 | + * @return string The HTTP body, which includes the SOAP payload |
|
131 | + * @access private |
|
132 | + */ |
|
133 | + function getHTTPBody($soapmsg) { |
|
134 | + if (count($this->requestAttachments) > 0) { |
|
135 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
136 | + $mimeMessage = new Mail_mimePart('', $params); |
|
137 | + unset($params); |
|
138 | + |
|
139 | + $params['content_type'] = 'text/xml'; |
|
140 | + $params['encoding'] = '8bit'; |
|
141 | + $params['charset'] = $this->soap_defencoding; |
|
142 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
143 | + |
|
144 | + foreach ($this->requestAttachments as $att) { |
|
145 | + unset($params); |
|
146 | + |
|
147 | + $params['content_type'] = $att['contenttype']; |
|
148 | + $params['encoding'] = 'base64'; |
|
149 | + $params['disposition'] = 'attachment'; |
|
150 | + $params['dfilename'] = $att['filename']; |
|
151 | + $params['cid'] = $att['cid']; |
|
152 | + |
|
153 | + if ($att['data'] == '' && $att['filename'] <> '') { |
|
154 | + if ($fd = fopen($att['filename'], 'rb')) { |
|
155 | + $data = fread($fd, filesize($att['filename'])); |
|
156 | + fclose($fd); |
|
157 | + } else { |
|
158 | + $data = ''; |
|
159 | + } |
|
160 | + $mimeMessage->addSubpart($data, $params); |
|
161 | + } else { |
|
162 | + $mimeMessage->addSubpart($att['data'], $params); |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + $output = $mimeMessage->encode(); |
|
167 | + $mimeHeaders = $output['headers']; |
|
168 | + |
|
169 | + foreach ($mimeHeaders as $k => $v) { |
|
170 | + $this->debug("MIME header $k: $v"); |
|
171 | + if (strtolower($k) == 'content-type') { |
|
172 | + // PHP header() seems to strip leading whitespace starting |
|
173 | + // the second line, so force everything to one line |
|
174 | + $this->mimeContentType = str_replace("\r\n", " ", $v); |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + return $output['body']; |
|
179 | + } |
|
180 | + |
|
181 | + return parent::getHTTPBody($soapmsg); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * gets the HTTP content type for the current request. |
|
186 | + * |
|
187 | + * Note: getHTTPBody must be called before this. |
|
188 | + * |
|
189 | + * @return string the HTTP content type for the current request. |
|
190 | + * @access private |
|
191 | + */ |
|
192 | + function getHTTPContentType() { |
|
193 | + if (count($this->requestAttachments) > 0) { |
|
194 | + return $this->mimeContentType; |
|
195 | + } |
|
196 | + return parent::getHTTPContentType(); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * gets the HTTP content type charset for the current request. |
|
201 | + * returns false for non-text content types. |
|
202 | + * |
|
203 | + * Note: getHTTPBody must be called before this. |
|
204 | + * |
|
205 | + * @return string the HTTP content type charset for the current request. |
|
206 | + * @access private |
|
207 | + */ |
|
208 | + function getHTTPContentTypeCharset() { |
|
209 | + if (count($this->requestAttachments) > 0) { |
|
210 | + return false; |
|
211 | + } |
|
212 | + return parent::getHTTPContentTypeCharset(); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * processes SOAP message returned from server |
|
217 | + * |
|
218 | + * @param array $headers The HTTP headers |
|
219 | + * @param string $data unprocessed response data from server |
|
220 | + * @return mixed value of the message, decoded into a PHP type |
|
221 | + * @access private |
|
222 | + */ |
|
223 | 223 | function parseResponse($headers, $data) { |
224 | - $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); |
|
225 | - $this->responseAttachments = array(); |
|
226 | - if (strstr($headers['content-type'], 'multipart/related')) { |
|
227 | - $this->debug('Decode multipart/related'); |
|
228 | - $input = ''; |
|
229 | - foreach ($headers as $k => $v) { |
|
230 | - $input .= "$k: $v\r\n"; |
|
231 | - } |
|
232 | - $params['input'] = $input . "\r\n" . $data; |
|
233 | - $params['include_bodies'] = true; |
|
234 | - $params['decode_bodies'] = true; |
|
235 | - $params['decode_headers'] = true; |
|
236 | - |
|
237 | - $structure = Mail_mimeDecode::decode($params); |
|
238 | - |
|
239 | - foreach ($structure->parts as $part) { |
|
240 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) { |
|
241 | - $this->debug('Have root part of type ' . $part->headers['content-type']); |
|
242 | - $root = $part->body; |
|
243 | - $return = parent::parseResponse($part->headers, $part->body); |
|
244 | - } else { |
|
245 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']); |
|
246 | - $info['data'] = $part->body; |
|
247 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
248 | - $info['contenttype'] = $part->headers['content-type']; |
|
249 | - $info['cid'] = $part->headers['content-id']; |
|
250 | - $this->responseAttachments[] = $info; |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - if (isset($return)) { |
|
255 | - $this->responseData = $root; |
|
256 | - return $return; |
|
257 | - } |
|
258 | - |
|
259 | - $this->setError('No root part found in multipart/related content'); |
|
260 | - return ''; |
|
261 | - } |
|
262 | - $this->debug('Not multipart/related'); |
|
263 | - return parent::parseResponse($headers, $data); |
|
264 | - } |
|
224 | + $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); |
|
225 | + $this->responseAttachments = array(); |
|
226 | + if (strstr($headers['content-type'], 'multipart/related')) { |
|
227 | + $this->debug('Decode multipart/related'); |
|
228 | + $input = ''; |
|
229 | + foreach ($headers as $k => $v) { |
|
230 | + $input .= "$k: $v\r\n"; |
|
231 | + } |
|
232 | + $params['input'] = $input . "\r\n" . $data; |
|
233 | + $params['include_bodies'] = true; |
|
234 | + $params['decode_bodies'] = true; |
|
235 | + $params['decode_headers'] = true; |
|
236 | + |
|
237 | + $structure = Mail_mimeDecode::decode($params); |
|
238 | + |
|
239 | + foreach ($structure->parts as $part) { |
|
240 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) { |
|
241 | + $this->debug('Have root part of type ' . $part->headers['content-type']); |
|
242 | + $root = $part->body; |
|
243 | + $return = parent::parseResponse($part->headers, $part->body); |
|
244 | + } else { |
|
245 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']); |
|
246 | + $info['data'] = $part->body; |
|
247 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
248 | + $info['contenttype'] = $part->headers['content-type']; |
|
249 | + $info['cid'] = $part->headers['content-id']; |
|
250 | + $this->responseAttachments[] = $info; |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + if (isset($return)) { |
|
255 | + $this->responseData = $root; |
|
256 | + return $return; |
|
257 | + } |
|
258 | + |
|
259 | + $this->setError('No root part found in multipart/related content'); |
|
260 | + return ''; |
|
261 | + } |
|
262 | + $this->debug('Not multipart/related'); |
|
263 | + return parent::parseResponse($headers, $data); |
|
264 | + } |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /* |
268 | 268 | * For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded. |
269 | 269 | */ |
270 | 270 | if (!extension_loaded('soap')) { |
271 | - class soapclientmime extends nusoap_client_mime { |
|
272 | - } |
|
271 | + class soapclientmime extends nusoap_client_mime { |
|
272 | + } |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -282,214 +282,214 @@ discard block |
||
282 | 282 | * @access public |
283 | 283 | */ |
284 | 284 | class nusoap_server_mime extends nusoap_server { |
285 | - /** |
|
286 | - * @var array Each array element in the return is an associative array with keys |
|
287 | - * data, filename, contenttype, cid |
|
288 | - * @access private |
|
289 | - */ |
|
290 | - var $requestAttachments = array(); |
|
291 | - /** |
|
292 | - * @var array Each array element in the return is an associative array with keys |
|
293 | - * data, filename, contenttype, cid |
|
294 | - * @access private |
|
295 | - */ |
|
296 | - var $responseAttachments; |
|
297 | - /** |
|
298 | - * @var string |
|
299 | - * @access private |
|
300 | - */ |
|
301 | - var $mimeContentType; |
|
302 | - |
|
303 | - /** |
|
304 | - * adds a MIME attachment to the current response. |
|
305 | - * |
|
306 | - * If the $data parameter contains an empty string, this method will read |
|
307 | - * the contents of the file named by the $filename parameter. |
|
308 | - * |
|
309 | - * If the $cid parameter is false, this method will generate the cid. |
|
310 | - * |
|
311 | - * @param string $data The data of the attachment |
|
312 | - * @param string $filename The filename of the attachment (default is empty string) |
|
313 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
314 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
315 | - * @return string The content-id (cid) of the attachment |
|
316 | - * @access public |
|
317 | - */ |
|
318 | - function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { |
|
319 | - if (! $cid) { |
|
320 | - $cid = md5(uniqid(time())); |
|
321 | - } |
|
322 | - |
|
323 | - $info['data'] = $data; |
|
324 | - $info['filename'] = $filename; |
|
325 | - $info['contenttype'] = $contenttype; |
|
326 | - $info['cid'] = $cid; |
|
327 | - |
|
328 | - $this->responseAttachments[] = $info; |
|
329 | - |
|
330 | - return $cid; |
|
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * clears the MIME attachments for the current response. |
|
335 | - * |
|
336 | - * @access public |
|
337 | - */ |
|
338 | - function clearAttachments() { |
|
339 | - $this->responseAttachments = array(); |
|
340 | - } |
|
341 | - |
|
342 | - /** |
|
343 | - * gets the MIME attachments from the current request. |
|
344 | - * |
|
345 | - * Each array element in the return is an associative array with keys |
|
346 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
347 | - * for addAttachment. |
|
348 | - * |
|
349 | - * @return array The attachments. |
|
350 | - * @access public |
|
351 | - */ |
|
352 | - function getAttachments() { |
|
353 | - return $this->requestAttachments; |
|
354 | - } |
|
355 | - |
|
356 | - /** |
|
357 | - * gets the HTTP body for the current response. |
|
358 | - * |
|
359 | - * @param string $soapmsg The SOAP payload |
|
360 | - * @return string The HTTP body, which includes the SOAP payload |
|
361 | - * @access private |
|
362 | - */ |
|
363 | - function getHTTPBody($soapmsg) { |
|
364 | - if (count($this->responseAttachments) > 0) { |
|
365 | - $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
366 | - $mimeMessage = new Mail_mimePart('', $params); |
|
367 | - unset($params); |
|
368 | - |
|
369 | - $params['content_type'] = 'text/xml'; |
|
370 | - $params['encoding'] = '8bit'; |
|
371 | - $params['charset'] = $this->soap_defencoding; |
|
372 | - $mimeMessage->addSubpart($soapmsg, $params); |
|
373 | - |
|
374 | - foreach ($this->responseAttachments as $att) { |
|
375 | - unset($params); |
|
376 | - |
|
377 | - $params['content_type'] = $att['contenttype']; |
|
378 | - $params['encoding'] = 'base64'; |
|
379 | - $params['disposition'] = 'attachment'; |
|
380 | - $params['dfilename'] = $att['filename']; |
|
381 | - $params['cid'] = $att['cid']; |
|
382 | - |
|
383 | - if ($att['data'] == '' && $att['filename'] <> '') { |
|
384 | - if ($fd = fopen($att['filename'], 'rb')) { |
|
385 | - $data = fread($fd, filesize($att['filename'])); |
|
386 | - fclose($fd); |
|
387 | - } else { |
|
388 | - $data = ''; |
|
389 | - } |
|
390 | - $mimeMessage->addSubpart($data, $params); |
|
391 | - } else { |
|
392 | - $mimeMessage->addSubpart($att['data'], $params); |
|
393 | - } |
|
394 | - } |
|
395 | - |
|
396 | - $output = $mimeMessage->encode(); |
|
397 | - $mimeHeaders = $output['headers']; |
|
398 | - |
|
399 | - foreach ($mimeHeaders as $k => $v) { |
|
400 | - $this->debug("MIME header $k: $v"); |
|
401 | - if (strtolower($k) == 'content-type') { |
|
402 | - // PHP header() seems to strip leading whitespace starting |
|
403 | - // the second line, so force everything to one line |
|
404 | - $this->mimeContentType = str_replace("\r\n", " ", $v); |
|
405 | - } |
|
406 | - } |
|
407 | - |
|
408 | - return $output['body']; |
|
409 | - } |
|
410 | - |
|
411 | - return parent::getHTTPBody($soapmsg); |
|
412 | - } |
|
413 | - |
|
414 | - /** |
|
415 | - * gets the HTTP content type for the current response. |
|
416 | - * |
|
417 | - * Note: getHTTPBody must be called before this. |
|
418 | - * |
|
419 | - * @return string the HTTP content type for the current response. |
|
420 | - * @access private |
|
421 | - */ |
|
422 | - function getHTTPContentType() { |
|
423 | - if (count($this->responseAttachments) > 0) { |
|
424 | - return $this->mimeContentType; |
|
425 | - } |
|
426 | - return parent::getHTTPContentType(); |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * gets the HTTP content type charset for the current response. |
|
431 | - * returns false for non-text content types. |
|
432 | - * |
|
433 | - * Note: getHTTPBody must be called before this. |
|
434 | - * |
|
435 | - * @return string the HTTP content type charset for the current response. |
|
436 | - * @access private |
|
437 | - */ |
|
438 | - function getHTTPContentTypeCharset() { |
|
439 | - if (count($this->responseAttachments) > 0) { |
|
440 | - return false; |
|
441 | - } |
|
442 | - return parent::getHTTPContentTypeCharset(); |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * processes SOAP message received from client |
|
447 | - * |
|
448 | - * @param array $headers The HTTP headers |
|
449 | - * @param string $data unprocessed request data from client |
|
450 | - * @return mixed value of the message, decoded into a PHP type |
|
451 | - * @access private |
|
452 | - */ |
|
285 | + /** |
|
286 | + * @var array Each array element in the return is an associative array with keys |
|
287 | + * data, filename, contenttype, cid |
|
288 | + * @access private |
|
289 | + */ |
|
290 | + var $requestAttachments = array(); |
|
291 | + /** |
|
292 | + * @var array Each array element in the return is an associative array with keys |
|
293 | + * data, filename, contenttype, cid |
|
294 | + * @access private |
|
295 | + */ |
|
296 | + var $responseAttachments; |
|
297 | + /** |
|
298 | + * @var string |
|
299 | + * @access private |
|
300 | + */ |
|
301 | + var $mimeContentType; |
|
302 | + |
|
303 | + /** |
|
304 | + * adds a MIME attachment to the current response. |
|
305 | + * |
|
306 | + * If the $data parameter contains an empty string, this method will read |
|
307 | + * the contents of the file named by the $filename parameter. |
|
308 | + * |
|
309 | + * If the $cid parameter is false, this method will generate the cid. |
|
310 | + * |
|
311 | + * @param string $data The data of the attachment |
|
312 | + * @param string $filename The filename of the attachment (default is empty string) |
|
313 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
314 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
315 | + * @return string The content-id (cid) of the attachment |
|
316 | + * @access public |
|
317 | + */ |
|
318 | + function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { |
|
319 | + if (! $cid) { |
|
320 | + $cid = md5(uniqid(time())); |
|
321 | + } |
|
322 | + |
|
323 | + $info['data'] = $data; |
|
324 | + $info['filename'] = $filename; |
|
325 | + $info['contenttype'] = $contenttype; |
|
326 | + $info['cid'] = $cid; |
|
327 | + |
|
328 | + $this->responseAttachments[] = $info; |
|
329 | + |
|
330 | + return $cid; |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * clears the MIME attachments for the current response. |
|
335 | + * |
|
336 | + * @access public |
|
337 | + */ |
|
338 | + function clearAttachments() { |
|
339 | + $this->responseAttachments = array(); |
|
340 | + } |
|
341 | + |
|
342 | + /** |
|
343 | + * gets the MIME attachments from the current request. |
|
344 | + * |
|
345 | + * Each array element in the return is an associative array with keys |
|
346 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
347 | + * for addAttachment. |
|
348 | + * |
|
349 | + * @return array The attachments. |
|
350 | + * @access public |
|
351 | + */ |
|
352 | + function getAttachments() { |
|
353 | + return $this->requestAttachments; |
|
354 | + } |
|
355 | + |
|
356 | + /** |
|
357 | + * gets the HTTP body for the current response. |
|
358 | + * |
|
359 | + * @param string $soapmsg The SOAP payload |
|
360 | + * @return string The HTTP body, which includes the SOAP payload |
|
361 | + * @access private |
|
362 | + */ |
|
363 | + function getHTTPBody($soapmsg) { |
|
364 | + if (count($this->responseAttachments) > 0) { |
|
365 | + $params['content_type'] = 'multipart/related; type="text/xml"'; |
|
366 | + $mimeMessage = new Mail_mimePart('', $params); |
|
367 | + unset($params); |
|
368 | + |
|
369 | + $params['content_type'] = 'text/xml'; |
|
370 | + $params['encoding'] = '8bit'; |
|
371 | + $params['charset'] = $this->soap_defencoding; |
|
372 | + $mimeMessage->addSubpart($soapmsg, $params); |
|
373 | + |
|
374 | + foreach ($this->responseAttachments as $att) { |
|
375 | + unset($params); |
|
376 | + |
|
377 | + $params['content_type'] = $att['contenttype']; |
|
378 | + $params['encoding'] = 'base64'; |
|
379 | + $params['disposition'] = 'attachment'; |
|
380 | + $params['dfilename'] = $att['filename']; |
|
381 | + $params['cid'] = $att['cid']; |
|
382 | + |
|
383 | + if ($att['data'] == '' && $att['filename'] <> '') { |
|
384 | + if ($fd = fopen($att['filename'], 'rb')) { |
|
385 | + $data = fread($fd, filesize($att['filename'])); |
|
386 | + fclose($fd); |
|
387 | + } else { |
|
388 | + $data = ''; |
|
389 | + } |
|
390 | + $mimeMessage->addSubpart($data, $params); |
|
391 | + } else { |
|
392 | + $mimeMessage->addSubpart($att['data'], $params); |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + $output = $mimeMessage->encode(); |
|
397 | + $mimeHeaders = $output['headers']; |
|
398 | + |
|
399 | + foreach ($mimeHeaders as $k => $v) { |
|
400 | + $this->debug("MIME header $k: $v"); |
|
401 | + if (strtolower($k) == 'content-type') { |
|
402 | + // PHP header() seems to strip leading whitespace starting |
|
403 | + // the second line, so force everything to one line |
|
404 | + $this->mimeContentType = str_replace("\r\n", " ", $v); |
|
405 | + } |
|
406 | + } |
|
407 | + |
|
408 | + return $output['body']; |
|
409 | + } |
|
410 | + |
|
411 | + return parent::getHTTPBody($soapmsg); |
|
412 | + } |
|
413 | + |
|
414 | + /** |
|
415 | + * gets the HTTP content type for the current response. |
|
416 | + * |
|
417 | + * Note: getHTTPBody must be called before this. |
|
418 | + * |
|
419 | + * @return string the HTTP content type for the current response. |
|
420 | + * @access private |
|
421 | + */ |
|
422 | + function getHTTPContentType() { |
|
423 | + if (count($this->responseAttachments) > 0) { |
|
424 | + return $this->mimeContentType; |
|
425 | + } |
|
426 | + return parent::getHTTPContentType(); |
|
427 | + } |
|
428 | + |
|
429 | + /** |
|
430 | + * gets the HTTP content type charset for the current response. |
|
431 | + * returns false for non-text content types. |
|
432 | + * |
|
433 | + * Note: getHTTPBody must be called before this. |
|
434 | + * |
|
435 | + * @return string the HTTP content type charset for the current response. |
|
436 | + * @access private |
|
437 | + */ |
|
438 | + function getHTTPContentTypeCharset() { |
|
439 | + if (count($this->responseAttachments) > 0) { |
|
440 | + return false; |
|
441 | + } |
|
442 | + return parent::getHTTPContentTypeCharset(); |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * processes SOAP message received from client |
|
447 | + * |
|
448 | + * @param array $headers The HTTP headers |
|
449 | + * @param string $data unprocessed request data from client |
|
450 | + * @return mixed value of the message, decoded into a PHP type |
|
451 | + * @access private |
|
452 | + */ |
|
453 | 453 | function parseRequest($headers, $data) { |
454 | - $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); |
|
455 | - $this->requestAttachments = array(); |
|
456 | - if (strstr($headers['content-type'], 'multipart/related')) { |
|
457 | - $this->debug('Decode multipart/related'); |
|
458 | - $input = ''; |
|
459 | - foreach ($headers as $k => $v) { |
|
460 | - $input .= "$k: $v\r\n"; |
|
461 | - } |
|
462 | - $params['input'] = $input . "\r\n" . $data; |
|
463 | - $params['include_bodies'] = true; |
|
464 | - $params['decode_bodies'] = true; |
|
465 | - $params['decode_headers'] = true; |
|
466 | - |
|
467 | - $structure = Mail_mimeDecode::decode($params); |
|
468 | - |
|
469 | - foreach ($structure->parts as $part) { |
|
470 | - if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) { |
|
471 | - $this->debug('Have root part of type ' . $part->headers['content-type']); |
|
472 | - $return = parent::parseRequest($part->headers, $part->body); |
|
473 | - } else { |
|
474 | - $this->debug('Have an attachment of type ' . $part->headers['content-type']); |
|
475 | - $info['data'] = $part->body; |
|
476 | - $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
477 | - $info['contenttype'] = $part->headers['content-type']; |
|
478 | - $info['cid'] = $part->headers['content-id']; |
|
479 | - $this->requestAttachments[] = $info; |
|
480 | - } |
|
481 | - } |
|
482 | - |
|
483 | - if (isset($return)) { |
|
484 | - return $return; |
|
485 | - } |
|
486 | - |
|
487 | - $this->setError('No root part found in multipart/related content'); |
|
488 | - return; |
|
489 | - } |
|
490 | - $this->debug('Not multipart/related'); |
|
491 | - return parent::parseRequest($headers, $data); |
|
492 | - } |
|
454 | + $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); |
|
455 | + $this->requestAttachments = array(); |
|
456 | + if (strstr($headers['content-type'], 'multipart/related')) { |
|
457 | + $this->debug('Decode multipart/related'); |
|
458 | + $input = ''; |
|
459 | + foreach ($headers as $k => $v) { |
|
460 | + $input .= "$k: $v\r\n"; |
|
461 | + } |
|
462 | + $params['input'] = $input . "\r\n" . $data; |
|
463 | + $params['include_bodies'] = true; |
|
464 | + $params['decode_bodies'] = true; |
|
465 | + $params['decode_headers'] = true; |
|
466 | + |
|
467 | + $structure = Mail_mimeDecode::decode($params); |
|
468 | + |
|
469 | + foreach ($structure->parts as $part) { |
|
470 | + if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) { |
|
471 | + $this->debug('Have root part of type ' . $part->headers['content-type']); |
|
472 | + $return = parent::parseRequest($part->headers, $part->body); |
|
473 | + } else { |
|
474 | + $this->debug('Have an attachment of type ' . $part->headers['content-type']); |
|
475 | + $info['data'] = $part->body; |
|
476 | + $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : ''; |
|
477 | + $info['contenttype'] = $part->headers['content-type']; |
|
478 | + $info['cid'] = $part->headers['content-id']; |
|
479 | + $this->requestAttachments[] = $info; |
|
480 | + } |
|
481 | + } |
|
482 | + |
|
483 | + if (isset($return)) { |
|
484 | + return $return; |
|
485 | + } |
|
486 | + |
|
487 | + $this->setError('No root part found in multipart/related content'); |
|
488 | + return; |
|
489 | + } |
|
490 | + $this->debug('Not multipart/related'); |
|
491 | + return parent::parseRequest($headers, $data); |
|
492 | + } |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /* |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | if ($exercise_info->start_time != '0000-00-00 00:00:00') { |
283 | 283 | $allowed_time = api_strtotime($exercise_info->start_time, 'UTC'); |
284 | 284 | if ($now < $allowed_time) { |
285 | - continue; |
|
285 | + continue; |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | $exercise_info->exercise = Display::url( |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | window.location.href=ui.tab; |
513 | 513 | }); |
514 | 514 | <?php |
515 | - //Displays js code to use a jqgrid |
|
516 | - echo Display::grid_js('courses', '', $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list); |
|
517 | - echo Display::grid_js('list_default', $url, $columns, $column_model,$extra_params,array(), ''); |
|
518 | - echo Display::grid_js('list_course', $url_by_course, $columns, $column_model,$extra_params_course,array(),''); |
|
519 | - echo Display::grid_js('list_week', $url_week, $column_week, $column_week_model, $extra_params_week,array(),''); |
|
515 | + //Displays js code to use a jqgrid |
|
516 | + echo Display::grid_js('courses', '', $columns_courses, $column_model_courses, $extra_params_courses, $new_course_list); |
|
517 | + echo Display::grid_js('list_default', $url, $columns, $column_model,$extra_params,array(), ''); |
|
518 | + echo Display::grid_js('list_course', $url_by_course, $columns, $column_model,$extra_params_course,array(),''); |
|
519 | + echo Display::grid_js('list_week', $url_week, $column_week, $column_week_model, $extra_params_week,array(),''); |
|
520 | 520 | |
521 | 521 | if (!api_is_anonymous()) { |
522 | 522 | echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array); |
@@ -18,24 +18,24 @@ discard block |
||
18 | 18 | private $_nonce_chars; |
19 | 19 | |
20 | 20 | /** |
21 | - * Constructor |
|
21 | + * Constructor |
|
22 | 22 | * |
23 | - * @access public |
|
23 | + * @access public |
|
24 | 24 | * @param api_key (String) The API Key (sometimes referred to as the consumer key) This value is usually supplied by the site you wish to use. |
25 | 25 | * @param shared_secret (String) The shared secret. This value is also usually provided by the site you wish to use. |
26 | - * @return OAuthSimple (Object) |
|
26 | + * @return OAuthSimple (Object) |
|
27 | 27 | */ |
28 | 28 | function __construct ($APIKey = "", $sharedSecret=""){ |
29 | 29 | |
30 | 30 | if (!empty($APIKey)) |
31 | - { |
|
32 | - $this->_secrets['consumer_key'] = $APIKey; |
|
33 | - } |
|
31 | + { |
|
32 | + $this->_secrets['consumer_key'] = $APIKey; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | if (!empty($sharedSecret)) |
36 | - { |
|
37 | - $this->_secrets['shared_secret'] = $sharedSecret; |
|
38 | - } |
|
36 | + { |
|
37 | + $this->_secrets['shared_secret'] = $sharedSecret; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | $this->_default_signature_method = "HMAC-SHA1"; |
41 | 41 | $this->_action = "GET"; |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | - * Reset the parameters and URL |
|
49 | - * |
|
50 | - * @access public |
|
51 | - * @return OAuthSimple (Object) |
|
52 | - */ |
|
48 | + * Reset the parameters and URL |
|
49 | + * |
|
50 | + * @access public |
|
51 | + * @return OAuthSimple (Object) |
|
52 | + */ |
|
53 | 53 | public function reset() { |
54 | 54 | $this->_parameters = Array(); |
55 | 55 | $this->path = NULL; |
@@ -59,87 +59,87 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | - * Set the parameters either from a hash or a string |
|
63 | - * |
|
64 | - * @access public |
|
65 | - * @param(string, object) List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash) |
|
66 | - * @return OAuthSimple (Object) |
|
67 | - */ |
|
62 | + * Set the parameters either from a hash or a string |
|
63 | + * |
|
64 | + * @access public |
|
65 | + * @param(string, object) List of parameters for the call, this can either be a URI string (e.g. "foo=bar&gorp=banana" or an object/hash) |
|
66 | + * @return OAuthSimple (Object) |
|
67 | + */ |
|
68 | 68 | public function setParameters ($parameters=Array()) { |
69 | 69 | |
70 | 70 | if (is_string($parameters)) |
71 | - { |
|
72 | - $parameters = $this->_parseParameterString($parameters); |
|
73 | - } |
|
71 | + { |
|
72 | + $parameters = $this->_parseParameterString($parameters); |
|
73 | + } |
|
74 | 74 | if (empty($this->_parameters)) |
75 | - { |
|
76 | - $this->_parameters = $parameters; |
|
77 | - } |
|
75 | + { |
|
76 | + $this->_parameters = $parameters; |
|
77 | + } |
|
78 | 78 | else if (!empty($parameters)) |
79 | - { |
|
80 | - $this->_parameters = array_merge($this->_parameters,$parameters); |
|
81 | - } |
|
79 | + { |
|
80 | + $this->_parameters = array_merge($this->_parameters,$parameters); |
|
81 | + } |
|
82 | 82 | if (empty($this->_parameters['oauth_nonce'])) |
83 | - { |
|
84 | - $this->_getNonce(); |
|
85 | - } |
|
83 | + { |
|
84 | + $this->_getNonce(); |
|
85 | + } |
|
86 | 86 | if (empty($this->_parameters['oauth_timestamp'])) |
87 | - { |
|
88 | - $this->_getTimeStamp(); |
|
89 | - } |
|
87 | + { |
|
88 | + $this->_getTimeStamp(); |
|
89 | + } |
|
90 | 90 | if (empty($this->_parameters['oauth_consumer_key'])) |
91 | - { |
|
92 | - $this->_getApiKey(); |
|
93 | - } |
|
91 | + { |
|
92 | + $this->_getApiKey(); |
|
93 | + } |
|
94 | 94 | if (empty($this->_parameters['oauth_token'])) |
95 | - { |
|
96 | - $this->_getAccessToken(); |
|
97 | - } |
|
95 | + { |
|
96 | + $this->_getAccessToken(); |
|
97 | + } |
|
98 | 98 | if (empty($this->_parameters['oauth_signature_method'])) |
99 | - { |
|
99 | + { |
|
100 | 100 | $this->setSignatureMethod(); |
101 | - } |
|
101 | + } |
|
102 | 102 | if (empty($this->_parameters['oauth_version'])) |
103 | - { |
|
103 | + { |
|
104 | 104 | $this->_parameters['oauth_version']="1.0"; |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | return $this; |
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
111 | - * Convenience method for setParameters |
|
112 | - * |
|
113 | - * @access public |
|
114 | - * @see setParameters |
|
115 | - */ |
|
111 | + * Convenience method for setParameters |
|
112 | + * |
|
113 | + * @access public |
|
114 | + * @see setParameters |
|
115 | + */ |
|
116 | 116 | public function setQueryString ($parameters) |
117 | 117 | { |
118 | 118 | return $this->setParameters($parameters); |
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | - * Set the target URL (does not include the parameters) |
|
123 | - * |
|
122 | + * Set the target URL (does not include the parameters) |
|
123 | + * |
|
124 | 124 | * @param path (String) the fully qualified URI (excluding query arguments) (e.g "http://example.org/foo") |
125 | - * @return OAuthSimple (Object) |
|
125 | + * @return OAuthSimple (Object) |
|
126 | 126 | */ |
127 | 127 | public function setURL ($path) |
128 | - { |
|
128 | + { |
|
129 | 129 | if (empty($path)) |
130 | - { |
|
130 | + { |
|
131 | 131 | throw new OAuthSimpleException('No path specified for OAuthSimple.setURL'); |
132 | - } |
|
132 | + } |
|
133 | 133 | $this->_path=$path; |
134 | 134 | |
135 | 135 | return $this; |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * Convenience method for setURL |
|
139 | + * Convenience method for setURL |
|
140 | 140 | * |
141 | 141 | * @param path (String) |
142 | - * @see setURL |
|
142 | + * @see setURL |
|
143 | 143 | */ |
144 | 144 | public function setPath ($path) |
145 | 145 | { |
@@ -147,39 +147,39 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | - * Set the "action" for the url, (e.g. GET,POST, DELETE, etc.) |
|
150 | + * Set the "action" for the url, (e.g. GET,POST, DELETE, etc.) |
|
151 | 151 | * |
152 | 152 | * @param action (String) HTTP Action word. |
153 | - * @return OAuthSimple (Object) |
|
153 | + * @return OAuthSimple (Object) |
|
154 | 154 | */ |
155 | 155 | public function setAction ($action) |
156 | 156 | { |
157 | 157 | if (empty($action)) |
158 | - { |
|
159 | - $action = 'GET'; |
|
160 | - } |
|
158 | + { |
|
159 | + $action = 'GET'; |
|
160 | + } |
|
161 | 161 | $action = strtoupper($action); |
162 | 162 | if (preg_match('/[^A-Z]/',$action)) |
163 | - { |
|
163 | + { |
|
164 | 164 | throw new OAuthSimpleException('Invalid action specified for OAuthSimple.setAction'); |
165 | - } |
|
165 | + } |
|
166 | 166 | $this->_action = $action; |
167 | 167 | |
168 | 168 | return $this; |
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | - * Set the signatures (as well as validate the ones you have) |
|
172 | + * Set the signatures (as well as validate the ones you have) |
|
173 | 173 | * |
174 | 174 | * @param signatures (object) object/hash of the token/signature pairs {api_key:, shared_secret:, oauth_token: oauth_secret:} |
175 | - * @return OAuthSimple (Object) |
|
175 | + * @return OAuthSimple (Object) |
|
176 | 176 | */ |
177 | 177 | public function signatures ($signatures) |
178 | 178 | { |
179 | 179 | if (!empty($signatures) && !is_array($signatures)) |
180 | - { |
|
180 | + { |
|
181 | 181 | throw new OAuthSimpleException('Must pass dictionary array to OAuthSimple.signatures'); |
182 | - } |
|
182 | + } |
|
183 | 183 | if (!empty($signatures)) |
184 | 184 | { |
185 | 185 | if (empty($this->_secrets)) |
@@ -189,33 +189,33 @@ discard block |
||
189 | 189 | $this->_secrets=array_merge($this->_secrets,$signatures); |
190 | 190 | } |
191 | 191 | if (isset($this->_secrets['api_key'])) |
192 | - { |
|
192 | + { |
|
193 | 193 | $this->_secrets['consumer_key'] = $this->_secrets['api_key']; |
194 | - } |
|
194 | + } |
|
195 | 195 | if (isset($this->_secrets['access_token'])) |
196 | - { |
|
196 | + { |
|
197 | 197 | $this->_secrets['oauth_token'] = $this->_secrets['access_token']; |
198 | - } |
|
198 | + } |
|
199 | 199 | if (isset($this->_secrets['access_secret'])) |
200 | - { |
|
200 | + { |
|
201 | 201 | $this->_secrets['shared_secret'] = $this->_secrets['access_secret']; |
202 | 202 | } |
203 | 203 | if (isset($this->_secrets['oauth_token_secret'])) |
204 | - { |
|
204 | + { |
|
205 | 205 | $this->_secrets['oauth_secret'] = $this->_secrets['oauth_token_secret']; |
206 | - } |
|
206 | + } |
|
207 | 207 | if (empty($this->_secrets['consumer_key'])) |
208 | - { |
|
208 | + { |
|
209 | 209 | throw new OAuthSimpleException('Missing required consumer_key in OAuthSimple.signatures'); |
210 | 210 | } |
211 | 211 | if (empty($this->_secrets['shared_secret'])) |
212 | - { |
|
212 | + { |
|
213 | 213 | throw new OAuthSimpleException('Missing requires shared_secret in OAuthSimple.signatures'); |
214 | - } |
|
214 | + } |
|
215 | 215 | if (!empty($this->_secrets['oauth_token']) && empty($this->_secrets['oauth_secret'])) |
216 | - { |
|
216 | + { |
|
217 | 217 | throw new OAuthSimpleException('Missing oauth_secret for supplied oauth_token in OAuthSimple.signatures'); |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | 220 | return $this; |
221 | 221 | } |
@@ -226,30 +226,30 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | - * Set the signature method (currently only Plaintext or SHA-MAC1) |
|
229 | + * Set the signature method (currently only Plaintext or SHA-MAC1) |
|
230 | 230 | * |
231 | 231 | * @param method (String) Method of signing the transaction (only PLAINTEXT and SHA-MAC1 allowed for now) |
232 | - * @return OAuthSimple (Object) |
|
233 | - */ |
|
232 | + * @return OAuthSimple (Object) |
|
233 | + */ |
|
234 | 234 | public function setSignatureMethod ($method="") |
235 | - { |
|
235 | + { |
|
236 | 236 | if (empty($method)) |
237 | - { |
|
237 | + { |
|
238 | 238 | $method = $this->_default_signature_method; |
239 | - } |
|
239 | + } |
|
240 | 240 | $method = strtoupper($method); |
241 | 241 | switch($method) |
242 | 242 | { |
243 | 243 | case 'PLAINTEXT': |
244 | 244 | case 'HMAC-SHA1': |
245 | 245 | $this->_parameters['oauth_signature_method']=$method; |
246 | - break; |
|
246 | + break; |
|
247 | 247 | default: |
248 | 248 | throw new OAuthSimpleException ("Unknown signing method $method specified for OAuthSimple.setSignatureMethod"); |
249 | - break; |
|
249 | + break; |
|
250 | 250 | } |
251 | 251 | |
252 | - return $this; |
|
252 | + return $this; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** sign the request |
@@ -258,30 +258,30 @@ discard block |
||
258 | 258 | * other helper functions. |
259 | 259 | * |
260 | 260 | * @param args (Array) hash of arguments for the call {action, path, parameters (array), method, signatures (array)} all arguments are optional. |
261 | - * @return (Array) signed values |
|
261 | + * @return (Array) signed values |
|
262 | 262 | */ |
263 | 263 | public function sign($args=array()) |
264 | 264 | { |
265 | 265 | if (!empty($args['action'])) |
266 | - { |
|
266 | + { |
|
267 | 267 | $this->setAction($args['action']); |
268 | - } |
|
268 | + } |
|
269 | 269 | if (!empty($args['path'])) |
270 | - { |
|
270 | + { |
|
271 | 271 | $this->setPath($args['path']); |
272 | 272 | } |
273 | 273 | if (!empty($args['method'])) |
274 | - { |
|
274 | + { |
|
275 | 275 | $this->setSignatureMethod($args['method']); |
276 | - } |
|
276 | + } |
|
277 | 277 | if (!empty($args['signatures'])) |
278 | - { |
|
278 | + { |
|
279 | 279 | $this->signatures($args['signatures']); |
280 | - } |
|
280 | + } |
|
281 | 281 | if (empty($args['parameters'])) |
282 | - { |
|
282 | + { |
|
283 | 283 | $args['parameters']=array(); |
284 | - } |
|
284 | + } |
|
285 | 285 | $this->setParameters($args['parameters']); |
286 | 286 | $normParams = $this->_normalizedParameters(); |
287 | 287 | |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | - * Return a formatted "header" string |
|
298 | + * Return a formatted "header" string |
|
299 | 299 | * |
300 | 300 | * NOTE: This doesn't set the "Authorization: " prefix, which is required. |
301 | 301 | * It's not set because various set header functions prefer different |
302 | 302 | * ways to do that. |
303 | 303 | * |
304 | 304 | * @param args (Array) |
305 | - * @return $result (String) |
|
306 | - */ |
|
305 | + * @return $result (String) |
|
306 | + */ |
|
307 | 307 | public function getHeaderString ($args=array()) |
308 | 308 | { |
309 | 309 | if (empty($this->_parameters['oauth_signature'])) |
310 | - { |
|
310 | + { |
|
311 | 311 | $this->sign($args); |
312 | - } |
|
312 | + } |
|
313 | 313 | $result = 'OAuth '; |
314 | 314 | |
315 | 315 | foreach ($this->_parameters as $pName => $pValue) |
316 | 316 | { |
317 | 317 | if (strpos($pName,'oauth_') !== 0) |
318 | - { |
|
318 | + { |
|
319 | 319 | continue; |
320 | - } |
|
320 | + } |
|
321 | 321 | if (is_array($pValue)) |
322 | 322 | { |
323 | 323 | foreach ($pValue as $val) |
@@ -342,19 +342,19 @@ discard block |
||
342 | 342 | { |
343 | 343 | list ($key,$token) = explode('=',$element); |
344 | 344 | if ($token) |
345 | - { |
|
345 | + { |
|
346 | 346 | $token = urldecode($token); |
347 | - } |
|
347 | + } |
|
348 | 348 | if (!empty($result[$key])) |
349 | 349 | { |
350 | 350 | if (!is_array($result[$key])) |
351 | - { |
|
351 | + { |
|
352 | 352 | $result[$key] = array($result[$key],$token); |
353 | - } |
|
353 | + } |
|
354 | 354 | else |
355 | - { |
|
355 | + { |
|
356 | 356 | array_push($result[$key],$token); |
357 | - } |
|
357 | + } |
|
358 | 358 | } |
359 | 359 | else |
360 | 360 | $result[$key]=$token; |
@@ -366,14 +366,14 @@ discard block |
||
366 | 366 | private static function _oauthEscape($string) |
367 | 367 | { |
368 | 368 | if ($string === 0) { return 0; } |
369 | - if ($string == '0') { return '0'; } |
|
369 | + if ($string == '0') { return '0'; } |
|
370 | 370 | if (strlen($string) == 0) { return ''; } |
371 | 371 | if (is_array($string)) { |
372 | 372 | throw new OAuthSimpleException('Array passed to _oauthEscape'); |
373 | - } |
|
373 | + } |
|
374 | 374 | $string = urlencode($string); |
375 | 375 | |
376 | - //FIX: urlencode of ~ and '+' |
|
376 | + //FIX: urlencode of ~ and '+' |
|
377 | 377 | $string = str_replace( |
378 | 378 | Array('%7E','+' ), // Replace these |
379 | 379 | Array('~', '%20'), // with these |
@@ -410,13 +410,13 @@ discard block |
||
410 | 410 | private function _getAccessToken() |
411 | 411 | { |
412 | 412 | if (!isset($this->_secrets['oauth_secret'])) |
413 | - { |
|
413 | + { |
|
414 | 414 | return ''; |
415 | - } |
|
415 | + } |
|
416 | 416 | if (!isset($this->_secrets['oauth_token'])) |
417 | - { |
|
417 | + { |
|
418 | 418 | throw new OAuthSimpleException('No access token (oauth_token) set for OAuthSimple.'); |
419 | - } |
|
419 | + } |
|
420 | 420 | $this->_parameters['oauth_token'] = $this->_secrets['oauth_token']; |
421 | 421 | |
422 | 422 | return $this->_parameters['oauth_token']; |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | |
430 | 430 | private function _normalizedParameters() |
431 | 431 | { |
432 | - $normalized_keys = array(); |
|
433 | - $return_array = array(); |
|
432 | + $normalized_keys = array(); |
|
433 | + $return_array = array(); |
|
434 | 434 | |
435 | 435 | foreach ( $this->_parameters as $paramName=>$paramValue) { |
436 | 436 | if (preg_match('/w+_secret/', $paramName) OR |
@@ -439,59 +439,59 @@ discard block |
||
439 | 439 | } |
440 | 440 | // Read parameters from a file. Hope you're practicing safe PHP. |
441 | 441 | //if (strpos($paramValue, '@') !== 0 && !file_exists(substr($paramValue, 1))) |
442 | - //{ |
|
443 | - if (is_array($paramValue)) |
|
444 | - { |
|
445 | - $normalized_keys[self::_oauthEscape($paramName)] = array(); |
|
446 | - foreach($paramValue as $item) |
|
447 | - { |
|
448 | - array_push($normalized_keys[self::_oauthEscape($paramName)], self::_oauthEscape($item)); |
|
449 | - } |
|
450 | - } |
|
451 | - else |
|
452 | - { |
|
453 | - $normalized_keys[self::_oauthEscape($paramName)] = self::_oauthEscape($paramValue); |
|
454 | - } |
|
455 | - //} |
|
456 | - } |
|
457 | - |
|
458 | - ksort($normalized_keys); |
|
459 | - |
|
460 | - foreach($normalized_keys as $key=>$val) |
|
461 | - { |
|
462 | - if (is_array($val)) |
|
463 | - { |
|
464 | - sort($val); |
|
465 | - foreach($val as $element) |
|
466 | - { |
|
467 | - array_push($return_array, $key . "=" . $element); |
|
468 | - } |
|
469 | - } |
|
470 | - else |
|
471 | - { |
|
472 | - array_push($return_array, $key .'='. $val); |
|
473 | - } |
|
442 | + //{ |
|
443 | + if (is_array($paramValue)) |
|
444 | + { |
|
445 | + $normalized_keys[self::_oauthEscape($paramName)] = array(); |
|
446 | + foreach($paramValue as $item) |
|
447 | + { |
|
448 | + array_push($normalized_keys[self::_oauthEscape($paramName)], self::_oauthEscape($item)); |
|
449 | + } |
|
450 | + } |
|
451 | + else |
|
452 | + { |
|
453 | + $normalized_keys[self::_oauthEscape($paramName)] = self::_oauthEscape($paramValue); |
|
454 | + } |
|
455 | + //} |
|
456 | + } |
|
457 | + |
|
458 | + ksort($normalized_keys); |
|
459 | + |
|
460 | + foreach($normalized_keys as $key=>$val) |
|
461 | + { |
|
462 | + if (is_array($val)) |
|
463 | + { |
|
464 | + sort($val); |
|
465 | + foreach($val as $element) |
|
466 | + { |
|
467 | + array_push($return_array, $key . "=" . $element); |
|
468 | + } |
|
469 | + } |
|
470 | + else |
|
471 | + { |
|
472 | + array_push($return_array, $key .'='. $val); |
|
473 | + } |
|
474 | 474 | |
475 | 475 | } |
476 | 476 | $presig = join("&", $return_array); |
477 | 477 | $sig = $this->_generateSignature($presig); |
478 | 478 | $this->_parameters['oauth_signature']=$sig; |
479 | 479 | array_push($return_array, "oauth_signature=$sig"); |
480 | - return join("&", $return_array); |
|
480 | + return join("&", $return_array); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | private function _generateSignature ($parameters="") |
485 | 485 | { |
486 | 486 | $secretKey = ''; |
487 | - if(isset($this->_secrets['shared_secret'])) |
|
488 | - { |
|
489 | - $secretKey = self::_oauthEscape($this->_secrets['shared_secret']); |
|
490 | - } |
|
491 | - |
|
492 | - $secretKey .= '&'; |
|
493 | - if(isset($this->_secrets['oauth_secret'])) |
|
494 | - { |
|
487 | + if(isset($this->_secrets['shared_secret'])) |
|
488 | + { |
|
489 | + $secretKey = self::_oauthEscape($this->_secrets['shared_secret']); |
|
490 | + } |
|
491 | + |
|
492 | + $secretKey .= '&'; |
|
493 | + if(isset($this->_secrets['oauth_secret'])) |
|
494 | + { |
|
495 | 495 | $secretKey .= self::_oauthEscape($this->_secrets['oauth_secret']); |
496 | 496 | } |
497 | 497 | if(!empty($parameters)){ |
@@ -507,33 +507,33 @@ discard block |
||
507 | 507 | return base64_encode(hash_hmac('sha1',$this->sbs,$secretKey,TRUE)); |
508 | 508 | default: |
509 | 509 | throw new OAuthSimpleException('Unknown signature method for OAuthSimple'); |
510 | - break; |
|
510 | + break; |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | class OAuthSimpleException extends Exception { |
516 | 516 | |
517 | - public function __construct($err, $isDebug = FALSE) |
|
518 | - { |
|
519 | - self::log_error($err); |
|
520 | - if ($isDebug) |
|
521 | - { |
|
522 | - self::display_error($err, TRUE); |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - public static function log_error($err) |
|
527 | - { |
|
528 | - error_log($err, 0); |
|
529 | - } |
|
530 | - |
|
531 | - public static function display_error($err, $kill = FALSE) |
|
532 | - { |
|
533 | - print_r($err); |
|
534 | - if ($kill === FALSE) |
|
535 | - { |
|
536 | - die(); |
|
537 | - } |
|
538 | - } |
|
517 | + public function __construct($err, $isDebug = FALSE) |
|
518 | + { |
|
519 | + self::log_error($err); |
|
520 | + if ($isDebug) |
|
521 | + { |
|
522 | + self::display_error($err, TRUE); |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + public static function log_error($err) |
|
527 | + { |
|
528 | + error_log($err, 0); |
|
529 | + } |
|
530 | + |
|
531 | + public static function display_error($err, $kill = FALSE) |
|
532 | + { |
|
533 | + print_r($err); |
|
534 | + if ($kill === FALSE) |
|
535 | + { |
|
536 | + die(); |
|
537 | + } |
|
538 | + } |
|
539 | 539 | } |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | $last_access = ''; |
8 | 8 | // get the last time the user accessed the tool |
9 | 9 | if (isset($_SESSION[$_course['id']]) && $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') { |
10 | - $last_access = get_last_tool_access(TOOL_DROPBOX); |
|
11 | - $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; |
|
10 | + $last_access = get_last_tool_access(TOOL_DROPBOX); |
|
11 | + $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; |
|
12 | 12 | } else { |
13 | - if (isset($_SESSION[$_course['id']])) { |
|
14 | - $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX]; |
|
15 | - } |
|
13 | + if (isset($_SESSION[$_course['id']])) { |
|
14 | + $last_access = $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX]; |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | $postAction = isset($_POST['action']) ? $_POST['action'] : null; |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | // Display the form for adding a new dropbox item. |
52 | 52 | if ($action == 'add') { |
53 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
54 | - api_not_allowed(); |
|
55 | - } |
|
53 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
54 | + api_not_allowed(); |
|
55 | + } |
|
56 | 56 | display_add_form( |
57 | 57 | $dropbox_unid, |
58 | 58 | $viewReceivedCategory, |
@@ -62,56 +62,56 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | if (isset($_POST['submitWork'])) { |
65 | - $check = Security::check_token(); |
|
66 | - if ($check) { |
|
65 | + $check = Security::check_token(); |
|
66 | + if ($check) { |
|
67 | 67 | store_add_dropbox(); |
68 | - } |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Display the form for adding a category |
72 | 72 | if ($action == 'addreceivedcategory' || $action == 'addsentcategory') { |
73 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
74 | - api_not_allowed(); |
|
75 | - } |
|
76 | - $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : ''; |
|
77 | - display_addcategory_form($categoryName, '', $_GET['action']); |
|
73 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
74 | + api_not_allowed(); |
|
75 | + } |
|
76 | + $categoryName = isset($_POST['category_name']) ? $_POST['category_name'] : ''; |
|
77 | + display_addcategory_form($categoryName, '', $_GET['action']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Editing a category: displaying the form |
81 | 81 | if ($action == 'editcategory' && isset($_GET['id'])) { |
82 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
83 | - api_not_allowed(); |
|
84 | - } |
|
85 | - if (!$_POST) { |
|
86 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
87 | - api_not_allowed(); |
|
88 | - } |
|
89 | - display_addcategory_form('', $_GET['id'], 'editcategory'); |
|
90 | - } |
|
82 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
83 | + api_not_allowed(); |
|
84 | + } |
|
85 | + if (!$_POST) { |
|
86 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
87 | + api_not_allowed(); |
|
88 | + } |
|
89 | + display_addcategory_form('', $_GET['id'], 'editcategory'); |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Storing a new or edited category |
94 | 94 | if (isset($_POST['StoreCategory'])) { |
95 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
96 | - api_not_allowed(); |
|
97 | - } |
|
98 | - $return_information = store_addcategory(); |
|
99 | - if ($return_information['type'] == 'confirmation') { |
|
100 | - Display :: display_confirmation_message($return_information['message']); |
|
101 | - } |
|
102 | - if ($return_information['type'] == 'error') { |
|
103 | - Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']); |
|
104 | - display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction); |
|
105 | - } |
|
95 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
96 | + api_not_allowed(); |
|
97 | + } |
|
98 | + $return_information = store_addcategory(); |
|
99 | + if ($return_information['type'] == 'confirmation') { |
|
100 | + Display :: display_confirmation_message($return_information['message']); |
|
101 | + } |
|
102 | + if ($return_information['type'] == 'error') { |
|
103 | + Display :: display_error_message(get_lang('FormHasErrorsPleaseComplete').'<br />'.$return_information['message']); |
|
104 | + display_addcategory_form($_POST['category_name'], $_POST['edit_id'], $postAction); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | 109 | // Move a File |
110 | 110 | if (($action == 'movesent' || $action == 'movereceived') AND isset($_GET['move_id'])) { |
111 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
112 | - api_not_allowed(); |
|
113 | - } |
|
114 | - display_move_form( |
|
111 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
112 | + api_not_allowed(); |
|
113 | + } |
|
114 | + display_move_form( |
|
115 | 115 | str_replace('move', '', $action), |
116 | 116 | $_GET['move_id'], |
117 | 117 | get_dropbox_categories(str_replace('move', '', $action)), |
@@ -122,33 +122,33 @@ discard block |
||
122 | 122 | ); |
123 | 123 | } |
124 | 124 | if (isset($_POST['do_move'])) { |
125 | - Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part'])); |
|
125 | + Display :: display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part'])); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Delete a file |
129 | 129 | if (($action == 'deletereceivedfile' || $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { |
130 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
131 | - api_not_allowed(); |
|
132 | - } |
|
133 | - $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
134 | - if ($action == 'deletereceivedfile') { |
|
135 | - $dropboxfile->deleteReceivedWork($_GET['id']); |
|
136 | - $message = get_lang('ReceivedFileDeleted'); |
|
137 | - } |
|
138 | - if ($action == 'deletesentfile') { |
|
139 | - $dropboxfile->deleteSentWork($_GET['id']); |
|
140 | - $message = get_lang('SentFileDeleted'); |
|
141 | - } |
|
142 | - Display :: display_confirmation_message($message); |
|
130 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
131 | + api_not_allowed(); |
|
132 | + } |
|
133 | + $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
134 | + if ($action == 'deletereceivedfile') { |
|
135 | + $dropboxfile->deleteReceivedWork($_GET['id']); |
|
136 | + $message = get_lang('ReceivedFileDeleted'); |
|
137 | + } |
|
138 | + if ($action == 'deletesentfile') { |
|
139 | + $dropboxfile->deleteSentWork($_GET['id']); |
|
140 | + $message = get_lang('SentFileDeleted'); |
|
141 | + } |
|
142 | + Display :: display_confirmation_message($message); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Delete a category |
146 | 146 | if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) { |
147 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
148 | - api_not_allowed(); |
|
149 | - } |
|
150 | - $message = delete_category($action, $_GET['id']); |
|
151 | - Display :: display_confirmation_message($message); |
|
147 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
148 | + api_not_allowed(); |
|
149 | + } |
|
150 | + $message = delete_category($action, $_GET['id']); |
|
151 | + Display :: display_confirmation_message($message); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Do an action on multiple files |
@@ -163,27 +163,27 @@ discard block |
||
163 | 163 | $postAction == 'delete_sent' || |
164 | 164 | $postAction == 'download_sent') |
165 | 165 | ) { |
166 | - $display_message = handle_multiple_actions(); |
|
167 | - Display :: display_normal_message($display_message); |
|
166 | + $display_message = handle_multiple_actions(); |
|
167 | + Display :: display_normal_message($display_message); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Store Feedback |
171 | 171 | |
172 | 172 | if (isset($_POST['feedback'])) { |
173 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
174 | - api_not_allowed(); |
|
175 | - } |
|
176 | - $check = Security::check_token(); |
|
177 | - if ($check) { |
|
178 | - $display_message = store_feedback(); |
|
179 | - Display :: display_normal_message($display_message); |
|
180 | - Security::check_token(); |
|
181 | - } |
|
173 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
174 | + api_not_allowed(); |
|
175 | + } |
|
176 | + $check = Security::check_token(); |
|
177 | + if ($check) { |
|
178 | + $display_message = store_feedback(); |
|
179 | + Display :: display_normal_message($display_message); |
|
180 | + Security::check_token(); |
|
181 | + } |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | // Error Message |
185 | 185 | if (isset($_GET['error']) AND !empty($_GET['error'])) { |
186 | - Display :: display_normal_message(get_lang($_GET['error'])); |
|
186 | + Display :: display_normal_message(get_lang($_GET['error'])); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $dropbox_data_sent = array(); |
@@ -191,96 +191,96 @@ discard block |
||
191 | 191 | $dropbox_data_recieved = array(); |
192 | 192 | |
193 | 193 | if ($action != 'add') { |
194 | - // Getting all the categories in the dropbox for the given user |
|
195 | - $dropbox_categories = get_dropbox_categories(); |
|
196 | - // Greating the arrays with the categories for the received files and for the sent files |
|
197 | - foreach ($dropbox_categories as $category) { |
|
198 | - if ($category['received'] == '1') { |
|
199 | - $dropbox_received_category[] = $category; |
|
200 | - } |
|
201 | - if ($category['sent'] == '1') { |
|
202 | - $dropbox_sent_category[] = $category; |
|
203 | - } |
|
204 | - } |
|
205 | - |
|
206 | - // ACTIONS |
|
207 | - if ($view == 'received' || !$showSentReceivedTabs) { |
|
208 | - //echo '<h3>'.get_lang('ReceivedFiles').'</h3>'; |
|
209 | - |
|
210 | - // This is for the categories |
|
211 | - if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
212 | - $view_dropbox_category_received = $viewReceivedCategory; |
|
213 | - } else { |
|
214 | - $view_dropbox_category_received = 0; |
|
215 | - } |
|
216 | - |
|
217 | - /* Menu Received */ |
|
218 | - |
|
219 | - if (api_get_session_id() == 0) { |
|
220 | - echo '<div class="actions">'; |
|
221 | - if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
222 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
223 | - echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
224 | - $movelist[0] = 'Root'; // move_received selectbox content |
|
225 | - } else { |
|
226 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
227 | - } |
|
228 | - echo '</div>'; |
|
229 | - } else { |
|
230 | - if (api_is_allowed_to_session_edit(false, true)) { |
|
231 | - echo '<div class="actions">'; |
|
232 | - if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
233 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
234 | - echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
235 | - $movelist[0] = 'Root'; // move_received selectbox content |
|
236 | - } else { |
|
237 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
238 | - } |
|
239 | - echo '</div>'; |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
243 | - |
|
244 | - if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
245 | - // This is for the categories |
|
246 | - if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
247 | - $view_dropbox_category_sent = $viewSentCategory; |
|
248 | - } else { |
|
249 | - $view_dropbox_category_sent = 0; |
|
250 | - } |
|
251 | - |
|
252 | - /* Menu Sent */ |
|
253 | - |
|
254 | - if (api_get_session_id() == 0) { |
|
255 | - echo '<div class="actions">'; |
|
256 | - if ($view_dropbox_category_sent != 0) { |
|
257 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
258 | - echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
259 | - } else { |
|
260 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
261 | - } |
|
262 | - if (empty($viewSentCategory)) { |
|
263 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
264 | - } |
|
265 | - echo '</div>'; |
|
266 | - } else { |
|
267 | - if (api_is_allowed_to_session_edit(false, true)) { |
|
268 | - echo '<div class="actions">'; |
|
269 | - if ($view_dropbox_category_sent != 0) { |
|
270 | - echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
271 | - echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
272 | - } else { |
|
273 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
274 | - } |
|
275 | - if (empty($viewSentCategory)) { |
|
276 | - echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
277 | - } |
|
278 | - echo '</div>'; |
|
279 | - } |
|
280 | - } |
|
281 | - } |
|
282 | - /* THE MENU TABS */ |
|
283 | - if ($showSentReceivedTabs) { |
|
194 | + // Getting all the categories in the dropbox for the given user |
|
195 | + $dropbox_categories = get_dropbox_categories(); |
|
196 | + // Greating the arrays with the categories for the received files and for the sent files |
|
197 | + foreach ($dropbox_categories as $category) { |
|
198 | + if ($category['received'] == '1') { |
|
199 | + $dropbox_received_category[] = $category; |
|
200 | + } |
|
201 | + if ($category['sent'] == '1') { |
|
202 | + $dropbox_sent_category[] = $category; |
|
203 | + } |
|
204 | + } |
|
205 | + |
|
206 | + // ACTIONS |
|
207 | + if ($view == 'received' || !$showSentReceivedTabs) { |
|
208 | + //echo '<h3>'.get_lang('ReceivedFiles').'</h3>'; |
|
209 | + |
|
210 | + // This is for the categories |
|
211 | + if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
212 | + $view_dropbox_category_received = $viewReceivedCategory; |
|
213 | + } else { |
|
214 | + $view_dropbox_category_received = 0; |
|
215 | + } |
|
216 | + |
|
217 | + /* Menu Received */ |
|
218 | + |
|
219 | + if (api_get_session_id() == 0) { |
|
220 | + echo '<div class="actions">'; |
|
221 | + if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
222 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
223 | + echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
224 | + $movelist[0] = 'Root'; // move_received selectbox content |
|
225 | + } else { |
|
226 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
227 | + } |
|
228 | + echo '</div>'; |
|
229 | + } else { |
|
230 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
231 | + echo '<div class="actions">'; |
|
232 | + if ($view_dropbox_category_received != 0 && api_is_allowed_to_session_edit(false, true)) { |
|
233 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category=0&view_sent_category='.$viewSentCategory.'&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
234 | + echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_received]['cat_name']).'</strong> '; |
|
235 | + $movelist[0] = 'Root'; // move_received selectbox content |
|
236 | + } else { |
|
237 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addreceivedcategory&view='.$view.'">'.Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
238 | + } |
|
239 | + echo '</div>'; |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | + |
|
244 | + if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
245 | + // This is for the categories |
|
246 | + if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
247 | + $view_dropbox_category_sent = $viewSentCategory; |
|
248 | + } else { |
|
249 | + $view_dropbox_category_sent = 0; |
|
250 | + } |
|
251 | + |
|
252 | + /* Menu Sent */ |
|
253 | + |
|
254 | + if (api_get_session_id() == 0) { |
|
255 | + echo '<div class="actions">'; |
|
256 | + if ($view_dropbox_category_sent != 0) { |
|
257 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
258 | + echo get_lang('Category').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
259 | + } else { |
|
260 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
261 | + } |
|
262 | + if (empty($viewSentCategory)) { |
|
263 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
264 | + } |
|
265 | + echo '</div>'; |
|
266 | + } else { |
|
267 | + if (api_is_allowed_to_session_edit(false, true)) { |
|
268 | + echo '<div class="actions">'; |
|
269 | + if ($view_dropbox_category_sent != 0) { |
|
270 | + echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> '; |
|
271 | + echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
272 | + } else { |
|
273 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".Display::return_icon('new_folder.png', get_lang('AddNewCategory'),'',ICON_SIZE_MEDIUM)."</a>\n"; |
|
274 | + } |
|
275 | + if (empty($viewSentCategory)) { |
|
276 | + echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".Display::return_icon('upload_file.png', get_lang('UploadNewFile'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
277 | + } |
|
278 | + echo '</div>'; |
|
279 | + } |
|
280 | + } |
|
281 | + } |
|
282 | + /* THE MENU TABS */ |
|
283 | + if ($showSentReceivedTabs) { |
|
284 | 284 | ?> |
285 | 285 | <ul class="nav nav-tabs"> |
286 | 286 | <li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> > |
@@ -294,80 +294,80 @@ discard block |
||
294 | 294 | </li> |
295 | 295 | </ul> |
296 | 296 | <?php |
297 | - } |
|
297 | + } |
|
298 | 298 | /* RECEIVED FILES */ |
299 | - if ($view == 'received' || !$showSentReceivedTabs) { |
|
300 | - // This is for the categories |
|
301 | - if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
302 | - $view_dropbox_category_received = $viewReceivedCategory; |
|
303 | - } else { |
|
304 | - $view_dropbox_category_received = 0; |
|
305 | - } |
|
306 | - |
|
307 | - // Object initialisation |
|
308 | - $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
309 | - // note: are the $is_courseAdmin and $is_courseTutor parameters needed???? |
|
310 | - |
|
311 | - // Constructing the array that contains the total number of feedback messages per document. |
|
312 | - $number_feedback = get_total_number_feedback(); |
|
313 | - |
|
314 | - // Sorting and paging options |
|
315 | - $sorting_options = array(); |
|
316 | - $paging_options = array(); |
|
317 | - |
|
318 | - // The headers of the sortable tables |
|
319 | - $column_header = array(); |
|
320 | - $column_header[] = array('', false, ''); |
|
321 | - $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
322 | - $column_header[] = array(get_lang('ReceivedTitle'), true, ''); |
|
323 | - $column_header[] = array(get_lang('Size'), true, ''); |
|
324 | - $column_header[] = array(get_lang('Authors'), true, ''); |
|
325 | - $column_header[] = array(get_lang('LastResent'), true); |
|
326 | - |
|
327 | - if (api_get_session_id() == 0) { |
|
328 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
329 | - } elseif (api_is_allowed_to_session_edit(false,true)) { |
|
330 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
331 | - } |
|
332 | - |
|
333 | - $column_header[] = array('RealDate', true); |
|
334 | - $column_header[] = array('RealSize', true); |
|
335 | - |
|
336 | - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
337 | - $column_show[] = 1; |
|
338 | - $column_show[] = 1; |
|
339 | - $column_show[] = 1; |
|
340 | - $column_show[] = 1; |
|
341 | - $column_show[] = 1; |
|
342 | - $column_show[] = 1; |
|
343 | - |
|
344 | - if (api_get_session_id() == 0) { |
|
345 | - $column_show[] = 1; |
|
346 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
347 | - $column_show[] = 1; |
|
348 | - } |
|
349 | - $column_show[] = 0; |
|
350 | - |
|
351 | - // Here we change the way how the columns are going to be sort |
|
352 | - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
353 | - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
354 | - |
|
355 | - $column_order[3] = 8; |
|
356 | - $column_order[5] = 7; |
|
357 | - |
|
358 | - // The content of the sortable table = the received files |
|
359 | - foreach ($dropbox_person -> receivedWork as $dropbox_file) { |
|
360 | - $dropbox_file_data = array(); |
|
361 | - if ($view_dropbox_category_received == $dropbox_file->category) { |
|
299 | + if ($view == 'received' || !$showSentReceivedTabs) { |
|
300 | + // This is for the categories |
|
301 | + if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') { |
|
302 | + $view_dropbox_category_received = $viewReceivedCategory; |
|
303 | + } else { |
|
304 | + $view_dropbox_category_received = 0; |
|
305 | + } |
|
306 | + |
|
307 | + // Object initialisation |
|
308 | + $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
309 | + // note: are the $is_courseAdmin and $is_courseTutor parameters needed???? |
|
310 | + |
|
311 | + // Constructing the array that contains the total number of feedback messages per document. |
|
312 | + $number_feedback = get_total_number_feedback(); |
|
313 | + |
|
314 | + // Sorting and paging options |
|
315 | + $sorting_options = array(); |
|
316 | + $paging_options = array(); |
|
317 | + |
|
318 | + // The headers of the sortable tables |
|
319 | + $column_header = array(); |
|
320 | + $column_header[] = array('', false, ''); |
|
321 | + $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
322 | + $column_header[] = array(get_lang('ReceivedTitle'), true, ''); |
|
323 | + $column_header[] = array(get_lang('Size'), true, ''); |
|
324 | + $column_header[] = array(get_lang('Authors'), true, ''); |
|
325 | + $column_header[] = array(get_lang('LastResent'), true); |
|
326 | + |
|
327 | + if (api_get_session_id() == 0) { |
|
328 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
329 | + } elseif (api_is_allowed_to_session_edit(false,true)) { |
|
330 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
331 | + } |
|
332 | + |
|
333 | + $column_header[] = array('RealDate', true); |
|
334 | + $column_header[] = array('RealSize', true); |
|
335 | + |
|
336 | + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
337 | + $column_show[] = 1; |
|
338 | + $column_show[] = 1; |
|
339 | + $column_show[] = 1; |
|
340 | + $column_show[] = 1; |
|
341 | + $column_show[] = 1; |
|
342 | + $column_show[] = 1; |
|
343 | + |
|
344 | + if (api_get_session_id() == 0) { |
|
345 | + $column_show[] = 1; |
|
346 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
347 | + $column_show[] = 1; |
|
348 | + } |
|
349 | + $column_show[] = 0; |
|
350 | + |
|
351 | + // Here we change the way how the columns are going to be sort |
|
352 | + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
353 | + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
354 | + |
|
355 | + $column_order[3] = 8; |
|
356 | + $column_order[5] = 7; |
|
357 | + |
|
358 | + // The content of the sortable table = the received files |
|
359 | + foreach ($dropbox_person -> receivedWork as $dropbox_file) { |
|
360 | + $dropbox_file_data = array(); |
|
361 | + if ($view_dropbox_category_received == $dropbox_file->category) { |
|
362 | 362 | // we only display the files that are in the category that we are in. |
363 | - $dropbox_file_data[] = $dropbox_file->id; |
|
363 | + $dropbox_file_data[] = $dropbox_file->id; |
|
364 | 364 | |
365 | - if (isset($_SESSION['_seen']) && !is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { |
|
366 | - $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array(); |
|
367 | - } |
|
365 | + if (isset($_SESSION['_seen']) && !is_array($_SESSION['_seen'][$_course['id']][TOOL_DROPBOX])) { |
|
366 | + $_SESSION['_seen'][$_course['id']][TOOL_DROPBOX] = array(); |
|
367 | + } |
|
368 | 368 | |
369 | - // New icon |
|
370 | - $new_icon = ''; |
|
369 | + // New icon |
|
370 | + $new_icon = ''; |
|
371 | 371 | if (isset($_SESSION['_seen'])) { |
372 | 372 | if ($dropbox_file->last_upload_date > $last_access && |
373 | 373 | !in_array( |
@@ -384,12 +384,12 @@ discard block |
||
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
387 | - $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
388 | - $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
389 | - $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
387 | + $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
388 | + $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
389 | + $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
390 | 390 | Display::return_icon('save.png', get_lang('Download'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a>'.$new_icon.'<br />'.$dropbox_file->description; |
391 | - $file_size = $dropbox_file->filesize; |
|
392 | - $dropbox_file_data[] = format_file_size($file_size); |
|
391 | + $file_size = $dropbox_file->filesize; |
|
392 | + $dropbox_file_data[] = format_file_size($file_size); |
|
393 | 393 | |
394 | 394 | $authorInfo = api_get_user_info($dropbox_file->uploader_id); |
395 | 395 | if ($authorInfo) { |
@@ -398,62 +398,62 @@ discard block |
||
398 | 398 | $dropbox_file_data[] = ''; |
399 | 399 | } |
400 | 400 | |
401 | - $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
402 | - $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
401 | + $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
402 | + $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
403 | 403 | api_format_date($last_upload_date).'</span>'; |
404 | 404 | |
405 | - $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
405 | + $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
406 | 406 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a> |
407 | 407 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movereceived&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a> |
408 | 408 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletereceivedfile&id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'. |
409 | 409 | Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
410 | 410 | |
411 | - // This is a hack to have an additional row in a sortable table |
|
412 | - |
|
413 | - if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) { |
|
414 | - $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table |
|
415 | - $action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
416 | - } |
|
417 | - if (api_get_session_id() == 0) { |
|
418 | - $dropbox_file_data[] = $action_icons; |
|
419 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
420 | - $dropbox_file_data[] = $action_icons; |
|
421 | - } |
|
422 | - $action_icons = ''; |
|
423 | - $dropbox_file_data[] = $last_upload_date; |
|
424 | - $dropbox_file_data[] = $file_size; |
|
425 | - $dropbox_data_recieved[] = $dropbox_file_data; |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - // The content of the sortable table = the categories (if we are not in the root) |
|
430 | - if ($view_dropbox_category_received == 0) { |
|
431 | - foreach ($dropbox_categories as $category) { |
|
432 | - /* Note: This can probably be shortened since the categories |
|
411 | + // This is a hack to have an additional row in a sortable table |
|
412 | + |
|
413 | + if ($action == 'viewfeedback' AND isset($_GET['id']) and is_numeric($_GET['id']) AND $dropbox_file->id == $_GET['id']) { |
|
414 | + $action_icons .= "</td></tr>"; // Ending the normal row of the sortable table |
|
415 | + $action_icons .= '<tr><td colspan="2"><a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?"'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a></td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
416 | + } |
|
417 | + if (api_get_session_id() == 0) { |
|
418 | + $dropbox_file_data[] = $action_icons; |
|
419 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
420 | + $dropbox_file_data[] = $action_icons; |
|
421 | + } |
|
422 | + $action_icons = ''; |
|
423 | + $dropbox_file_data[] = $last_upload_date; |
|
424 | + $dropbox_file_data[] = $file_size; |
|
425 | + $dropbox_data_recieved[] = $dropbox_file_data; |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + // The content of the sortable table = the categories (if we are not in the root) |
|
430 | + if ($view_dropbox_category_received == 0) { |
|
431 | + foreach ($dropbox_categories as $category) { |
|
432 | + /* Note: This can probably be shortened since the categories |
|
433 | 433 | for the received files are already in the |
434 | 434 | $dropbox_received_category array;*/ |
435 | - $dropbox_category_data = array(); |
|
436 | - if ($category['received'] == '1') { |
|
437 | - $movelist[$category['cat_id']] = $category['cat_name']; |
|
435 | + $dropbox_category_data = array(); |
|
436 | + if ($category['received'] == '1') { |
|
437 | + $movelist[$category['cat_id']] = $category['cat_name']; |
|
438 | 438 | // This is where the checkbox icon for the files appear |
439 | - $dropbox_category_data[] = $category['cat_id']; |
|
440 | - // The icon of the category |
|
441 | - $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">'; |
|
442 | - $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>'; |
|
443 | - $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>'; |
|
444 | - $dropbox_category_data[] = ''; |
|
445 | - $dropbox_category_data[] = ''; |
|
446 | - $dropbox_category_data[] = ''; |
|
447 | - $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> |
|
439 | + $dropbox_category_data[] = $category['cat_id']; |
|
440 | + // The icon of the category |
|
441 | + $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$category['cat_id'].'&view_sent_category='.$viewSentCategory.'&view='.$view.'">'; |
|
442 | + $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', $category['cat_name']).'</a>'; |
|
443 | + $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=received">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$category['cat_name'].'</a>'; |
|
444 | + $dropbox_category_data[] = ''; |
|
445 | + $dropbox_category_data[] = ''; |
|
446 | + $dropbox_category_data[] = ''; |
|
447 | + $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> |
|
448 | 448 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletereceivedcategory&id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
449 | - } |
|
450 | - if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
451 | - $dropbox_data_recieved[] = $dropbox_category_data; |
|
452 | - } |
|
453 | - } |
|
454 | - } |
|
455 | - |
|
456 | - // Displaying the table |
|
449 | + } |
|
450 | + if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
451 | + $dropbox_data_recieved[] = $dropbox_category_data; |
|
452 | + } |
|
453 | + } |
|
454 | + } |
|
455 | + |
|
456 | + // Displaying the table |
|
457 | 457 | $additional_get_parameters = array( |
458 | 458 | 'view' => $view, |
459 | 459 | 'view_received_category' => $viewReceivedCategory, |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | 'download_received' => get_lang('Download') |
465 | 465 | ); |
466 | 466 | |
467 | - if (is_array($movelist)) { |
|
468 | - foreach ($movelist as $catid => $catname){ |
|
469 | - $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname); |
|
470 | - } |
|
471 | - } |
|
467 | + if (is_array($movelist)) { |
|
468 | + foreach ($movelist as $catid => $catname){ |
|
469 | + $selectlist['move_received_'.$catid] = get_lang('Move') . '->'. Security::remove_XSS($catname); |
|
470 | + } |
|
471 | + } |
|
472 | 472 | |
473 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
474 | - $selectlist = array(); |
|
475 | - } |
|
473 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
474 | + $selectlist = array(); |
|
475 | + } |
|
476 | 476 | echo '<div class="files-table">'; |
477 | 477 | Display::display_sortable_config_table( |
478 | 478 | 'dropbox', |
@@ -486,154 +486,154 @@ discard block |
||
486 | 486 | $selectlist |
487 | 487 | ); |
488 | 488 | echo '</div>'; |
489 | - } |
|
490 | - |
|
491 | - /* SENT FILES */ |
|
492 | - |
|
493 | - if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
494 | - // This is for the categories |
|
495 | - if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
496 | - $view_dropbox_category_sent = $viewSentCategory; |
|
497 | - } else { |
|
498 | - $view_dropbox_category_sent = 0; |
|
499 | - } |
|
500 | - |
|
501 | - // Object initialisation |
|
502 | - $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
503 | - |
|
504 | - // Constructing the array that contains the total number of feedback messages per document. |
|
505 | - $number_feedback = get_total_number_feedback(); |
|
506 | - |
|
507 | - // Sorting and paging options |
|
508 | - $sorting_options = array(); |
|
509 | - $paging_options = array(); |
|
510 | - |
|
511 | - // The headers of the sortable tables |
|
512 | - $column_header = array(); |
|
513 | - |
|
514 | - $column_header[] = array('', false, ''); |
|
515 | - $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
516 | - $column_header[] = array(get_lang('SentTitle'), true, ''); |
|
517 | - $column_header[] = array(get_lang('Size'), true, ''); |
|
518 | - $column_header[] = array(get_lang('SentTo'), true, ''); |
|
519 | - $column_header[] = array(get_lang('LastResent'), true, ''); |
|
520 | - |
|
521 | - if (api_get_session_id() == 0) { |
|
522 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
523 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
524 | - $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
525 | - } |
|
526 | - |
|
527 | - $column_header[] = array('RealDate', true); |
|
528 | - $column_header[] = array('RealSize', true); |
|
529 | - |
|
530 | - $column_show = array(); |
|
531 | - $column_order = array(); |
|
532 | - |
|
533 | - // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
534 | - $column_show[] = 1; |
|
535 | - $column_show[] = 1; |
|
536 | - $column_show[] = 1; |
|
537 | - $column_show[] = 1; |
|
538 | - $column_show[] = 1; |
|
539 | - $column_show[] = 1; |
|
540 | - if (api_get_session_id() == 0) { |
|
541 | - $column_show[] = 1; |
|
542 | - } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
543 | - $column_show[] = 1; |
|
544 | - } |
|
545 | - $column_show[] = 0; |
|
546 | - |
|
547 | - // Here we change the way how the colums are going to be sort |
|
548 | - // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
549 | - // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
550 | - |
|
551 | - $column_order[3] = 8; |
|
552 | - $column_order[5] = 7; |
|
553 | - |
|
554 | - // The content of the sortable table = the received files |
|
555 | - foreach ($dropbox_person->sentWork as $dropbox_file) { |
|
556 | - $dropbox_file_data = array(); |
|
557 | - |
|
558 | - if ($view_dropbox_category_sent == $dropbox_file->category) { |
|
559 | - $dropbox_file_data[] = $dropbox_file->id; |
|
560 | - $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
561 | - $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
562 | - $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
489 | + } |
|
490 | + |
|
491 | + /* SENT FILES */ |
|
492 | + |
|
493 | + if (!$view || $view == 'sent' || !$showSentReceivedTabs) { |
|
494 | + // This is for the categories |
|
495 | + if (isset($viewSentCategory) AND $viewSentCategory != '') { |
|
496 | + $view_dropbox_category_sent = $viewSentCategory; |
|
497 | + } else { |
|
498 | + $view_dropbox_category_sent = 0; |
|
499 | + } |
|
500 | + |
|
501 | + // Object initialisation |
|
502 | + $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); |
|
503 | + |
|
504 | + // Constructing the array that contains the total number of feedback messages per document. |
|
505 | + $number_feedback = get_total_number_feedback(); |
|
506 | + |
|
507 | + // Sorting and paging options |
|
508 | + $sorting_options = array(); |
|
509 | + $paging_options = array(); |
|
510 | + |
|
511 | + // The headers of the sortable tables |
|
512 | + $column_header = array(); |
|
513 | + |
|
514 | + $column_header[] = array('', false, ''); |
|
515 | + $column_header[] = array(get_lang('Type'), true, 'style="width:40px"', 'style="text-align:center"'); |
|
516 | + $column_header[] = array(get_lang('SentTitle'), true, ''); |
|
517 | + $column_header[] = array(get_lang('Size'), true, ''); |
|
518 | + $column_header[] = array(get_lang('SentTo'), true, ''); |
|
519 | + $column_header[] = array(get_lang('LastResent'), true, ''); |
|
520 | + |
|
521 | + if (api_get_session_id() == 0) { |
|
522 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
523 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
524 | + $column_header[] = array(get_lang('Modify'), false, '', 'nowrap style="text-align: right"'); |
|
525 | + } |
|
526 | + |
|
527 | + $column_header[] = array('RealDate', true); |
|
528 | + $column_header[] = array('RealSize', true); |
|
529 | + |
|
530 | + $column_show = array(); |
|
531 | + $column_order = array(); |
|
532 | + |
|
533 | + // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide |
|
534 | + $column_show[] = 1; |
|
535 | + $column_show[] = 1; |
|
536 | + $column_show[] = 1; |
|
537 | + $column_show[] = 1; |
|
538 | + $column_show[] = 1; |
|
539 | + $column_show[] = 1; |
|
540 | + if (api_get_session_id() == 0) { |
|
541 | + $column_show[] = 1; |
|
542 | + } elseif (api_is_allowed_to_session_edit(false, true)) { |
|
543 | + $column_show[] = 1; |
|
544 | + } |
|
545 | + $column_show[] = 0; |
|
546 | + |
|
547 | + // Here we change the way how the colums are going to be sort |
|
548 | + // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate |
|
549 | + // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" |
|
550 | + |
|
551 | + $column_order[3] = 8; |
|
552 | + $column_order[5] = 7; |
|
553 | + |
|
554 | + // The content of the sortable table = the received files |
|
555 | + foreach ($dropbox_person->sentWork as $dropbox_file) { |
|
556 | + $dropbox_file_data = array(); |
|
557 | + |
|
558 | + if ($view_dropbox_category_sent == $dropbox_file->category) { |
|
559 | + $dropbox_file_data[] = $dropbox_file->id; |
|
560 | + $link_open = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'">'; |
|
561 | + $dropbox_file_data[] = $link_open.DocumentManager::build_document_icon_tag('file', $dropbox_file->title).'</a>'; |
|
562 | + $dropbox_file_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&id='.$dropbox_file->id.'&action=download">'. |
|
563 | 563 | Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.$dropbox_file->title.'</a><br />'.$dropbox_file->description; |
564 | - $file_size = $dropbox_file->filesize; |
|
565 | - $dropbox_file_data[] = format_file_size($file_size); |
|
564 | + $file_size = $dropbox_file->filesize; |
|
565 | + $dropbox_file_data[] = format_file_size($file_size); |
|
566 | 566 | $receivers_celldata = null; |
567 | - foreach ($dropbox_file->recipients as $recipient) { |
|
568 | - $userInfo = api_get_user_info($recipient['user_id']); |
|
569 | - $receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata; |
|
570 | - } |
|
571 | - $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. |
|
572 | - $dropbox_file_data[] = $receivers_celldata; |
|
573 | - $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
574 | - $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
575 | - api_format_date($last_upload_date).'</span>'; |
|
576 | - |
|
577 | - //$dropbox_file_data[] = $dropbox_file->author; |
|
578 | - $receivers_celldata = ''; |
|
579 | - |
|
580 | - $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
567 | + foreach ($dropbox_file->recipients as $recipient) { |
|
568 | + $userInfo = api_get_user_info($recipient['user_id']); |
|
569 | + $receivers_celldata = UserManager::getUserProfileLink($userInfo).', '.$receivers_celldata; |
|
570 | + } |
|
571 | + $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. |
|
572 | + $dropbox_file_data[] = $receivers_celldata; |
|
573 | + $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); |
|
574 | + $dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'. |
|
575 | + api_format_date($last_upload_date).'</span>'; |
|
576 | + |
|
577 | + //$dropbox_file_data[] = $dropbox_file->author; |
|
578 | + $receivers_celldata = ''; |
|
579 | + |
|
580 | + $action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').' |
|
581 | 581 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=viewfeedback&id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('discuss.png', get_lang('Comment'),'',ICON_SIZE_SMALL).'</a> |
582 | 582 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=movesent&move_id='.$dropbox_file->id.'&'.$sort_params.'">'.Display::return_icon('move.png', get_lang('Move'),'',ICON_SIZE_SMALL).'</a> |
583 | 583 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletesentfile&id='.$dropbox_file->id.'&'.$sort_params.'" onclick="javascript: return confirmation(\''.$dropbox_file->title.'\');">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
584 | - // This is a hack to have an additional row in a sortable table |
|
585 | - if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) { |
|
586 | - $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table |
|
587 | - $action_icons .= "<tr><td colspan=\"2\">"; |
|
588 | - $action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>"; |
|
589 | - $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
590 | - } |
|
591 | - $dropbox_file_data[] = $action_icons; |
|
592 | - $dropbox_file_data[] = $last_upload_date; |
|
593 | - $dropbox_file_data[] = $file_size; |
|
594 | - $action_icons = ''; |
|
595 | - $dropbox_data_sent[] = $dropbox_file_data; |
|
596 | - } |
|
597 | - } |
|
584 | + // This is a hack to have an additional row in a sortable table |
|
585 | + if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) { |
|
586 | + $action_icons .= "</td></tr>\n"; // ending the normal row of the sortable table |
|
587 | + $action_icons .= "<tr><td colspan=\"2\">"; |
|
588 | + $action_icons .= "<a href=\"".api_get_path(WEB_CODE_PATH)."dropbox/index.php?".api_get_cidreq()."&view_received_category=".$viewReceivedCategory."&view_sent_category=".$viewSentCategory."&view=".$view.'&'.$sort_params."\">".get_lang('CloseFeedback')."</a>"; |
|
589 | + $action_icons .= "</td><td colspan=\"7\">".feedback($dropbox_file->feedback2)."</td></tr>"; |
|
590 | + } |
|
591 | + $dropbox_file_data[] = $action_icons; |
|
592 | + $dropbox_file_data[] = $last_upload_date; |
|
593 | + $dropbox_file_data[] = $file_size; |
|
594 | + $action_icons = ''; |
|
595 | + $dropbox_data_sent[] = $dropbox_file_data; |
|
596 | + } |
|
597 | + } |
|
598 | 598 | |
599 | 599 | $moveList = array(); |
600 | - // The content of the sortable table = the categories (if we are not in the root) |
|
601 | - if ($view_dropbox_category_sent == 0) { |
|
602 | - foreach ($dropbox_categories as $category) { |
|
603 | - $dropbox_category_data = array(); |
|
600 | + // The content of the sortable table = the categories (if we are not in the root) |
|
601 | + if ($view_dropbox_category_sent == 0) { |
|
602 | + foreach ($dropbox_categories as $category) { |
|
603 | + $dropbox_category_data = array(); |
|
604 | 604 | |
605 | - if ($category['sent'] == '1') { |
|
605 | + if ($category['sent'] == '1') { |
|
606 | 606 | |
607 | 607 | $moveList[$category['cat_id']] = $category['cat_name']; |
608 | - $dropbox_category_data[] = $category['cat_id']; |
|
609 | - // This is where the checkbox icon for the files appear. |
|
610 | - $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">'; |
|
611 | - $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>'; |
|
612 | - $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>'; |
|
613 | - //$dropbox_category_data[] = ''; |
|
614 | - $dropbox_category_data[] = ''; |
|
615 | - //$dropbox_category_data[] = ''; |
|
616 | - $dropbox_category_data[] = ''; |
|
617 | - $dropbox_category_data[] = ''; |
|
618 | - $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'. |
|
608 | + $dropbox_category_data[] = $category['cat_id']; |
|
609 | + // This is where the checkbox icon for the files appear. |
|
610 | + $link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">'; |
|
611 | + $dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>'; |
|
612 | + $dropbox_category_data[] = '<a href="'.api_get_path(WEB_CODE_PATH).'dropbox/dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>'; |
|
613 | + //$dropbox_category_data[] = ''; |
|
614 | + $dropbox_category_data[] = ''; |
|
615 | + //$dropbox_category_data[] = ''; |
|
616 | + $dropbox_category_data[] = ''; |
|
617 | + $dropbox_category_data[] = ''; |
|
618 | + $dropbox_category_data[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=editcategory&id='.$category['cat_id'].'">'. |
|
619 | 619 | Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> |
620 | 620 | <a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$viewSentCategory.'&view='.$view.'&action=deletesentcategory&id='.$category['cat_id'].'" onclick="javascript: return confirmation(\''.Security::remove_XSS($category['cat_name']).'\');">'. |
621 | 621 | Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
622 | - } |
|
623 | - if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
624 | - $dropbox_data_sent[] = $dropbox_category_data; |
|
625 | - } |
|
626 | - } |
|
627 | - } |
|
628 | - |
|
629 | - // Displaying the table |
|
630 | - $additional_get_parameters = array( |
|
622 | + } |
|
623 | + if (is_array($dropbox_category_data) && count($dropbox_category_data) > 0) { |
|
624 | + $dropbox_data_sent[] = $dropbox_category_data; |
|
625 | + } |
|
626 | + } |
|
627 | + } |
|
628 | + |
|
629 | + // Displaying the table |
|
630 | + $additional_get_parameters = array( |
|
631 | 631 | 'view' => $view, |
632 | 632 | 'view_received_category' => $viewReceivedCategory, |
633 | 633 | 'view_sent_category' => $viewSentCategory |
634 | 634 | ); |
635 | 635 | |
636 | - $selectlist = array( |
|
636 | + $selectlist = array( |
|
637 | 637 | 'delete_received' => get_lang('Delete'), |
638 | 638 | 'download_received' => get_lang('Download') |
639 | 639 | ); |
@@ -644,12 +644,12 @@ discard block |
||
644 | 644 | } |
645 | 645 | } |
646 | 646 | |
647 | - if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
648 | - $selectlist = array('download_received' => get_lang('Download')); |
|
649 | - } |
|
647 | + if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { |
|
648 | + $selectlist = array('download_received' => get_lang('Download')); |
|
649 | + } |
|
650 | 650 | |
651 | 651 | echo '<div class="files-table">'; |
652 | - Display::display_sortable_config_table( |
|
652 | + Display::display_sortable_config_table( |
|
653 | 653 | 'dropbox', |
654 | 654 | $column_header, |
655 | 655 | $dropbox_data_sent, |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | $selectlist |
662 | 662 | ); |
663 | 663 | echo '</div>'; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | Display::display_footer(); |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * private function creating a new work object |
|
81 | - * |
|
82 | - * @param int $uploader_id |
|
83 | - * @param string $title |
|
84 | - * @param string $description |
|
85 | - * @param string $author |
|
86 | - * @param string $filename |
|
87 | - * @param int $filesize |
|
88 | - * |
|
89 | - * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) |
|
90 | - * As a consequence this parameter can be removed |
|
91 | - */ |
|
92 | - public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) |
|
79 | + /** |
|
80 | + * private function creating a new work object |
|
81 | + * |
|
82 | + * @param int $uploader_id |
|
83 | + * @param string $title |
|
84 | + * @param string $description |
|
85 | + * @param string $author |
|
86 | + * @param string $filename |
|
87 | + * @param int $filesize |
|
88 | + * |
|
89 | + * @todo $author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads) |
|
90 | + * As a consequence this parameter can be removed |
|
91 | + */ |
|
92 | + public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize) |
|
93 | 93 | { |
94 | 94 | // Fill in the properties |
95 | 95 | $this->uploader_id = intval($uploader_id); |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | // Check if object exists already. If it does, the old object is used |
105 | 105 | // with updated information (authors, description, upload_date) |
106 | 106 | $this->isOldWork = false; |
107 | - $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
107 | + $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
108 | 108 | WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'"; |
109 | 109 | $result = Database::query($sql); |
110 | - $res = Database::fetch_array($result); |
|
111 | - if ($res) { |
|
112 | - $this->isOldWork = true; |
|
113 | - } |
|
114 | - // Insert or update the dropbox_file table and set the id property |
|
115 | - if ($this->isOldWork) { |
|
116 | - $this->id = $res['id']; |
|
117 | - $this->upload_date = $res['upload_date']; |
|
110 | + $res = Database::fetch_array($result); |
|
111 | + if ($res) { |
|
112 | + $this->isOldWork = true; |
|
113 | + } |
|
114 | + // Insert or update the dropbox_file table and set the id property |
|
115 | + if ($this->isOldWork) { |
|
116 | + $this->id = $res['id']; |
|
117 | + $this->upload_date = $res['upload_date']; |
|
118 | 118 | |
119 | 119 | $params = [ |
120 | 120 | 'filesize' => $this->filesize, |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | $params, |
131 | 131 | ['c_id = ? AND id = ?' => [$course_id, $this->id]] |
132 | 132 | ); |
133 | - } else { |
|
134 | - $this->upload_date = $this->last_upload_date; |
|
135 | - $params = [ |
|
133 | + } else { |
|
134 | + $this->upload_date = $this->last_upload_date; |
|
135 | + $params = [ |
|
136 | 136 | 'c_id' => $course_id, |
137 | 137 | 'uploader_id' => $this->uploader_id, |
138 | 138 | 'filename' => $this->filename, |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | 'last_upload_date' => $this->last_upload_date, |
145 | 145 | 'session_id' => api_get_session_id(), |
146 | 146 | 'cat_id' => 0 |
147 | - ]; |
|
147 | + ]; |
|
148 | 148 | |
149 | - $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params); |
|
150 | - if ($this->id) { |
|
151 | - $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}"; |
|
152 | - Database::query($sql); |
|
153 | - } |
|
154 | - } |
|
149 | + $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params); |
|
150 | + if ($this->id) { |
|
151 | + $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}"; |
|
152 | + Database::query($sql); |
|
153 | + } |
|
154 | + } |
|
155 | 155 | |
156 | 156 | $sql = "SELECT count(file_id) as count |
157 | 157 | FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")"; |
166 | 166 | Database::query($sql); |
167 | 167 | } |
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * private function creating existing object by retreiving info from db |
|
172 | - * |
|
173 | - * @param int $id |
|
174 | - */ |
|
175 | - public function _createExistingWork($id) |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * private function creating existing object by retreiving info from db |
|
172 | + * |
|
173 | + * @param int $id |
|
174 | + */ |
|
175 | + public function _createExistingWork($id) |
|
176 | 176 | { |
177 | - $course_id = api_get_course_int_id(); |
|
177 | + $course_id = api_get_course_int_id(); |
|
178 | 178 | |
179 | 179 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
180 | 180 | |
@@ -222,52 +222,52 @@ discard block |
||
222 | 222 | } |
223 | 223 | $this->feedback2= $feedback2; |
224 | 224 | } |
225 | - } |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | class Dropbox_SentWork extends Dropbox_Work |
229 | 229 | { |
230 | - public $recipients; //array of ['id']['name'] arrays |
|
231 | - |
|
232 | - /** |
|
233 | - * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
234 | - * depending on the number of parameters |
|
235 | - * |
|
236 | - * @param unknown_type $arg1 |
|
237 | - * @param unknown_type $arg2 |
|
238 | - * @param unknown_type $arg3 |
|
239 | - * @param unknown_type $arg4 |
|
240 | - * @param unknown_type $arg5 |
|
241 | - * @param unknown_type $arg6 |
|
242 | - * @param unknown_type $arg7 |
|
243 | - * @return Dropbox_SentWork |
|
244 | - */ |
|
245 | - public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
230 | + public $recipients; //array of ['id']['name'] arrays |
|
231 | + |
|
232 | + /** |
|
233 | + * Constructor calls private functions to create a new work or retreive an existing work from DB |
|
234 | + * depending on the number of parameters |
|
235 | + * |
|
236 | + * @param unknown_type $arg1 |
|
237 | + * @param unknown_type $arg2 |
|
238 | + * @param unknown_type $arg3 |
|
239 | + * @param unknown_type $arg4 |
|
240 | + * @param unknown_type $arg5 |
|
241 | + * @param unknown_type $arg6 |
|
242 | + * @param unknown_type $arg7 |
|
243 | + * @return Dropbox_SentWork |
|
244 | + */ |
|
245 | + public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null) |
|
246 | 246 | { |
247 | - if (func_num_args() > 1) { |
|
248 | - $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
249 | - } else { |
|
250 | - $this->_createExistingSentWork($arg1); |
|
251 | - } |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * private function creating a new SentWork object |
|
256 | - * |
|
257 | - * @param int $uploader_id |
|
258 | - * @param string $title |
|
259 | - * @param string $description |
|
260 | - * @param string $author |
|
261 | - * @param string $filename |
|
262 | - * @param int $filesize |
|
263 | - * @param array $recipient_ids |
|
264 | - */ |
|
265 | - public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
247 | + if (func_num_args() > 1) { |
|
248 | + $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7); |
|
249 | + } else { |
|
250 | + $this->_createExistingSentWork($arg1); |
|
251 | + } |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * private function creating a new SentWork object |
|
256 | + * |
|
257 | + * @param int $uploader_id |
|
258 | + * @param string $title |
|
259 | + * @param string $description |
|
260 | + * @param string $author |
|
261 | + * @param string $filename |
|
262 | + * @param int $filesize |
|
263 | + * @param array $recipient_ids |
|
264 | + */ |
|
265 | + public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids) |
|
266 | 266 | { |
267 | 267 | $dropbox_cnf = getDropboxConf(); |
268 | 268 | $_course = api_get_course_info(); |
269 | 269 | |
270 | - // Call constructor of Dropbox_Work object |
|
270 | + // Call constructor of Dropbox_Work object |
|
271 | 271 | parent::__construct( |
272 | 272 | $uploader_id, |
273 | 273 | $title, |
@@ -277,33 +277,33 @@ discard block |
||
277 | 277 | $filesize |
278 | 278 | ); |
279 | 279 | |
280 | - $course_id = api_get_course_int_id(); |
|
281 | - |
|
282 | - // Do sanity checks on recipient_ids array & property fillin |
|
283 | - // The sanity check for ex-coursemembers is already done in base constructor |
|
284 | - $uploader_id = (int) $uploader_id; |
|
280 | + $course_id = api_get_course_int_id(); |
|
285 | 281 | |
286 | - $justSubmit = false; |
|
287 | - if (is_int($recipient_ids)) { |
|
288 | - $justSubmit = true; |
|
289 | - $recipient_ids = array($recipient_ids + $this->id); |
|
290 | - } elseif (count($recipient_ids) == 0) { |
|
291 | - $justSubmit = true; |
|
292 | - $recipient_ids = array($uploader_id); |
|
293 | - } |
|
282 | + // Do sanity checks on recipient_ids array & property fillin |
|
283 | + // The sanity check for ex-coursemembers is already done in base constructor |
|
284 | + $uploader_id = (int) $uploader_id; |
|
285 | + |
|
286 | + $justSubmit = false; |
|
287 | + if (is_int($recipient_ids)) { |
|
288 | + $justSubmit = true; |
|
289 | + $recipient_ids = array($recipient_ids + $this->id); |
|
290 | + } elseif (count($recipient_ids) == 0) { |
|
291 | + $justSubmit = true; |
|
292 | + $recipient_ids = array($uploader_id); |
|
293 | + } |
|
294 | 294 | |
295 | - if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
296 | - die(get_lang('GeneralError').' (code 209)'); |
|
297 | - } |
|
295 | + if (! is_array($recipient_ids) || count($recipient_ids) == 0) { |
|
296 | + die(get_lang('GeneralError').' (code 209)'); |
|
297 | + } |
|
298 | 298 | |
299 | - foreach ($recipient_ids as $rec) { |
|
300 | - if (empty($rec)) { |
|
301 | - continue; |
|
299 | + foreach ($recipient_ids as $rec) { |
|
300 | + if (empty($rec)) { |
|
301 | + continue; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | //this check is done when validating submitted data |
305 | - $this->recipients[] = array('id' => $rec); |
|
306 | - } |
|
305 | + $this->recipients[] = array('id' => $rec); |
|
306 | + } |
|
307 | 307 | |
308 | 308 | $table_post = Database::get_course_table(TABLE_DROPBOX_POST); |
309 | 309 | $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON); |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | $mailId = get_mail_id_base(); |
314 | 314 | |
315 | 315 | // Insert data in dropbox_post and dropbox_person table for each recipient |
316 | - foreach ($this->recipients as $rec) { |
|
316 | + foreach ($this->recipients as $rec) { |
|
317 | 317 | $file_id = (int)$this->id; |
318 | 318 | $user_id = (int)$rec['id']; |
319 | - $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id) |
|
319 | + $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id) |
|
320 | 320 | VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)"; |
321 | - Database::query($sql); |
|
321 | + Database::query($sql); |
|
322 | 322 | // If work already exists no error is generated |
323 | 323 | |
324 | 324 | /** |
@@ -335,13 +335,13 @@ discard block |
||
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - // Update item_property table for each recipient |
|
339 | - if (($ownerid = $this->uploader_id) > $mailId) { |
|
340 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
341 | - } |
|
342 | - if (($recipid = $rec["id"]) > $mailId) { |
|
343 | - $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
344 | - } |
|
338 | + // Update item_property table for each recipient |
|
339 | + if (($ownerid = $this->uploader_id) > $mailId) { |
|
340 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
341 | + } |
|
342 | + if (($recipid = $rec["id"]) > $mailId) { |
|
343 | + $recipid = $ownerid; // mailing file recipient = mailing id, not a person |
|
344 | + } |
|
345 | 345 | api_item_property_update( |
346 | 346 | $_course, |
347 | 347 | TOOL_DROPBOX, |
@@ -351,90 +351,90 @@ discard block |
||
351 | 351 | null, |
352 | 352 | $recipid |
353 | 353 | ); |
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * private function creating existing object by retreiving info from db |
|
359 | - * |
|
360 | - * @param unknown_type $id |
|
361 | - */ |
|
362 | - public function _createExistingSentWork($id) |
|
354 | + } |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * private function creating existing object by retreiving info from db |
|
359 | + * |
|
360 | + * @param unknown_type $id |
|
361 | + */ |
|
362 | + public function _createExistingSentWork($id) |
|
363 | 363 | { |
364 | 364 | $id = intval($id); |
365 | 365 | |
366 | - $course_id = api_get_course_int_id(); |
|
366 | + $course_id = api_get_course_int_id(); |
|
367 | 367 | |
368 | - // Call constructor of Dropbox_Work object |
|
369 | - parent::__construct($id); |
|
368 | + // Call constructor of Dropbox_Work object |
|
369 | + parent::__construct($id); |
|
370 | 370 | |
371 | - // Fill in recipients array |
|
372 | - $this->recipients = array(); |
|
373 | - $sql = "SELECT dest_user_id, feedback_date, feedback |
|
371 | + // Fill in recipients array |
|
372 | + $this->recipients = array(); |
|
373 | + $sql = "SELECT dest_user_id, feedback_date, feedback |
|
374 | 374 | FROM ".Database::get_course_table(TABLE_DROPBOX_POST)." |
375 | 375 | WHERE c_id = $course_id AND file_id = ".intval($id).""; |
376 | 376 | $result = Database::query($sql); |
377 | - while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
378 | - // Check for deleted users |
|
379 | - $dest_user_id = $res['dest_user_id']; |
|
380 | - $user_info = api_get_user_info($dest_user_id); |
|
381 | - //$this->category = $res['cat_id']; |
|
382 | - if (!$user_info) { |
|
383 | - $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
384 | - } else { |
|
385 | - $this->recipients[] = array( |
|
377 | + while ($res = Database::fetch_array($result, 'ASSOC')) { |
|
378 | + // Check for deleted users |
|
379 | + $dest_user_id = $res['dest_user_id']; |
|
380 | + $user_info = api_get_user_info($dest_user_id); |
|
381 | + //$this->category = $res['cat_id']; |
|
382 | + if (!$user_info) { |
|
383 | + $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', '')); |
|
384 | + } else { |
|
385 | + $this->recipients[] = array( |
|
386 | 386 | 'id' => $dest_user_id, |
387 | 387 | 'name' => $user_info['complete_name'], |
388 | 388 | 'user_id' => $dest_user_id, |
389 | - 'feedback_date' => $res['feedback_date'], |
|
389 | + 'feedback_date' => $res['feedback_date'], |
|
390 | 390 | 'feedback' => $res['feedback'] |
391 | 391 | ); |
392 | - } |
|
393 | - } |
|
394 | - } |
|
392 | + } |
|
393 | + } |
|
394 | + } |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | class Dropbox_Person |
398 | 398 | { |
399 | - // The receivedWork and the sentWork arrays are sorted. |
|
400 | - public $receivedWork; // an array of Dropbox_Work objects |
|
401 | - public $sentWork; // an array of Dropbox_SentWork objects |
|
402 | - |
|
403 | - public $userId = 0; |
|
404 | - public $isCourseAdmin = false; |
|
405 | - public $isCourseTutor = false; |
|
406 | - public $_orderBy = ''; // private property that determines by which field |
|
407 | - |
|
408 | - /** |
|
409 | - * Constructor for recreating the Dropbox_Person object |
|
410 | - * |
|
411 | - * @param int $userId |
|
412 | - * @param bool $isCourseAdmin |
|
413 | - * @param bool $isCourseTutor |
|
414 | - * @return Dropbox_Person |
|
415 | - */ |
|
416 | - public function __construct($userId, $isCourseAdmin, $isCourseTutor) |
|
399 | + // The receivedWork and the sentWork arrays are sorted. |
|
400 | + public $receivedWork; // an array of Dropbox_Work objects |
|
401 | + public $sentWork; // an array of Dropbox_SentWork objects |
|
402 | + |
|
403 | + public $userId = 0; |
|
404 | + public $isCourseAdmin = false; |
|
405 | + public $isCourseTutor = false; |
|
406 | + public $_orderBy = ''; // private property that determines by which field |
|
407 | + |
|
408 | + /** |
|
409 | + * Constructor for recreating the Dropbox_Person object |
|
410 | + * |
|
411 | + * @param int $userId |
|
412 | + * @param bool $isCourseAdmin |
|
413 | + * @param bool $isCourseTutor |
|
414 | + * @return Dropbox_Person |
|
415 | + */ |
|
416 | + public function __construct($userId, $isCourseAdmin, $isCourseTutor) |
|
417 | 417 | { |
418 | - $course_id = api_get_course_int_id(); |
|
418 | + $course_id = api_get_course_int_id(); |
|
419 | 419 | |
420 | - // Fill in properties |
|
420 | + // Fill in properties |
|
421 | 421 | $this->userId = $userId; |
422 | 422 | $this->isCourseAdmin = $isCourseAdmin; |
423 | 423 | $this->isCourseTutor = $isCourseTutor; |
424 | 424 | $this->receivedWork = array(); |
425 | 425 | $this->sentWork = array(); |
426 | 426 | |
427 | - // Note: perhaps include an ex coursemember check to delete old files |
|
427 | + // Note: perhaps include an ex coursemember check to delete old files |
|
428 | 428 | |
429 | - $session_id = api_get_session_id(); |
|
430 | - $condition_session = api_get_session_condition($session_id); |
|
429 | + $session_id = api_get_session_id(); |
|
430 | + $condition_session = api_get_session_condition($session_id); |
|
431 | 431 | |
432 | - $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
433 | - $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
434 | - $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
432 | + $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST); |
|
433 | + $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON); |
|
434 | + $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE); |
|
435 | 435 | |
436 | 436 | // Find all entries where this person is the recipient |
437 | - $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
437 | + $sql = "SELECT DISTINCT r.file_id, r.cat_id |
|
438 | 438 | FROM $post_tbl r |
439 | 439 | INNER JOIN $person_tbl p |
440 | 440 | ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id ) |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | r.dest_user_id = ".intval($this->userId)." $condition_session "; |
444 | 444 | |
445 | 445 | $result = Database::query($sql); |
446 | - while ($res = Database::fetch_array($result)) { |
|
447 | - $temp = new Dropbox_Work($res['file_id']); |
|
448 | - $temp->category = $res['cat_id']; |
|
449 | - $this->receivedWork[] = $temp; |
|
450 | - } |
|
451 | - // Find all entries where this person is the sender/uploader |
|
446 | + while ($res = Database::fetch_array($result)) { |
|
447 | + $temp = new Dropbox_Work($res['file_id']); |
|
448 | + $temp->category = $res['cat_id']; |
|
449 | + $this->receivedWork[] = $temp; |
|
450 | + } |
|
451 | + // Find all entries where this person is the sender/uploader |
|
452 | 452 | $sql = "SELECT DISTINCT f.id |
453 | 453 | FROM $file_tbl f |
454 | 454 | INNER JOIN $person_tbl p |
@@ -459,160 +459,160 @@ discard block |
||
459 | 459 | $condition_session |
460 | 460 | "; |
461 | 461 | $result = Database::query($sql); |
462 | - while ($res = Database::fetch_array($result)) { |
|
463 | - $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
464 | - } |
|
465 | - } |
|
466 | - |
|
467 | - /** |
|
468 | - * Deletes all the received work of this person |
|
469 | - */ |
|
470 | - public function deleteAllReceivedWork() |
|
462 | + while ($res = Database::fetch_array($result)) { |
|
463 | + $this->sentWork[] = new Dropbox_SentWork($res['id']); |
|
464 | + } |
|
465 | + } |
|
466 | + |
|
467 | + /** |
|
468 | + * Deletes all the received work of this person |
|
469 | + */ |
|
470 | + public function deleteAllReceivedWork() |
|
471 | 471 | { |
472 | - $course_id = api_get_course_int_id(); |
|
473 | - // Delete entries in person table concerning received works |
|
474 | - foreach ($this->receivedWork as $w) { |
|
472 | + $course_id = api_get_course_int_id(); |
|
473 | + // Delete entries in person table concerning received works |
|
474 | + foreach ($this->receivedWork as $w) { |
|
475 | 475 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
476 | 476 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
477 | - Database::query($sql); |
|
478 | - } |
|
477 | + Database::query($sql); |
|
478 | + } |
|
479 | 479 | // Check for unused files |
480 | - removeUnusedFiles(); |
|
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Deletes all the received categories and work of this person |
|
485 | - * @param integer $id |
|
486 | - */ |
|
487 | - public function deleteReceivedWorkFolder($id) |
|
480 | + removeUnusedFiles(); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Deletes all the received categories and work of this person |
|
485 | + * @param integer $id |
|
486 | + */ |
|
487 | + public function deleteReceivedWorkFolder($id) |
|
488 | 488 | { |
489 | 489 | $course_id = api_get_course_int_id(); |
490 | 490 | |
491 | - $id = intval($id); |
|
492 | - $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
491 | + $id = intval($id); |
|
492 | + $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." |
|
493 | 493 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
494 | - if (!Database::query($sql)) return false; |
|
495 | - $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ." |
|
494 | + if (!Database::query($sql)) return false; |
|
495 | + $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ." |
|
496 | 496 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
497 | - if (!Database::query($sql)) return false; |
|
498 | - $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)." |
|
497 | + if (!Database::query($sql)) return false; |
|
498 | + $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)." |
|
499 | 499 | WHERE c_id = $course_id AND cat_id = '".$id."' "; |
500 | - if (!Database::query($sql)) return false; |
|
501 | - return true; |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
505 | - * Deletes a received dropbox file of this person with id=$id |
|
506 | - * |
|
507 | - * @param integer $id |
|
508 | - */ |
|
509 | - public function deleteReceivedWork($id) |
|
500 | + if (!Database::query($sql)) return false; |
|
501 | + return true; |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | + * Deletes a received dropbox file of this person with id=$id |
|
506 | + * |
|
507 | + * @param integer $id |
|
508 | + */ |
|
509 | + public function deleteReceivedWork($id) |
|
510 | 510 | { |
511 | - $course_id = api_get_course_int_id(); |
|
512 | - $id = intval($id); |
|
513 | - |
|
514 | - // index check |
|
515 | - $found = false; |
|
516 | - foreach ($this->receivedWork as $w) { |
|
517 | - if ($w->id == $id) { |
|
518 | - $found = true; |
|
519 | - break; |
|
520 | - } |
|
521 | - } |
|
522 | - |
|
523 | - if (!$found) { |
|
524 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
525 | - die(get_lang('GeneralError').' (code 216)'); |
|
526 | - } |
|
527 | - } |
|
528 | - // Delete entries in person table concerning received works |
|
511 | + $course_id = api_get_course_int_id(); |
|
512 | + $id = intval($id); |
|
513 | + |
|
514 | + // index check |
|
515 | + $found = false; |
|
516 | + foreach ($this->receivedWork as $w) { |
|
517 | + if ($w->id == $id) { |
|
518 | + $found = true; |
|
519 | + break; |
|
520 | + } |
|
521 | + } |
|
522 | + |
|
523 | + if (!$found) { |
|
524 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
525 | + die(get_lang('GeneralError').' (code 216)'); |
|
526 | + } |
|
527 | + } |
|
528 | + // Delete entries in person table concerning received works |
|
529 | 529 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
530 | 530 | WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'"; |
531 | - Database::query($sql); |
|
532 | - removeUnusedFiles(); // Check for unused files |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * Deletes all the sent dropbox files of this person |
|
537 | - */ |
|
538 | - public function deleteAllSentWork() |
|
531 | + Database::query($sql); |
|
532 | + removeUnusedFiles(); // Check for unused files |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * Deletes all the sent dropbox files of this person |
|
537 | + */ |
|
538 | + public function deleteAllSentWork() |
|
539 | 539 | { |
540 | - $course_id = api_get_course_int_id(); |
|
541 | - //delete entries in person table concerning sent works |
|
542 | - foreach ($this->sentWork as $w) { |
|
540 | + $course_id = api_get_course_int_id(); |
|
541 | + //delete entries in person table concerning sent works |
|
542 | + foreach ($this->sentWork as $w) { |
|
543 | 543 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
544 | 544 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'"; |
545 | - Database::query($sql); |
|
546 | - removeMoreIfMailing($w->id); |
|
547 | - } |
|
548 | - removeUnusedFiles(); // Check for unused files |
|
549 | - } |
|
550 | - |
|
551 | - /** |
|
552 | - * Deletes a sent dropbox file of this person with id=$id |
|
553 | - * |
|
554 | - * @param unknown_type $id |
|
555 | - */ |
|
556 | - public function deleteSentWork($id) |
|
545 | + Database::query($sql); |
|
546 | + removeMoreIfMailing($w->id); |
|
547 | + } |
|
548 | + removeUnusedFiles(); // Check for unused files |
|
549 | + } |
|
550 | + |
|
551 | + /** |
|
552 | + * Deletes a sent dropbox file of this person with id=$id |
|
553 | + * |
|
554 | + * @param unknown_type $id |
|
555 | + */ |
|
556 | + public function deleteSentWork($id) |
|
557 | 557 | { |
558 | - $course_id = api_get_course_int_id(); |
|
559 | - |
|
560 | - $id = intval($id); |
|
561 | - |
|
562 | - // index check |
|
563 | - $found = false; |
|
564 | - foreach ($this->sentWork as $w) { |
|
565 | - if ($w->id == $id) { |
|
566 | - $found = true; |
|
567 | - break; |
|
568 | - } |
|
569 | - } |
|
570 | - if (!$found) { |
|
571 | - if (!$this->deleteReceivedWorkFolder($id)) { |
|
572 | - die(get_lang('GeneralError').' (code 219)'); |
|
573 | - } |
|
574 | - } |
|
575 | - //$file_id = $this->sentWork[$index]->id; |
|
576 | - // Delete entries in person table concerning sent works |
|
558 | + $course_id = api_get_course_int_id(); |
|
559 | + |
|
560 | + $id = intval($id); |
|
561 | + |
|
562 | + // index check |
|
563 | + $found = false; |
|
564 | + foreach ($this->sentWork as $w) { |
|
565 | + if ($w->id == $id) { |
|
566 | + $found = true; |
|
567 | + break; |
|
568 | + } |
|
569 | + } |
|
570 | + if (!$found) { |
|
571 | + if (!$this->deleteReceivedWorkFolder($id)) { |
|
572 | + die(get_lang('GeneralError').' (code 219)'); |
|
573 | + } |
|
574 | + } |
|
575 | + //$file_id = $this->sentWork[$index]->id; |
|
576 | + // Delete entries in person table concerning sent works |
|
577 | 577 | $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." |
578 | 578 | WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'"; |
579 | - Database::query($sql); |
|
580 | - removeMoreIfMailing($id); |
|
581 | - removeUnusedFiles(); // Check for unused files |
|
582 | - } |
|
583 | - |
|
584 | - /** |
|
585 | - * Updates feedback for received work of this person with id=$id |
|
586 | - * |
|
587 | - * @param string $id |
|
588 | - * @param string $text |
|
589 | - */ |
|
590 | - public function updateFeedback($id, $text) |
|
579 | + Database::query($sql); |
|
580 | + removeMoreIfMailing($id); |
|
581 | + removeUnusedFiles(); // Check for unused files |
|
582 | + } |
|
583 | + |
|
584 | + /** |
|
585 | + * Updates feedback for received work of this person with id=$id |
|
586 | + * |
|
587 | + * @param string $id |
|
588 | + * @param string $text |
|
589 | + */ |
|
590 | + public function updateFeedback($id, $text) |
|
591 | 591 | { |
592 | - $course_id = api_get_course_int_id(); |
|
592 | + $course_id = api_get_course_int_id(); |
|
593 | 593 | $_course = api_get_course_info(); |
594 | 594 | $dropbox_cnf = getDropboxConf(); |
595 | 595 | |
596 | - $id = intval($id); |
|
596 | + $id = intval($id); |
|
597 | 597 | |
598 | - // index check |
|
599 | - $found = false; |
|
600 | - $wi = -1; |
|
601 | - foreach ($this->receivedWork as $w) { |
|
602 | - $wi++; |
|
603 | - if ($w->id == $id){ |
|
604 | - $found = true; |
|
605 | - break; |
|
606 | - } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
607 | - } |
|
598 | + // index check |
|
599 | + $found = false; |
|
600 | + $wi = -1; |
|
601 | + foreach ($this->receivedWork as $w) { |
|
602 | + $wi++; |
|
603 | + if ($w->id == $id){ |
|
604 | + $found = true; |
|
605 | + break; |
|
606 | + } // foreach (... as $wi -> $w) gives error 221! (no idea why...) |
|
607 | + } |
|
608 | 608 | |
609 | - if (!$found) { |
|
610 | - return false; |
|
611 | - } |
|
609 | + if (!$found) { |
|
610 | + return false; |
|
611 | + } |
|
612 | 612 | |
613 | - $feedback_date = api_get_utc_datetime(); |
|
614 | - $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
615 | - $this->receivedWork[$wi]->feedback = $text; |
|
613 | + $feedback_date = api_get_utc_datetime(); |
|
614 | + $this->receivedWork[$wi]->feedback_date = $feedback_date; |
|
615 | + $this->receivedWork[$wi]->feedback = $text; |
|
616 | 616 | |
617 | 617 | $params = [ |
618 | 618 | 'feedback_date' => $feedback_date, |
@@ -630,11 +630,11 @@ discard block |
||
630 | 630 | ] |
631 | 631 | ); |
632 | 632 | |
633 | - // Update item_property table |
|
633 | + // Update item_property table |
|
634 | 634 | $mailId = get_mail_id_base(); |
635 | - if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) { |
|
636 | - $ownerid = getUserOwningThisMailing($ownerid); |
|
637 | - } |
|
635 | + if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) { |
|
636 | + $ownerid = getUserOwningThisMailing($ownerid); |
|
637 | + } |
|
638 | 638 | |
639 | 639 | api_item_property_update( |
640 | 640 | $_course, |
@@ -646,33 +646,33 @@ discard block |
||
646 | 646 | $ownerid |
647 | 647 | ); |
648 | 648 | |
649 | - } |
|
649 | + } |
|
650 | 650 | |
651 | - /** |
|
652 | - * Filter the received work |
|
653 | - * @param string $type |
|
654 | - * @param string $value |
|
655 | - */ |
|
656 | - public function filter_received_work($type, $value) |
|
651 | + /** |
|
652 | + * Filter the received work |
|
653 | + * @param string $type |
|
654 | + * @param string $value |
|
655 | + */ |
|
656 | + public function filter_received_work($type, $value) |
|
657 | 657 | { |
658 | 658 | $dropbox_cnf = getDropboxConf(); |
659 | - $new_received_work = array(); |
|
659 | + $new_received_work = array(); |
|
660 | 660 | $mailId = get_mail_id_base(); |
661 | 661 | foreach ($this->receivedWork as $work) { |
662 | - switch ($type) { |
|
663 | - case 'uploader_id': |
|
664 | - if ($work->uploader_id == $value || |
|
665 | - ($work->uploader_id > $mailId && |
|
662 | + switch ($type) { |
|
663 | + case 'uploader_id': |
|
664 | + if ($work->uploader_id == $value || |
|
665 | + ($work->uploader_id > $mailId && |
|
666 | 666 | getUserOwningThisMailing($work->uploader_id) == $value) |
667 | 667 | ) { |
668 | - $new_received_work[] = $work; |
|
669 | - } |
|
670 | - break; |
|
671 | - default: |
|
672 | - $new_received_work[] = $work; |
|
668 | + $new_received_work[] = $work; |
|
669 | + } |
|
670 | + break; |
|
671 | + default: |
|
672 | + $new_received_work[] = $work; |
|
673 | 673 | break; |
674 | - } |
|
675 | - } |
|
676 | - $this->receivedWork = $new_received_work; |
|
677 | - } |
|
674 | + } |
|
675 | + } |
|
676 | + $this->receivedWork = $new_received_work; |
|
677 | + } |
|
678 | 678 | } |
@@ -10,46 +10,46 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class ForumThreadLink extends AbstractLink |
12 | 12 | { |
13 | - private $forum_thread_table = null; |
|
14 | - private $itemprop_table = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_FORUM_THREAD); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function get_type_name() |
|
29 | - { |
|
30 | - return get_lang('ForumThreads'); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function is_allowed_to_change_name() |
|
37 | - { |
|
38 | - return false; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
43 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
44 | - */ |
|
45 | - public function get_not_created_links() |
|
46 | - { |
|
47 | - if (empty($this->course_code)) { |
|
48 | - die('Error in get_not_created_links() : course code not set'); |
|
49 | - } |
|
50 | - |
|
51 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
52 | - $sql = 'SELECT thread_id,thread_title,thread_title_qualify |
|
13 | + private $forum_thread_table = null; |
|
14 | + private $itemprop_table = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_FORUM_THREAD); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function get_type_name() |
|
29 | + { |
|
30 | + return get_lang('ForumThreads'); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function is_allowed_to_change_name() |
|
37 | + { |
|
38 | + return false; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
43 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
44 | + */ |
|
45 | + public function get_not_created_links() |
|
46 | + { |
|
47 | + if (empty($this->course_code)) { |
|
48 | + die('Error in get_not_created_links() : course code not set'); |
|
49 | + } |
|
50 | + |
|
51 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
52 | + $sql = 'SELECT thread_id,thread_title,thread_title_qualify |
|
53 | 53 | FROM '.$this->get_forum_thread_table().' |
54 | 54 | forum_thread WHERE thread_id NOT IN |
55 | 55 | ( |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | ) |
61 | 61 | AND forum_thread.session_id='.api_get_session_id(); |
62 | 62 | |
63 | - $result = Database::query($sql); |
|
63 | + $result = Database::query($sql); |
|
64 | 64 | |
65 | 65 | $cats = array(); |
66 | 66 | while ($data = Database::fetch_array($result)) { |
@@ -75,29 +75,29 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | return $cats; |
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Generate an array of all exercises available. |
|
82 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
83 | - */ |
|
84 | - public function get_all_links() |
|
85 | - { |
|
86 | - if (empty($this->course_code)) { |
|
87 | - die('Error in get_not_created_links() : course code not set'); |
|
88 | - } |
|
89 | - |
|
90 | - $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
91 | - $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
92 | - $session_id = api_get_session_id(); |
|
93 | - |
|
94 | - if ($session_id) { |
|
95 | - $session_condition = 'tl.session_id='.api_get_session_id(); |
|
96 | - } else { |
|
97 | - $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
98 | - } |
|
99 | - |
|
100 | - $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Generate an array of all exercises available. |
|
82 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
83 | + */ |
|
84 | + public function get_all_links() |
|
85 | + { |
|
86 | + if (empty($this->course_code)) { |
|
87 | + die('Error in get_not_created_links() : course code not set'); |
|
88 | + } |
|
89 | + |
|
90 | + $tbl_grade_links = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
91 | + $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
92 | + $session_id = api_get_session_id(); |
|
93 | + |
|
94 | + if ($session_id) { |
|
95 | + $session_condition = 'tl.session_id='.api_get_session_id(); |
|
96 | + } else { |
|
97 | + $session_condition = '(tl.session_id = 0 OR tl.session_id IS NULL)'; |
|
98 | + } |
|
99 | + |
|
100 | + $sql = 'SELECT tl.thread_id, tl.thread_title, tl.thread_title_qualify |
|
101 | 101 | FROM '.$tbl_grade_links.' tl INNER JOIN '.$tbl_item_property.' ip |
102 | 102 | ON (tl.thread_id = ip.ref AND tl.c_id = ip.c_id) |
103 | 103 | WHERE |
@@ -108,23 +108,23 @@ discard block |
||
108 | 108 | '.$session_condition.' |
109 | 109 | '; |
110 | 110 | |
111 | - $result = Database::query($sql); |
|
112 | - while ($data = Database::fetch_array($result)) { |
|
113 | - if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") { |
|
114 | - $cats[] = array($data['thread_id'], $data['thread_title_qualify']); |
|
115 | - } else { |
|
116 | - $cats[] = array($data['thread_id'], $data['thread_title']); |
|
117 | - } |
|
118 | - } |
|
119 | - $my_cats = isset($cats) ? $cats : null; |
|
111 | + $result = Database::query($sql); |
|
112 | + while ($data = Database::fetch_array($result)) { |
|
113 | + if ( isset($data['thread_title_qualify']) && $data['thread_title_qualify'] != "") { |
|
114 | + $cats[] = array($data['thread_id'], $data['thread_title_qualify']); |
|
115 | + } else { |
|
116 | + $cats[] = array($data['thread_id'], $data['thread_title']); |
|
117 | + } |
|
118 | + } |
|
119 | + $my_cats = isset($cats) ? $cats : null; |
|
120 | 120 | |
121 | - return $my_cats; |
|
122 | - } |
|
121 | + return $my_cats; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | /** |
125 | - * Has anyone done this exercise yet ? |
|
126 | - * @return boolean |
|
127 | - */ |
|
125 | + * Has anyone done this exercise yet ? |
|
126 | + * @return boolean |
|
127 | + */ |
|
128 | 128 | public function has_results() |
129 | 129 | { |
130 | 130 | $table = Database :: get_course_table(TABLE_FORUM_POST); |
@@ -138,50 +138,50 @@ discard block |
||
138 | 138 | $number = Database::fetch_row($result); |
139 | 139 | |
140 | 140 | return $number[0] != 0; |
141 | - } |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * @param int $stud_id |
|
143 | + /** |
|
144 | + * @param int $stud_id |
|
145 | 145 | * @param string $type |
146 | 146 | * |
147 | - * @return array|null |
|
148 | - */ |
|
149 | - public function calc_score($stud_id = null, $type = null) |
|
150 | - { |
|
147 | + * @return array|null |
|
148 | + */ |
|
149 | + public function calc_score($stud_id = null, $type = null) |
|
150 | + { |
|
151 | 151 | require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; |
152 | 152 | $threadInfo = get_thread_information('', $this->get_ref_id()); |
153 | 153 | |
154 | - $thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
154 | + $thread_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
|
155 | 155 | |
156 | 156 | $sessionId = $this->get_session_id(); |
157 | 157 | $sessionCondition = api_get_session_condition($sessionId, true, false, 'session_id'); |
158 | 158 | |
159 | - $sql = 'SELECT thread_qualify_max |
|
159 | + $sql = 'SELECT thread_qualify_max |
|
160 | 160 | FROM '.Database :: get_course_table(TABLE_FORUM_THREAD)." |
161 | 161 | WHERE |
162 | 162 | c_id = ".$this->course_id." AND |
163 | 163 | thread_id = '".$this->get_ref_id()."' |
164 | 164 | $sessionCondition |
165 | 165 | "; |
166 | - $query = Database::query($sql); |
|
167 | - $assignment = Database::fetch_array($query); |
|
166 | + $query = Database::query($sql); |
|
167 | + $assignment = Database::fetch_array($query); |
|
168 | 168 | |
169 | - $sql = "SELECT * FROM $thread_qualify |
|
169 | + $sql = "SELECT * FROM $thread_qualify |
|
170 | 170 | WHERE |
171 | 171 | c_id = ".$this->course_id." AND |
172 | 172 | thread_id = ".$this->get_ref_id()." |
173 | 173 | $sessionCondition |
174 | 174 | "; |
175 | - if (isset($stud_id)) { |
|
176 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
177 | - } |
|
175 | + if (isset($stud_id)) { |
|
176 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
177 | + } |
|
178 | 178 | |
179 | - // order by id, that way the student's first attempt is accessed first |
|
180 | - $sql .= ' ORDER BY qualify_time DESC'; |
|
181 | - $scores = Database::query($sql); |
|
179 | + // order by id, that way the student's first attempt is accessed first |
|
180 | + $sql .= ' ORDER BY qualify_time DESC'; |
|
181 | + $scores = Database::query($sql); |
|
182 | 182 | |
183 | - // for 1 student |
|
184 | - if (isset($stud_id)) { |
|
183 | + // for 1 student |
|
184 | + if (isset($stud_id)) { |
|
185 | 185 | if ($threadInfo['thread_peer_qualify'] == 0) { |
186 | 186 | // Classic way of calculate score |
187 | 187 | if ($data = Database::fetch_array($scores)) { |
@@ -209,175 +209,175 @@ discard block |
||
209 | 209 | } |
210 | 210 | return [$score/$counter, $assignment['thread_qualify_max']]; |
211 | 211 | } |
212 | - } else { |
|
213 | - // All students -> get average |
|
214 | - $students = array(); // user list, needed to make sure we only |
|
215 | - // take first attempts into account |
|
216 | - $counter = 0; |
|
217 | - $sum = 0; |
|
218 | - $bestResult = 0; |
|
219 | - $weight = 0; |
|
220 | - $sumResult = 0; |
|
221 | - |
|
222 | - while ($data = Database::fetch_array($scores)) { |
|
223 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
224 | - if ($assignment['thread_qualify_max'] != 0) { |
|
225 | - $students[$data['user_id']] = $data['qualify']; |
|
226 | - $counter++; |
|
227 | - $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
228 | - $sumResult += $data['qualify']; |
|
229 | - if ($data['qualify'] > $bestResult) { |
|
230 | - $bestResult = $data['qualify']; |
|
231 | - } |
|
232 | - $weight = $assignment['thread_qualify_max']; |
|
233 | - } |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - if ($counter == 0) { |
|
238 | - return null; |
|
239 | - } else { |
|
240 | - switch ($type) { |
|
241 | - case 'best': |
|
242 | - return array($bestResult, $weight); |
|
243 | - break; |
|
244 | - case 'average': |
|
245 | - return array($sumResult/$counter, $weight); |
|
246 | - break; |
|
247 | - case 'ranking': |
|
248 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
249 | - break; |
|
250 | - default: |
|
251 | - return array($sum, $counter); |
|
252 | - break; |
|
253 | - } |
|
254 | - } |
|
255 | - } |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Lazy load function to get the database table of the student publications |
|
260 | - */ |
|
261 | - private function get_forum_thread_table() |
|
262 | - { |
|
263 | - return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
264 | - } |
|
265 | - |
|
266 | - public function needs_name_and_description() |
|
267 | - { |
|
268 | - return false; |
|
269 | - } |
|
270 | - |
|
271 | - public function needs_max() |
|
272 | - { |
|
273 | - return false; |
|
274 | - } |
|
275 | - |
|
276 | - public function needs_results() |
|
277 | - { |
|
278 | - return false; |
|
279 | - } |
|
212 | + } else { |
|
213 | + // All students -> get average |
|
214 | + $students = array(); // user list, needed to make sure we only |
|
215 | + // take first attempts into account |
|
216 | + $counter = 0; |
|
217 | + $sum = 0; |
|
218 | + $bestResult = 0; |
|
219 | + $weight = 0; |
|
220 | + $sumResult = 0; |
|
221 | + |
|
222 | + while ($data = Database::fetch_array($scores)) { |
|
223 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
224 | + if ($assignment['thread_qualify_max'] != 0) { |
|
225 | + $students[$data['user_id']] = $data['qualify']; |
|
226 | + $counter++; |
|
227 | + $sum += $data['qualify'] / $assignment['thread_qualify_max']; |
|
228 | + $sumResult += $data['qualify']; |
|
229 | + if ($data['qualify'] > $bestResult) { |
|
230 | + $bestResult = $data['qualify']; |
|
231 | + } |
|
232 | + $weight = $assignment['thread_qualify_max']; |
|
233 | + } |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + if ($counter == 0) { |
|
238 | + return null; |
|
239 | + } else { |
|
240 | + switch ($type) { |
|
241 | + case 'best': |
|
242 | + return array($bestResult, $weight); |
|
243 | + break; |
|
244 | + case 'average': |
|
245 | + return array($sumResult/$counter, $weight); |
|
246 | + break; |
|
247 | + case 'ranking': |
|
248 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
249 | + break; |
|
250 | + default: |
|
251 | + return array($sum, $counter); |
|
252 | + break; |
|
253 | + } |
|
254 | + } |
|
255 | + } |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Lazy load function to get the database table of the student publications |
|
260 | + */ |
|
261 | + private function get_forum_thread_table() |
|
262 | + { |
|
263 | + return $this->forum_thread_table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
264 | + } |
|
265 | + |
|
266 | + public function needs_name_and_description() |
|
267 | + { |
|
268 | + return false; |
|
269 | + } |
|
270 | + |
|
271 | + public function needs_max() |
|
272 | + { |
|
273 | + return false; |
|
274 | + } |
|
275 | + |
|
276 | + public function needs_results() |
|
277 | + { |
|
278 | + return false; |
|
279 | + } |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function get_name() |
|
285 | - { |
|
286 | - $this->get_exercise_data(); |
|
287 | - $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
288 | - $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
289 | - if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
290 | - return $this->exercise_data['thread_title_qualify']; |
|
291 | - } else { |
|
292 | - return $thread_title; |
|
293 | - } |
|
294 | - } |
|
284 | + public function get_name() |
|
285 | + { |
|
286 | + $this->get_exercise_data(); |
|
287 | + $thread_title=isset($this->exercise_data['thread_title']) ? $this->exercise_data['thread_title'] : ''; |
|
288 | + $thread_title_qualify=isset($this->exercise_data['thread_title_qualify']) ? $this->exercise_data['thread_title_qualify'] : ''; |
|
289 | + if ( isset($thread_title_qualify) && $thread_title_qualify!="") { |
|
290 | + return $this->exercise_data['thread_title_qualify']; |
|
291 | + } else { |
|
292 | + return $thread_title; |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | 296 | /** |
297 | 297 | * @return string |
298 | 298 | */ |
299 | - public function get_description() |
|
300 | - { |
|
301 | - return '';//$this->exercise_data['description']; |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Check if this still links to an exercise |
|
306 | - */ |
|
307 | - public function is_valid_link() |
|
308 | - { |
|
309 | - $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
299 | + public function get_description() |
|
300 | + { |
|
301 | + return '';//$this->exercise_data['description']; |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Check if this still links to an exercise |
|
306 | + */ |
|
307 | + public function is_valid_link() |
|
308 | + { |
|
309 | + $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().' |
|
310 | 310 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().''; |
311 | - $result = Database::query($sql); |
|
312 | - $number = Database::fetch_row($result); |
|
313 | - return ($number[0] != 0); |
|
314 | - } |
|
315 | - |
|
316 | - public function get_test_id() |
|
317 | - { |
|
318 | - return 'DEBUG:ID'; |
|
319 | - } |
|
320 | - |
|
321 | - public function get_link() |
|
322 | - { |
|
323 | - $sessionId = api_get_session_id(); |
|
324 | - //it was extracts the forum id |
|
325 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
311 | + $result = Database::query($sql); |
|
312 | + $number = Database::fetch_row($result); |
|
313 | + return ($number[0] != 0); |
|
314 | + } |
|
315 | + |
|
316 | + public function get_test_id() |
|
317 | + { |
|
318 | + return 'DEBUG:ID'; |
|
319 | + } |
|
320 | + |
|
321 | + public function get_link() |
|
322 | + { |
|
323 | + $sessionId = api_get_session_id(); |
|
324 | + //it was extracts the forum id |
|
325 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table()." |
|
326 | 326 | WHERE c_id = '.$this->course_id.' AND thread_id = '".$this->get_ref_id()."' AND session_id = ".$sessionId.""; |
327 | - $result = Database::query($sql); |
|
328 | - $row = Database::fetch_array($result,'ASSOC'); |
|
329 | - $forum_id=$row['forum_id']; |
|
330 | - |
|
331 | - $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
332 | - return $url; |
|
333 | - } |
|
334 | - |
|
335 | - private function get_exercise_data() |
|
336 | - { |
|
337 | - $session_id = api_get_session_id(); |
|
338 | - if ($session_id) { |
|
339 | - $session_condition = 'session_id='.api_get_session_id(); |
|
340 | - } else { |
|
341 | - $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
342 | - } |
|
343 | - |
|
344 | - if (!isset($this->exercise_data)) { |
|
345 | - $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
327 | + $result = Database::query($sql); |
|
328 | + $row = Database::fetch_array($result,'ASSOC'); |
|
329 | + $forum_id=$row['forum_id']; |
|
330 | + |
|
331 | + $url = api_get_path(WEB_PATH).'main/forum/viewthread.php?'.api_get_cidreq_params($this->get_course_code(), $sessionId).'&thread='.$this->get_ref_id().'&gradebook=view&forum='.$forum_id; |
|
332 | + return $url; |
|
333 | + } |
|
334 | + |
|
335 | + private function get_exercise_data() |
|
336 | + { |
|
337 | + $session_id = api_get_session_id(); |
|
338 | + if ($session_id) { |
|
339 | + $session_condition = 'session_id='.api_get_session_id(); |
|
340 | + } else { |
|
341 | + $session_condition = '(session_id = 0 OR session_id IS NULL)'; |
|
342 | + } |
|
343 | + |
|
344 | + if (!isset($this->exercise_data)) { |
|
345 | + $sql = 'SELECT * FROM '.$this->get_forum_thread_table().' |
|
346 | 346 | WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND '.$session_condition; |
347 | - $query = Database::query($sql); |
|
348 | - $this->exercise_data = Database::fetch_array($query); |
|
349 | - } |
|
350 | - return $this->exercise_data; |
|
351 | - } |
|
352 | - |
|
353 | - public function get_icon_name() |
|
354 | - { |
|
355 | - return 'forum'; |
|
356 | - } |
|
357 | - |
|
358 | - function save_linked_data() |
|
359 | - { |
|
360 | - $weight = (float)$this->get_weight(); |
|
361 | - $ref_id = $this->get_ref_id(); |
|
362 | - |
|
363 | - if (!empty($ref_id)) { |
|
364 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
347 | + $query = Database::query($sql); |
|
348 | + $this->exercise_data = Database::fetch_array($query); |
|
349 | + } |
|
350 | + return $this->exercise_data; |
|
351 | + } |
|
352 | + |
|
353 | + public function get_icon_name() |
|
354 | + { |
|
355 | + return 'forum'; |
|
356 | + } |
|
357 | + |
|
358 | + function save_linked_data() |
|
359 | + { |
|
360 | + $weight = (float)$this->get_weight(); |
|
361 | + $ref_id = $this->get_ref_id(); |
|
362 | + |
|
363 | + if (!empty($ref_id)) { |
|
364 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET thread_weight='.$weight.' |
|
365 | 365 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
366 | - Database::query($sql); |
|
367 | - } |
|
368 | - } |
|
369 | - |
|
370 | - function delete_linked_data() |
|
371 | - { |
|
372 | - $ref_id = $this->get_ref_id(); |
|
373 | - if (!empty($ref_id)) { |
|
374 | - //Cleans forum |
|
375 | - $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
366 | + Database::query($sql); |
|
367 | + } |
|
368 | + } |
|
369 | + |
|
370 | + function delete_linked_data() |
|
371 | + { |
|
372 | + $ref_id = $this->get_ref_id(); |
|
373 | + if (!empty($ref_id)) { |
|
374 | + //Cleans forum |
|
375 | + $sql = 'UPDATE '.$this->get_forum_thread_table().' SET |
|
376 | 376 | thread_qualify_max = 0, |
377 | 377 | thread_weight = 0, |
378 | 378 | thread_title_qualify = "" |
379 | 379 | WHERE c_id = '.$this->course_id.' AND thread_id= '.$ref_id; |
380 | - Database::query($sql); |
|
381 | - } |
|
382 | - } |
|
380 | + Database::query($sql); |
|
381 | + } |
|
382 | + } |
|
383 | 383 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | //Event::event_download($doc_url); |
24 | 24 | if (isset($_course['path'])) { |
25 | 25 | $course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
26 | - $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
26 | + $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
27 | 27 | } else { |
28 | 28 | $course_path = api_get_path(SYS_COURSE_PATH).$cid.'/document'; |
29 | - $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
29 | + $full_file_name = $course_path.Security::remove_XSS($doc_url); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if(!is_file($full_file_name)) { |
33 | - exit; |
|
33 | + exit; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if (!Security::check_abs_path($full_file_name, $course_path.'/')) { |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | $extension=strtolower($extension[sizeof($extension)-1]); |
42 | 42 | |
43 | 43 | switch($extension) { |
44 | - case 'gz': $content_type='application/x-gzip'; break; |
|
45 | - case 'zip': $content_type='application/zip'; break; |
|
46 | - case 'pdf': $content_type='application/pdf'; break; |
|
47 | - case 'png': $content_type='image/png'; break; |
|
48 | - case 'gif': $content_type='image/gif'; break; |
|
49 | - case 'jpg': $content_type='image/jpeg'; break; |
|
50 | - case 'txt': $content_type='text/plain'; break; |
|
51 | - case 'htm': $content_type='text/html'; break; |
|
52 | - case 'html': $content_type='text/html'; break; |
|
53 | - default: $content_type='application/octet-stream'; break; |
|
44 | + case 'gz': $content_type='application/x-gzip'; break; |
|
45 | + case 'zip': $content_type='application/zip'; break; |
|
46 | + case 'pdf': $content_type='application/pdf'; break; |
|
47 | + case 'png': $content_type='image/png'; break; |
|
48 | + case 'gif': $content_type='image/gif'; break; |
|
49 | + case 'jpg': $content_type='image/jpeg'; break; |
|
50 | + case 'txt': $content_type='text/plain'; break; |
|
51 | + case 'htm': $content_type='text/html'; break; |
|
52 | + case 'html': $content_type='text/html'; break; |
|
53 | + default: $content_type='application/octet-stream'; break; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | header('Content-disposition: filename='.$filename); |
@@ -68,30 +68,30 @@ discard block |
||
68 | 68 | */ |
69 | 69 | |
70 | 70 | if ($content_type == 'text/html') { |
71 | - $directory_name = dirname($full_file_name); |
|
71 | + $directory_name = dirname($full_file_name); |
|
72 | 72 | |
73 | - $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name); |
|
73 | + $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name); |
|
74 | 74 | |
75 | - if($dir[strlen($dir)-1] != '/') { |
|
76 | - $dir.='/'; |
|
77 | - } |
|
75 | + if($dir[strlen($dir)-1] != '/') { |
|
76 | + $dir.='/'; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - //Parse whole file at one |
|
81 | - $fp = fopen($full_file_name, "r"); |
|
82 | - $file_content = fread ($fp, filesize ($full_file_name)); |
|
83 | - fclose($fp); |
|
80 | + //Parse whole file at one |
|
81 | + $fp = fopen($full_file_name, "r"); |
|
82 | + $file_content = fread ($fp, filesize ($full_file_name)); |
|
83 | + fclose($fp); |
|
84 | 84 | $exercisePath = api_get_self(); |
85 | - $exfile = explode('/',$exercisePath); |
|
86 | - $exfile = $exfile[sizeof($exfile)-1]; |
|
87 | - $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile)); |
|
88 | - $exercisePath = $exercisePath; |
|
85 | + $exfile = explode('/',$exercisePath); |
|
86 | + $exfile = $exfile[sizeof($exfile)-1]; |
|
87 | + $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile)); |
|
88 | + $exercisePath = $exercisePath; |
|
89 | 89 | |
90 | - $content = $file_content; |
|
91 | - $mit = "function Finish(){"; |
|
90 | + $content = $file_content; |
|
91 | + $mit = "function Finish(){"; |
|
92 | 92 | |
93 | - $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". |
|
94 | - "function mySaveScore() // This function included by Dokeos System\n". |
|
93 | + $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n". |
|
94 | + "function mySaveScore() // This function included by Dokeos System\n". |
|
95 | 95 | "{\n". |
96 | 96 | " if (SaveScoreVariable==0)\n". |
97 | 97 | " {\n". |
@@ -109,23 +109,23 @@ discard block |
||
109 | 109 | "// Must be included \n". |
110 | 110 | "function Finish(){\n". |
111 | 111 | " mySaveScore();"; |
112 | - $newcontent = str_replace($mit,$js_content,$content); |
|
112 | + $newcontent = str_replace($mit,$js_content,$content); |
|
113 | 113 | |
114 | - $prehref="javascript:void(0);"; |
|
115 | - $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; |
|
116 | - $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
114 | + $prehref="javascript:void(0);"; |
|
115 | + $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; |
|
116 | + $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
117 | 117 | |
118 | 118 | |
119 | - $prehref="class=\"GridNum\" onclick="; |
|
120 | - $posthref="class=\"GridNum\" onMouseover="; |
|
121 | - $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
119 | + $prehref="class=\"GridNum\" onclick="; |
|
120 | + $posthref="class=\"GridNum\" onMouseover="; |
|
121 | + $newcontent = str_replace($prehref,$posthref,$newcontent); |
|
122 | 122 | |
123 | 123 | |
124 | - header('Content-length: '.strlen($newcontent)); |
|
125 | - // Dipsp. |
|
126 | - echo $newcontent; |
|
124 | + header('Content-length: '.strlen($newcontent)); |
|
125 | + // Dipsp. |
|
126 | + echo $newcontent; |
|
127 | 127 | |
128 | - exit(); |
|
128 | + exit(); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | //normal case, all non-html files |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | */ |
83 | 83 | interface WSCMErrorHandler |
84 | 84 | { |
85 | - /** |
|
86 | - * Handle method |
|
87 | - * |
|
88 | - * @param WSError Error |
|
89 | - */ |
|
90 | - public function handle($error); |
|
85 | + /** |
|
86 | + * Handle method |
|
87 | + * |
|
88 | + * @param WSError Error |
|
89 | + */ |
|
90 | + public function handle($error); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,57 +95,57 @@ discard block |
||
95 | 95 | */ |
96 | 96 | class WSCM |
97 | 97 | { |
98 | - /** |
|
99 | - * Chamilo configuration |
|
100 | - * |
|
101 | - * @var array |
|
102 | - */ |
|
103 | - protected $_configuration; |
|
98 | + /** |
|
99 | + * Chamilo configuration |
|
100 | + * |
|
101 | + * @var array |
|
102 | + */ |
|
103 | + protected $_configuration; |
|
104 | 104 | |
105 | - /** |
|
106 | - * Constructor |
|
107 | - */ |
|
108 | - public function __construct() |
|
105 | + /** |
|
106 | + * Constructor |
|
107 | + */ |
|
108 | + public function __construct() |
|
109 | 109 | { |
110 | - $this->_configuration = $GLOBALS['_configuration']; |
|
111 | - } |
|
110 | + $this->_configuration = $GLOBALS['_configuration']; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Verifies the API key |
|
115 | - * |
|
116 | - * @param string Secret key |
|
117 | - * @return mixed WSError in case of failure, null in case of success |
|
118 | - */ |
|
119 | - protected function verifyKey($secret_key) |
|
113 | + /** |
|
114 | + * Verifies the API key |
|
115 | + * |
|
116 | + * @param string Secret key |
|
117 | + * @return mixed WSError in case of failure, null in case of success |
|
118 | + */ |
|
119 | + protected function verifyKey($secret_key) |
|
120 | 120 | { |
121 | - $ip = trim($_SERVER['REMOTE_ADDR']); |
|
122 | - // if we are behind a reverse proxy, assume it will send the |
|
123 | - // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
124 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
125 | - list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
126 | - $ip = trim($ip1); |
|
127 | - } |
|
128 | - $security_key = $ip.$this->_configuration['security_key']; |
|
121 | + $ip = trim($_SERVER['REMOTE_ADDR']); |
|
122 | + // if we are behind a reverse proxy, assume it will send the |
|
123 | + // HTTP_X_FORWARDED_FOR header and use this IP instead |
|
124 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
125 | + list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']); |
|
126 | + $ip = trim($ip1); |
|
127 | + } |
|
128 | + $security_key = $ip.$this->_configuration['security_key']; |
|
129 | 129 | |
130 | - if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
131 | - return new WSCMError(1, "API key is invalid"); |
|
132 | - } else { |
|
133 | - return null; |
|
134 | - } |
|
135 | - } |
|
130 | + if(!api_is_valid_secret_key($secret_key, $security_key)) { |
|
131 | + return new WSCMError(1, "API key is invalid"); |
|
132 | + } else { |
|
133 | + return null; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Verifies if the user is valid |
|
139 | - * |
|
140 | - * @param <String> $username of the user in chamilo |
|
141 | - * @param <String> $pass of the same user (in MD5 of SHA) |
|
142 | - * |
|
143 | - * return "valid" if username e password are correct! Else, return a message error |
|
144 | - */ |
|
145 | - public function verifyUserPass($username, $pass) |
|
137 | + /** |
|
138 | + * Verifies if the user is valid |
|
139 | + * |
|
140 | + * @param <String> $username of the user in chamilo |
|
141 | + * @param <String> $pass of the same user (in MD5 of SHA) |
|
142 | + * |
|
143 | + * return "valid" if username e password are correct! Else, return a message error |
|
144 | + */ |
|
145 | + public function verifyUserPass($username, $pass) |
|
146 | 146 | { |
147 | - $login = $username; |
|
148 | - $password = $pass; |
|
147 | + $login = $username; |
|
148 | + $password = $pass; |
|
149 | 149 | |
150 | 150 | $userRepo = UserManager::getRepository(); |
151 | 151 | /** @var User $uData */ |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | return get_lang('InvalidId'); |
181 | - } |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Gets the real user id based on the user id field name and value. |
|
185 | - * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
186 | - * in the system database |
|
187 | - * |
|
188 | - * @param string User id field name |
|
189 | - * @param string User id value |
|
190 | - * @return mixed System user id if the user was found, WSError otherwise |
|
191 | - */ |
|
183 | + /** |
|
184 | + * Gets the real user id based on the user id field name and value. |
|
185 | + * Note that if the user id field name is "chamilo_user_id", it will use the user id |
|
186 | + * in the system database |
|
187 | + * |
|
188 | + * @param string User id field name |
|
189 | + * @param string User id value |
|
190 | + * @return mixed System user id if the user was found, WSError otherwise |
|
191 | + */ |
|
192 | 192 | protected function getUserId($user_id_field_name, $user_id_value) |
193 | 193 | { |
194 | 194 | if ($user_id_field_name == "chamilo_user_id") { |
@@ -210,16 +210,16 @@ discard block |
||
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | - /** |
|
214 | - * Gets the real course id based on the course id field name and value. |
|
215 | - * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
216 | - * in the system database |
|
217 | - * |
|
218 | - * @param string Course id field name |
|
219 | - * @param string Course id value |
|
220 | - * @return mixed System course id if the course was found, WSError otherwise |
|
221 | - */ |
|
222 | - protected function getCourseId($course_id_field_name, $course_id_value) |
|
213 | + /** |
|
214 | + * Gets the real course id based on the course id field name and value. |
|
215 | + * Note that if the course id field name is "chamilo_course_id", it will use the course id |
|
216 | + * in the system database |
|
217 | + * |
|
218 | + * @param string Course id field name |
|
219 | + * @param string Course id value |
|
220 | + * @return mixed System course id if the course was found, WSError otherwise |
|
221 | + */ |
|
222 | + protected function getCourseId($course_id_field_name, $course_id_value) |
|
223 | 223 | { |
224 | 224 | if ($course_id_field_name == "chamilo_course_id") { |
225 | 225 | if (CourseManager::get_course_code_from_course_id($course_id_value) != null) { |
@@ -238,78 +238,78 @@ discard block |
||
238 | 238 | return $courseId; |
239 | 239 | } |
240 | 240 | } |
241 | - } |
|
241 | + } |
|
242 | 242 | |
243 | - /** |
|
244 | - * Gets the real session id based on the session id field name and value. |
|
245 | - * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
246 | - * in the system database |
|
247 | - * |
|
248 | - * @param string Session id field name |
|
249 | - * @param string Session id value |
|
250 | - * @return mixed System session id if the session was found, WSError otherwise |
|
251 | - */ |
|
252 | - protected function getSessionId($session_id_field_name, $session_id_value) |
|
253 | - { |
|
254 | - if ($session_id_field_name == "chamilo_session_id") { |
|
255 | - $session = SessionManager::fetch((int)$session_id_value); |
|
256 | - if(!empty($session)) { |
|
257 | - return intval($session_id_value); |
|
258 | - } else { |
|
259 | - return new WSCMError(300, "Session not found"); |
|
260 | - } |
|
261 | - } else { |
|
262 | - $session_id = SessionManager::getSessionIdFromOriginalId( |
|
263 | - $session_id_value, |
|
264 | - $session_id_field_name |
|
265 | - ); |
|
266 | - if($session_id == 0) { |
|
267 | - return new WSCMError(300, "Session not found"); |
|
268 | - } else { |
|
269 | - return $session_id; |
|
270 | - } |
|
271 | - } |
|
272 | - } |
|
243 | + /** |
|
244 | + * Gets the real session id based on the session id field name and value. |
|
245 | + * Note that if the session id field name is "chamilo_session_id", it will use the session id |
|
246 | + * in the system database |
|
247 | + * |
|
248 | + * @param string Session id field name |
|
249 | + * @param string Session id value |
|
250 | + * @return mixed System session id if the session was found, WSError otherwise |
|
251 | + */ |
|
252 | + protected function getSessionId($session_id_field_name, $session_id_value) |
|
253 | + { |
|
254 | + if ($session_id_field_name == "chamilo_session_id") { |
|
255 | + $session = SessionManager::fetch((int)$session_id_value); |
|
256 | + if(!empty($session)) { |
|
257 | + return intval($session_id_value); |
|
258 | + } else { |
|
259 | + return new WSCMError(300, "Session not found"); |
|
260 | + } |
|
261 | + } else { |
|
262 | + $session_id = SessionManager::getSessionIdFromOriginalId( |
|
263 | + $session_id_value, |
|
264 | + $session_id_field_name |
|
265 | + ); |
|
266 | + if($session_id == 0) { |
|
267 | + return new WSCMError(300, "Session not found"); |
|
268 | + } else { |
|
269 | + return $session_id; |
|
270 | + } |
|
271 | + } |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Handles an error by calling the WSError error handler |
|
276 | - * |
|
277 | - * @param WSError Error |
|
278 | - */ |
|
279 | - protected function handleError($error) |
|
280 | - { |
|
281 | - $handler = WSCMError::getErrorHandler(); |
|
282 | - $handler->handle($error); |
|
283 | - } |
|
274 | + /** |
|
275 | + * Handles an error by calling the WSError error handler |
|
276 | + * |
|
277 | + * @param WSError Error |
|
278 | + */ |
|
279 | + protected function handleError($error) |
|
280 | + { |
|
281 | + $handler = WSCMError::getErrorHandler(); |
|
282 | + $handler->handle($error); |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Gets a successful result |
|
287 | - * |
|
288 | - * @return array Array with a code of 0 and a message 'Operation was successful' |
|
289 | - */ |
|
290 | - protected function getSuccessfulResult() |
|
291 | - { |
|
292 | - return array('code' => 0, 'message' => 'Operation was successful'); |
|
293 | - } |
|
285 | + /** |
|
286 | + * Gets a successful result |
|
287 | + * |
|
288 | + * @return array Array with a code of 0 and a message 'Operation was successful' |
|
289 | + */ |
|
290 | + protected function getSuccessfulResult() |
|
291 | + { |
|
292 | + return array('code' => 0, 'message' => 'Operation was successful'); |
|
293 | + } |
|
294 | 294 | |
295 | - /** |
|
296 | - * Test function. Returns the string success |
|
297 | - * |
|
298 | - * @return string Success |
|
299 | - */ |
|
300 | - public function test() |
|
301 | - { |
|
302 | - return "success"; |
|
303 | - } |
|
295 | + /** |
|
296 | + * Test function. Returns the string success |
|
297 | + * |
|
298 | + * @return string Success |
|
299 | + */ |
|
300 | + public function test() |
|
301 | + { |
|
302 | + return "success"; |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
307 | - * @param <type> $string |
|
308 | - * @return <type> $string |
|
309 | - */ |
|
310 | - public function nl2br_revert($string) |
|
305 | + /** |
|
306 | + * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not) |
|
307 | + * @param <type> $string |
|
308 | + * @return <type> $string |
|
309 | + */ |
|
310 | + public function nl2br_revert($string) |
|
311 | 311 | { |
312 | - return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
313 | - } |
|
312 | + return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); |
|
313 | + } |
|
314 | 314 | } |
315 | 315 |
@@ -13,21 +13,21 @@ discard block |
||
13 | 13 | |
14 | 14 | public function find_id_user($username, $password, $name) |
15 | 15 | { |
16 | - if ($this->verifyUserPass($username, $password) == "valid") { |
|
16 | + if ($this->verifyUserPass($username, $password) == "valid") { |
|
17 | 17 | $listResult = "#"; |
18 | 18 | |
19 | 19 | $listArrayResult = Array(); |
20 | 20 | $listArray = Array(); |
21 | 21 | |
22 | 22 | $list = $this->get_user_list_like_start(array('firstname'=>$name), array('firstname')); |
23 | - foreach ($list as $userData) { |
|
24 | - $listArray[] = $userData['user_id']; |
|
25 | - } |
|
23 | + foreach ($list as $userData) { |
|
24 | + $listArray[] = $userData['user_id']; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | $list = $this->get_user_list_like_start(array('lastname'=>$name), array('firstname')); |
28 | - foreach ($list as $userData) { |
|
29 | - $listArray[] = $userData['user_id']; |
|
30 | - } |
|
28 | + foreach ($list as $userData) { |
|
29 | + $listArray[] = $userData['user_id']; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | $list = $this->get_user_list_like_start(array('email'=>$name), array('firstname')); |
33 | 33 | foreach ($list as $userData) { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | global $charset; |
91 | 91 | if ($this->verifyUserPass($username, $password) == "valid") { |
92 | - $user_id = UserManager::get_user_id_from_username($username); |
|
92 | + $user_id = UserManager::get_user_id_from_username($username); |
|
93 | 93 | $message_title = get_lang('Invitation'); |
94 | 94 | $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message); |
95 | 95 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | |
130 | 130 | |
131 | 131 | /** |
132 | - * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
133 | - * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
134 | - * @param array $order_by a list of fields on which sort |
|
135 | - * @return array An array with all users of the platform. |
|
136 | - * @todo optional course code parameter, optional sorting parameters... |
|
132 | + * Get a list of users of which the given conditions match with a LIKE '%cond%' |
|
133 | + * @param array $conditions a list of condition (exemple : status=>STUDENT) |
|
134 | + * @param array $order_by a list of fields on which sort |
|
135 | + * @return array An array with all users of the platform. |
|
136 | + * @todo optional course code parameter, optional sorting parameters... |
|
137 | 137 | *@todo Use the UserManager class |
138 | 138 | * @todo security filter order by |
139 | - */ |
|
139 | + */ |
|
140 | 140 | private static function get_user_list_like_start($conditions = array(), $order_by = array()) |
141 | 141 | { |
142 | 142 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |