Completed
Pull Request — 1.11.x (#1688)
by José
28:44
created
src/Chamilo/UserBundle/Entity/Repository/UserRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
                         INNER JOIN ChamiloUserBundle:User AS U WITH UF.friendUserId = U
259 259
                         WHERE
260 260
                             U.status != 6 AND
261
-                            UF.relationType NOT IN(" . USER_RELATION_TYPE_DELETED . ", " . USER_RELATION_TYPE_RRHH . ") AND
261
+                            UF.relationType NOT IN(" . USER_RELATION_TYPE_DELETED.", ".USER_RELATION_TYPE_RRHH.") AND
262 262
                             UF.userId = $currentUserId AND
263 263
                             UF.friendUserId != $currentUserId AND
264 264
                             U = R.user AND
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 $dql = "SELECT DISTINCT U
283 283
                         FROM ChamiloUserBundle:User U
284 284
                         INNER JOIN ChamiloCoreBundle:TrackEOnline T WITH U.id = T.loginUserId
285
-                        WHERE T.loginDate >= '" . $limit_date . "'";
285
+                        WHERE T.loginDate >= '" . $limit_date."'";
286 286
             }
287 287
         }
288 288
 
Please login to merge, or discard this patch.
plugin/ims_lti/create.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
         Display::return_message($plugin->get_lang('ToolAdded'), 'success')
34 34
     );
35 35
 
36
-    header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/list.php');
36
+    header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/list.php');
37 37
     exit;
38 38
 }
39 39
 
Please login to merge, or discard this patch.
plugin/ims_lti/OAuthSimple.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @param shared_secret (String) The shared secret. This value is also usually provided by the site you wish to use.
26 26
 	 * @return OAuthSimple (Object)
27 27
      */
