Completed
Push — 1.11.x ( d00fca...f1f062 )
by José
28:05
created
main/admin/skill_profile.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 $listAction = api_get_self();
19 19
 
20
-$action =  '';
20
+$action = '';
21 21
 if (isset($_GET['action']) && in_array($_GET['action'], ['add', 'edit', 'delete', 'move_up', 'move_down'])) {
22 22
     $action = $_GET['action'];
23 23
 }
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 }
44 44
 $formToDisplay = $form->returnForm();
45 45
 
46
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
47
-$interbreadcrumb[] = array ('url' => 'skill.php', 'name' => get_lang('ManageSkillsLevels'));
48
-$interbreadcrumb[] = array ('url' =>  api_get_self(), 'name' => get_lang('SkillProfile'));
46
+$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
47
+$interbreadcrumb[] = array('url' => 'skill.php', 'name' => get_lang('ManageSkillsLevels'));
48
+$interbreadcrumb[] = array('url' =>  api_get_self(), 'name' => get_lang('SkillProfile'));
49 49
 
50 50
 $tpl = new Template($action);
51 51
 switch ($action) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         $position = $item->getPosition();
57 57
 
58 58
         if (!empty($position)) {
59
-            $item->setPosition($position-1);
59
+            $item->setPosition($position - 1);
60 60
         }
61 61
         $em->persist($item);
62 62
         $em->flush();
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
         $position = $item->getPosition();
71 71
 
72
-        $item->setPosition($position+1);
72
+        $item->setPosition($position + 1);
73 73
 
74 74
         $em->persist($item);
75 75
         $em->flush();
Please login to merge, or discard this patch.
main/document/create_audio.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -63,35 +63,35 @@  discard block
 block discarded – undo
63 63
 }
64 64
 
65 65
 if ($dir[0] != '/') {
66
-    $dir = '/' . $dir;
66
+    $dir = '/'.$dir;
67 67
 }
68 68
 
69 69
 if ($dir[strlen($dir) - 1] != '/') {
70 70
     $dir .= '/';
71 71
 }
72 72
 
73
-$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
73
+$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
74 74
 
75 75
 if (!is_dir($filepath)) {
76
-    $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
76
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
77 77
     $dir = '/';
78 78
 }
79 79
 
80 80
 //groups //TODO: clean
81 81
 if (!empty($groupId)) {
82 82
     $interbreadcrumb[] = array(
83
-        "url" => "../group/group_space.php?" . api_get_cidreq(),
83
+        "url" => "../group/group_space.php?".api_get_cidreq(),
84 84
         "name" => get_lang('GroupSpace')
85 85
     );
86 86
     $group = GroupManager:: get_group_properties($groupId);
87 87
     $path = explode('/', $dir);
88
-    if ('/' . $path[1] != $group['directory']) {
88
+    if ('/'.$path[1] != $group['directory']) {
89 89
         api_not_allowed(true);
90 90
     }
91 91
 }
92 92
 
93 93
 $interbreadcrumb[] = array(
94
-    "url" => "./document.php?curdirpath=" . urlencode($dir) . "&" . api_get_cidreq(),
94
+    "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(),
95 95
     "name" => get_lang('Documents')
96 96
 );
97 97
 
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 
129 129
 $dir_acum = '';
130 130
 for ($i = 0; $i < $array_len; $i++) {
131
-    $url_dir = 'document.php?&curdirpath=' . $dir_acum . $dir_array[$i];
131
+    $url_dir = 'document.php?&curdirpath='.$dir_acum.$dir_array[$i];
132 132
     //Max char 80
133 133
     $url_to_who = cut($dir_array[$i], 80);
134 134
     $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
135
-    $dir_acum .= $dir_array[$i] . '/';
135
+    $dir_acum .= $dir_array[$i].'/';
136 136
 }
137 137
 
138 138
 $service = isset($_GET['service']) ? $_GET['service'] : 'pediaphon';
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 Display:: display_header($nameTools, 'Doc');
141 141
 
142 142
 echo '<div class="actions">';
143
-echo '<a href="document.php?id=' . $document_id . '">' .
144
-    Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '',
145
-        ICON_SIZE_MEDIUM) . '</a>';
143
+echo '<a href="document.php?id='.$document_id.'">'.
144
+    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '',
145
+        ICON_SIZE_MEDIUM).'</a>';
146 146
 
147
-echo '<a href="create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&service=pediaphon">' .
148
-    Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM) . '</a>';
147
+echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=pediaphon">'.
148
+    Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM).'</a>';
149 149
 
150
-echo '<a href="create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&service=google">' .
151
-    Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM) . '</a>';
150
+echo '<a href="create_audio.php?'.api_get_cidreq().'&id='.$document_id.'&service=google">'.
151
+    Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM).'</a>';
152 152
 echo '</div>';
153 153
 ?>
154 154
     <!-- javascript and styles for textareaCounter-->
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
 $selected_language = null;
214 214
 
215 215
 while ($row = Database::fetch_array($result_select)) {
216
-    $options[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
216
+    $options[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
217 217
     if (in_array($row['isocode'], array('de', 'en', 'es', 'fr'))) {
218
-        $options_pedia[$row['isocode']] = $row['original_name'] . ' (' . $row['english_name'] . ')';
218
+        $options_pedia[$row['isocode']] = $row['original_name'].' ('.$row['english_name'].')';
219 219
     }
220 220
 }
221 221
 
222 222
 if ($service == 'google') {
223
-    $selected_language = api_get_language_isocode();//lang default is the course language
223
+    $selected_language = api_get_language_isocode(); //lang default is the course language
224 224
 
225 225
     $form = new FormValidator('form1', 'post', api_get_self().'?'.api_get_cidreq(), '', array('id' => 'form1'));
226 226
     $form->addHeader(get_lang('HelpText2Audio'));
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
         var voices = new Array()
273 273
 
274 274
         <!--German -->
275
-        voices['de'] = ["<?php echo get_lang('Female') . ' (de1)'; ?>|de1", "<?php echo get_lang('Male') . ' (de2)'; ?>|de2", "<?php echo get_lang('Female') . ' (de3)'; ?>|de3", "<?php echo get_lang('Male') . ' (de4)'; ?>|de4", "<?php echo get_lang('Female') . ' (de5)'; ?>|de5", "<?php echo get_lang('Male') . ' (de6)'; ?>|de6", "<?php echo get_lang('Female') . ' (de7)'; ?>|de7", "<?php echo get_lang('Female') . ' (de8 HQ)'; ?>|de8"]
275
+        voices['de'] = ["<?php echo get_lang('Female').' (de1)'; ?>|de1", "<?php echo get_lang('Male').' (de2)'; ?>|de2", "<?php echo get_lang('Female').' (de3)'; ?>|de3", "<?php echo get_lang('Male').' (de4)'; ?>|de4", "<?php echo get_lang('Female').' (de5)'; ?>|de5", "<?php echo get_lang('Male').' (de6)'; ?>|de6", "<?php echo get_lang('Female').' (de7)'; ?>|de7", "<?php echo get_lang('Female').' (de8 HQ)'; ?>|de8"]
276 276
 
277 277
         <!--English -->
278
-        voices['en'] = ["<?php echo get_lang('Male') . ' (en1)'; ?>|en1", "<?php echo get_lang('Male') . ' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female') . ' (us1)'; ?>|us1", "<?php echo get_lang('Male') . ' (us2)'; ?>|us2", "<?php echo get_lang('Male') . ' (us3)'; ?>|us3", "<?php echo get_lang('Female') . '(us4 HQ)'; ?>|us4"]
278
+        voices['en'] = ["<?php echo get_lang('Male').' (en1)'; ?>|en1", "<?php echo get_lang('Male').' (en2 HQ)'; ?>|en2", "<?php echo get_lang('Female').' (us1)'; ?>|us1", "<?php echo get_lang('Male').' (us2)'; ?>|us2", "<?php echo get_lang('Male').' (us3)'; ?>|us3", "<?php echo get_lang('Female').'(us4 HQ)'; ?>|us4"]
279 279
 
280 280
         <!--Spanish -->
281
-        voices['es'] = ["<?php echo get_lang('Male') . ' (es5 HQ)'; ?>|es5"]
281
+        voices['es'] = ["<?php echo get_lang('Male').' (es5 HQ)'; ?>|es5"]
282 282
 
283 283
         <!--French -->
284
-        voices['fr'] = ["<?php echo get_lang('Female') . ' (fr8 HQ)'; ?>|fr8"]
284
+        voices['fr'] = ["<?php echo get_lang('Female').' (fr8 HQ)'; ?>|fr8"]
285 285
 
286 286
         $(document).ready(function () {
287 287
             $('.lang').on('change', function () {
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
  */
313 313
 function downloadMP3_google($filepath, $dir)
314 314
 {
315
-    $location = 'create_audio.php?' . api_get_cidreq() . '&id=' . intval($_POST['id']) . '&service=google';
315
+    $location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&service=google';
316 316
 
317 317
     //security
318 318
     if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
319
-        echo '<script>window.location.href="' . $location . '"</script>';
319
+        echo '<script>window.location.href="'.$location.'"</script>';
320 320
         return;
321 321
     }
322 322
 
@@ -326,33 +326,33 @@  discard block
 block discarded – undo
326 326
     $clean_title = trim($_POST['title']);
327 327
     $clean_text = trim($_POST['text']);
328 328
     if (empty($clean_title) || empty($clean_text)) {
329
-        echo '<script>window.location.href="' . $location . '"</script>';
329
+        echo '<script>window.location.href="'.$location.'"</script>';
330 330
         
331 331
         return;
332 332
     }
333 333
     $clean_title = Security::remove_XSS($clean_title);
334 334
     $clean_title = Database::escape_string($clean_title);
335
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
335
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
336 336
 
337 337
     $clean_text = Security::remove_XSS($clean_text);
338 338
     $clean_lang = Security::remove_XSS($_POST['lang']);
339 339
 
340 340
     $extension = 'mp3';
341
-    $audio_filename = $clean_title . '.' . $extension;
341
+    $audio_filename = $clean_title.'.'.$extension;
342 342
     $audio_title = str_replace('_', ' ', $clean_title);
343 343
 
344 344
     //prevent duplicates
345
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
345
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
346 346
         $i = 1;
347
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
347
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
348 348
             $i++;
349 349
         }
350
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
351
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
350
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
351
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
352 352
         $audio_title = str_replace('_', ' ', $audio_title);
353 353
     }
354 354
 
355
-    $documentPath = $filepath . '/' . $audio_filename;
355
+    $documentPath = $filepath.'/'.$audio_filename;
356 356
 
357 357
     $clean_text = api_replace_dangerous_char($clean_text);
358 358
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
     $proxySettings = api_get_configuration_value('proxy_settings');
363 363
     $key = api_get_configuration_value('translate_app_google_key');
364
-    $url = "https://www.googleapis.com/language/translate/v2?key=$key&" . $clean_lang . "&target=$clean_lang&q=" . urlencode($clean_text) . "";
364
+    $url = "https://www.googleapis.com/language/translate/v2?key=$key&".$clean_lang."&target=$clean_lang&q=".urlencode($clean_text)."";
365 365
 
366 366
     if (empty($proxySettings)) {
367 367
         $content = file_get_contents($url);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
     $relativeUrlPath = $dir;
382 382
     $doc_id = add_document(
383 383
         $_course,
384
-        $relativeUrlPath . $audio_filename,
384
+        $relativeUrlPath.$audio_filename,
385 385
         'file',
386 386
         filesize($documentPath),
387 387
         $audio_title
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     );
401 401
     Display::display_confirmation_message(get_lang('DocumentCreated'));
402 402
     //return to location
403
-    echo '<script>window.location.href="' . $location . '"</script>';
403
+    echo '<script>window.location.href="'.$location.'"</script>';
404 404
 }
405 405
 
406 406
 /**
@@ -413,10 +413,10 @@  discard block
 block discarded – undo
413 413
  */
414 414
 function downloadMP3_pediaphon($filepath, $dir)
415 415
 {
416
-    $location = 'create_audio.php?' . api_get_cidreq() . '&id=' . intval($_POST['id']) . '&service=pediaphon';
416
+    $location = 'create_audio.php?'.api_get_cidreq().'&id='.intval($_POST['id']).'&service=pediaphon';
417 417
     //security
418 418
     if (!isset($_POST['lang']) && !isset($_POST['text']) && !isset($_POST['title']) && !isset($filepath) && !isset($dir)) {
419
-        echo '<script>window.location.href="' . $location . '"</script>';
419
+        echo '<script>window.location.href="'.$location.'"</script>';
420 420
         return;
421 421
     }
422 422
     $_course = api_get_course_info();
@@ -426,33 +426,33 @@  discard block
 block discarded – undo
426 426
     $clean_text = trim($_POST['text']);
427 427
     $clean_voices = Security::remove_XSS($_POST['voices']);
428 428
     if (empty($clean_title) || empty($clean_text) || empty($clean_voices)) {
429
-        echo '<script>window.location.href="' . $location . '"</script>';
429
+        echo '<script>window.location.href="'.$location.'"</script>';
430 430
 
431 431
         return;
432 432
     }
433 433
     $clean_title = Security::remove_XSS($clean_title);
434 434
     $clean_title = Database::escape_string($clean_title);
435
-    $clean_title = str_replace(' ', '_', $clean_title);//compound file names
435
+    $clean_title = str_replace(' ', '_', $clean_title); //compound file names
436 436
     $clean_text = Security::remove_XSS($clean_text);
437 437
     $clean_lang = Security::remove_XSS($_POST['lang']);
438 438
     $clean_speed = Security::remove_XSS($_POST['speed']);
439 439
 
440 440
     $extension = 'mp3';
441
-    $audio_filename = $clean_title . '.' . $extension;
441
+    $audio_filename = $clean_title.'.'.$extension;
442 442
     $audio_title = str_replace('_', ' ', $clean_title);
443 443
 
444 444
     //prevent duplicates
445
-    if (file_exists($filepath . '/' . $clean_title . '.' . $extension)) {
445
+    if (file_exists($filepath.'/'.$clean_title.'.'.$extension)) {
446 446
         $i = 1;
447
-        while (file_exists($filepath . '/' . $clean_title . '_' . $i . '.' . $extension)) {
447
+        while (file_exists($filepath.'/'.$clean_title.'_'.$i.'.'.$extension)) {
448 448
             $i++;
449 449
         }
450
-        $audio_filename = $clean_title . '_' . $i . '.' . $extension;
451
-        $audio_title = $clean_title . '_' . $i . '.' . $extension;
450
+        $audio_filename = $clean_title.'_'.$i.'.'.$extension;
451
+        $audio_title = $clean_title.'_'.$i.'.'.$extension;
452 452
         $audio_title = str_replace('_', ' ', $audio_title);
453 453
     }
454 454
 
455
-    $documentPath = $filepath . '/' . $audio_filename;
455
+    $documentPath = $filepath.'/'.$audio_filename;
456 456
     $clean_text = api_replace_dangerous_char($clean_text);
457 457
 
458 458
     //adding the file
@@ -461,17 +461,17 @@  discard block
 block discarded – undo
461 461
         $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi';
462 462
         $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/';
463 463
     } else {
464
-        $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_' . $clean_lang . '.cgi';//en, es, fr
465
-        $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/' . $clean_lang . '\/(.*)\.mp3\"/';
464
+        $url_pediaphon = 'http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi'; //en, es, fr
465
+        $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/';
466 466
     }
467 467
 
468
-    $data = "stimme=" . $clean_voices . "&inputtext=" . $clean_text . "&speed=" . $clean_speed . "&go=speak";
468
+    $data = "stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak";
469 469
     $opts = array(
470 470
         'http' =>
471 471
             array(
472 472
                 'method' => 'POST',
473 473
                 'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
474
-                "Content-Length: " . strlen($data) . "\r\n",
474
+                "Content-Length: ".strlen($data)."\r\n",
475 475
                 'content' => $data
476 476
             )
477 477
     );
@@ -515,5 +515,5 @@  discard block
 block discarded – undo
515 515
     );
516 516
     Display::display_confirmation_message(get_lang('DocumentCreated'));
517 517
     //return to location
518
-    echo '<script>window.location.href="' . $location . '"</script>';
518
+    echo '<script>window.location.href="'.$location.'"</script>';
519 519
 }
Please login to merge, or discard this patch.
main/badge/issued_all.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
14 14
 
15 15
 if (!$userId || !$skillId) {
16
-    header('Location: ' . api_get_path(WEB_PATH));
16
+    header('Location: '.api_get_path(WEB_PATH));
17 17
     exit;
18 18
 }
19 19
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         Display::return_message(get_lang('NoResults'), 'error')
32 32
     );
33 33
 
34
-    header('Location: ' . api_get_path(WEB_PATH));
34
+    header('Location: '.api_get_path(WEB_PATH));
35 35
     exit;
36 36
 }
37 37
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         $entityManager->persist($skillIssue);
168 168
         $entityManager->flush();
169 169
 
170
-        header("Location: " . $skillIssue->getIssueUrlAll());
170
+        header("Location: ".$skillIssue->getIssueUrlAll());
171 171
         exit;
172 172
     }
173 173
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $entityManager->persist($skillUserComment);
199 199
         $entityManager->flush();
200 200
 
201
-        header("Location: " . $skillIssue->getIssueUrlAll());
201
+        header("Location: ".$skillIssue->getIssueUrlAll());
202 202
         exit;
203 203
     }
204 204
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
             $backpack = $configBackpack;
215 215
         }
216 216
 
217
-        $htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>';
217
+        $htmlHeadXtra[] = '<script src="'.$backpack.'issuer.js"></script>';
218 218
         $objSkill = new Skill();
219 219
         $assertionUrl = $skillIssueInfo['badge_assertion'];
220 220
         $skills = $objSkill->get($skillId);
221
-        $unbakedBadge = api_get_path(SYS_UPLOAD_PATH) . "badges/".$skills['icon'];
221
+        $unbakedBadge = api_get_path(SYS_UPLOAD_PATH)."badges/".$skills['icon'];
222 222
         if (!is_file($unbakedBadge)) {
223 223
             $unbakedBadge = api_get_path(WEB_CODE_PATH).'img/icons/128/badges-default.png';
224 224
         }
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
                 mkdir($bakedBadge, api_get_permissions_for_new_directories(), true);
237 237
             }
238 238
             $skillRelUserId = $skillIssueInfo['id'];
239
-            if (!file_exists($bakedBadge . "/badge_" . $skillRelUserId)) {
240
-                file_put_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png", $bakedInfo);
239
+            if (!file_exists($bakedBadge."/badge_".$skillRelUserId)) {
240
+                file_put_contents($bakedBadge."/badge_".$skillRelUserId.".png", $bakedInfo);
241 241
             }
242 242
 
243 243
             //Process to validate a baked badge
244
-            $badgeContent = file_get_contents($bakedBadge . "/badge_" . $skillRelUserId . ".png");
244
+            $badgeContent = file_get_contents($bakedBadge."/badge_".$skillRelUserId.".png");
245 245
             $verifyBakedBadge = $png->extractBadgeInfo($badgeContent);
246 246
             if (!is_array($verifyBakedBadge)) {
247 247
                 $badgeInfoError = true;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
             if (!$badgeInfoError) {
251 251
                 $personalBadge = UserManager::getUserPathById($userId, "web");
252
-                $personalBadge = $personalBadge."badges/badge_" . $skillRelUserId . ".png";
252
+                $personalBadge = $personalBadge."badges/badge_".$skillRelUserId.".png";
253 253
             }
254 254
         }
255 255
     }
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/SkillRelUser.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
      */
456 456
     public function getIssueUrl()
457 457
     {
458
-        return api_get_path(WEB_PATH) . "badge/{$this->id}";
458
+        return api_get_path(WEB_PATH)."badge/{$this->id}";
459 459
     }
460 460
 
461 461
     /**
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
      */
465 465
     public function getIssueUrlAll()
466 466
     {
467
-        return api_get_path(WEB_PATH) . "skill/{$this->skill->getId()}/user/{$this->user->getId()}";
467
+        return api_get_path(WEB_PATH)."skill/{$this->skill->getId()}/user/{$this->user->getId()}";
468 468
     }
469 469
 
470 470
     /**
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
      */
474 474
     public function getAssertionUrl()