28
-    function __construct ($APIKey = "", $sharedSecret=""){
28
+    function __construct($APIKey = "", $sharedSecret = "") {
29 29
 
30 30
         if (!empty($APIKey))
31 31
 		{
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 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 66
 	 * @return OAuthSimple (Object)
67 67
 	 */
68
-    public function setParameters ($parameters=Array()) {
68
+    public function setParameters($parameters = Array()) {
69 69
 
70 70
         if (is_string($parameters))
71 71
 		{
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		}
78 78
         else if (!empty($parameters))
79 79
 		{
80
-			$this->_parameters = array_merge($this->_parameters,$parameters);
80
+			$this->_parameters = array_merge($this->_parameters, $parameters);
81 81
 		}
82 82
         if (empty($this->_parameters['oauth_nonce']))
83 83
 		{
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		}
102 102
         if (empty($this->_parameters['oauth_version']))
103 103
 		{
104
-            $this->_parameters['oauth_version']="1.0";
104
+            $this->_parameters['oauth_version'] = "1.0";
105 105
 		}
106 106
 
107 107
         return $this;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @access public
114 114
 	 * @see setParameters
115 115
 	 */
116
-    public function setQueryString ($parameters)
116
+    public function setQueryString($parameters)
117 117
     {
118 118
         return $this->setParameters($parameters);
119 119
     }
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
      * @param path (String) the fully qualified URI (excluding query arguments) (e.g "http://example.org/foo")
125 125
 	 * @return OAuthSimple (Object)
126 126
      */
127
-    public function setURL ($path)
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
-        $this->_path=$path;
133
+        $this->_path = $path;
134 134
 
135 135
         return $this;
136 136
     }
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
      * @param path (String)
142 142
 	 * @see setURL
143 143
      */
144
-    public function setPath ($path)
144
+    public function setPath($path)
145 145
     {
146
-        return $this->_path=$path;
146
+        return $this->_path = $path;
147 147
     }
148 148
 
149 149
     /**
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
      * @param action (String) HTTP Action word.
153 153
 	 * @return OAuthSimple (Object)
154 154
      */
155
-    public function setAction ($action)
155
+    public function setAction($action)
156 156
     {
157 157
         if (empty($action))
158 158
 		{
159 159
 			$action = 'GET';
160 160
 		}
161 161
         $action = strtoupper($action);
162
-        if (preg_match('/[^A-Z]/',$action))
162
+        if (preg_match('/[^A-Z]/', $action))
163 163
 		{
164 164
             throw new OAuthSimpleException('Invalid action specified for OAuthSimple.setAction');
165 165
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      * @param signatures (object) object/hash of the token/signature pairs {api_key:, shared_secret:, oauth_token: oauth_secret:}
175 175
 	 * @return OAuthSimple (Object)
176 176
      */
177
-    public function signatures ($signatures)
177
+    public function signatures($signatures)
178 178
     {
179 179
         if (!empty($signatures) && !is_array($signatures))
180 180
 		{
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
         {
185 185
             if (empty($this->_secrets))
186 186
             {
187
-                $this->_secrets=Array();
187
+                $this->_secrets = Array();
188 188
             }
189
-            $this->_secrets=array_merge($this->_secrets,$signatures);
189
+            $this->_secrets = array_merge($this->_secrets, $signatures);
190 190
         }
191 191
         if (isset($this->_secrets['api_key']))
192 192
 		{
@@ -231,21 +231,21 @@  discard block
 block discarded – undo
231 231
      * @param method (String) Method of signing the transaction (only PLAINTEXT and SHA-MAC1 allowed for now)
232 232
 	 * @return OAuthSimple (Object)
233 233
     */
234
-    public function setSignatureMethod ($method="")
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
-        switch($method)
241
+        switch ($method)
242 242
         {
243 243
             case 'PLAINTEXT':
244 244
             case 'HMAC-SHA1':
245
-                $this->_parameters['oauth_signature_method']=$method;
245
+                $this->_parameters['oauth_signature_method'] = $method;
246 246
 				break;
247 247
             default:
248
-                throw new OAuthSimpleException ("Unknown signing method $method specified for OAuthSimple.setSignatureMethod");
248
+                throw new OAuthSimpleException("Unknown signing method $method specified for OAuthSimple.setSignatureMethod");
249 249
 				break;
250 250
         }
251 251
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      * @param args (Array) hash of arguments for the call {action, path, parameters (array), method, signatures (array)} all arguments are optional.
261 261
 	 * @return (Array) signed values
262 262
      */
263
-    public function sign($args=array())
263
+    public function sign($args = array())
264 264
     {
265 265
         if (!empty($args['action']))
266 266
 		{
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
 		}
281 281
         if (empty($args['parameters']))
282 282
 		{
283
-            $args['parameters']=array();
283
+            $args['parameters'] = array();
284 284
 		}
285 285
         $this->setParameters($args['parameters']);
286 286
         $normParams = $this->_normalizedParameters();
287 287
 
288
-        return Array (
288
+        return Array(
289 289
             'parameters' => $this->_parameters,
290 290
             'signature' => self::_oauthEscape($this->_parameters['oauth_signature']),
291
-            'signed_url' => $this->_path . '?' . $normParams,
291
+            'signed_url' => $this->_path.'?'.$normParams,
292 292
             'header' => $this->getHeaderString(),
293 293
             'sbs'=> $this->sbs
294 294
             );
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
      * @param args (Array)
305 305
 	 * @return $result (String)
306 306
     */
307
-    public function getHeaderString ($args=array())
307
+    public function getHeaderString($args = array())
308 308
     {
309 309
         if (empty($this->_parameters['oauth_signature']))
310 310
 		{
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
         foreach ($this->_parameters as $pName => $pValue)
316 316
         {
317
-            if (strpos($pName,'oauth_') !== 0)
317
+            if (strpos($pName, 'oauth_') !== 0)
318 318
 			{
319 319
                 continue;
320 320
 			}
@@ -322,25 +322,25 @@  discard block
 block discarded – undo
322 322
             {
323 323
                 foreach ($pValue as $val)
324 324
                 {
325
-                    $result .= $pName .'="' . self::_oauthEscape($val) . '", ';
325
+                    $result .= $pName.'="'.self::_oauthEscape($val).'", ';
326 326
                 }
327 327
             }
328 328
             else
329 329
             {
330
-                $result .= $pName . '="' . self::_oauthEscape($pValue) . '", ';
330
+                $result .= $pName.'="'.self::_oauthEscape($pValue).'", ';
331 331
             }
332 332
         }
333 333
 
334
-        return preg_replace('/, $/','',$result);
334
+        return preg_replace('/, $/', '', $result);
335 335
     }
336 336
 
337
-    private function _parseParameterString ($paramString)
337
+    private function _parseParameterString($paramString)
338 338
     {
339
-        $elements = explode('&',$paramString);
339
+        $elements = explode('&', $paramString);
340 340
         $result = array();
341 341
         foreach ($elements as $element)
342 342
         {
343
-            list ($key,$token) = explode('=',$element);
343
+            list ($key, $token) = explode('=', $element);
344 344
             if ($token)
345 345
 			{
346 346
                 $token = urldecode($token);
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
             {
350 350
                 if (!is_array($result[$key]))
351 351
 				{
352
-                    $result[$key] = array($result[$key],$token);
352
+                    $result[$key] = array($result[$key], $token);
353 353
 				}
354 354
                 else
355 355
 				{
356
-                    array_push($result[$key],$token);
356
+                    array_push($result[$key], $token);
357 357
 				}
358 358
             }
359 359
             else
360
-                $result[$key]=$token;
360
+                $result[$key] = $token;
361 361
         }
362 362
         return $result;
363 363
     }
@@ -375,21 +375,21 @@  discard block
 block discarded – undo
375 375
 
376 376
 	    //FIX: urlencode of ~ and '+'
377 377
         $string = str_replace(
378
-            Array('%7E','+'  ), // Replace these
379
-            Array('~',  '%20'), // with these
378
+            Array('%7E', '+'), // Replace these
379
+            Array('~', '%20'), // with these
380 380
             $string);
381 381
 
382 382
         return $string;
383 383
     }
384 384
 
385
-    private function _getNonce($length=5)
385
+    private function _getNonce($length = 5)
386 386
     {
387 387
         $result = '';
388 388
         $cLength = strlen($this->_nonce_chars);
389
-        for ($i=0; $i < $length; $i++)
389
+        for ($i = 0; $i < $length; $i++)
390 390
         {
391
-            $rnum = rand(0,$cLength - 1);
392
-            $result .= substr($this->_nonce_chars,$rnum,1);
391
+            $rnum = rand(0, $cLength - 1);
392
+            $result .= substr($this->_nonce_chars, $rnum, 1);
393 393
         }
394 394
         $this->_parameters['oauth_nonce'] = $result;
395 395
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
         {
403 403
             throw new OAuthSimpleException('No consumer_key set for OAuthSimple');
404 404
         }
405
-        $this->_parameters['oauth_consumer_key']=$this->_secrets['consumer_key'];
405
+        $this->_parameters['oauth_consumer_key'] = $this->_secrets['consumer_key'];
406 406
 
407 407
         return $this->_parameters['oauth_consumer_key'];
408 408
     }
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		$normalized_keys = array();
433 433
 		$return_array = array();
434 434
 
435
-        foreach ( $this->_parameters as $paramName=>$paramValue) {
435
+        foreach ($this->_parameters as $paramName=>$paramValue) {
436 436
             if (preg_match('/w+_secret/', $paramName) OR
437 437
                 $paramName == "oauth_signature") {
438 438
                     continue;
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 				if (is_array($paramValue))
444 444
 				{
445 445
 					$normalized_keys[self::_oauthEscape($paramName)] = array();
446
-					foreach($paramValue as $item)
446
+					foreach ($paramValue as $item)
447 447
 					{
448
-						array_push($normalized_keys[self::_oauthEscape($paramName)],  self::_oauthEscape($item));
448
+						array_push($normalized_keys[self::_oauthEscape($paramName)], self::_oauthEscape($item));
449 449
 					}
450 450
 				}
451 451
 				else
@@ -457,54 +457,54 @@  discard block
 block discarded – undo
457 457
 
458 458
 		ksort($normalized_keys);
459 459
 
460
-		foreach($normalized_keys as $key=>$val)
460
+		foreach ($normalized_keys as $key=>$val)
461 461
 		{
462 462
 			if (is_array($val))
463 463
 			{
464 464
 				sort($val);
465
-				foreach($val as $element)
465
+				foreach ($val as $element)
466 466
 				{
467
-					array_push($return_array, $key . "=" . $element);
467
+					array_push($return_array, $key."=".$element);
468 468
 				}
469 469
 			}
470 470
 			else
471 471
 			{
472
-				array_push($return_array, $key .'='. $val);
472
+				array_push($return_array, $key.'='.$val);
473 473
 			}
474 474
 
475 475
         }
476 476
         $presig = join("&", $return_array);
477 477
         $sig = $this->_generateSignature($presig);
478
-        $this->_parameters['oauth_signature']=$sig;
478
+        $this->_parameters['oauth_signature'] = $sig;
479 479
         array_push($return_array, "oauth_signature=$sig");
480 480
 		return join("&", $return_array);
481 481
     }
482 482
 
483 483
 
484
-    private function _generateSignature ($parameters="")
484
+    private function _generateSignature($parameters = "")
485 485
     {
486 486
         $secretKey = '';
487
-		if(isset($this->_secrets['shared_secret']))
487
+		if (isset($this->_secrets['shared_secret']))
488 488
 		{
489 489
 			$secretKey = self::_oauthEscape($this->_secrets['shared_secret']);
490 490
 		}
491 491
 
492 492
 		$secretKey .= '&';
493
-		if(isset($this->_secrets['oauth_secret']))
493
+		if (isset($this->_secrets['oauth_secret']))
494 494
 		{
495 495
             $secretKey .= self::_oauthEscape($this->_secrets['oauth_secret']);
496 496
         }
497
-        if(!empty($parameters)){
497
+        if (!empty($parameters)) {
498 498
             $parameters = urlencode($parameters);
499 499
         }
500
-        switch($this->_parameters['oauth_signature_method'])
500
+        switch ($this->_parameters['oauth_signature_method'])
501 501
         {
502 502
             case 'PLAINTEXT':
503
-                return urlencode($secretKey);;
503
+                return urlencode($secretKey); ;
504 504
             case 'HMAC-SHA1':
505 505
                 $this->sbs = self::_oauthEscape($this->_action).'&'.self::_oauthEscape($this->_path).'&'.$parameters;
506 506
 
507
-                return base64_encode(hash_hmac('sha1',$this->sbs,$secretKey,TRUE));
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 510
 				break;
Please login to merge, or discard this patch.
plugin/ims_lti/edit.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         Display::return_message($plugin->get_lang('NoTool'), 'error')
21 21
     );
22 22
 
23
-    header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/list.php');
23
+    header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/list.php');
24 24
     exit;
25 25
 }
26 26
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         Display::return_message($plugin->get_lang('ToolEdited'), 'success')
59 59
     );
60 60
 
61
-    header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/list.php');
61
+    header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/list.php');
62 62
     exit;
63 63
 }
64 64
 
Please login to merge, or discard this patch.
plugin/ims_lti/ImsLtiTool.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@
 block discarded – undo
173 173
         $foo = explode('=', $strings);
174 174
 
175 175
         return [
176
-            'key' => 'custom_' . $foo[0],
176
+            'key' => 'custom_'.$foo[0],
177 177
             'value' => $foo[1]
178 178
         ];
179 179
     }
Please login to merge, or discard this patch.
plugin/ims_lti/ImsLtiPlugin.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             return false;
112 112
         }
113 113
 
114
-        $sql = 'DROP TABLE IF EXISTS ' . self::TABLE_TOOL;
114
+        $sql = 'DROP TABLE IF EXISTS '.self::TABLE_TOOL;
115 115
         Database::query($sql);
116 116
 
117 117
         return true;
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $button = Display::toolbarButton(
126 126
             $this->get_lang('AddExternalTool'),
127
-            api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/add.php',
127
+            api_get_path(WEB_PLUGIN_PATH).'ims_lti/add.php',
128 128
             'cog',
129 129
             'primary'
130 130
         );
131 131
 
132 132
         $this->course_settings = [
133 133
             [
134
-                'name' => $this->get_lang('ImsLtiDescription') . $button . '<hr>',
134
+                'name' => $this->get_lang('ImsLtiDescription').$button.'<hr>',
135 135
                 'type' => 'html'
136 136
             ]
137 137
         ];
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             ->setId($cToolId)
154 154
             ->setCId($course->getId())
155 155
             ->setName($tool->getName())
156
-            ->setLink($this->get_name() . '/start.php?' . http_build_query(['id' => $tool->getId()]))
157
-            ->setImage($this->get_name() . '.png')
156
+            ->setLink($this->get_name().'/start.php?'.http_build_query(['id' => $tool->getId()]))
157
+            ->setImage($this->get_name().'.png')
158 158
             ->setVisibility(1)
159 159
             ->setAdmin(0)
160 160
             ->setAddress('squaregray.gif')
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         $text = $this->get_lang('ImsLtiDescription');
173 173
         $text .= sprintf(
174 174
             $this->get_lang('ManageToolButton'),
175
-            api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/list.php'
175
+            api_get_path(WEB_PLUGIN_PATH).'ims_lti/list.php'
176 176
         );
177 177
 
178 178
         return $text;
Please login to merge, or discard this patch.
plugin/ims_lti/start.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 if (empty($toolId)) {
8 8
     if (api_is_platform_admin()) {
9
-        header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/list.php');
9
+        header('Location: '.api_get_path(WEB_PLUGIN_PATH).'ims_lti/list.php');
10 10
         exit;
11 11
     }
12 12
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 $template = new Template($imsLtiPlugin->get_title());
26 26
 $template->assign(
27 27
     'launch_url',
28
-    api_get_path(WEB_PLUGIN_PATH) . 'ims_lti/form.php?' . http_build_query(['id' => $tool->getId()])
28
+    api_get_path(WEB_PLUGIN_PATH).'ims_lti/form.php?'.http_build_query(['id' => $tool->getId()])
29 29
 );
30 30
 
31 31
 $content = $template->fetch('ims_lti/view/start.tpl');
Please login to merge, or discard this patch.
main/dropbox/dropbox_download.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
     if ($_GET['sent_received'] == 'sent') {
33 33
         // here we also incorporate the person table to make sure that deleted sent documents are not included.
34 34
         $sql = "SELECT DISTINCT file.id, file.filename, file.title
35
-                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." file
36
-                INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." person
35
+                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE)." file
36
+                INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_PERSON)." person
37 37
                 ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
38 38
                 WHERE
39 39
                     file.uploader_id = $user_id AND
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 
44 44
     if ($_GET['sent_received'] == 'received') {
45 45
         $sql = "SELECT DISTINCT file.id, file.filename, file.title
46
-                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." file
47
-                INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." person
46
+                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE)." file
47
+                INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_PERSON)." person
48 48
                 ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
49 49
                 INNER JOIN ".Database::get_course_table(TABLE_DROPBOX_POST)." post
50 50
                 ON (post.file_id = file.id AND post.c_id = $course_id AND file.c_id = $course_id)
51 51
                 WHERE
52 52
                     post.cat_id = ".intval($_GET['cat_id'])." AND
53
-                    post.dest_user_id = $user_id" ;
53
+                    post.dest_user_id = $user_id";
54 54
     }
55 55
     $files_to_download = array();
56 56
     $result = Database::query($sql);
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
     $work = new Dropbox_Work($_GET['id']);
99 99
 
100
-    $path = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox/' . $work -> filename; //path to file as stored on server
100
+    $path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$work -> filename; //path to file as stored on server
101 101
 
102
-    if (!Security::check_abs_path($path, api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox/')) {
102
+    if (!Security::check_abs_path($path, api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/')) {
103 103
         exit;
104 104
     }
105 105
     $file = $work->title;
Please login to merge, or discard this patch.
main/dropbox/dropbox_functions.inc.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     // STEP 2: at least one file has to be selected. If not we return an error message
44 44
     $ids = isset($_GET['id']) ? $_GET['id'] : array();
45
-    if (count($ids)>0) {
45
+    if (count($ids) > 0) {
46 46
         $checked_file_ids = $_POST['id'];
47 47
     } else {
48 48
         foreach ($_POST as $key => $value) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     }
134 134
 
135 135
     $cat = get_dropbox_category($id);
136
-    if (count($cat)==0) {
136
+    if (count($cat) == 0) {
137 137
         return false;
138 138
     }
139 139
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     }
158 158
 
159 159
     // step 1: delete the category
160
-    $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
160
+    $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
161 161
             WHERE c_id = $course_id AND cat_id='".intval($id)."' AND $sentreceived='1'";
162 162
     Database::query($sql);
163 163
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
             $return_message = get_lang('ReceivedFileMoved');
236 236
         }
237 237
         if ($part == 'sent') {
238
-            $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
238
+            $sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FILE)."
239 239
                     SET cat_id = ".intval($target)."
240 240
                     WHERE
241 241
                         c_id = $course_id AND
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     $session_id = api_get_session_id();
271 271
     $condition_session = api_get_session_condition($session_id);
272 272
 
273
-    $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
273
+    $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
274 274
             WHERE c_id = $course_id AND user_id='".$_user['user_id']."' $condition_session";
275 275
 
276 276
     $result = Database::query($sql);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 {
293 293
     $course_id = api_get_course_int_id();
294 294
     if (empty($id) or $id != intval($id)) { return array(); }
295
-    $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
295
+    $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
296 296
             WHERE c_id = $course_id AND cat_id='".$id."'";
297 297
     $res = Database::query($sql);
298 298
     if ($res === false) {
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
     if (!isset($_POST['edit_id'])) {
342 342
         $session_id = api_get_session_id();
343 343
         // step 3a, we check if the category doesn't already exist
344
-        $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
344
+        $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
345 345
                 WHERE
346 346
                     c_id = $course_id AND
347 347
                     user_id='".$_user['user_id']."' AND
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
             ];
365 365
             $id = Database::insert(Database::get_course_table(TABLE_DROPBOX_CATEGORY), $params);
366 366
             if ($id) {
367
-                $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ." SET cat_id = iid WHERE iid = $id";
367
+                $sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)." SET cat_id = iid WHERE iid = $id";
368 368
                 Database::query($sql);
369 369
             }
370 370
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 
414 414
     if (isset($id) && $id != '') {
415 415
         // retrieve the category we are editing
416
-        $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
416
+        $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
417 417
                 WHERE c_id = $course_id AND cat_id = ".intval($id);
418 418
         $result = Database::query($sql);
419 419
         $row = Database::fetch_array($result);
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 
603 603
                 $full_name = $userInfo['complete_name'].$groupNameListToString;
604 604
                 $current_user_id = $current_user['user_id'];
605
-                $options['user_' . $current_user_id] = $full_name;
605
+                $options['user_'.$current_user_id] = $full_name;
606 606
             }
607 607
         }
608 608
     }
@@ -702,8 +702,8 @@  discard block
 block discarded – undo
702 702
 
703 703
     // select all files that aren't referenced anymore
704 704
     $sql = "SELECT DISTINCT f.id, f.filename
705
-            FROM " . Database::get_course_table(TABLE_DROPBOX_FILE) . " f
706
-            LEFT JOIN " . Database::get_course_table(TABLE_DROPBOX_PERSON) . " p
705
+            FROM " . Database::get_course_table(TABLE_DROPBOX_FILE)." f
706
+            LEFT JOIN " . Database::get_course_table(TABLE_DROPBOX_PERSON)." p
707 707
             ON (f.id = p.file_id)
708 708
             WHERE p.user_id IS NULL AND
709 709
                   f.c_id = $course_id
@@ -711,14 +711,14 @@  discard block
 block discarded – undo
711 711
     $result = Database::query($sql);
712 712
     while ($res = Database::fetch_array($result)) {
713 713
         //delete the selected files from the post and file tables
714
-        $sql = "DELETE FROM " . Database::get_course_table(TABLE_DROPBOX_POST) . "
715
-                WHERE c_id = $course_id AND file_id = '" . $res['id'] . "'";
714
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
715
+                WHERE c_id = $course_id AND file_id = '".$res['id']."'";
716 716
         Database::query($sql);
717
-        $sql = "DELETE FROM " . Database::get_course_table(TABLE_DROPBOX_FILE) . "
718
-                WHERE c_id = $course_id AND id ='" . $res['id'] . "'";
717
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_FILE)."
718
+                WHERE c_id = $course_id AND id ='".$res['id']."'";
719 719
         Database::query($sql);
720 720
         //delete file from server
721
-        @unlink( api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox/' . $res['filename']);
721
+        @unlink(api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$res['filename']);
722 722
     }
723 723
 }
724 724
 
@@ -740,11 +740,11 @@  discard block
 block discarded – undo
740 740
 
741 741
     $mailingPseudoId = intval($mailingPseudoId);
742 742
     $sql = "SELECT f.uploader_id
743
-            FROM " . Database::get_course_table(TABLE_DROPBOX_FILE) . " f
744
-            LEFT JOIN " . Database::get_course_table(TABLE_DROPBOX_POST) . " p
743
+            FROM " . Database::get_course_table(TABLE_DROPBOX_FILE)." f
744
+            LEFT JOIN " . Database::get_course_table(TABLE_DROPBOX_POST)." p
745 745
             ON (f.id = p.file_id AND f.c_id = $course_id AND p.c_id = $course_id)
746 746
             WHERE
747
-                p.dest_user_id = '" . $mailingPseudoId . "' AND
747
+                p.dest_user_id = '".$mailingPseudoId."' AND
748 748
                 p.c_id = $course_id
749 749
             ";
750 750
     $result = Database::query($sql);
@@ -770,21 +770,21 @@  discard block
 block discarded – undo
770 770
     //    for all content files, replace mailingPseudoId by owner as uploader
771 771
     $file_id = intval($file_id);
772 772
     $sql = "SELECT p.dest_user_id
773
-            FROM " . Database::get_course_table(TABLE_DROPBOX_POST) . " p
774
-            WHERE c_id = $course_id AND p.file_id = '" . $file_id . "'";
773
+            FROM " . Database::get_course_table(TABLE_DROPBOX_POST)." p
774
+            WHERE c_id = $course_id AND p.file_id = '".$file_id."'";
775 775
     $result = Database::query($sql);
776 776
 
777 777
     if ($res = Database::fetch_array($result)) {
778 778
         $mailingPseudoId = $res['dest_user_id'];
779 779
         $mailId = get_mail_id_base();
780 780
         if ($mailingPseudoId > $mailId) {
781
-            $sql = "DELETE FROM " . Database::get_course_table(TABLE_DROPBOX_PERSON) . "
782
-                    WHERE c_id = $course_id AND user_id='" . $mailingPseudoId . "'";
781
+            $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
782
+                    WHERE c_id = $course_id AND user_id='".$mailingPseudoId."'";
783 783
             Database::query($sql);
784 784
 
785
-            $sql = "UPDATE " . Database::get_course_table(TABLE_DROPBOX_FILE) ."
786
-                    SET uploader_id='" . api_get_user_id() . "'
787
-                    WHERE c_id = $course_id AND uploader_id='" . $mailingPseudoId . "'";
785
+            $sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FILE)."
786
+                    SET uploader_id='" . api_get_user_id()."'
787
+                    WHERE c_id = $course_id AND uploader_id='".$mailingPseudoId."'";
788 788
             Database::query($sql);
789 789
         }
790 790
     }
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
             }
926 926
         }
927 927
     } else {  // rename file to login_filename_uniqueId format
928
-        $dropbox_filename = $_user['username'] . "_" . $dropbox_filename . "_".uniqid('');
928
+        $dropbox_filename = $_user['username']."_".$dropbox_filename."_".uniqid('');
929 929
     }
930 930
 
931 931
     // creating the array that contains all the users who will receive the file
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
         }
945 945
     }
946 946
 
947
-    @move_uploaded_file($dropbox_filetmpname, api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/dropbox/' . $dropbox_filename);
947
+    @move_uploaded_file($dropbox_filetmpname, api_get_path(SYS_COURSE_PATH).$_course['path'].'/dropbox/'.$dropbox_filename);
948 948
 
949 949
     $b_send_mail = api_get_course_setting('email_alert_on_new_doc_dropbox');
950 950
 
@@ -965,14 +965,14 @@  discard block
 block discarded – undo
965 965
                 ),
966 966
                 $recipent_temp['email'],
967 967
                 get_lang('NewDropboxFileUploaded'),
968
-                get_lang('NewDropboxFileUploadedContent').' <a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?' . api_get_cidreq() . '">'.get_lang('SeeFile').'</a>'.
968
+                get_lang('NewDropboxFileUploadedContent').' <a href="'.api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq().'">'.get_lang('SeeFile').'</a>'.
969 969
                 "\n\n".
970 970
                 api_get_person_name(
971 971
                     $_user['firstName'],
972 972
                     $_user['lastName'],
973 973
                     null,
974 974
                     PERSON_NAME_EMAIL_ADDRESS
975
-                )."\n".  get_lang('Email') ." : ".$_user['mail'],
975
+                )."\n".get_lang('Email')." : ".$_user['mail'],
976 976
                 api_get_person_name(
977 977
                     $_user['firstName'],
978 978
                     $_user['lastName'],
@@ -1068,12 +1068,12 @@  discard block
 block discarded – undo
1068 1068
     $id = intval($id);
1069 1069
     $user_id = intval($user_id);
1070 1070
 
1071
-    $sql = "SELECT file_id FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
1071
+    $sql = "SELECT file_id FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
1072 1072
             WHERE c_id = $course_id AND user_id = $user_id AND file_id = ".$id;
1073 1073
     $result = Database::query($sql);
1074 1074
     $number_users_who_see_file = Database::num_rows($result);
1075 1075
 
1076
-    $sql = "SELECT file_id FROM ". Database::get_course_table(TABLE_DROPBOX_POST) ."
1076
+    $sql = "SELECT file_id FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
1077 1077
             WHERE c_id = $course_id AND dest_user_id = $user_id AND file_id = ".$id;
1078 1078
     $result = Database::query($sql);
1079 1079
     $count = Database::num_rows($result);
@@ -1087,12 +1087,12 @@  discard block
 block discarded – undo
1087 1087
 {
1088 1088
     $id = intval($id);
1089 1089
     $course_id = api_get_course_int_id();
1090
-    $sql = "SELECT file_id FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
1090
+    $sql = "SELECT file_id FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
1091 1091
             WHERE c_id = $course_id AND file_id = ".$id;
1092 1092
     $result = Database::query($sql);
1093 1093
     $number_users_who_see_file = Database::num_rows($result);
1094 1094
 
1095
-    $sql = "SELECT file_id FROM ". Database::get_course_table(TABLE_DROPBOX_POST) ."
1095
+    $sql = "SELECT file_id FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
1096 1096
             WHERE c_id = $course_id AND file_id = ".$id;
1097 1097
     $result = Database::query($sql);
1098 1098
     $count = Database::num_rows($result);
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 
1125 1125
         $id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FEEDBACK), $params);
1126 1126
         if ($id) {
1127
-            $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK) ." SET feedback_id = iid WHERE iid = $id";
1127
+            $sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FEEDBACK)." SET feedback_id = iid WHERE iid = $id";
1128 1128
             Database::query($sql);
1129 1129
         }
1130 1130
 
@@ -1151,10 +1151,10 @@  discard block
 block discarded – undo
1151 1151
 
1152 1152
     // note: we also have to add the check if the user has received or sent this file.
1153 1153
     $sql = "SELECT DISTINCT file.filename, file.title, file.author, file.description
1154
-            FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ." file
1155
-            INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." person
1154
+            FROM ". Database::get_course_table(TABLE_DROPBOX_FILE)." file
1155
+            INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_PERSON)." person
1156 1156
             ON (person.file_id=file.id AND file.c_id = $course_id AND person.c_id = $course_id)