475 475
     {
476
-        $url = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?";
476
+        $url = api_get_path(WEB_CODE_PATH)."badge/assertion.php?";
477 477
 
478 478
         $url .= http_build_query(array(
479 479
             'user' => $this->user->getId(),
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
     /**
199 199
      * Get user
200
-     * @return \User
200
+     * @return User
201 201
      */
202 202
     public function getUser()
203 203
     {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
     /**
514 514
      * Calculate the average value from the feedback comments
515
-     * @return int
515
+     * @return string
516 516
      */
517 517
     public function getAverage()
518 518
     {
Please login to merge, or discard this patch.
main/document/edit_draw.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 $dir = str_replace('\\', '/', $dir);
38 38
 
39 39
 /* Constants & Variables */
40
-$current_session_id=api_get_session_id();
40
+$current_session_id = api_get_session_id();
41 41
 $group_id = api_get_group_id();
42 42
 
43 43
 //path for svg-edit save
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 $file = basename($get_file);
51 51
 $temp_file = explode(".", $file);
52 52
 $filename = $temp_file[0];
53
-$nameTools = get_lang('EditDocument') . ': ' . $filename;
54
-$courseDir = $_course['path'] . '/document';
53
+$nameTools = get_lang('EditDocument').': '.$filename;
54
+$courseDir = $_course['path'].'/document';
55 55
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
56 56
 
57 57
 /*	Other initialization code */
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
 Display :: display_header($nameTools, 'Doc');
126 126
 echo '<div class="actions">';
127 127
 echo '<a href="document.php?id='.$parent_id.'">'.
128
-    Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
128
+    Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
129 129
 echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.'&origin=editdraw">'.
130
-    Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
130
+    Display::return_icon('edit.png', get_lang('Rename').'/'.get_lang('Comments'), '', ICON_SIZE_MEDIUM).'</a>';
131 131
 echo '</div>';
132 132
 
133 133
 if (api_browser_support('svg')) {
134 134
 	//automatic loading the course language
135 135
 	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
136
-	$langsvgedit  = api_get_language_isocode();
136
+	$langsvgedit = api_get_language_isocode();
137 137
 	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
138 138
 	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
139 139
 	$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 //path for svg-edit save
47 47
 $_SESSION['draw_dir'] = Security::remove_XSS($dir);
48 48
 if ($_SESSION['draw_dir'] == '/') {
49
-	$_SESSION['draw_dir'] = '';
49
+    $_SESSION['draw_dir'] = '';
50 50
 }
51 51
 $_SESSION['draw_file'] = basename(Security::remove_XSS($file_path));
52 52
 $get_file = Security::remove_XSS($file_path);
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
 /* Please, do not modify this dirname formatting */
63 63
 
64 64
 if (strstr($dir, '..')) {
65
-	$dir = '/';
65
+    $dir = '/';
66 66
 }
67 67
 
68 68
 if ($dir[0] == '.') {
69
-	$dir = substr($dir, 1);
69
+    $dir = substr($dir, 1);
70 70
 }
71 71
 
72 72
 if ($dir[0] != '/') {
73
-	$dir = '/'.$dir;
73
+    $dir = '/'.$dir;
74 74
 }
75 75
 
76 76
 if ($dir[strlen($dir) - 1] != '/') {
77
-	$dir .= '/';
77
+    $dir .= '/';
78 78
 }
79 79
 
80 80
 $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir;
81 81
 
82 82
 if (!is_dir($filepath)) {
83
-	$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
84
-	$dir = '/';
83
+    $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
84
+    $dir = '/';
85 85
 }
86 86
 
87 87
 //groups //TODO:clean
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
         'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(),
91 91
         'name' => get_lang('GroupSpace'),
92 92
     );
93
-	$group_document = true;
94
-	$noPHP_SELF = true;
93
+    $group_document = true;
94
+    $noPHP_SELF = true;
95 95
 }
96 96
 
97 97
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 }
118 118
 
119 119
 $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights ||
120
-	DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
120
+    DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
121 121
 
122 122
 if (!$is_allowedToEdit) {
123
-	api_not_allowed(true);
123
+    api_not_allowed(true);
124 124
 }
125 125
 
126 126
 Event::event_access_tool(TOOL_DOCUMENT);
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 echo '</div>';
135 135
 
136 136
 if (api_browser_support('svg')) {
137
-	//automatic loading the course language
138
-	$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
139
-	$langsvgedit  = api_get_language_isocode();
140
-	$langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
141
-	$langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
142
-	$svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
143
-	?>
137
+    //automatic loading the course language
138
+    $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');
139
+    $langsvgedit  = api_get_language_isocode();
140
+    $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit;
141
+    $langsvgedit = file_exists(api_get_path(LIBRARY_PATH).'javascript/svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en';
142
+    $svg_url = api_get_path(WEB_LIBRARY_PATH).'javascript/svgedit/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit;
143
+    ?>
144 144
 	<script>
145 145
 	document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo  $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>');
146 146
 	function resizeIframe() {
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
 
159 159
     <?php
160 160
     echo '<noscript>';
161
-	echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
162
-	echo '</noscript>';
161
+    echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>';
162
+    echo '</noscript>';
163 163
 } else {
164
-	Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
164
+    Display::display_error_message(get_lang('BrowserDontSupportsSVG'));
165 165
 }
166 166
 Display::display_footer();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,13 +96,14 @@
 block discarded – undo
96 96
 
97 97
 $is_certificate_mode = DocumentManager::is_certificate_mode($dir);
98 98
 
99
-if (!$is_certificate_mode)
99
+if (!$is_certificate_mode) {
100 100
     $interbreadcrumb[] = array(
101 101
         "url" => "./document.php?curdirpath=".urlencode($my_cur_dir_path).'&'.api_get_cidreq(),
102 102
         "name" => get_lang('Documents'),
103 103
     );
104
-else
104
+} else {
105 105
     $interbreadcrumb[] = array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
106
+}
106 107
 
107 108
 // Interbreadcrumb for the current directory root path
108 109
 if (empty($document_data['parents'])) {
Please login to merge, or discard this patch.
main/inc/lib/api.lib.php 4 patches
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1701,7 +1701,9 @@  discard block
 block discarded – undo
1701 1701
     }
1702 1702
 
1703 1703
     global $_course;
1704
-    if ($_course == '-1') $_course = array();
1704
+    if ($_course == '-1') {
1705
+        $_course = array();
1706
+    }
1705 1707
     return $_course;
1706 1708
 }
1707 1709
 
@@ -4154,18 +4156,21 @@  discard block
 block discarded – undo
4154 4156
     switch ($lang_type) {
4155 4157
         case 'platform_lang':
4156 4158
             $temp_lang = api_get_setting('platformLanguage');
4157
-            if (!empty($temp_lang))
4158
-                $return = $temp_lang;
4159
+            if (!empty($temp_lang)) {
4160
+                            $return = $temp_lang;
4161
+            }
4159 4162
             break;
4160 4163
         case 'user_profil_lang':
4161 4164
             $_user = api_get_user_info();
4162 4165
 
4163
-            if (isset($_user['language']) && !empty($_user['language']))
4164
-                $return = $_user['language'];
4166
+            if (isset($_user['language']) && !empty($_user['language'])) {
4167
+                            $return = $_user['language'];
4168
+            }
4165 4169
             break;
4166 4170
         case 'user_selected_lang':
4167
-            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice']))
4168
-                $return = $_SESSION['user_language_choice'];
4171
+            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) {
4172
+                            $return = $_SESSION['user_language_choice'];
4173
+            }
4169 4174
             break;
4170 4175
         case 'course_lang':
4171 4176
             global $_course;
@@ -5434,8 +5439,7 @@  discard block
 block discarded – undo
5434 5439
             $is_courseAdmin = false;
5435 5440
             $is_courseCoach = true;
5436 5441
             $is_sessionAdmin = false;
5437
-        }
5438
-        elseif ($row[0]['session_admin_id'] == $userid) {
5442
+        } elseif ($row[0]['session_admin_id'] == $userid) {
5439 5443
             $is_courseMember = false;
5440 5444
             $is_courseTutor = false;
5441 5445
             $is_courseAdmin = false;
@@ -5778,8 +5782,7 @@  discard block
 block discarded – undo
5778 5782
     elseif (isset($_ENV['OS'])) {
5779 5783
         // Sometimes $_ENV['OS'] may not be present (bugs?)
5780 5784
         $os = $_ENV['OS'];
5781
-    }
5782
-    elseif (defined('PHP_OS')) {
5785
+    } elseif (defined('PHP_OS')) {
5783 5786
         // PHP_OS means on which OS PHP was compiled, this is why
5784 5787
         // using PHP_OS is the last choice for detection.
5785 5788
         $os = PHP_OS;
@@ -5843,12 +5846,10 @@  discard block
 block discarded – undo
5843 5846
     if ($delta_width > $delta_height) {
5844 5847
         $result['width'] = ceil($image_width * $resize_factor_height);
5845 5848
         $result['height'] = ceil($image_height * $resize_factor_height);
5846
-    }
5847
-    elseif ($delta_width < $delta_height) {
5849
+    } elseif ($delta_width < $delta_height) {
5848 5850
         $result['width'] = ceil($image_width * $resize_factor_width);
5849 5851
         $result['height'] = ceil($image_height * $resize_factor_width);
5850
-    }
5851
-    else {
5852
+    } else {
5852 5853
         $result['width'] = ceil($target_width);
5853 5854
         $result['height'] = ceil($target_height);
5854 5855
     }
@@ -6629,7 +6630,9 @@  discard block
 block discarded – undo
6629 6630
         }
6630 6631
         $ip = trim($ip1);
6631 6632
     }
6632
-    if (!empty($debug)) error_log('Real IP: '.$ip);
6633
+    if (!empty($debug)) {
6634
+        error_log('Real IP: '.$ip);
6635
+    }
6633 6636
     return $ip;
6634 6637
 }
6635 6638
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -626,7 +626,6 @@  discard block
 block discarded – undo
626 626
  * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too.
627 627
  *
628 628
  * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
629
-
630 629
  * @param string $path (optional)   A path which type is to be converted. Also, it may be a defined constant for a path.
631 630
  * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored.
632 631
  * @return string                   The requested path or the converted path.
@@ -1733,7 +1732,6 @@  discard block
 block discarded – undo
1733 1732
 
1734 1733
 /**
1735 1734
  * Returns the current course info array.
1736
-
1737 1735
  * Now if the course_code is given, the returned array gives info about that
1738 1736
  * particular course, not specially the current one.
1739 1737
  * @param int $id Numeric ID of the course
@@ -6210,7 +6208,7 @@  discard block
 block discarded – undo
6210 6208
 function api_get_jquery_ui_js($include_jqgrid = false) {
6211 6209
     $libraries = array();
6212 6210
     if ($include_jqgrid) {
6213
-       $libraries[]='jqgrid';
6211
+        $libraries[]='jqgrid';
6214 6212
     }
6215 6213
     return api_get_jquery_libraries_js($libraries);
6216 6214
 }
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1275,6 +1275,7 @@  discard block
 block discarded – undo
1275 1275
  * Gets the list of courses a specific user is subscribed to
1276 1276
  * @param int       User ID
1277 1277
  * @param boolean   $fetch_session Whether to get session courses or not - NOT YET IMPLEMENTED
1278
+ * @param integer $userid
1278 1279
  * @return array    Array of courses in the form [0]=>('code'=>xxx,'db'=>xxx,'dir'=>xxx,'status'=>d)
1279 1280
  */
1280 1281
 function api_get_user_courses($userid, $fetch_session = true)
@@ -3049,7 +3050,7 @@  discard block
 block discarded – undo
3049 3050
 * on the session visibility
3050 3051
 * @param bool $tutor  Whether to check if the user has the tutor role
3051 3052
 * @param bool  $coach Whether to check if the user has the coach role
3052
-* @return boolean true: the user has the rights to edit, false: he does not
3053
+* @return boolean|null true: the user has the rights to edit, false: he does not
3053 3054
 */
3054 3055
 function api_is_allowed_to_session_edit($tutor = false, $coach = false)
3055 3056
 {
@@ -5228,6 +5229,7 @@  discard block
 block discarded – undo
5228 5229
  * @param string    Whether we want a simple list (display a category) or
5229 5230
  * a grouped list (group by variable as in settings.php default). Values: 'list' or 'group'
5230 5231
  * @param int       Access URL's ID. Optional. Uses 1 by default, which is the unique URL
5232
+ * @param string $cat
5231 5233
  * @return array    Array of database results for the current settings of the current access URL
5232 5234
  */
5233 5235
 function &api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0)
@@ -6621,7 +6623,7 @@  discard block
 block discarded – undo
6621 6623
 /**
6622 6624
  * Returns an array of global configuration settings which should be ignored
6623 6625
  * when printing the configuration settings screens
6624
- * @return array Array of strings, each identifying one of the excluded settings
6626
+ * @return string[] Array of strings, each identifying one of the excluded settings
6625 6627
  */
6626 6628
 function api_get_locked_settings() {
6627 6629
     return array(
@@ -6662,6 +6664,7 @@  discard block
 block discarded – undo
6662 6664
  * false if he isn't. If the user ID is given and is an integer, then the same
6663 6665
  * ID is simply returned
6664 6666
  * @param  integer User ID
6667
+ * @param integer $user_id
6665 6668
  * @return boolean Integer User ID is logged in, or false otherwise
6666 6669
  */
6667 6670
 function api_user_is_login($user_id = null) {
@@ -7082,6 +7085,7 @@  discard block
 block discarded – undo
7082 7085
 /**
7083 7086
  * Gets memory limit in bytes
7084 7087
  * @param string The memory size (128M, 1G, 1000K, etc)
7088
+ * @param string $mem
7085 7089
  * @return int
7086 7090
  * @assert (null) === false
7087 7091
  * @assert ('1t')  === 1099511627776
@@ -8100,8 +8104,8 @@  discard block
 block discarded – undo
8100 8104
  * Adds or Subtract a time in hh:mm:ss to a datetime
8101 8105
  *
8102 8106
  * @param $datetime
8103
- * @param $time
8104
- * @param $operation - True for Add, False to Subtract
8107
+ * @param string $time
8108
+ * @param boolean $operation - True for Add, False to Subtract
8105 8109
  * @return string
8106 8110
  */
8107 8111
 function api_add_sub_hours_to_date_time($datetime, $time, $operation)
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -41,19 +41,19 @@  discard block
 block discarded – undo
41 41
 define('PLATFORM_ADMIN', 11);
42 42
 define('SESSION_COURSE_COACH', 12);
43 43
 define('SESSION_GENERAL_COACH', 13);
44
-define('COURSE_STUDENT', 14);   //student subscribed in a course
45
-define('SESSION_STUDENT', 15);  //student subscribed in a session course
44
+define('COURSE_STUDENT', 14); //student subscribed in a course
45
+define('SESSION_STUDENT', 15); //student subscribed in a session course
46 46
 define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
47 47
 define('STUDENT_BOSS', 17); // student is boss
48 48
 define('INVITEE', 20);
49 49
 
50 50
 // Table of status
51
-$_status_list[COURSEMANAGER] = 'teacher';        // 1
52
-$_status_list[SESSIONADMIN] = 'session_admin';  // 3
53
-$_status_list[DRH] = 'drh';            // 4
54
-$_status_list[STUDENT] = 'user';           // 5
55
-$_status_list[ANONYMOUS] = 'anonymous';      // 6
56
-$_status_list[INVITEE] = 'invited';        // 20
51
+$_status_list[COURSEMANAGER] = 'teacher'; // 1
52
+$_status_list[SESSIONADMIN] = 'session_admin'; // 3
53
+$_status_list[DRH] = 'drh'; // 4
54
+$_status_list[STUDENT] = 'user'; // 5
55
+$_status_list[ANONYMOUS] = 'anonymous'; // 6
56
+$_status_list[INVITEE] = 'invited'; // 20
57 57
 
58 58
 // COURSE VISIBILITY CONSTANTS
59 59
 /** only visible for course admin */
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 define('IS_WINDOWS_OS', api_is_windows_os());
268 268
 
269 269
 // Checks for installed optional php-extensions.
270
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
271
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
272
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
270
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
271
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
272
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
273 273
 
274 274
 // Patterns for processing paths.                                   // Examples:
275
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
276
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
277
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
275
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
276
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
277
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
278 278
 
279 279
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
280 280
 // basic (leaf elements)
@@ -363,19 +363,19 @@  discard block
 block discarded – undo
363 363
 define('LINK_HOTPOTATOES', 9);
364 364
 
365 365
 // Score display types constants
366
-define('SCORE_DIV', 1);    // X / Y
367
-define('SCORE_PERCENT', 2);    // XX %
368
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
369
-define('SCORE_AVERAGE', 4);    // XX %
370
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
371
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
372
-define('SCORE_SIMPLE', 7);    // X
373
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
374
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
375
-define('SCORE_CUSTOM', 10);    // Good!
376
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
377
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
378
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
366
+define('SCORE_DIV', 1); // X / Y
367
+define('SCORE_PERCENT', 2); // XX %
368
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
369
+define('SCORE_AVERAGE', 4); // XX %
370
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
371
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
372
+define('SCORE_SIMPLE', 7); // X
373
+define('SCORE_IGNORE_SPLIT', 8); //  ??
374
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
375
+define('SCORE_CUSTOM', 10); // Good!
376
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
377
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
378
+define('SCORE_ONLY_SCORE', 13); // X - Good!
379 379
 
380 380
 define('SCORE_BOTH', 1);
381 381
 define('SCORE_ONLY_DEFAULT', 2);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 define('TIMELINE_STATUS_INACTIVE', '2');
559 559
 
560 560
 // Event email template class
561
-define('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
561
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
562 562
 define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
563 563
 
564 564
 // Course home
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
     $emptyConfigurationParam = false;
672 672
     if (empty($configuration)) {
673
-        $configuration = (array)$_configuration;
673
+        $configuration = (array) $_configuration;
674 674
         $emptyConfigurationParam = true;
675 675
     }
676 676
 
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
                         && (($server_protocol == 'http'
703 703
                                 && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))
704 704
                     ) {
705
-                        $server_name .= ":" . $_SERVER['SERVER_PORT'];
705
+                        $server_name .= ":".$_SERVER['SERVER_PORT'];
706 706
                     }
707
-                    $root_web = $server_protocol . '://' . $server_name . $root_rel;
708
-                    $root_sys = str_replace('\\', '/', realpath(__DIR__ . '/../../../')) . '/';
707
+                    $root_web = $server_protocol.'://'.$server_name.$root_rel;
708
+                    $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
709 709
                 }
710 710
                 // Here we give up, so we don't touch anything.
711 711
             }
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
                 $sys_course_code =
897 897
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
898 898
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
899
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
899
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
900 900
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
901 901
             }
902 902
         }
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
                 if (in_array($ext, $exts)) {
930 930
                     //Use host as defined in $_configuration['cdn'], without
931 931
                     // trailing slash
932
-                    return str_replace($web_root,$host.'/',$web_path);
932
+                    return str_replace($web_root, $host.'/', $web_path);
933 933
                 }
934 934
             }