1157
-            INNER JOIN ". Database::get_course_table(TABLE_DROPBOX_POST) ." post
1157
+            INNER JOIN ".Database::get_course_table(TABLE_DROPBOX_POST)." post
1158 1158
             ON (post.file_id = file.id AND post.c_id = $course_id AND file.c_id = $course_id)
1159 1159
             WHERE
1160 1160
                 file.id IN (".implode(', ', $fileList).") AND
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
         // Adding the content.
1249 1249
         $return .= "\n<tr>";
1250 1250
         foreach ($column as $column_key => $column_value) {
1251
-            if (!in_array($column_value,$dont_show_columns)) {
1251
+            if (!in_array($column_value, $dont_show_columns)) {
1252 1252
                 $return .= "\n\t<td>";
1253 1253
                 if (in_array($column_value, $make_link)) {
1254 1254
                     $return .= '<a href="'.$value[$column_value].'">'.$value[$column_value].'</a>';
@@ -1276,11 +1276,11 @@  discard block
 block discarded – undo
1276 1276
 {
1277 1277
     $course_id = api_get_course_int_id();
1278 1278
     $sql = "SELECT COUNT(feedback_id) AS total, file_id
1279
-            FROM ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK) ."
1279
+            FROM ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK)."
1280 1280
             WHERE c_id = $course_id GROUP BY file_id";
1281 1281
     $result = Database::query($sql);
1282 1282
     $return = array();
1283
-    while ($row=Database::fetch_array($result)) {
1283
+    while ($row = Database::fetch_array($result)) {
1284 1284
         $return[$row['file_id']] = $row['total'];
1285 1285
     }
1286 1286
     return $return;
Please login to merge, or discard this patch.