935 935
         }
@@ -1373,10 +1373,10 @@  discard block
 block discarded – undo
1373 1373
 
1374 1374
     if (isset($user['email'])) {
1375 1375
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1376
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1376
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1377 1377
     } else {
1378 1378
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1379
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1379
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1380 1380
     }
1381 1381
     $user_id = intval($user['user_id']);
1382 1382
     // Maintain the user_id index for backwards compatibility
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
 
1466 1466
         if (isset($userFromSession)) {
1467 1467
             if (!empty($cacheAvailable)) {
1468
-                $apcVar = api_get_configuration_value('apc_prefix') . 'userinfo_' . $userFromSession['user_id'];
1468
+                $apcVar = api_get_configuration_value('apc_prefix').'userinfo_'.$userFromSession['user_id'];
1469 1469
                 if (apcu_exists($apcVar)) {
1470 1470
                     $user = apcu_fetch($apcVar);
1471 1471
                 } else {
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
     // Re-use user information if not stale and already stored in APCu
1489 1489
     if (!empty($cacheAvailable)) {
1490
-        $apcVar = api_get_configuration_value('apc_prefix') . 'userinfo_' . $user_id;
1490
+        $apcVar = api_get_configuration_value('apc_prefix').'userinfo_'.$user_id;
1491 1491
         if (apcu_exists($apcVar)) {
1492 1492
             $user = apcu_fetch($apcVar);
1493 1493
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
         }
1496 1496
     }
1497 1497
 
1498
-    $sql = "SELECT * FROM " . Database:: get_main_table(TABLE_MAIN_USER) . "
1498
+    $sql = "SELECT * FROM ".Database:: get_main_table(TABLE_MAIN_USER)."
1499 1499
             WHERE id = $user_id";
1500 1500
     $result = Database::query($sql);
1501 1501
     if (Database::num_rows($result) > 0) {
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
         foreach ($param_list1 as $key => $enreg) {
1961 1961
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1962 1962
         }
1963
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1963
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1964 1964
         foreach ($param_list2 as $enreg) {
1965 1965
             $enreg = explode('=', $enreg);
1966 1966
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1993,12 +1993,12 @@  discard block
 block discarded – undo
1993 1993
         $length = 2;
1994 1994
     }
1995 1995
     $password = '';
1996
-    for ($i = 0; $i < $length; $i ++) {
1996
+    for ($i = 0; $i < $length; $i++) {
1997 1997
         $password .= $characters[rand() % strlen($characters)];
1998 1998
     }
1999 1999
 
2000 2000
     // At least 2 digits
2001
-    for ($i = 0; $i < 2; $i ++) {
2001
+    for ($i = 0; $i < 2; $i++) {
2002 2002
         $password .= $numbers[rand() % strlen($numbers)];
2003 2003
     }
2004 2004
 
@@ -2026,10 +2026,10 @@  discard block
 block discarded – undo
2026 2026
     $digits = 0;
2027 2027
     $consequent_characters = 0;
2028 2028
     $previous_character_code = 0;
2029
-    for ($i = 0; $i < $password_length; $i ++) {
2029
+    for ($i = 0; $i < $password_length; $i++) {
2030 2030
         $current_character_code = api_ord(api_substr($password, $i, 1));
2031 2031
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
2032
-            $consequent_characters ++;
2032
+            $consequent_characters++;
2033 2033
             if ($consequent_characters == 3) {
2034 2034
                 return false;
2035 2035
             }
@@ -2037,9 +2037,9 @@  discard block
 block discarded – undo
2037 2037
             $consequent_characters = 1;
2038 2038
         }
2039 2039
         if ($current_character_code >= 97 && $current_character_code <= 122) {
2040
-            $letters ++;
2040
+            $letters++;
2041 2041
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
2042
-            $digits ++;
2042
+            $digits++;
2043 2043
         } else {
2044 2044
             return false;
2045 2045
         }
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
         if (empty($session_id)) { return null; }
2145 2145
     }
2146 2146
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2147
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2147
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2148 2148
     $r = Database::query($s);
2149 2149
     $c = Database::num_rows($r);
2150 2150
     if ($c > 0) {
@@ -2314,9 +2314,9 @@  discard block
 block discarded – undo
2314 2314
  */
2315 2315
 function api_get_session_image($session_id, $status_id)
2316 2316
 {
2317
-    $session_id = (int)$session_id;
2317
+    $session_id = (int) $session_id;
2318 2318
     $session_img = '';
2319
-    if ((int)$status_id != 5) { //check whether is not a student
2319
+    if ((int) $status_id != 5) { //check whether is not a student
2320 2320
         if ($session_id > 0) {
2321 2321
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2322 2322
                 'star.png',
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2594 2594
 {
2595 2595
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2596
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2596
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2597 2597
 
2598 2598
     $user_id = intval($user_id);
2599 2599
     $session_id = intval($session_id);
@@ -2667,7 +2667,7 @@  discard block
 block discarded – undo
2667 2667
                 ORDER BY access_start_date, access_end_date, name";
2668 2668
         $result = Database::query($sql);
2669 2669
         if (!empty($sessionIsCoach)) {
2670
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2670
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2671 2671
         } else {
2672 2672
             $sessionIsCoach = Database::store_result($result);
2673 2673
         }
@@ -2841,7 +2841,7 @@  discard block
 block discarded – undo
2841 2841
             return '';
2842 2842
         }
2843 2843
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
2844
-        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl);
2844
+        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl);
2845 2845
         //showinframes doesn't handle student view anyway...
2846 2846
         //return '';
2847 2847
         $is_framed = true;
@@ -3323,7 +3323,7 @@  discard block
 block discarded – undo
3323 3323
         }
3324 3324
         $content .= '<div class="well">';
3325 3325
         $content .= $form->returnForm();
3326
-        $content .='</div>';
3326
+        $content .= '</div>';
3327 3327
         if (api_is_cas_activated()) {
3328 3328
             $content .= "</div>";
3329 3329
         }
@@ -3375,7 +3375,7 @@  discard block
 block discarded – undo
3375 3375
         }
3376 3376
         $msg .= '<div class="well">';
3377 3377
         $msg .= $form->returnForm();
3378
-        $msg .='</div>';
3378
+        $msg .= '</div>';
3379 3379
         if ($casEnabled) {
3380 3380
             $msg .= "</div>";
3381 3381
         }
@@ -3405,7 +3405,7 @@  discard block
 block discarded – undo
3405 3405
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3406 3406
     list ($year, $month, $day) = explode('-', $last_post_date);
3407 3407
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3408
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3408
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3409 3409
 }
3410 3410
 
3411 3411
 /**
@@ -3877,7 +3877,7 @@  discard block
 block discarded – undo
3877 3877
                 c_id = $course_id AND
3878 3878
                 tool = '$tool'
3879 3879
                 $session_condition ";
3880
-    $rs  = Database::query($sql);
3880
+    $rs = Database::query($sql);
3881 3881
     $list = array();
3882 3882
     if (Database::num_rows($rs) > 0) {
3883 3883
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -3958,7 +3958,7 @@  discard block
 block discarded – undo
3958 3958
                 tool = '$tool' AND
3959 3959
                 ref = $ref
3960 3960
                 $sessionCondition";
3961
-    $rs  = Database::query($sql);
3961
+    $rs = Database::query($sql);
3962 3962
     $item_property_id = '';
3963 3963
     if (Database::num_rows($rs) > 0) {
3964 3964
         $row = Database::fetch_array($rs);
@@ -4019,7 +4019,7 @@  discard block
 block discarded – undo
4019 4019
     if ($result == false) {
4020 4020
         $result = array();
4021 4021
     } else {
4022
-        $result = Database::store_result($result,'ASSOC');
4022
+        $result = Database::store_result($result, 'ASSOC');
4023 4023
     }
4024 4024
 
4025 4025
     return $result;
@@ -4071,7 +4071,7 @@  discard block
 block discarded – undo
4071 4071
     $rs  = Database::query($sql);
4072 4072
     $row = array();
4073 4073
     if (Database::num_rows($rs) > 0) {
4074
-        $row = Database::fetch_array($rs,'ASSOC');
4074
+        $row = Database::fetch_array($rs, 'ASSOC');
4075 4075
     }
4076 4076
 
4077 4077
     return $row;
@@ -4106,7 +4106,7 @@  discard block
 block discarded – undo
4106 4106
     $languages  = $language_list['name'];
4107 4107
     $folder     = $language_list['folder'];
4108 4108
 
4109
-    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
4109
+    $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
4110 4110
     foreach ($languages as $key => $value) {
4111 4111
         if ($folder[$key] == $default) {
4112 4112
             $selected = ' selected="selected"';
@@ -4156,8 +4156,8 @@  discard block
 block discarded – undo
4156 4156
     }
4157 4157
     </script>';
4158 4158
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4159
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4160
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4159
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4160
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4161 4161
 
4162 4162
     foreach ($original_languages as $key => $value) {
4163 4163
         if ($folder[$key] == $user_selected_language) {
@@ -4165,13 +4165,13 @@  discard block
 block discarded – undo
4165 4165
         } else {
4166 4166
             $option_end = '>';
4167 4167
         }
4168
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4168
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4169 4169
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4170
-        $html .=  $value.'</option>';
4170
+        $html .= $value.'</option>';
4171 4171
     }
4172
-    $html .=  '</select>';
4173
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4174
-    $html .=  '</form>';
4172
+    $html .= '</select>';
4173
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4174
+    $html .= '</form>';
4175 4175
     return $html;
4176 4176
 }
4177 4177
 
@@ -4389,7 +4389,7 @@  discard block
 block discarded – undo
4389 4389
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4390 4390
  */
4391 4391
 function api_get_themes() {
4392
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4392
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4393 4393
     $list_dir = array();
4394 4394
     $list_name = array();
4395 4395
 
@@ -4550,7 +4550,7 @@  discard block
 block discarded – undo
4550 4550
     if (is_file($dirname) || is_link($dirname)) {
4551 4551
         $res = unlink($dirname);
4552 4552
         if ($res === false) {
4553
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4553
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4554 4554
         }
4555 4555
         return $res;
4556 4556
     }
@@ -4587,7 +4587,7 @@  discard block
 block discarded – undo
4587 4587
     if ($delete_only_content_in_folder == false) {
4588 4588
         $res = rmdir($dirname);
4589 4589
         if ($res === false) {
4590
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4590
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4591 4591
         }
4592 4592
     }
4593 4593
     return $res;
@@ -4672,7 +4672,7 @@  discard block
 block discarded – undo
4672 4672
 
4673 4673
     $course_id = $course_info['real_id'];
4674 4674
 
4675
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4675
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4676 4676
 
4677 4677
     $new_pathname = $base_path_document;
4678 4678
     $path = '';
@@ -4690,7 +4690,7 @@  discard block
 block discarded – undo
4690 4690
                         path = '$path' AND
4691 4691
                         filetype = 'folder' AND
4692 4692
                         session_id = '$session_id'";
4693
-            $rs1  = Database::query($sql);
4693
+            $rs1 = Database::query($sql);
4694 4694
             $num_rows = Database::num_rows($rs1);
4695 4695
 
4696 4696
             if ($num_rows == 0) {
@@ -4850,7 +4850,7 @@  discard block
 block discarded – undo
4850 4850
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4851 4851
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4852 4852
             }
4853
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4853
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4854 4854
 
4855 4855
             // Parse array syntax.
4856 4856
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -5016,7 +5016,7 @@  discard block
 block discarded – undo
5016 5016
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5017 5017
     $var = Database::escape_string($var);
5018 5018
     $value = Database::escape_string($value);
5019
-    $access_url = (int)$access_url;
5019
+    $access_url = (int) $access_url;
5020 5020
     if (empty($access_url)) { $access_url = 1; }
5021 5021
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
5022 5022
     if (!empty($subvar)) {
@@ -5057,11 +5057,11 @@  discard block
 block discarded – undo
5057 5057
                 $row = Database::fetch_array($res);
5058 5058
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
5059 5059
                         VALUES
5060
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5061
-                        "'".$row['type']."','".$row['category']."'," .
5062
-                        "'$value','".$row['title']."'," .
5063
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5064
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
5060
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5061
+                        "'".$row['type']."','".$row['category']."',".
5062
+                        "'$value','".$row['title']."',".
5063
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5064
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
5065 5065
                 Database::query($insert);
5066 5066
             } else {
5067 5067
                 // Such a setting does not exist.
@@ -5083,11 +5083,11 @@  discard block
 block discarded – undo
5083 5083
                 if ($row['access_url_changeable'] == 1) {
5084 5084
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
5085 5085
                             ('".$row['variable']."',".
5086
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5087
-                            "'".$row['type']."','".$row['category']."'," .
5088
-                            "'$value','".$row['title']."'," .
5086
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5087
+                            "'".$row['type']."','".$row['category']."',".
5088
+                            "'$value','".$row['title']."',".
5089 5089
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
5090
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5090
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5091 5091
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
5092 5092
                     Database::query($insert);
5093 5093
                 }
@@ -5120,10 +5120,10 @@  discard block
 block discarded – undo
5120 5120
         $value = Database::escape_string($value);
5121 5121
         $sql = "UPDATE $t_s SET selected_value = '$value'
5122 5122
                 WHERE category = '$category' AND access_url = $access_url";
5123
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5123
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5124 5124
             $sql .= " AND ( ";
5125 5125
             $i = 0;
5126
-            foreach ($fieldtype as $type){
5126
+            foreach ($fieldtype as $type) {
5127 5127
                 if ($i > 0) {
5128 5128
                     $sql .= ' OR ';
5129 5129
                 }
@@ -5138,10 +5138,10 @@  discard block
 block discarded – undo
5138 5138
     } else {
5139 5139
         $sql = "UPDATE $t_s SET selected_value = NULL
5140 5140
                 WHERE category = '$category' AND access_url = $access_url";
5141
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5141
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5142 5142
             $sql .= " AND ( ";
5143 5143
             $i = 0;
5144
-            foreach ($fieldtype as $type){
5144
+            foreach ($fieldtype as $type) {
5145 5145
                 if ($i > 0) {
5146 5146
                     $sql .= ' OR ';
5147 5147
                 }
@@ -5254,7 +5254,7 @@  discard block
 block discarded – undo
5254 5254
         $sql .= " ORDER BY 1,2 ASC";
5255 5255
     }
5256 5256
     $result = Database::query($sql);
5257
-    $result = Database::store_result($result,'ASSOC');
5257
+    $result = Database::store_result($result, 'ASSOC');
5258 5258
 
5259 5259
     return $result;
5260 5260
 }
@@ -5321,12 +5321,12 @@  discard block
 block discarded – undo
5321 5321
 
5322 5322
     // Item not found for this access_url, we have to check if the whole thing is missing
5323 5323
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5324
-    $insert = "INSERT INTO $t_settings " .
5325
-                "(variable,selected_value," .
5326
-                "type,category," .
5327
-                "subkey,title," .
5328
-                "comment,scope," .
5329
-                "subkeytext,access_url,access_url_changeable)" .
5324
+    $insert = "INSERT INTO $t_settings ".
5325
+                "(variable,selected_value,".
5326
+                "type,category,".
5327
+                "subkey,title,".
5328
+                "comment,scope,".
5329
+                "subkeytext,access_url,access_url_changeable)".
5330 5330
                 " VALUES ('$var','$val',";
5331 5331
     if (isset($type)) {
5332 5332
         $type = Database::escape_string($type);
@@ -5492,7 +5492,7 @@  discard block
 block discarded – undo
5492 5492
             $result = Database::query($sql);
5493 5493
 
5494 5494
             //if ($row = Database::fetch_array($result)) {
5495
-            if (Database::num_rows($result) > 0 ) {
5495
+            if (Database::num_rows($result) > 0) {
5496 5496
                 $is_courseMember = true;
5497 5497
                 $is_courseTutor = true;
5498 5498
                 $is_courseCoach = true;
@@ -5782,7 +5782,7 @@  discard block
 block discarded – undo
5782 5782
     } else {
5783 5783
         return false;
5784 5784
     }
5785
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5785
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5786 5786
 }
5787 5787
 
5788 5788
 /**
@@ -6373,7 +6373,7 @@  discard block
 block discarded – undo
6373 6373
 function api_get_jquery_ui_js($include_jqgrid = false) {
6374 6374
     $libraries = array();
6375 6375
     if ($include_jqgrid) {
6376
-       $libraries[]='jqgrid';
6376
+       $libraries[] = 'jqgrid';
6377 6377
     }
6378 6378
     return api_get_jquery_libraries_js($libraries);
6379 6379
 }
@@ -6396,12 +6396,12 @@  discard block
 block discarded – undo
6396 6396
 
6397 6397
     //jqgrid js and css
6398 6398
     if (in_array('jqgrid', $libraries)) {
6399
-        $languaje   = 'en';
6399
+        $languaje = 'en';
6400 6400
         $platform_isocode = strtolower(api_get_language_isocode());
6401 6401
 
6402 6402
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6403 6403
         $jqgrid_langs = array(
6404
-            'bg', 'bg1251', 'cat','cn','cs','da','de','el','en','es','fa','fi','fr','gl','he','hu','is','it','ja','nl','no','pl','pt-br','pt','ro','ru','sk','sr','sv','tr','ua'
6404
+            'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua'
6405 6405
         );
6406 6406
 
6407 6407
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6432,7 +6432,7 @@  discard block
 block discarded – undo
6432 6432
 
6433 6433
     // jquery datepicker
6434 6434
     if (in_array('datepicker', $libraries)) {
6435
-        $languaje   = 'en-GB';
6435
+        $languaje = 'en-GB';
6436 6436
         $platform_isocode = strtolower(api_get_language_isocode());
6437 6437
 
6438 6438
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6598,7 +6598,7 @@  discard block
 block discarded – undo
6598 6598
  * @return void
6599 6599
  */
6600 6600
 function api_check_php_version($my_inc_path = null) {
6601
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6601
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6602 6602
         $global_error_code = 1;
6603 6603
         // Incorrect PHP version
6604 6604
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6614,7 +6614,7 @@  discard block
 block discarded – undo
6614 6614
  */
6615 6615
 function api_check_archive_dir() {
6616 6616
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6617
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6617
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6618 6618
         api_not_allowed(true, $message);
6619 6619
     }
6620 6620
 }
@@ -6677,7 +6677,7 @@  discard block
 block discarded – undo
6677 6677
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6678 6678
  * @version CEV CHANGE 24APR2012
6679 6679
  */
6680
-function api_get_real_ip(){
6680
+function api_get_real_ip() {
6681 6681
     // Guess the IP if behind a reverse proxy
6682 6682
     global $debug;
6683 6683
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6703,23 +6703,23 @@  discard block
 block discarded – undo
6703 6703
  * @author Yannick Warnier for improvements and managment of multiple ranges
6704 6704
  * @todo check for IPv6 support
6705 6705
  */
6706
-function api_check_ip_in_range($ip,$range)
6706
+function api_check_ip_in_range($ip, $range)
6707 6707
 {
6708 6708
     if (empty($ip) or empty($range)) {
6709 6709
         return false;
6710 6710
     }
6711
-    $ip_ip = ip2long ($ip);
6711
+    $ip_ip = ip2long($ip);
6712 6712
     // divide range param into array of elements
6713
-    if (strpos($range,',')!==false) {
6714
-        $ranges = explode(',',$range);
6713
+    if (strpos($range, ',') !== false) {
6714
+        $ranges = explode(',', $range);
6715 6715
     } else {
6716 6716
         $ranges = array($range);
6717 6717
     }
6718 6718
     foreach ($ranges as $range) {
6719 6719
         $range = trim($range);
6720 6720
         if (empty($range)) { continue; }
6721
-        if (strpos($range,'/')===false) {
6722
-            if (strcmp($ip,$range)===0) {
6721
+        if (strpos($range, '/') === false) {
6722
+            if (strcmp($ip, $range) === 0) {
6723 6723
                 return true; // there is a direct IP match, return OK
6724 6724
             }
6725 6725
             continue; //otherwise, get to the next range
@@ -6727,7 +6727,7 @@  discard block
 block discarded – undo
6727 6727
         // the range contains a "/", so analyse completely
6728 6728
         list ($net, $mask) = explode("/", $range);
6729 6729
 
6730
-        $ip_net = ip2long ($net);
6730
+        $ip_net = ip2long($net);
6731 6731
         // mask binary magic
6732 6732
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6733 6733
 
@@ -7065,14 +7065,14 @@  discard block
 block discarded – undo
7065 7065
  * @assert (0) === true
7066 7066
  * @assert ('1G') === true
7067 7067
  */
7068
-function api_set_memory_limit($mem){
7068
+function api_set_memory_limit($mem) {
7069 7069
     //if ini_set() not available, this function is useless
7070 7070
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
7071 7071
         return false;
7072 7072
     }
7073 7073
 
7074 7074
     $memory_limit = ini_get('memory_limit');
7075
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
7075
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
7076 7076
         ini_set('memory_limit', $mem);
7077 7077
         return true;
7078 7078
     }
@@ -7089,21 +7089,21 @@  discard block
 block discarded – undo
7089 7089
  * @assert ('1m')  === 1048576
7090 7090
  * @assert ('100k') === 102400
7091 7091
  */
7092
-function api_get_bytes_memory_limit($mem){
7093
-    $size = strtolower(substr($mem,-1));
7092
+function api_get_bytes_memory_limit($mem) {
7093
+    $size = strtolower(substr($mem, -1));
7094 7094
 
7095 7095
     switch ($size) {
7096 7096
         case 't':
7097
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
7097
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
7098 7098
             break;
7099 7099
         case 'g':
7100
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
7100
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
7101 7101
             break;
7102 7102
         case 'm':
7103
-            $mem = intval(substr($mem,0,-1))*1024*1024;
7103
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
7104 7104
             break;
7105 7105
         case 'k':
7106
-            $mem = intval(substr($mem,0,-1))*1024;
7106
+            $mem = intval(substr($mem, 0, -1)) * 1024;
7107 7107
             break;
7108 7108
         default:
7109 7109
             // we assume it's integer only
@@ -7166,7 +7166,7 @@  discard block
 block discarded – undo
7166 7166
     ];
7167 7167
 
7168 7168
     $js = api_get_asset('pwstrength-bootstrap/dist/pwstrength-bootstrap.min.js');
7169
-    $js .=  "<script>    
7169
+    $js .= "<script>    
7170 7170
     var errorMessages = {
7171 7171
         password_to_short : \"" . get_lang('PasswordIsTooShort')."\",
7172 7172
         same_as_username : \"".get_lang('YourPasswordCannotBeTheSameAsYourUsername')."\"
@@ -7213,7 +7213,7 @@  discard block
 block discarded – undo
7213 7213
         return false;
7214 7214
     }
7215 7215
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7216
-    $time = time() + $minutesToBlock*60;
7216
+    $time = time() + $minutesToBlock * 60;
7217 7217
     UserManager::update_extra_field_value(
7218 7218
         $userInfo['user_id'],
7219 7219
         'captcha_blocked_until_date',
@@ -7287,7 +7287,7 @@  discard block
 block discarded – undo
7287 7287
         $out_res = str_replace('"', "''", $out_res);
7288 7288
     }
7289 7289
     // avoid text stuck together when tags are removed, adding a space after >
7290
-    $out_res = str_replace (">", "> ", $out_res);
7290
+    $out_res = str_replace(">", "> ", $out_res);
7291 7291
     $out_res = strip_tags($out_res);
7292 7292
 
7293 7293
     return $out_res;
@@ -7496,7 +7496,7 @@  discard block
 block discarded – undo
7496 7496
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7497 7497
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7498 7498
         if (isset($hostingParams[$limitName])) {
7499
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7499
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7500 7500
         }
7501 7501
         api_mail_html(null, $email, $subject, $body);
7502 7502
     }
@@ -7628,7 +7628,7 @@  discard block
 block discarded – undo
7628 7628
  */
7629 7629
 function api_set_site_use_cookie_warning_cookie()
7630 7630
 {
7631
-    setcookie('ChamiloUsesCookies', 'ok', time()+31556926);
7631
+    setcookie('ChamiloUsesCookies', 'ok', time() + 31556926);
7632 7632
 }
7633 7633
 
7634 7634
 /**
@@ -7682,10 +7682,10 @@  discard block
 block discarded – undo
7682 7682
         return false;
7683 7683
     }
7684 7684
 
7685
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7685
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7686 7686
 
7687 7687
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7688
-        $fp = fopen($fullPath . '/index.html', 'w');
7688
+        $fp = fopen($fullPath.'/index.html', 'w');
7689 7689
 
7690 7690
         if ($fp) {
7691 7691
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7750,7 +7750,7 @@  discard block
 block discarded – undo
7750 7750
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
7751 7751
         }
7752 7752
     }
7753
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
7753
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
7754 7754
 
7755 7755
     // 5 = low, 1 = high
7756 7756
     $mail->Priority = 3;
@@ -7896,11 +7896,11 @@  discard block
 block discarded – undo
7896 7896
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
7897 7897
         if ($mail->SMTPDebug) {
7898 7898
             error_log(
7899
-                "Connection details :: " .
7900
-                "Protocol: " . $mail->Mailer . ' :: ' .
7901
-                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
7902
-                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
7903
-                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
7899
+                "Connection details :: ".
7900
+                "Protocol: ".$mail->Mailer.' :: '.
7901
+                "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '.
7902
+                "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '.
7903
+                ($mail->SMTPAuth ? "  User/Pass: ".$mail->Username.':'.$mail->Password : '')
7904 7904
             );
7905 7905
         }
7906 7906
         return 0;
@@ -7976,13 +7976,13 @@  discard block
 block discarded – undo
7976 7976
  * @return array
7977 7977
  *
7978 7978
  */
7979
-function api_unique_multidim_array($array, $key){
7979
+function api_unique_multidim_array($array, $key) {
7980 7980
     $temp_array = [];
7981 7981
     $i = 0;
7982 7982
     $key_array = [];
7983 7983
 
7984
-    foreach($array as $val){
7985
-        if(!in_array($val[$key],$key_array)){
7984
+    foreach ($array as $val) {
7985
+        if (!in_array($val[$key], $key_array)) {
7986 7986
             $key_array[$i] = $val[$key];
7987 7987
             $temp_array[$i] = $val;
7988 7988
         }
@@ -8026,7 +8026,7 @@  discard block
 block discarded – undo
8026 8026
         // No "dangerous" files
8027 8027
         $name = disable_dangerous_file($name);
8028 8028
 
8029
-        $pathId = '/'.substr((string)$itemId, 0, 1).'/'.$itemId.'/';
8029
+        $pathId = '/'.substr((string) $itemId, 0, 1).'/'.$itemId.'/';
8030 8030
         $path = api_get_path(SYS_UPLOAD_PATH).$type.$pathId;
8031 8031
 
8032 8032
         if (!is_dir($path)) {
@@ -8115,9 +8115,9 @@  discard block
 block discarded – undo
8115 8115
     $timeSeconds = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;
8116 8116
 
8117 8117
     if ($operation) {
8118
-        $date->add(new DateInterval('PT' . $timeSeconds . 'S'));
8118
+        $date->add(new DateInterval('PT'.$timeSeconds.'S'));
8119 8119
     } else {
8120
-        $date->sub(new DateInterval('PT' . $timeSeconds . 'S'));
8120
+        $date->sub(new DateInterval('PT'.$timeSeconds.'S'));
8121 8121
     }
8122 8122
 
8123 8123
 
Please login to merge, or discard this patch.
main/dropbox/dropbox_class.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
 	 * @param string $author
268 268
 	 * @param string $filename
269 269
 	 * @param int $filesize
270
-	 * @param array $recipient_ids
270
+	 * @param unknown_type|null $recipient_ids
271 271
 	 */
272 272
 	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
273 273
     {
Please login to merge, or discard this patch.
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
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 110
 		$res = Database::fetch_array($result);
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 
149 149
 			$this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150 150
 			if ($this->id) {
151
-				$sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
151
+				$sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FILE)." SET id = iid WHERE iid = {$this->id}";
152 152
 				Database::query($sql);
153 153
 			}
154 154
 		}
155 155
 
156 156
         $sql = "SELECT count(file_id) as count
157
-        		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
157
+        		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON)."
158 158
 				WHERE c_id = $course_id AND file_id = ".intval($this->id)." AND user_id = ".$this->uploader_id;
159 159
         $result = Database::query($sql);
160 160
         $row = Database::fetch_array($result);
161 161
         if ($row['count'] == 0) {
162 162
 
163 163
             // Insert entries into person table
164
-            $sql = "INSERT INTO ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." (c_id, file_id, user_id)
164
+            $sql = "INSERT INTO ".Database::get_course_table(TABLE_DROPBOX_PERSON)." (c_id, file_id, user_id)
165 165
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
166 166
             Database::query($sql);
167 167
         }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
         $action = isset($_GET['action']) ? $_GET['action'] : null;
180 180
 
181 181
         // Do some sanity checks
182
-        $id	= intval($id);
182
+        $id = intval($id);
183 183
 
184 184
         // Get the data from DB
185 185
         $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
186
-                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
186
+                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE)."
187 187
                 WHERE c_id = $course_id AND id = ".$id."";
188 188
         $result = Database::query($sql);
189 189
         $res = Database::fetch_array($result, 'ASSOC');
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         // Getting the feedback on the work.
213 213
         if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
214 214
             $feedback2 = array();
215
-            $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK) ."
215
+            $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_FEEDBACK)."
216 216
                     WHERE c_id = $course_id AND file_id='".$id."' 
217 217
                     ORDER BY feedback_id ASC";
218 218
             $result = Database::query($sql);
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
                 $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
221 221
                 $feedback2[] = $row_feedback;
222 222
             }
223
-            $this->feedback2= $feedback2;
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
230
+	public $recipients; //array of ['id']['name'] arrays
231 231
 
232 232
 	/**
233 233
 	 * Constructor calls private functions to create a new work or retreive an existing work from DB
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			$recipient_ids = array($uploader_id);
293 293
 		}
294 294
 
295
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
295
+		if (!is_array($recipient_ids) || count($recipient_ids) == 0) {
296 296
 			die(get_lang('GeneralError').' (code 209)');
297 297
 		}
298 298
 
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
         $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
309 309
         $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
310 310
         $session_id = api_get_session_id();
311
-        $user  = api_get_user_id();
311
+        $user = api_get_user_id();
312 312
         $now = api_get_utc_datetime();
313 313
         $mailId = get_mail_id_base();
314 314
 
315 315
         // Insert data in dropbox_post and dropbox_person table for each recipient
316 316
 		foreach ($this->recipients as $rec) {
317
-            $file_id = (int)$this->id;
318
-            $user_id = (int)$rec['id'];
317
+            $file_id = (int) $this->id;
318
+            $user_id = (int) $rec['id'];
319 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 321
 	        Database::query($sql);
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
                 // Do not add recipient in person table if mailing zip or just upload.
333 333
                 if (!$justSubmit) {
334
-                    Database::query($sql);	// If work already exists no error is generated
334
+                    Database::query($sql); // If work already exists no error is generated
335 335
                 }
336 336
             }
337 337
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 			    $ownerid = getUserOwningThisMailing($ownerid);
341 341
 			}
342 342
 			if (($recipid = $rec["id"]) > $mailId) {
343
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
343
+			    $recipid = $ownerid; // mailing file recipient = mailing id, not a person
344 344
 			}
345 345
             api_item_property_update(
346 346
                 $_course,
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 class Dropbox_Person
398 398
 {
399 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
400
+	public $receivedWork; // an array of Dropbox_Work objects
401
+	public $sentWork; // an array of Dropbox_SentWork objects
402 402
 
403 403
 	public $userId = 0;
404 404
 	public $isCourseAdmin = false;
405 405
 	public $isCourseTutor = false;
406
-	public $_orderBy = '';	// private property that determines by which field
406
+	public $_orderBy = ''; // private property that determines by which field
407 407
 
408 408
 	/**
409 409
 	 * Constructor for recreating the Dropbox_Person object
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	    $course_id = api_get_course_int_id();
473 473
 		// Delete entries in person table concerning received works
474 474
 		foreach ($this->receivedWork as $w) {
475
-            $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
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 477
 			Database::query($sql);
478 478
 		}
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
         $course_id = api_get_course_int_id();
490 490
 
491 491
 		$id = intval($id);
492
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
492
+		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_FILE)."
493 493
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
494 494
 		if (!Database::query($sql)) return false;
495
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
495
+		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
496 496
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497 497
 		if (!Database::query($sql)) return false;
498 498
 		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 			}
527 527
 		}
528 528
 		// Delete entries in person table concerning received works
529
-        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
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 531
 		Database::query($sql);
532
-		removeUnusedFiles();	// Check for unused files
532
+		removeUnusedFiles(); // Check for unused files
533 533
 	}
534 534
 
535 535
 	/**
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 	    $course_id = api_get_course_int_id();
541 541
 		//delete entries in person table concerning sent works
542 542
 		foreach ($this->sentWork as $w) {
543
-            $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
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 545
 			Database::query($sql);
546 546
 			removeMoreIfMailing($w->id);
547 547
 		}
548
-		removeUnusedFiles();	// Check for unused files
548
+		removeUnusedFiles(); // Check for unused files
549 549
 	}
550 550
 
551 551
 	/**
@@ -574,11 +574,11 @@  discard block
 block discarded – undo
574 574
 		}
575 575
 		//$file_id = $this->sentWork[$index]->id;
576 576
 		// Delete entries in person table concerning sent works
577
-        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
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 579
 		Database::query($sql);
580 580
 		removeMoreIfMailing($id);
581
-		removeUnusedFiles();	// Check for unused files
581
+		removeUnusedFiles(); // Check for unused files
582 582
 	}
583 583
 
584 584
 	/**
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 		$wi = -1;
601 601
 		foreach ($this->receivedWork as $w) {
602 602
 			$wi++;
603
-			if ($w->id == $id){
603
+			if ($w->id == $id) {
604 604
 			   $found = true;
605 605
 			   break;
606 606
 			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -491,13 +491,19 @@
 block discarded – undo
491 491
 		$id = intval($id);
492 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;
494
+		if (!Database::query($sql)) {
495
+		    return false;
496
+		}
495 497
 		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
496 498
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497
-		if (!Database::query($sql)) return false;
499
+		if (!Database::query($sql)) {
500
+		    return false;
501
+		}
498 502
 		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
499 503
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
500
-		if (!Database::query($sql)) return false;
504
+		if (!Database::query($sql)) {
505
+		    return false;
506
+		}
501 507
 		return true;
502 508
 	}
503 509
 
Please login to merge, or discard this patch.
main/gradebook/lib/be/category.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1545,7 +1545,7 @@
 block discarded – undo
1545 1545
      * Retrieve all categories inside a course independent category
1546 1546
      * that should be visible to a student.
1547 1547
      * @param integer $cat_id parent category
1548
-     * @param $stud_id student id
1548
+     * @param integer $stud_id student id
1549 1549
      * @param $cats optional: if defined, the categories will be added to this array
1550 1550
      */
1551 1551
     public function get_independent_categories_with_result_for_student($cat_id, $stud_id, $cats = array())
Please login to merge, or discard this patch.
Indentation   -2 removed lines patch added patch discarded remove patch
@@ -1583,7 +1583,6 @@  discard block
 block discarded – undo
1583 1583
      * @param string $course_code Course code (optional)
1584 1584
      * @param int    $session_id Session ID (optional)
1585 1585
      * @param bool   $order
1586
-
1587 1586
      * @return array Array of subcategories
1588 1587
      */
1589 1588
     public function get_subcategories($stud_id = null, $course_code = null, $session_id = null, $order = null)
@@ -1862,7 +1861,6 @@  discard block
 block discarded – undo
1862 1861
      * This function, locks a category , only one who can unlock it is
1863 1862
      * the platform administrator.
1864 1863
      * @param int locked 1 or unlocked 0
1865
-
1866 1864
      * @return boolean|null
1867 1865
      * */
1868 1866
     public function lock($locked)
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function set_session_id($session_id = 0)
203 203
     {
204
-        $this->session_id = (int)$session_id;
204
+        $this->session_id = (int) $session_id;
205 205
     }
206 206
 
207 207
     /**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         $skills = $this->get_skills();
291 291
         $skill_select = array();
292 292
         if (!empty($skills)) {
293
-            foreach($skills as $skill) {
293
+            foreach ($skills as $skill) {
294 294
                 $skill_select[$skill['id']] = $skill['name'];
295 295
             }
296 296
         }
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public static function load_session_categories($id = null, $session_id = null)
326 326
     {
327
-        if (isset($id) && (int)$id === 0) {
327
+        if (isset($id) && (int) $id === 0) {
328 328
             $cats = array();
329 329
             $cats[] = Category::create_root_category();
330 330
             return $cats;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         if (!empty($session_id)) {
338 338
             $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
339 339
             $sql = 'SELECT id, course_code
340
-                    FROM '.$tbl_grade_categories. '
340
+                    FROM '.$tbl_grade_categories.'
341 341
                     WHERE session_id = '.$session_id;
342 342
             $result_session = Database::query($sql);
343 343
             if (Database::num_rows($result_session) > 0) {
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     ) {
378 378
         //if the category given is explicitly 0 (not null), then create
379 379
         // a root category object (in memory)
380
-        if (isset($id) && (int)$id === 0) {
380
+        if (isset($id) && (int) $id === 0) {
381 381
             $cats = array();
382 382
             $cats[] = Category::create_root_category();
383 383
 
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
         $sql = 'SELECT * FROM '.$tbl_grade_categories;
389 389
         $paramcount = 0;
390 390
         if (isset($id)) {
391
-            $sql.= ' WHERE id = '.intval($id);
392
-            $paramcount ++;
391
+            $sql .= ' WHERE id = '.intval($id);
392
+            $paramcount++;
393 393
         }
394 394
 
395 395
         if (isset($user_id)) {
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
             if (empty($session_id)) {
426 426
                 $sql .= ' AND (session_id IS NULL OR session_id = 0) ';
427 427
             } else {
428
-                $sql .= ' AND session_id = '.(int)$session_id.' ';
428
+                $sql .= ' AND session_id = '.(int) $session_id.' ';
429 429
             }
430 430
             //}
431
-            $paramcount ++;
431
+            $paramcount++;
432 432
         }
433 433
 
434 434
         if (isset($parent_id)) {
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                             $default_weight = $default_weight_setting;
596 596
                         }
597 597
                         foreach ($components as $component) {
598
-                            $gradebook =  new Gradebook();
598
+                            $gradebook = new Gradebook();
599 599
                             $params = array();
600 600
 
601 601
                             $params['name'] = $component['acronym'];
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
                 }
613 613
             }
614 614
 
615
-            $gradebook= new Gradebook();
615
+            $gradebook = new Gradebook();
616 616
             $gradebook->update_skills_to_gradebook(
617 617
                 $this->id,
618 618
                 $this->get_skills(false)
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
             }
688 688
         }
689 689
 
690
-        $gradebook= new Gradebook();
690
+        $gradebook = new Gradebook();
691 691
         $gradebook->update_skills_to_gradebook(
692 692
             $this->id,
693 693
             $this->get_skills(false),
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
         if (!empty($links)) {
708 708
             foreach ($links as $link_item) {
709 709
                 if (isset($link_item)) {
710
-                    $new_item_weight =  $new_weight * $link_item->get_weight() / $old_weight;
710
+                    $new_item_weight = $new_weight * $link_item->get_weight() / $old_weight;
711 711
                     $link_item->set_weight($new_item_weight);
712 712
                     $link_item->save();
713 713
                 }
@@ -811,9 +811,9 @@  discard block
 block discarded – undo
811 811
         }
812 812
 
813 813
         if (!isset($parent)) {
814
-            $sql.= ' AND parent_id is null';
814
+            $sql .= ' AND parent_id is null';
815 815
         } else {
816
-            $sql.= ' AND parent_id = '.intval($parent);
816
+            $sql .= ' AND parent_id = '.intval($parent);
817 817
         }
818 818
 
819 819
         $result = Database::query($sql);
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
                     }
915 915
 
916 916
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
917
-                        $ressum += $score[0]/$score[1] * $catweight;
917
+                        $ressum += $score[0] / $score[1] * $catweight;
918 918
                     }
919 919
                 }
920 920
             }
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                     }
1004 1004
 
1005 1005
                     if (isset($score) && !empty($score[1]) && !empty($catweight)) {
1006
-                        $ressum += $score[0]/$score[1] * $catweight;
1006
+                        $ressum += $score[0] / $score[1] * $catweight;
1007 1007
 
1008 1008
                         if ($ressum > $bestResult) {
1009 1009
                             $bestResult = $ressum;
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
                 // session, we don't check his registration to these, but this
1146 1146
                 // could be an improvement
1147 1147
                 if (!empty($session_id)) {
1148
-                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int)$session_id;
1148
+                    $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id = ".(int) $session_id;
1149 1149
                 } else {
1150 1150
                     $sql .= " AND course_code = '".Database::escape_string($course_code)."' AND session_id is null OR session_id=0";
1151 1151
                 }
@@ -1169,9 +1169,9 @@  discard block
 block discarded – undo
1169 1169
                 // could be an improvement
1170 1170
                 $sql .= " AND course_code  = '".Database::escape_string($course_code)."'";
1171 1171
                 if (!empty($session_id)) {
1172
-                    $sql .= " AND session_id = ".(int)$session_id;
1172
+                    $sql .= " AND session_id = ".(int) $session_id;
1173 1173
                 } else {
1174
-                    $sql .="AND session_id IS NULL OR session_id=0";
1174
+                    $sql .= "AND session_id IS NULL OR session_id=0";
1175 1175
                 }
1176 1176
             } else {
1177 1177
                 $sql .= ' AND course_code IN
@@ -1185,10 +1185,10 @@  discard block
 block discarded – undo
1185 1185
                     )';
1186 1186
             }
1187 1187
         } elseif (api_is_platform_admin()) {
1188
-            if (isset($session_id) && $session_id!=0) {
1189
-                $sql.=' AND session_id='.intval($session_id);
1188
+            if (isset($session_id) && $session_id != 0) {
1189
+                $sql .= ' AND session_id='.intval($session_id);
1190 1190
             } else {
1191
-                $sql.=' AND coalesce(session_id,0)=0';
1191
+                $sql .= ' AND coalesce(session_id,0)=0';
1192 1192
             }
1193 1193
         }
1194 1194
         $result = Database::query($sql);
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
     public function get_root_categories_for_teacher($user_id, $course_code = null, $session_id = null)
1219 1219
     {
1220 1220
         if ($user_id == null) {
1221
-            return Category::load(null,null,$course_code,0,null,$session_id);
1221
+            return Category::load(null, null, $course_code, 0, null, $session_id);
1222 1222
         }
1223 1223
 
1224 1224
         $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE);
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
         if (!empty($course_code)) {
1231 1231
             $sql .= " AND course_code = '".Database::escape_string($course_code)."' ";
1232 1232
             if (!empty($session_id)) {
1233
-                $sql .= " AND session_id = ".(int)$session_id;
1233
+                $sql .= " AND session_id = ".(int) $session_id;
1234 1234
             }
1235 1235
         } else {
1236 1236
             $sql .= ' AND course_code in
@@ -1296,20 +1296,20 @@  discard block
 block discarded – undo
1296 1296
             $targets[] = $root;
1297 1297
 
1298 1298
             if (isset($this->course_code) && !empty($this->course_code)) {
1299
-                $crscats = Category::load(null,null,$this->course_code,0);
1299
+                $crscats = Category::load(null, null, $this->course_code, 0);
1300 1300
                 foreach ($crscats as $cat) {
1301 1301
                     if ($this->can_be_moved_to_cat($cat)) {
1302
-                        $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1303
-                        $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1302
+                        $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1303
+                        $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1304 1304
                     }
1305 1305
                 }
1306 1306
             }
1307 1307
 
1308
-            $indcats = Category::load(null,$user,0,0);
1308
+            $indcats = Category::load(null, $user, 0, 0);
1309 1309
             foreach ($indcats as $cat) {
1310 1310
                 if ($this->can_be_moved_to_cat($cat)) {
1311
-                    $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1312
-                    $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1311
+                    $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1312
+                    $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1313 1313
                 }
1314 1314
             }
1315 1315
 
@@ -1323,11 +1323,11 @@  discard block
 block discarded – undo
1323 1323
      */
1324 1324
     private function add_target_subcategories($targets, $level, $catid)
1325 1325
     {
1326
-        $subcats = Category::load(null,null,null,$catid);
1326
+        $subcats = Category::load(null, null, null, $catid);
1327 1327
         foreach ($subcats as $cat) {
1328 1328
             if ($this->can_be_moved_to_cat($cat)) {
1329
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1330
-                $targets = $this->add_target_subcategories($targets, $level+1, $cat->get_id());
1329
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1330
+                $targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
1331 1331
             }
1332 1332
         }
1333 1333
 
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
      * Impossible when origin and target are the same... children won't be processed
1341 1341
      * either. (a category can't be moved to one of its own children)
1342 1342
      */
1343
-    private function can_be_moved_to_cat ($cat)
1343
+    private function can_be_moved_to_cat($cat)
1344 1344
     {
1345 1345
         return $cat->get_id() != $this->get_id();
1346 1346
     }
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
     {
1370 1370
         $cats = Category::load(null, null, null, $this->id, null);
1371 1371
         $evals = Evaluation::load(null, null, null, $this->id, null);
1372
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
1372
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
1373 1373
 
1374 1374
         foreach ($cats as $cat) {
1375 1375
             $cat->set_course_code($this->get_course_code());
@@ -1402,15 +1402,15 @@  discard block
 block discarded – undo
1402 1402
             $user = (api_is_platform_admin() ? null : api_get_user_id());
1403 1403
             $cats = Category::get_root_categories_for_teacher($user);
1404 1404
             foreach ($cats as $cat) {
1405
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1406
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),null);
1405
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1406
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), null);
1407 1407
             }
1408 1408
         } else {
1409 1409
             // student
1410 1410
             $cats = Category::get_root_categories_for_student(api_get_user_id());
1411 1411
             foreach ($cats as $cat) {
1412
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1413
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(), 1);
1412
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1413
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), 1);
1414 1414
             }
1415 1415
         }
1416 1416
 
@@ -1422,14 +1422,14 @@  discard block
 block discarded – undo
1422 1422
      * @param integer $level
1423 1423
      * @param null|integer $visible
1424 1424
      */
1425
-    private function add_subtree ($targets, $level, $catid, $visible)
1425
+    private function add_subtree($targets, $level, $catid, $visible)
1426 1426
     {
1427
-        $subcats = Category::load(null,null,null,$catid,$visible);
1427
+        $subcats = Category::load(null, null, null, $catid, $visible);
1428 1428
 
1429 1429
         if (!empty($subcats)) {
1430 1430
             foreach ($subcats as $cat) {
1431
-                $targets[] = array ($cat->get_id(), $cat->get_name(), $level+1);
1432
-                $targets = Category::add_subtree($targets, $level+1, $cat->get_id(),$visible);
1431
+                $targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
1432
+                $targets = Category::add_subtree($targets, $level + 1, $cat->get_id(), $visible);
1433 1433
             }
1434 1434
         }
1435 1435
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
      * @param integer $user_id
1442 1442
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1443 1443
      */
1444
-    public function get_not_created_course_categories ($user_id)
1444
+    public function get_not_created_course_categories($user_id)
1445 1445
     {
1446 1446
         $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
1447 1447
         $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1463,9 +1463,9 @@  discard block
 block discarded – undo
1463 1463
                 )';
1464 1464
         $result = Database::query($sql);
1465 1465
 
1466
-        $cats=array();
1467
-        while ($data=Database::fetch_array($result)) {
1468
-            $cats[] = array ($data['code'], $data['title']);
1466
+        $cats = array();
1467
+        while ($data = Database::fetch_array($result)) {
1468
+            $cats[] = array($data['code'], $data['title']);
1469 1469
         }
1470 1470
 
1471 1471
         return $cats;
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
      * @param integer $user_id
1477 1477
      * @return array 2-dimensional array - every element contains 2 subelements (code, title)
1478 1478
      */
1479
-    public function get_all_courses ($user_id)
1479
+    public function get_all_courses($user_id)
1480 1480
     {
1481 1481
         $tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
1482 1482
         $tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
         $result = Database::query($sql);
1491 1491
         $cats = array();
1492 1492
         while ($data = Database::fetch_array($result)) {
1493
-            $cats[] = array ($data['code'], $data['title']);
1493
+            $cats[] = array($data['code'], $data['title']);
1494 1494
         }
1495 1495
 
1496 1496
         return $cats;
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
     {
1504 1504
         $cats = Category::load(null, null, null, $this->id, null);
1505 1505
         $evals = Evaluation::load(null, null, null, $this->id, null);
1506
-        $links = LinkFactory::load(null,null,null,null,null,$this->id,null);
1506
+        $links = LinkFactory::load(null, null, null, null, null, $this->id, null);
1507 1507
         if (!empty($cats)) {
1508 1508
             foreach ($cats as $cat) {
1509 1509
                 $cat->set_visible($this->is_visible());
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
      * @param string $name_mask search string
1859 1859
      * @return array category objects matching the search criterium
1860 1860
      */
1861
-    public function find_category($name_mask,$allcat)
1861
+    public function find_category($name_mask, $allcat)
1862 1862
     {
1863 1863
         $foundcats = array();
1864 1864
         foreach ($allcat as $search_cat) {
@@ -1901,9 +1901,9 @@  discard block
 block discarded – undo
1901 1901
                 }
1902 1902
             }
1903 1903
 
1904
-            $link_to_lock= $this->get_links();
1904
+            $link_to_lock = $this->get_links();
1905 1905
             if (!empty($link_to_lock)) {
1906
-                foreach ($link_to_lock as $item ) {
1906
+                foreach ($link_to_lock as $item) {
1907 1907
                     $item->lock($locked);
1908 1908
                 }
1909 1909
             }
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
                 return [
1992 1992
                     'badge_link' => Display::toolbarButton(
1993 1993
                         get_lang('ExportBadges'),
1994
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
1994
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
1995 1995
                         'external-link'
1996 1996
                     )
1997 1997
                 ];
@@ -2022,7 +2022,7 @@  discard block
 block discarded – undo
2022 2022
             $fileWasGenerated = $certificate_obj->html_file_is_generated();
2023 2023
 
2024 2024
             if (!empty($fileWasGenerated)) {
2025
-                $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
2025
+                $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id'];
2026 2026
 
2027 2027
                 $certificates = Display::toolbarButton(get_lang('DisplayCertificate'), $url, 'eye', 'primary');
2028 2028
 
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 
2039 2039
                 $hideExportLink = api_get_setting('hide_certificate_export_link');
2040 2040
                 $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
2041
-                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
2041
+                if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true')) {
2042 2042
                     $exportToPDF = null;
2043 2043
                 }
2044 2044
 
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
                 if ($skillToolEnabled && $userHasSkills) {
2052 2052
                     $html['badge_link'] = Display::toolbarButton(
2053 2053
                         get_lang('ExportBadges'),
2054
-                        api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user=$user_id",
2054
+                        api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
2055 2055
                         'external-link'
2056 2056
                     );
2057 2057
                 }
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
                     $certificate_obj = new Certificate($value_certificate['id']);
2109 2109
                     $certificate_obj->generate(array('hide_print_button' => true));
2110 2110
                     if ($certificate_obj->html_file_is_generated()) {
2111
-                        $certificate_path_list[]= $certificate_obj->html_file;
2111
+                        $certificate_path_list[] = $certificate_obj->html_file;
2112 2112
                     }
2113 2113
                 }
2114 2114
             }
Please login to merge, or discard this patch.
plugin/courseblock/install.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For license terms, see /license.txt */
3 3
 
4
-require_once dirname(__FILE__) . '/config.php';
4
+require_once dirname(__FILE__).'/config.php';
5 5
 
6 6
 if (!api_is_platform_admin()) {
7 7
     die ('You must have admin permissions to install plugins');
Please login to merge, or discard this patch.