Completed
Pull Request — 1.11.x (#1305)
by José
101:20 queued 63:48
created
main/lp/lp_controller.php 1 patch
Braces   +226 added lines, -113 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 $use_anonymous = true;
14 14
 
15 15
 $debug = 0;
16
-if ($debug > 0) error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
16
+if ($debug > 0) {
17
+    error_log('New LP -+- Entered lp_controller.php -+- (action: '.$_REQUEST['action'].')', 0);
18
+}
17 19
 
18 20
 // Language files that needs to be included.
19 21
 if (isset($_GET['action'])) {
@@ -231,10 +233,14 @@  discard block
 block discarded – undo
231 233
     // If refresh is set, we regenerate the oLP object from the database (kind of flush).
232 234
     Session::erase('refresh');
233 235
     $myrefresh = 1;
234
-    if ($debug > 0) error_log('New LP - Refresh asked', 0);
235
-}
236
+    if ($debug > 0) {
237
+        error_log('New LP - Refresh asked', 0);
238
+    }
239
+    }
236 240
 
237
-if ($debug > 0) error_log('New LP - Passed refresh check', 0);
241
+if ($debug > 0) {
242
+    error_log('New LP - Passed refresh check', 0);
243
+}
238 244
 
239 245
 if (!empty($_REQUEST['dialog_box'])) {
240 246
     $dialog_box = stripslashes(urldecode($_REQUEST['dialog_box']));
@@ -244,17 +250,23 @@  discard block
 block discarded – undo
244 250
 $lp_found = false;
245 251
 
246 252
 if (isset($_SESSION['lpobject'])) {
247
-    if ($debug > 0) error_log('New LP - SESSION[lpobject] is defined', 0);
253
+    if ($debug > 0) {
254
+        error_log('New LP - SESSION[lpobject] is defined', 0);
255
+    }
248 256
     $oLP = unserialize($_SESSION['lpobject']);
249 257
     if (isset($oLP) && is_object($oLP)) {
250
-        if ($debug > 0) error_log('New LP - oLP is object', 0);
258
+        if ($debug > 0) {
259
+            error_log('New LP - oLP is object', 0);
260
+        }
251 261
         if ($myrefresh == 1 OR
252 262
             empty($oLP->cc) OR
253 263
             $oLP->cc != api_get_course_id() OR
254 264
             $oLP->lp_view_session_id != $session_id OR
255 265
             $oLP->scorm_debug == '1'
256 266
         ) {
257
-            if ($debug > 0) error_log('New LP - Course has changed, discard lp object', 0);
267
+            if ($debug > 0) {
268
+                error_log('New LP - Course has changed, discard lp object', 0);
269
+            }
258 270
             if ($myrefresh == 1) { $myrefresh_id = $oLP->get_id(); }
259 271
             $oLP = null;
260 272
             Session::erase('oLP');
@@ -268,13 +280,19 @@  discard block
 block discarded – undo
268 280
 
269 281
 $course_id = api_get_course_int_id();
270 282
 
271
-if ($debug>0) error_log('New LP - Passed data remains check', 0);
283
+if ($debug>0) {
284
+    error_log('New LP - Passed data remains check', 0);
285
+}
272 286
 
273 287
 if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $_REQUEST['lp_id'])) {
274
-    if ($debug > 0) error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
288
+    if ($debug > 0) {
289
+        error_log('New LP - oLP is not object, has changed or refresh been asked, getting new', 0);
290
+    }
275 291
     // Regenerate a new lp object? Not always as some pages don't need the object (like upload?)
276 292
     if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) {
277
-        if ($debug > 0) error_log('New LP - lp_id is defined', 0);
293
+        if ($debug > 0) {
294
+            error_log('New LP - lp_id is defined', 0);
295
+        }
278 296
         // Select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
279 297
         // right object.
280 298
         if (!empty($_REQUEST['lp_id'])) {
@@ -286,49 +304,67 @@  discard block
 block discarded – undo
286 304
         $lp_table = Database::get_course_table(TABLE_LP_MAIN);
287 305
         if (is_numeric($lp_id)) {
288 306
             $sel = "SELECT lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
289
-            if ($debug > 0) error_log('New LP - querying '.$sel, 0);
307
+            if ($debug > 0) {
308
+                error_log('New LP - querying '.$sel, 0);
309
+            }
290 310
             $res = Database::query($sel);
291 311
 
292 312
             if (Database::num_rows($res)) {
293 313
                 $row = Database::fetch_array($res);
294 314
                 $type = $row['lp_type'];
295
-                if ($debug > 0) error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
315
+                if ($debug > 0) {
316
+                    error_log('New LP - found row - type '.$type. ' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
317
+                }
296 318
                 switch ($type) {
297 319
                     case 1:
298
-                        if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
320
+                        if ($debug > 0) {
321
+                            error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
322
+                        }
299 323
 
300 324
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
301 325
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
302 326
                         break;
303 327
                     case 2:
304
-                        if ($debug > 0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
328
+                        if ($debug > 0) {
329
+                            error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
330
+                        }
305 331
                         $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id());
306 332
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
307 333
                         break;
308 334
                     case 3:
309
-                        if ($debug > 0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
335
+                        if ($debug > 0) {
336
+                            error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
337
+                        }
310 338
                         $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id());
311 339
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
312 340
                         break;
313 341
                     default:
314
-                        if ($debug > 0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
342
+                        if ($debug > 0) {
343
+                            error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
344
+                        }
315 345
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
316 346
                         if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
317 347
                         break;
318 348
                 }
319 349
             }
320 350
         } else {
321
-            if ($debug > 0) error_log('New LP - Request[lp_id] is not numeric', 0);
351
+            if ($debug > 0) {
352
+                error_log('New LP - Request[lp_id] is not numeric', 0);
353
+            }
322 354
         }
323 355
     } else {
324
-        if ($debug > 0) error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
356
+        if ($debug > 0) {
357
+            error_log('New LP - Request[lp_id] and refresh_id were empty', 0);
358
+        }
325 359
     }
326 360
     if ($lp_found) {
327 361
         $_SESSION['oLP'] = $oLP;
328 362
     }
329 363
 }
330 364
 
331
-if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
365
+if ($debug > 0) {
366
+    error_log('New LP - Passed oLP creation check', 0);
367
+}
332 368
 
333 369
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
334 370
 
@@ -372,11 +408,15 @@  discard block
 block discarded – undo
372 408
         if (!$is_allowed_to_edit) {
373 409
             api_not_allowed(true);
374 410
         }
375
-        if ($debug > 0) error_log('New LP - add item action triggered', 0);
411
+        if ($debug > 0) {
412
+            error_log('New LP - add item action triggered', 0);
413
+        }
376 414
 
377 415
         if (!$lp_found) {
378 416
             //check if the learnpath ID was defined, otherwise send back to list
379
-            if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
417
+            if ($debug > 0) {
418
+                error_log('New LP - No learnpath given for add item', 0);
419
+            }
380 420
             require 'lp_list.php';
381 421
         } else {
382 422
             $_SESSION['refresh'] = 1;
@@ -465,11 +505,15 @@  discard block
 block discarded – undo
465 505
             api_not_allowed(true);
466 506
         }
467 507
 
468
-        if ($debug > 0) error_log('New LP - add audio action triggered', 0);
508
+        if ($debug > 0) {
509
+            error_log('New LP - add audio action triggered', 0);
510
+        }
469 511
 
470 512
         if (!$lp_found) {
471 513
             //check if the learnpath ID was defined, otherwise send back to list
472
-            if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0);
514
+            if ($debug > 0) {
515
+                error_log('New LP - No learnpath given for add audio', 0);
516
+            }
473 517
             require 'lp_list.php';
474 518
         } else {
475 519
             $_SESSION['refresh'] = 1;
@@ -543,7 +587,9 @@  discard block
 block discarded – undo
543 587
         if (!$is_allowed_to_edit) {
544 588
             api_not_allowed(true);
545 589
         }
546
-        if ($debug > 0) error_log('New LP - add_lp action triggered', 0);
590
+        if ($debug > 0) {
591
+            error_log('New LP - add_lp action triggered', 0);
592
+        }
547 593
         if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) {
548 594
             $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']);
549 595
             $_SESSION['refresh'] = 1;
@@ -602,7 +648,9 @@  discard block
 block discarded – undo
602 648
         if (!$is_allowed_to_edit) {
603 649
             api_not_allowed(true);
604 650
         }
605
-        if ($debug > 0) error_log('New LP - admin_view action triggered', 0);
651
+        if ($debug > 0) {
652
+            error_log('New LP - admin_view action triggered', 0);
653
+        }
606 654
         if (!$lp_found) {
607 655
             error_log('New LP - No learnpath given for admin_view', 0);
608 656
             require 'lp_list.php';
@@ -616,9 +664,10 @@  discard block
 block discarded – undo
616 664
             if (!$is_allowed_to_edit) {
617 665
                 api_not_allowed(true);
618 666
             }
619
-            if ($debug > 0) error_log('New LP - auto_launch action triggered', 0);
620
-            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; }
621
-            else {
667
+            if ($debug > 0) {
668
+                error_log('New LP - auto_launch action triggered', 0);
669
+            }
670
+            if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } else {
622 671
                 $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
623 672
                 require 'lp_list.php';
624 673
                 exit;
@@ -629,10 +678,11 @@  discard block
 block discarded – undo
629 678
         if (!$is_allowed_to_edit) {
630 679
             api_not_allowed(true);
631 680
         }
632
-        if ($debug > 0) error_log('New LP - build action triggered', 0);
681
+        if ($debug > 0) {
682
+            error_log('New LP - build action triggered', 0);
683
+        }
633 684
 
634
-        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
635
-        else {
685
+        if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } else {
636 686
             $_SESSION['refresh'] = 1;
637 687
             //require 'lp_build.php';
638 688
             $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
@@ -644,7 +694,9 @@  discard block
 block discarded – undo
644 694
         if (!$is_allowed_to_edit) {
645 695
             api_not_allowed(true);
646 696
         }
647
-        if ($debug > 0) error_log('New LP - edit item action triggered', 0);
697
+        if ($debug > 0) {
698
+            error_log('New LP - edit item action triggered', 0);
699
+        }
648 700
 
649 701
         if (!$lp_found) {
650 702
             error_log('New LP - No learnpath given for edit item', 0);
@@ -699,9 +751,10 @@  discard block
 block discarded – undo
699 751
         if (!$is_allowed_to_edit) {
700 752
             api_not_allowed(true);
701 753
         }
702
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
703
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
704
-        else {
754
+        if ($debug > 0) {
755
+            error_log('New LP - edit item prereq action triggered', 0);
756
+        }
757
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
705 758
             if (isset($_POST['submit_button'])) {
706 759
                 //Updating the lp.modified_on
707 760
                 $_SESSION['oLP']->set_modified_on();
@@ -729,9 +782,10 @@  discard block
 block discarded – undo
729 782
         if (!$is_allowed_to_edit) {
730 783
             api_not_allowed(true);
731 784
         }
732
-        if ($debug > 0) error_log('New LP - move item action triggered', 0);
733
-        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; }
734
-        else {
785
+        if ($debug > 0) {
786
+            error_log('New LP - move item action triggered', 0);
787
+        }
788
+        if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } else {
735 789
             $_SESSION['refresh'] = 1;
736 790
             if (isset($_POST['submit_button'])) {
737 791
                 //Updating the lp.modified_on
@@ -764,7 +818,9 @@  discard block
 block discarded – undo
764 818
         if (!$is_allowed_to_edit) {
765 819
             api_not_allowed(true);
766 820
         }
767
-        if ($debug > 0) error_log('New LP - view_item action triggered', 0);
821
+        if ($debug > 0) {
822
+            error_log('New LP - view_item action triggered', 0);
823
+        }
768 824
         if (!$lp_found) {
769 825
             error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php';
770 826
         } else {
@@ -776,7 +832,9 @@  discard block
 block discarded – undo
776 832
         if (!$is_allowed_to_edit) {
777 833
             api_not_allowed(true);
778 834
         }
779
-        if ($debug > 0) error_log('New LP - upload action triggered', 0);
835
+        if ($debug > 0) {
836
+            error_log('New LP - upload action triggered', 0);
837
+        }
780 838
         $cwdir = getcwd();
781 839
         require 'lp_upload.php';
782 840
         // Reinit current working directory as many functions in upload change it.
@@ -793,9 +851,10 @@  discard block
 block discarded – undo
793 851
             api_not_allowed(true);
794 852
         }
795 853
 
796
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
797
-        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; }
798
-        else {
854
+        if ($debug > 0) {
855
+            error_log('New LP - export action triggered', 0);
856
+        }
857
+        if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } else {
799 858
             $_SESSION['oLP']->copy();
800 859
         }
801 860
         require 'lp_list.php';
@@ -828,7 +887,9 @@  discard block
 block discarded – undo
828 887
             api_not_allowed(true);
829 888
         }
830 889
 
831
-        if ($debug > 0) error_log('New LP - export action triggered', 0);
890
+        if ($debug > 0) {
891
+            error_log('New LP - export action triggered', 0);
892
+        }
832 893
         if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php';
833 894
         } else {
834 895
             $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
@@ -842,9 +903,10 @@  discard block
 block discarded – undo
842 903
         if (!$is_allowed_to_edit) {
843 904
             api_not_allowed(true);
844 905
         }
845
-        if ($debug > 0) error_log('New LP - delete action triggered', 0);
846
-        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; }
847
-        else {
906
+        if ($debug > 0) {
907
+            error_log('New LP - delete action triggered', 0);
908
+        }
909
+        if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } else {
848 910
             $_SESSION['refresh'] = 1;
849 911
             $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
850 912
             Session::erase('oLP');
@@ -856,9 +918,10 @@  discard block
 block discarded – undo
856 918
         if (!$is_allowed_to_edit) {
857 919
             api_not_allowed(true);
858 920
         }
859
-        if ($debug > 0) error_log('New LP - visibility action triggered', 0);
860
-        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; }
861
-        else {
921
+        if ($debug > 0) {
922
+            error_log('New LP - visibility action triggered', 0);
923
+        }
924
+        if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } else {
862 925
             learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']);
863 926
             require 'lp_list.php';
864 927
         }
@@ -868,9 +931,10 @@  discard block
 block discarded – undo
868 931
         if (!$is_allowed_to_edit) {
869 932
             api_not_allowed(true);
870 933
         }
871
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
872
-        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; }
873
-        else {
934
+        if ($debug > 0) {
935
+            error_log('New LP - publish action triggered', 0);
936
+        }
937
+        if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } else {
874 938
             learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']);
875 939
             require 'lp_list.php';
876 940
         }
@@ -880,7 +944,9 @@  discard block
 block discarded – undo
880 944
         if (!$is_allowed_to_edit) {
881 945
             api_not_allowed(true);
882 946
         }
883
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
947
+        if ($debug > 0) {
948
+            error_log('New LP - publish action triggered', 0);
949
+        }
884 950
         if (!$lp_found) {
885 951
             error_log('New LP - No learnpath given for publish', 0);
886 952
             require 'lp_list.php';
@@ -894,7 +960,9 @@  discard block
 block discarded – undo
894 960
         if (!$is_allowed_to_edit) {
895 961
             api_not_allowed(true);
896 962
         }
897
-        if ($debug > 0) error_log('New LP - publish action triggered', 0);
963
+        if ($debug > 0) {
964
+            error_log('New LP - publish action triggered', 0);
965
+        }
898 966
         if (!$lp_found) {
899 967
             error_log('New LP - No learnpath given for publish', 0);
900 968
             require 'lp_list.php';
@@ -907,9 +975,10 @@  discard block
 block discarded – undo
907 975
         if (!$is_allowed_to_edit) {
908 976
             api_not_allowed(true);
909 977
         }
910
-        if ($debug > 0) error_log('New LP - edit action triggered', 0);
911
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
912
-        else {
978
+        if ($debug > 0) {
979
+            error_log('New LP - edit action triggered', 0);
980
+        }
981
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
913 982
             $_SESSION['refresh'] = 1;
914 983
             require 'lp_edit.php';
915 984
         }
@@ -918,9 +987,10 @@  discard block
 block discarded – undo
918 987
         if (!$is_allowed_to_edit) {
919 988
             api_not_allowed(true);
920 989
         }
921
-        if ($debug > 0) error_log('New LP - update_lp action triggered', 0);
922
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; }
923
-        else {
990
+        if ($debug > 0) {
991
+            error_log('New LP - update_lp action triggered', 0);
992
+        }
993
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } else {
924 994
             $_SESSION['refresh'] = 1;
925 995
             $lp_name = Security::remove_XSS($_REQUEST['lp_name']);
926 996
             $_SESSION['oLP']->set_name($lp_name);
@@ -989,8 +1059,9 @@  discard block
 block discarded – undo
989 1059
             );
990 1060
             $extraFieldValue->saveFieldValues($_REQUEST);
991 1061
 
992
-            if ($_FILES['lp_preview_image']['size'] > 0)
993
-                $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1062
+            if ($_FILES['lp_preview_image']['size'] > 0) {
1063
+                            $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
1064
+            }
994 1065
 
995 1066
             if (api_get_setting('search_enabled') === 'true') {
996 1067
                 require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -1030,9 +1101,10 @@  discard block
 block discarded – undo
1030 1101
         if (!$is_allowed_to_edit) {
1031 1102
             api_not_allowed(true);
1032 1103
         }
1033
-        if ($debug > 0) error_log('New LP - add sub item action triggered', 0);
1034
-        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; }
1035
-        else {
1104
+        if ($debug > 0) {
1105
+            error_log('New LP - add sub item action triggered', 0);
1106
+        }
1107
+        if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } else {
1036 1108
             $_SESSION['refresh'] = 1;
1037 1109
             if (!empty($_REQUEST['parent_item_id'])) {
1038 1110
                 $_SESSION['from_learnpath']='yes';
@@ -1048,7 +1120,9 @@  discard block
 block discarded – undo
1048 1120
         if (!$is_allowed_to_edit) {
1049 1121
             api_not_allowed(true);
1050 1122
         }
1051
-        if ($debug > 0) error_log('New LP - delete item action triggered', 0);
1123
+        if ($debug > 0) {
1124
+            error_log('New LP - delete item action triggered', 0);
1125
+        }
1052 1126
         if (!$lp_found) {
1053 1127
             error_log('New LP - No learnpath given for delete item', 0);
1054 1128
             require 'lp_list.php';
@@ -1067,9 +1141,10 @@  discard block
 block discarded – undo
1067 1141
         if (!$is_allowed_to_edit) {
1068 1142
             api_not_allowed(true);
1069 1143
         }
1070
-        if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
1071
-        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
1072
-        else {
1144
+        if ($debug > 0) {
1145
+            error_log('New LP - edit item prereq action triggered', 0);
1146
+        }
1147
+        if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } else {
1073 1148
             if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) {
1074 1149
                 $_SESSION['refresh'] = 1;
1075 1150
                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']);
@@ -1078,64 +1153,80 @@  discard block
 block discarded – undo
1078 1153
         }
1079 1154
         break;
1080 1155
     case 'restart':
1081
-        if ($debug > 0) error_log('New LP - restart action triggered', 0);
1082
-        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; }
1083
-        else {
1156
+        if ($debug > 0) {
1157
+            error_log('New LP - restart action triggered', 0);
1158
+        }
1159
+        if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } else {
1084 1160
             $_SESSION['oLP']->restart();
1085 1161
             require 'lp_view.php';
1086 1162
         }
1087 1163
         break;
1088 1164
     case 'last':
1089
-        if ($debug > 0) error_log('New LP - last action triggered', 0);
1090
-        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; }
1091
-        else {
1165
+        if ($debug > 0) {
1166
+            error_log('New LP - last action triggered', 0);
1167
+        }
1168
+        if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } else {
1092 1169
             $_SESSION['oLP']->last();
1093 1170
             require 'lp_view.php';
1094 1171
         }
1095 1172
         break;
1096 1173
     case 'first':
1097
-        if ($debug > 0) error_log('New LP - first action triggered', 0);
1098
-        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; }
1099
-        else {
1174
+        if ($debug > 0) {
1175
+            error_log('New LP - first action triggered', 0);
1176
+        }
1177
+        if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } else {
1100 1178
             $_SESSION['oLP']->first();
1101 1179
             require 'lp_view.php';
1102 1180
         }
1103 1181
         break;
1104 1182
     case 'next':
1105
-        if ($debug > 0) error_log('New LP - next action triggered', 0);
1106
-        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; }
1107
-        else {
1183
+        if ($debug > 0) {
1184
+            error_log('New LP - next action triggered', 0);
1185
+        }
1186
+        if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } else {
1108 1187
             $_SESSION['oLP']->next();
1109 1188
             require 'lp_view.php';
1110 1189
         }
1111 1190
         break;
1112 1191
     case 'previous':
1113
-        if ($debug > 0) error_log('New LP - previous action triggered', 0);
1114
-        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; }
1115
-        else {
1192
+        if ($debug > 0) {
1193
+            error_log('New LP - previous action triggered', 0);
1194
+        }
1195
+        if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } else {
1116 1196
             $_SESSION['oLP']->previous();
1117 1197
             require 'lp_view.php';
1118 1198
         }
1119 1199
         break;
1120 1200
     case 'content':
1121
-        if ($debug > 0) error_log('New LP - content action triggered', 0);
1122
-        if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1201
+        if ($debug > 0) {
1202
+            error_log('New LP - content action triggered', 0);
1203
+        }
1204
+        if ($debug > 0) {
1205
+            error_log('New LP - Item id is '.intval($_GET['item_id']), 0);
1206
+        }
1123 1207
         if (!$lp_found) {
1124 1208
             error_log('New LP - No learnpath given for content', 0);
1125 1209
             require 'lp_list.php';
1126 1210
         } else {
1127
-            if ($debug > 0) error_log('New LP - save_last()', 0);
1211
+            if ($debug > 0) {
1212
+                error_log('New LP - save_last()', 0);
1213
+            }
1128 1214
             $_SESSION['oLP']->save_last();
1129
-            if ($debug > 0) error_log('New LP - set_current_item()', 0);
1215
+            if ($debug > 0) {
1216
+                error_log('New LP - set_current_item()', 0);
1217
+            }
1130 1218
             $_SESSION['oLP']->set_current_item($_GET['item_id']);
1131
-            if ($debug > 0) error_log('New LP - start_current_item()', 0);
1219
+            if ($debug > 0) {
1220
+                error_log('New LP - start_current_item()', 0);
1221
+            }
1132 1222
             $_SESSION['oLP']->start_current_item();
1133 1223
             require 'lp_content.php';
1134 1224
         }
1135 1225
         break;
1136 1226
     case 'view':
1137
-        if ($debug > 0)
1138
-            error_log('New LP - view action triggered', 0);
1227
+        if ($debug > 0) {
1228
+                    error_log('New LP - view action triggered', 0);
1229
+        }
1139 1230
         if (!$lp_found) {
1140 1231
             error_log('New LP - No learnpath given for view', 0);
1141 1232
             require 'lp_list.php';
@@ -1148,17 +1239,19 @@  discard block
 block discarded – undo
1148 1239
         }
1149 1240
         break;
1150 1241
     case 'save':
1151
-        if ($debug > 0) error_log('New LP - save action triggered', 0);
1152
-        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; }
1153
-        else {
1242
+        if ($debug > 0) {
1243
+            error_log('New LP - save action triggered', 0);
1244
+        }
1245
+        if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } else {
1154 1246
             $_SESSION['oLP']->save_item();
1155 1247
             require 'lp_save.php';
1156 1248
         }
1157 1249
         break;
1158 1250
     case 'stats':
1159
-        if ($debug > 0) error_log('New LP - stats action triggered', 0);
1160
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1161
-        else {
1251
+        if ($debug > 0) {
1252
+            error_log('New LP - stats action triggered', 0);
1253
+        }
1254
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1162 1255
             $_SESSION['oLP']->save_current();
1163 1256
             $_SESSION['oLP']->save_last();
1164 1257
             $output = require 'lp_stats.php';
@@ -1166,7 +1259,9 @@  discard block
 block discarded – undo
1166 1259
         }
1167 1260
         break;
1168 1261
     case 'list':
1169
-        if ($debug > 0) error_log('New LP - list action triggered', 0);
1262
+        if ($debug > 0) {
1263
+            error_log('New LP - list action triggered', 0);
1264
+        }
1170 1265
         if ($lp_found) {
1171 1266
             $_SESSION['refresh'] = 1;
1172 1267
             $_SESSION['oLP']->save_last();
@@ -1175,7 +1270,9 @@  discard block
 block discarded – undo
1175 1270
         break;
1176 1271
     case 'mode':
1177 1272
         // Switch between fullscreen and embedded mode.
1178
-        if ($debug > 0) error_log('New LP - mode change triggered', 0);
1273
+        if ($debug > 0) {
1274
+            error_log('New LP - mode change triggered', 0);
1275
+        }
1179 1276
         $mode = $_REQUEST['mode'];
1180 1277
         if ($mode == 'fullscreen') {
1181 1278
             $_SESSION['oLP']->mode = 'fullscreen';
@@ -1189,7 +1286,9 @@  discard block
 block discarded – undo
1189 1286
         require 'lp_view.php';
1190 1287
         break;
1191 1288
     case 'switch_view_mode':
1192
-        if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0);
1289
+        if ($debug > 0) {
1290
+            error_log('New LP - switch_view_mode action triggered', 0);
1291
+        }
1193 1292
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1194 1293
         if (Security::check_token('get')) {
1195 1294
             $_SESSION['refresh'] = 1;
@@ -1198,7 +1297,9 @@  discard block
 block discarded – undo
1198 1297
         require 'lp_list.php';
1199 1298
         break;
1200 1299
     case 'switch_force_commit':
1201
-        if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0);
1300
+        if ($debug > 0) {
1301
+            error_log('New LP - switch_force_commit action triggered', 0);
1302
+        }
1202 1303
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1203 1304
         $_SESSION['refresh'] = 1;
1204 1305
         $_SESSION['oLP']->update_default_scorm_commit();
@@ -1221,25 +1322,33 @@  discard block
 block discarded – undo
1221 1322
 		break;
1222 1323
      */
1223 1324
 	case 'switch_attempt_mode':
1224
-		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
1325
+		if($debug>0) {
1326
+		    error_log('New LP - switch_reinit action triggered',0);
1327
+		}
1225 1328
 		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
1226 1329
 		$_SESSION['refresh'] = 1;
1227 1330
 		$_SESSION['oLP']->switch_attempt_mode();
1228 1331
         require 'lp_list.php';
1229 1332
         break;
1230 1333
     case 'switch_scorm_debug':
1231
-        if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0);
1334
+        if ($debug > 0) {
1335
+            error_log('New LP - switch_scorm_debug action triggered', 0);
1336
+        }
1232 1337
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
1233 1338
         $_SESSION['refresh'] = 1;
1234 1339
         $_SESSION['oLP']->update_scorm_debug();
1235 1340
         require 'lp_list.php';
1236 1341
         break;
1237 1342
     case 'intro_cmdAdd':
1238
-        if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0);
1343
+        if ($debug > 0) {
1344
+            error_log('New LP - intro_cmdAdd action triggered', 0);
1345
+        }
1239 1346
         // Add introduction section page.
1240 1347
         break;
1241 1348
     case 'js_api_refresh':
1242
-        if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
1349
+        if ($debug > 0) {
1350
+            error_log('New LP - js_api_refresh action triggered', 0);
1351
+        }
1243 1352
         if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
1244 1353
         if (isset($_REQUEST['item_id'])) {
1245 1354
             $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
@@ -1247,8 +1356,7 @@  discard block
 block discarded – undo
1247 1356
         require 'lp_message.php';
1248 1357
         break;
1249 1358
     case 'return_to_course_homepage':
1250
-        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
1251
-        else {
1359
+        if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } else {
1252 1360
             $_SESSION['oLP']->save_current();
1253 1361
             $_SESSION['oLP']->save_last();
1254 1362
             $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
@@ -1266,8 +1374,9 @@  discard block
 block discarded – undo
1266 1374
         require 'lp_list_search.php';
1267 1375
         break;
1268 1376
     case 'impress':
1269
-        if ($debug > 0)
1270
-            error_log('New LP - view action triggered', 0);
1377
+        if ($debug > 0) {
1378
+                    error_log('New LP - view action triggered', 0);
1379
+        }
1271 1380
         if (!$lp_found) {
1272 1381
             error_log('New LP - No learnpath given for view', 0);
1273 1382
             require 'lp_list.php';
@@ -1441,15 +1550,19 @@  discard block
 block discarded – undo
1441 1550
         ]);
1442 1551
         break;
1443 1552
     default:
1444
-        if ($debug > 0) error_log('New LP - default action triggered', 0);
1553
+        if ($debug > 0) {
1554
+            error_log('New LP - default action triggered', 0);
1555
+        }
1445 1556
         require 'lp_list.php';
1446 1557
         break;
1447 1558
 }
1448 1559
 
1449 1560
 if (!empty($_SESSION['oLP'])) {
1450 1561
     $_SESSION['lpobject'] = serialize($_SESSION['oLP']);
1451
-    if ($debug > 0) error_log('New LP - lpobject is serialized in session', 0);
1452
-}
1562
+    if ($debug > 0) {
1563
+        error_log('New LP - lpobject is serialized in session', 0);
1564
+    }
1565
+    }
1453 1566
 
1454 1567
 if (!empty($redirectTo)) {
1455 1568
     header("Location: $redirectTo");
Please login to merge, or discard this patch.
main/webservices/registration.soap.php 1 patch
Braces   +186 added lines, -64 removed lines patch added patch discarded remove patch
@@ -63,14 +63,16 @@  discard block
 block discarded – undo
63 63
         list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
64 64
         $ip = trim($ip1);
65 65
     }
66
-    if ($debug)
67
-        error_log("ip: $ip");
66
+    if ($debug) {
67
+            error_log("ip: $ip");
68
+    }
68 69
     // Check if a file that limits access from webservices exists and contains
69 70
     // the restraining check
70 71
     if (is_file('webservice-auth-ip.conf.php')) {
71 72
         include 'webservice-auth-ip.conf.php';
72
-        if ($debug)
73
-            error_log("webservice-auth-ip.conf.php file included");
73
+        if ($debug) {
74
+                    error_log("webservice-auth-ip.conf.php file included");
75
+        }
74 76
         if (!empty($ws_auth_ip)) {
75 77
             $check_ip = true;
76 78
             $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
@@ -556,7 +558,9 @@  discard block
 block discarded – undo
556 558
 
557 559
     // First check wether the login already exists
558 560
     if (!UserManager::is_username_available($loginName)) {
559
-        if ($debug) error_log("Username $loginName is not available");
561
+        if ($debug) {
562
+            error_log("Username $loginName is not available");
563
+        }
560 564
         return 0;
561 565
     }
562 566
 
@@ -1049,9 +1053,15 @@  discard block
 block discarded – undo
1049 1053
         );
1050 1054
     }
1051 1055
 
1052
-    if ($debug) error_log('$userId found: '. $userId);
1053
-    if ($debug) error_log('$courseId found: '. $courseId);
1054
-    if ($debug) error_log('$sessionId found: '. $sessionId);
1056
+    if ($debug) {
1057
+        error_log('$userId found: '. $userId);
1058
+    }
1059
+    if ($debug) {
1060
+        error_log('$courseId found: '. $courseId);
1061
+    }
1062
+    if ($debug) {
1063
+        error_log('$sessionId found: '. $sessionId);
1064
+    }
1055 1065
 
1056 1066
     return [
1057 1067
         'user_id' => $userId,
@@ -1081,13 +1091,17 @@  discard block
 block discarded – undo
1081 1091
 {
1082 1092
     global $debug;
1083 1093
 
1084
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1094
+    if ($debug) {
1095
+        error_log('WSSubscribeTeacherToSessionCourse');
1096
+    }
1085 1097
 
1086 1098
     if (!WSHelperVerifyKey($params)) {
1087 1099
         return returnError(WS_ERROR_SECRET_KEY);
1088 1100
     }
1089 1101
 
1090
-    if ($debug) error_log('Params '. print_r($params, 1));
1102
+    if ($debug) {
1103
+        error_log('Params '. print_r($params, 1));
1104
+    }
1091 1105
 
1092 1106
     $params = parseCourseSessionUserParams($params);
1093 1107
 
@@ -1100,13 +1114,17 @@  discard block
 block discarded – undo
1100 1114
     $result = 0;
1101 1115
 
1102 1116
     if (!empty($coaches)) {
1103
-        if ($debug) error_log('Coaches:  '. print_r($coaches, 1));
1117
+        if ($debug) {
1118
+            error_log('Coaches:  '. print_r($coaches, 1));
1119
+        }
1104 1120
         if (in_array($userId, $coaches)) {
1105 1121
             $result = 1;
1106 1122
         }
1107 1123
     }
1108 1124
 
1109
-    if ($debug) error_log('Result:  '. $result);
1125
+    if ($debug) {
1126
+        error_log('Result:  '. $result);
1127
+    }
1110 1128
 
1111 1129
     return $result;
1112 1130
 }
@@ -1132,13 +1150,17 @@  discard block
 block discarded – undo
1132 1150
 {
1133 1151
     global $debug;
1134 1152
 
1135
-    if ($debug) error_log('WSSubscribeTeacherToSessionCourse');
1153
+    if ($debug) {
1154
+        error_log('WSSubscribeTeacherToSessionCourse');
1155
+    }
1136 1156
 
1137 1157
     if (!WSHelperVerifyKey($params)) {
1138 1158
         return returnError(WS_ERROR_SECRET_KEY);
1139 1159
     }
1140 1160
 
1141
-    if ($debug) error_log('Params '. print_r($params, 1));
1161
+    if ($debug) {
1162
+        error_log('Params '. print_r($params, 1));
1163
+    }
1142 1164
 
1143 1165
     $params = parseCourseSessionUserParams($params);
1144 1166
 
@@ -1152,7 +1174,9 @@  discard block
 block discarded – undo
1152 1174
     $result = 0;
1153 1175
 
1154 1176
     if (!empty($coaches)) {
1155
-        if ($debug) error_log('Coaches:  ' . print_r($coaches, 1));
1177
+        if ($debug) {
1178
+            error_log('Coaches:  ' . print_r($coaches, 1));
1179
+        }
1156 1180
         if (!in_array($userId, $coaches)) {
1157 1181
             $result = 1;
1158 1182
         }
@@ -1160,7 +1184,9 @@  discard block
 block discarded – undo
1160 1184
         $result = 1;
1161 1185
     }
1162 1186
 
1163
-    if ($debug) error_log('Final Result: '. $result);
1187
+    if ($debug) {
1188
+        error_log('Final Result: '. $result);
1189
+    }
1164 1190
 
1165 1191
     return $result;
1166 1192
 }
@@ -1212,8 +1238,12 @@  discard block
 block discarded – undo
1212 1238
 {
1213 1239
     global $_user, $_configuration, $debug;
1214 1240
     $debug = 1;
1215
-    if ($debug) error_log('WSCreateUserPasswordCrypted');
1216
-    if ($debug) error_log(print_r($params,1));
1241
+    if ($debug) {
1242
+        error_log('WSCreateUserPasswordCrypted');
1243
+    }
1244
+    if ($debug) {
1245
+        error_log(print_r($params,1));
1246
+    }
1217 1247
 
1218 1248
     if (!WSHelperVerifyKey($params)) {
1219 1249
         return returnError(WS_ERROR_SECRET_KEY);
@@ -1245,22 +1275,30 @@  discard block
 block discarded – undo
1245 1275
         if ($_configuration['password_encryption'] === $encrypt_method ) {
1246 1276
             if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
1247 1277
                 $msg = "Encryption $encrypt_method is invalid";
1248
-                if ($debug) error_log($msg);
1278
+                if ($debug) {
1279
+                    error_log($msg);
1280
+                }
1249 1281
                 return $msg;
1250 1282
 
1251 1283
             } else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
1252 1284
                 $msg = "Encryption $encrypt_method is invalid";
1253
-                if ($debug) error_log($msg);
1285
+                if ($debug) {
1286
+                    error_log($msg);
1287
+                }
1254 1288
                 return $msg;
1255 1289
             }
1256 1290
         } else {
1257 1291
             $msg = "This encryption $encrypt_method is not configured";
1258
-            if ($debug) error_log($msg);
1292
+            if ($debug) {
1293
+                error_log($msg);
1294
+            }
1259 1295
             return $msg;
1260 1296
         }
1261 1297
     } else {
1262 1298
         $msg = 'The chamilo setting $_configuration["password_encryption"] is not configured';
1263
-        if ($debug) error_log($msg);
1299
+        if ($debug) {
1300
+            error_log($msg);
1301
+        }
1264 1302
         return $msg;
1265 1303
     }
1266 1304
 
@@ -1280,10 +1318,14 @@  discard block
 block discarded – undo
1280 1318
         $original_user_id_name
1281 1319
     );
1282 1320
 
1283
-    if ($debug) error_log('Ready to create user');
1321
+    if ($debug) {
1322
+        error_log('Ready to create user');
1323
+    }
1284 1324
 
1285 1325
     if ($user_id > 0) {
1286
-        if ($debug) error_log('User found with id: '.$user_id);
1326
+        if ($debug) {
1327
+            error_log('User found with id: '.$user_id);
1328
+        }
1287 1329
 
1288 1330
         // Check whether user is not active
1289 1331
         //@todo why this condition exists??
@@ -1294,7 +1336,9 @@  discard block
 block discarded – undo
1294 1336
         $count_check_user = Database::num_rows($resu);
1295 1337
         if ($count_check_user > 0) {
1296 1338
 
1297
-            if ($debug) error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1339
+            if ($debug) {
1340
+                error_log('User id: '.$user_id.' exists and is NOT active. Updating user and setting setting active = 1');
1341
+            }
1298 1342
 
1299 1343
             $sql = "UPDATE $table_user SET
1300 1344
                     lastname='".Database::escape_string($lastName)."',
@@ -1315,7 +1359,9 @@  discard block
 block discarded – undo
1315 1359
                     hr_dept_id=".intval($hr_dept_id)." 
1316 1360
                 WHERE user_id='".$r_check_user[0]."'";
1317 1361
 
1318
-            if ($debug) error_log($sql);
1362
+            if ($debug) {
1363
+                error_log($sql);
1364
+            }
1319 1365
             Database::query($sql);
1320 1366
 
1321 1367
             if (is_array($extra_list) && count($extra_list) > 0) {
@@ -1332,11 +1378,15 @@  discard block
 block discarded – undo
1332 1378
             }
1333 1379
             return $r_check_user[0];
1334 1380
         } else {
1335
-            if ($debug) error_log('User exists but is active. Cant be updated');
1381
+            if ($debug) {
1382
+                error_log('User exists but is active. Cant be updated');
1383
+            }
1336 1384
             return 0;
1337 1385
         }
1338 1386
     } else {
1339
-        if ($debug) error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1387
+        if ($debug) {
1388
+            error_log("User not found with original_id = $original_user_id_value and original_name = $original_user_id_name");
1389
+        }
1340 1390
     }
1341 1391
 
1342 1392
     // Default language.
@@ -1352,7 +1402,9 @@  discard block
 block discarded – undo
1352 1402
 
1353 1403
     // First check wether the login already exists
1354 1404
     if (!UserManager::is_username_available($loginName)) {
1355
-        if ($debug) error_log("Username $loginName is not available");
1405
+        if ($debug) {
1406
+            error_log("Username $loginName is not available");
1407
+        }
1356 1408
         return 0;
1357 1409
     }
1358 1410
 
@@ -1374,7 +1426,9 @@  discard block
 block discarded – undo
1374 1426
             expiration_date     = '".Database::escape_string($expiration_date)."',
1375 1427
             hr_dept_id          = '".Database::escape_string($hr_dept_id)."',
1376 1428
             active              = '".Database::escape_string($active)."'";
1377
-    if ($debug) error_log($sql);
1429
+    if ($debug) {
1430
+        error_log($sql);
1431
+    }
1378 1432
 
1379 1433
     Database::query($sql);
1380 1434
     $return = Database::insert_id();
@@ -1386,7 +1440,9 @@  discard block
 block discarded – undo
1386 1440
 
1387 1441
         $url_id = api_get_current_access_url_id();
1388 1442
         UrlManager::add_user_to_url($return, $url_id);
1389
-        if ($debug) error_log("Adding user_id = $return to URL id $url_id ");
1443
+        if ($debug) {
1444
+            error_log("Adding user_id = $return to URL id $url_id ");
1445
+        }
1390 1446
 
1391 1447
         // Create extra field for the original_user_id_name
1392 1448
         UserManager::create_extra_field(
@@ -1423,7 +1479,9 @@  discard block
 block discarded – undo
1423 1479
             }
1424 1480
         }
1425 1481
     } else {
1426
-        if ($debug) error_log('Error while inserting a user');
1482
+        if ($debug) {
1483
+            error_log('Error while inserting a user');
1484
+        }
1427 1485
 
1428 1486
         return 0;
1429 1487
     }
@@ -4194,7 +4252,9 @@  discard block
 block discarded – undo
4194 4252
             continue;
4195 4253
         }
4196 4254
 
4197
-        if (empty($nolimit) && $duration) $nolimit = 1;
4255
+        if (empty($nolimit) && $duration) {
4256
+            $nolimit = 1;
4257
+        }
4198 4258
 
4199 4259
         if (empty($nolimit)) {
4200 4260
             $date_start = "$year_start-".(($month_start < 10) ? "0$month_start" : $month_start)."-".(($day_start < 10) ? "0$day_start" : $day_start).' 00:00:00';
@@ -4507,7 +4567,9 @@  discard block
 block discarded – undo
4507 4567
     if (!WSHelperVerifyKey($params)) {
4508 4568
         return returnError(WS_ERROR_SECRET_KEY);
4509 4569
     }
4510
-    if ($debug) error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4570
+    if ($debug) {
4571
+        error_log('WSSubscribeUserToCourse params: '.print_r($params,1));
4572
+    }
4511 4573
 
4512 4574
     $results = array();
4513 4575
     $userscourses = $params['userscourses'];
@@ -4526,7 +4588,9 @@  discard block
 block discarded – undo
4526 4588
             $original_user_id['original_user_id_value'],
4527 4589
             $original_user_id['original_user_id_name']
4528 4590
         );
4529
-        if ($debug) error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4591
+        if ($debug) {
4592
+            error_log('WSSubscribeUserToCourse user_id: '.$user_id);
4593
+        }
4530 4594
 
4531 4595
         if ($user_id == 0) {
4532 4596
             // If user was not found, there was a problem
@@ -4544,13 +4608,19 @@  discard block
 block discarded – undo
4544 4608
                 // Course was not found
4545 4609
                 $resultValue = 0;
4546 4610
             } else {
4547
-                if ($debug) error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4611
+                if ($debug) {
4612
+                    error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
4613
+                }
4548 4614
                 $result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false);
4549 4615
                 if ($result) {
4550 4616
                     $resultValue = 1;
4551
-                    if ($debug) error_log('WSSubscribeUserToCourse subscribed');
4617
+                    if ($debug) {
4618
+                        error_log('WSSubscribeUserToCourse subscribed');
4619
+                    }
4552 4620
                 } else {
4553
-                    if ($debug) error_log('WSSubscribeUserToCourse NOT subscribed: ');
4621
+                    if ($debug) {
4622
+                        error_log('WSSubscribeUserToCourse NOT subscribed: ');
4623
+                    }
4554 4624
                 }
4555 4625
             }
4556 4626
         }
@@ -4609,8 +4679,12 @@  discard block
 block discarded – undo
4609 4679
 function WSSubscribeUserToCourseSimple($params) {
4610 4680
     global $debug;
4611 4681
 
4612
-    if ($debug) error_log('WSSubscribeUserToCourseSimple');
4613
-    if ($debug) error_log('Params '. print_r($params, 1));
4682
+    if ($debug) {
4683
+        error_log('WSSubscribeUserToCourseSimple');
4684
+    }
4685
+    if ($debug) {
4686
+        error_log('Params '. print_r($params, 1));
4687
+    }
4614 4688
     if (!WSHelperVerifyKey($params)) {
4615 4689
         return returnError(WS_ERROR_SECRET_KEY);
4616 4690
     }
@@ -4628,7 +4702,9 @@  discard block
 block discarded – undo
4628 4702
     if (empty($user_data)) {
4629 4703
         // If user was not found, there was a problem
4630 4704
         $result = "User $user_id does not exist";
4631
-        if ($debug) error_log($result);
4705
+        if ($debug) {
4706
+            error_log($result);
4707
+        }
4632 4708
         return $result;
4633 4709
     }
4634 4710
     if (!empty($course_code)) {
@@ -4636,14 +4712,22 @@  discard block
 block discarded – undo
4636 4712
         if (empty($course_data)) {
4637 4713
             // Course was not found
4638 4714
             $result = "Course $course_code does not exist in the platform ";
4639
-            if ($debug) error_log($result);
4715
+            if ($debug) {
4716
+                error_log($result);
4717
+            }
4640 4718
         } else {
4641
-            if ($debug) error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4719
+            if ($debug) {
4720
+                error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
4721
+            }
4642 4722
             if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status)) {
4643 4723
                 $result = 'User was not registered possible reasons: User already registered to the course, Course visibility doesnt allow user subscriptions ';
4644
-                if ($debug) error_log($result);
4724
+                if ($debug) {
4725
+                    error_log($result);
4726
+                }
4645 4727
             } else {
4646
-                if ($debug) error_log('User registered to the course: '.$course_data['code']);
4728
+                if ($debug) {
4729
+                    error_log('User registered to the course: '.$course_data['code']);
4730
+                }
4647 4731
                 $result = 1;
4648 4732
             }
4649 4733
         }
@@ -4696,8 +4780,12 @@  discard block
 block discarded – undo
4696 4780
 function WSGetUser($params)
4697 4781
 {
4698 4782
     global $debug;
4699
-    if ($debug) error_log('WSGetUser');
4700
-    if ($debug) error_log('$params: '.print_r($params, 1));
4783
+    if ($debug) {
4784
+        error_log('WSGetUser');
4785
+    }
4786
+    if ($debug) {
4787
+        error_log('$params: '.print_r($params, 1));
4788
+    }
4701 4789
 
4702 4790
     if (!WSHelperVerifyKey($params)) {
4703 4791
         return returnError(WS_ERROR_SECRET_KEY);
@@ -4751,8 +4839,12 @@  discard block
 block discarded – undo
4751 4839
 function WSGetUserFromUsername($params)
4752 4840
 {
4753 4841
     global $debug;
4754
-    if ($debug) error_log('WSGetUserFromUsername');
4755
-    if ($debug) error_log('$params: '.print_r($params, 1));
4842
+    if ($debug) {
4843
+        error_log('WSGetUserFromUsername');
4844
+    }
4845
+    if ($debug) {
4846
+        error_log('$params: '.print_r($params, 1));
4847
+    }
4756 4848
 
4757 4849
     if (!WSHelperVerifyKey($params)) {
4758 4850
         return returnError(WS_ERROR_SECRET_KEY);
@@ -5219,7 +5311,9 @@  discard block
 block discarded – undo
5219 5311
                 SessionManager::suscribe_users_to_session($sessionId, array($user_id), SESSION_VISIBLE_READ_ONLY, false);
5220 5312
                 $results[] = 1;
5221 5313
 
5222
-                if ($debug) error_log("subscribe user:$user_id to session $sessionId");
5314
+                if ($debug) {
5315
+                    error_log("subscribe user:$user_id to session $sessionId");
5316
+                }
5223 5317
             }
5224 5318
         }
5225 5319
     } // end principal foreach
@@ -5303,7 +5397,9 @@  discard block
 block discarded – undo
5303 5397
                 SESSION_VISIBLE_READ_ONLY,
5304 5398
                 false
5305 5399
             );
5306
-            if ($debug) error_log('User registered to the course: '.$session_id);
5400
+            if ($debug) {
5401
+                error_log('User registered to the course: '.$session_id);
5402
+            }
5307 5403
             $result = 1;
5308 5404
         }
5309 5405
     }
@@ -5451,7 +5547,9 @@  discard block
 block discarded – undo
5451 5547
 
5452 5548
                 $results[] = 1;
5453 5549
 
5454
-                if ($debug) error_log("Unsubscribe user:$user_id to session:$id_session");
5550
+                if ($debug) {
5551
+                    error_log("Unsubscribe user:$user_id to session:$id_session");
5552
+                }
5455 5553
             }
5456 5554
         }
5457 5555
     } // end principal foreach
@@ -5598,7 +5696,9 @@  discard block
 block discarded – undo
5598 5696
         return returnError(WS_ERROR_SECRET_KEY);
5599 5697
     }
5600 5698
 
5601
-    if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5699
+    if ($debug) {
5700
+        error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
5701
+    }
5602 5702
 
5603 5703
     $coursessessions_params = $params['coursessessions'];
5604 5704
     $results = array();
@@ -5644,7 +5744,9 @@  discard block
 block discarded – undo
5644 5744
                     array($courseInfo['real_id']),
5645 5745
                     false
5646 5746
                 );
5647
-                if ($debug) error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5747
+                if ($debug) {
5748
+                    error_log("add_courses_to_session: course:$courseCode to session:$sessionId");
5749
+                }
5648 5750
 
5649 5751
                 $results[] = 1;
5650 5752
             }
@@ -6917,7 +7019,9 @@  discard block
 block discarded – undo
6917 7019
     if (!WSHelperVerifyKey($params)) {
6918 7020
         return returnError(WS_ERROR_SECRET_KEY);
6919 7021
     }
6920
-    if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1));
7022
+    if ($debug) {
7023
+        error_log('WSAddUserVisibilityToCourseCatalogue params: '.print_r($params, 1));
7024
+    }
6921 7025
 
6922 7026
     $results = array();
6923 7027
     $userscourses = $params['userscourses'];
@@ -6933,7 +7037,9 @@  discard block
 block discarded – undo
6933 7037
             $original_user_id['original_user_id_value'],
6934 7038
             $original_user_id['original_user_id_name']
6935 7039
         );
6936
-        if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId);
7040
+        if ($debug) {
7041
+            error_log('WSAddUserVisibilityToCourseCatalogue userId: '.$userId);
7042
+        }
6937 7043
 
6938 7044
         if ($userId == 0) {
6939 7045
             // If user was not found, there was a problem
@@ -6950,13 +7056,19 @@  discard block
 block discarded – undo
6950 7056
                 // Course was not found
6951 7057
                 $resultValue = 0;
6952 7058
             } else {
6953
-                if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode);
7059
+                if ($debug) {
7060
+                    error_log('WSAddUserVisibilityToCourseCatalogue courseCode: '.$courseCode);
7061
+                }
6954 7062
                 $result = CourseManager::addUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible);
6955 7063
                 if ($result) {
6956 7064
                     $resultValue = 1;
6957
-                    if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue registered');
7065
+                    if ($debug) {
7066
+                        error_log('WSAddUserVisibilityToCourseCatalogue registered');
7067
+                    }
6958 7068
                 } else {
6959
-                    if ($debug) error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: ');
7069
+                    if ($debug) {
7070
+                        error_log('WSAddUserVisibilityToCourseCatalogue NOT registered: ');
7071
+                    }
6960 7072
                 }
6961 7073
             }
6962 7074
         }
@@ -6989,7 +7101,9 @@  discard block
 block discarded – undo
6989 7101
     if (!WSHelperVerifyKey($params)) {
6990 7102
         return returnError(WS_ERROR_SECRET_KEY);
6991 7103
     }
6992
-    if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1));
7104
+    if ($debug) {
7105
+        error_log('WSRemoveUserVisibilityToCourseInCatalogue params: '.print_r($params, 1));
7106
+    }
6993 7107
 
6994 7108
     $results = array();
6995 7109
     $userscourses = $params['userscourses'];
@@ -7005,7 +7119,9 @@  discard block
 block discarded – undo
7005 7119
             $original_user_id['original_user_id_value'],
7006 7120
             $original_user_id['original_user_id_name']
7007 7121
         );
7008
-        if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId);
7122
+        if ($debug) {
7123
+            error_log('WSRemoveUserVisibilityToCourseInCatalogue user_id: '.$userId);
7124
+        }
7009 7125
 
7010 7126
         if ($userId == 0) {
7011 7127
             // If user was not found, there was a problem
@@ -7023,13 +7139,19 @@  discard block
 block discarded – undo
7023 7139
                 // Course was not found
7024 7140
                 $resultValue = 0;
7025 7141
             } else {
7026
-                if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode);
7142
+                if ($debug) {
7143
+                    error_log('WSRemoveUserVisibilityToCourseInCatalogue courseCode: '.$courseCode);
7144
+                }
7027 7145
                 $result = CourseManager::removeUserVisibilityToCourseInCatalogue($userId, $courseCode, $visible);
7028 7146
                 if ($result) {
7029 7147
                     $resultValue = 1;
7030
-                    if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue removed');
7148
+                    if ($debug) {
7149
+                        error_log('WSRemoveUserVisibilityToCourseInCatalogue removed');
7150
+                    }
7031 7151
                 } else {
7032
-                    if ($debug) error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: ');
7152
+                    if ($debug) {
7153
+                        error_log('WSRemoveUserVisibilityToCourseInCatalogue NOT removed: ');
7154
+                    }
7033 7155
                 }
7034 7156
             }
7035 7157
         }
Please login to merge, or discard this patch.
src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -532,7 +532,9 @@  discard block
 block discarded – undo
532 532
 
533 533
                                 if (in_array($file_info['extension'], array('html', 'htm'))) {
534 534
                                     $content = file_get_contents($path.$document->path);
535
-                                    if (UTF8_CONVERT) $content = utf8_encode($content);
535
+                                    if (UTF8_CONVERT) {
536
+                                        $content = utf8_encode($content);
537
+                                    }
536 538
                                     $content = DocumentManager::replace_urls_inside_content_html_from_copy_course(
537 539
                                         $content,
538 540
                                         $this->course->code,
@@ -2788,8 +2790,9 @@  discard block
 block discarded – undo
2788 2790
                             echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>';
2789 2791
                         }*/
2790 2792
                     } elseif(is_dir($path)) {
2791
-                        if (!is_dir($dest . '/' . $file))
2792
-                        mkdir($dest . '/' . $file);
2793
+                        if (!is_dir($dest . '/' . $file)) {
2794
+                                                mkdir($dest . '/' . $file);
2795
+                        }
2793 2796
                         self:: allow_create_all_directory($path, $dest . '/' . $file, $overwrite);
2794 2797
                     }
2795 2798
                 }
Please login to merge, or discard this patch.
main/upload/upload.document.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,9 +64,10 @@
 block discarded – undo
64 64
     	$new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : '';
65 65
     	$new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : '';
66 66
 
67
-    	if ($new_path && ($new_comment || $new_title))
68
-    	if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
67
+    	if ($new_path && ($new_comment || $new_title)) {
68
+    	    	if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
69 69
         	$table_document = Database::get_course_table(TABLE_DOCUMENT);
70
+    	}
70 71
         	$ct = '';
71 72
             if ($new_comment) {
72 73
                 $ct .= ", comment='$new_comment'";
Please login to merge, or discard this patch.
main/exercise/hotspot_admin.inc.php 1 patch
Braces   +29 added lines, -11 removed lines patch added patch discarded remove patch
@@ -679,12 +679,15 @@  discard block
 block discarded – undo
679 679
                                     $option1 = $option2 = $option3 = '';
680 680
                                     for ($k = 1; $k <= 100; $k++) {
681 681
                                         $selected1 = $selected2 = $selected3 = '';
682
-                                        if ($k == $threadhold1[$i])
683
-                                            $selected1 = 'selected="selected"';
684
-                                        if ($k == $threadhold2[$i])
685
-                                            $selected2 = 'selected="selected"';
686
-                                        if ($k == $threadhold3[$i])
687
-                                            $selected3 = 'selected="selected"';
682
+                                        if ($k == $threadhold1[$i]) {
683
+                                                                                    $selected1 = 'selected="selected"';
684
+                                        }
685
+                                        if ($k == $threadhold2[$i]) {
686
+                                                                                    $selected2 = 'selected="selected"';
687
+                                        }
688
+                                        if ($k == $threadhold3[$i]) {
689
+                                                                                    $selected3 = 'selected="selected"';
690
+                                        }
688 691
                                         $option1.='<option ' . $selected1 . ' >' . $k . ' % </option>';
689 692
                                         $option2.='<option ' . $selected2 . ' >' . $k . ' % </option>';
690 693
                                         $option3.='<option ' . $selected3 . '>' . $k . ' %</option>';
@@ -731,7 +734,10 @@  discard block
 block discarded – undo
731 734
                                                 <div class="checkbox">
732 735
                                                     <p>
733 736
                                                         <label>
734
-                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]"  <?php if ($try[$i] == 1) echo'checked'; ?> />
737
+                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]"  <?php if ($try[$i] == 1) {
738
+    echo'checked';
739
+}
740
+?> />
735 741
                                                             <?php echo get_lang('TryAgain'); ?>
736 742
                                                         </label>
737 743
                                                     </p>
@@ -784,7 +790,10 @@  discard block
 block discarded – undo
784 790
                                                             <div class="checkbox">
785 791
                                                                 <p>
786 792
                                                                     <label>
787
-                                                                        <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
793
+                                                                        <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) {
794
+    echo'checked';
795
+}
796
+?> />
788 797
                                                                         <?php echo get_lang('TryAgain'); ?>
789 798
                                                                     </label>
790 799
                                                                 </p>
@@ -823,7 +832,10 @@  discard block
 block discarded – undo
823 832
                                             <th ><?php echo get_lang('OAR'); ?>*</th>
824 833
                                             <?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
825 834
                                                 <th colspan="2" ><?php echo get_lang('Comment'); ?></th>
826
-                                                <th ><?php if ($answerType == HOT_SPOT_DELINEATION) echo get_lang('Scenario'); ?></th>
835
+                                                <th ><?php if ($answerType == HOT_SPOT_DELINEATION) {
836
+    echo get_lang('Scenario');
837
+}
838
+?></th>
827 839
                                             <?php } else { ?>
828 840
                                                 <th colspan="3" ><?php echo get_lang('Comment'); ?></th>
829 841
                                             <?php } ?>
@@ -849,7 +861,10 @@  discard block
 block discarded – undo
849 861
                                                 <div class="checkbox">
850 862
                                                     <p>
851 863
                                                         <label>
852
-                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) echo'checked'; ?> />
864
+                                                            <input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) {
865
+    echo'checked';
866
+}
867
+?> />
853 868
                                                             <?php echo get_lang('TryAgain'); ?>
854 869
                                                         </label>
855 870
                                                     </p>
@@ -998,7 +1013,10 @@  discard block
 block discarded – undo
998 1013
                                         <div class="checkbox">
999 1014
                                             <p>
1000 1015
                                                 <label>
1001
-                                                    <input type="checkbox" class="checkbox" name="try_noerror" <?php if ($try_noerror == 1) echo'checked'; ?> />
1016
+                                                    <input type="checkbox" class="checkbox" name="try_noerror" <?php if ($try_noerror == 1) {
1017
+    echo'checked';
1018
+}
1019
+?> />
1002 1020
                                                     <?php echo get_lang('TryAgain'); ?>
1003 1021
                                                 </label>
1004 1022
                                             </p>
Please login to merge, or discard this patch.
main/inc/lib/blog.lib.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1007,8 +1007,9 @@  discard block
 block discarded – undo
1007 1007
             $blog_post_actions .= '</a>';
1008 1008
         }
1009 1009
 
1010
-        if (api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1011
-            $rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1010
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) {
1011
+                    $rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1012
+        }
1012 1013
 
1013 1014
         $blog_post_text=stripslashes($blog_post_text);
1014 1015
 
@@ -1652,8 +1653,9 @@  discard block
 block discarded – undo
1652 1653
 
1653 1654
                         $arrPermissions = array();
1654 1655
 
1655
-                        while ($row = Database::fetch_array($result))
1656
-                            $arrPermissions[] = $row['action'];
1656
+                        while ($row = Database::fetch_array($result)) {
1657
+                                                    $arrPermissions[] = $row['action'];
1658
+                        }
1657 1659
 
1658 1660
                             echo '<tr>';
1659 1661
                             echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
@@ -2329,8 +2331,9 @@  discard block
 block discarded – undo
2329 2331
         //Handle leap year
2330 2332
         $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2331 2333
 
2332
-        if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2333
-            $numberofdays[2] = 29;
2334
+        if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) {
2335
+                    $numberofdays[2] = 29;
2336
+        }
2334 2337
 
2335 2338
         //Get the first day of the month
2336 2339
         $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
@@ -2360,8 +2363,9 @@  discard block
 block discarded – undo
2360 2363
         if( Database::num_rows($result) > 0) {
2361 2364
             while($blog_post = Database::fetch_array($result)) {
2362 2365
                 // If the day of this post is not yet in the array, add it.
2363
-                if (!in_array($blog_post['post_day'], $posts))
2364
-                    $posts[] = $blog_post['post_day'];
2366
+                if (!in_array($blog_post['post_day'], $posts)) {
2367
+                                    $posts[] = $blog_post['post_day'];
2368
+                }
2365 2369
             }
2366 2370
         }
2367 2371
 
@@ -2400,8 +2404,9 @@  discard block
 block discarded – undo
2400 2404
 
2401 2405
         echo "<tr>";
2402 2406
 
2403
-        for($ii = 1; $ii < 8; $ii ++)
2404
-            echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2407
+        for($ii = 1; $ii < 8; $ii ++) {
2408
+                    echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2409
+        }
2405 2410
 
2406 2411
         echo "</tr>";
2407 2412
 
@@ -2411,8 +2416,9 @@  discard block
 block discarded – undo
2411 2416
         while ($curday <= $numberofdays[$month]) {
2412 2417
             echo "<tr>";
2413 2418
             for ($ii = 0; $ii < 7; $ii ++) {
2414
-                if (($curday == -1) && ($ii == $startdayofweek))
2415
-                    $curday = 1;
2419
+                if (($curday == -1) && ($ii == $startdayofweek)) {
2420
+                                    $curday = 1;
2421
+                }
2416 2422
 
2417 2423
                 if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2418 2424
                     $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
@@ -2426,10 +2432,11 @@  discard block
 block discarded – undo
2426 2432
                     echo "<td " . $class.">";
2427 2433
 
2428 2434
                     // If there are posts on this day, create a filter link.
2429
-                    if(in_array($curday, $posts))
2430
-                        echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2431
-                    else
2432
-                        echo $dayheader;
2435
+                    if(in_array($curday, $posts)) {
2436
+                                            echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2437
+                    } else {
2438
+                                            echo $dayheader;
2439
+                    }
2433 2440
 
2434 2441
                     if (count($tasks) > 0) {
2435 2442
                         if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
@@ -2444,8 +2451,9 @@  discard block
 block discarded – undo
2444 2451
 
2445 2452
                     echo "</td>";
2446 2453
                     $curday ++;
2447
-                } else
2448
-                    echo "<td>&nbsp;</td>";
2454
+                } else {
2455
+                                    echo "<td>&nbsp;</td>";
2456
+                }
2449 2457
             }
2450 2458
             echo "</tr>";
2451 2459
         }
Please login to merge, or discard this patch.
main/inc/lib/message.lib.php 1 patch
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -143,8 +143,9 @@  discard block
 block discarded – undo
143 143
             $direction = 'DESC';
144 144
         } else {
145 145
             $column = intval($column);
146
-            if (!in_array($direction, array('ASC', 'DESC')))
147
-                $direction = 'ASC';
146
+            if (!in_array($direction, array('ASC', 'DESC'))) {
147
+                            $direction = 'ASC';
148
+            }
148 149
         }
149 150
 
150 151
         $keyword = Session::read('message_search_keyword');
@@ -697,8 +698,9 @@  discard block
 block discarded – undo
697 698
      */
698 699
     public static function update_message($user_id, $message_id)
699 700
     {
700
-        if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id)))
701
-            return false;
701
+        if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) {
702
+                    return false;
703
+        }
702 704
 
703 705
         $table_message = Database::get_main_table(TABLE_MESSAGE);
704 706
         $sql = "UPDATE $table_message SET msg_status = '0'
@@ -738,8 +740,9 @@  discard block
 block discarded – undo
738 740
      */
739 741
     public static function get_message_by_user($user_id, $message_id)
740 742
     {
741
-        if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id)))
742
-            return false;
743
+        if ($message_id != strval(intval($message_id)) || $user_id != strval(intval($user_id))) {
744
+                    return false;
745
+        }
743 746
         $table_message = Database::get_main_table(TABLE_MESSAGE);
744 747
         $query = "SELECT * FROM $table_message
745 748
                   WHERE user_receiver_id=" . intval($user_id) . " AND id='" . intval($message_id) . "'";
@@ -864,8 +867,9 @@  discard block
 block discarded – undo
864 867
      */
865 868
     public static function exist_message($user_id, $id)
866 869
     {
867
-        if ($id != strval(intval($id)) || $user_id != strval(intval($user_id)))
868
-            return false;
870
+        if ($id != strval(intval($id)) || $user_id != strval(intval($user_id))) {
871
+                    return false;
872
+        }
869 873
         $table_message = Database::get_main_table(TABLE_MESSAGE);
870 874
         $query = "SELECT id FROM $table_message
871 875
                   WHERE
@@ -896,8 +900,9 @@  discard block
 block discarded – undo
896 900
             $direction = 'DESC';
897 901
         } else {
898 902
             $column = intval($column);
899
-            if (!in_array($direction, array('ASC', 'DESC')))
900
-                $direction = 'ASC';
903
+            if (!in_array($direction, array('ASC', 'DESC'))) {
904
+                            $direction = 'ASC';
905
+            }
901 906
         }
902 907
         $table_message = Database::get_main_table(TABLE_MESSAGE);
903 908
         $request = api_is_xml_http_request();
Please login to merge, or discard this patch.
main/admin/user_move_stats.php 1 patch
Braces   +99 added lines, -43 removed lines patch added patch discarded remove patch
@@ -107,7 +107,9 @@  discard block
 block discarded – undo
107 107
                 //Check if the user is registered in the session otherwise we will add it
108 108
                 $result = SessionManager::get_users_by_session($new_session_id);
109 109
                 if (empty($result) || !in_array($user_id, array_keys($result))) {
110
-                    if ($debug) echo 'User added to the session';
110
+                    if ($debug) {
111
+                        echo 'User added to the session';
112
+                    }
111 113
                     //Registering user to the new session
112 114
                     SessionManager::suscribe_users_to_session($new_session_id,array($user_id),false);
113 115
                 }
@@ -142,10 +144,11 @@  discard block
 block discarded – undo
142 144
                     $list[$row['exe_id']]= $row;
143 145
                 }
144 146
 
145
-                if (!empty($list))
146
-                    foreach ($list as $exe_id =>$data) {
147
+                if (!empty($list)) {
148
+                                    foreach ($list as $exe_id =>$data) {
147 149
                         if ($update_database) {
148 150
                             $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id";
151
+                }
149 152
                             $res = Database::query($sql);
150 153
                             $result_message[$TABLETRACK_EXERCICES]++;
151 154
                         } else {
@@ -169,10 +172,11 @@  discard block
 block discarded – undo
169 172
                         $list[$row['exe_id']]= $row;
170 173
                     }
171 174
 
172
-                    if (!empty($list))
173
-                        foreach ($list as $exe_id =>$data) {
175
+                    if (!empty($list)) {
176
+                                            foreach ($list as $exe_id =>$data) {
174 177
                             if ($update_database) {
175 178
                                 $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id";
179
+                    }
176 180
                                 $res = Database::query($sql);
177 181
                                 $result_message[$TABLETRACK_EXERCICES]++;
178 182
                             } else {
@@ -197,10 +201,11 @@  discard block
 block discarded – undo
197 201
                     $list[$row['course_access_id']] = $row;
198 202
                 }
199 203
 
200
-                if (!empty($list))
201
-                    foreach ($list as $id => $data) {
204
+                if (!empty($list)) {
205
+                                    foreach ($list as $id => $data) {
202 206
                         if ($update_database) {
203 207
                             $sql = "UPDATE $TBL_TRACK_E_COURSE_ACCESS SET session_id = $new_session_id WHERE course_access_id = $id";
208
+                }
204 209
                             if ($debug) {
205 210
                                 echo $sql;
206 211
                             }
@@ -219,13 +224,18 @@  discard block
 block discarded – undo
219 224
                 while($row = Database::fetch_array($res,'ASSOC')) {
220 225
                     $list[] = $row['access_id'];
221 226
                 }
222
-                if (!empty($list))
223
-                    foreach ($list as $id) {
227
+                if (!empty($list)) {
228
+                                    foreach ($list as $id) {
224 229
                         if ($update_database) {
225 230
                             $sql = "UPDATE $TBL_TRACK_E_LAST_ACCESS SET access_session_id = $new_session_id WHERE access_id = $id";
226
-                            if ($debug) echo $sql;
231
+                }
232
+                            if ($debug) {
233
+                                echo $sql;
234
+                            }
227 235
                             $res = Database::query($sql);
228
-                            if ($debug) error_log(__FILE__ . ' +' . __LINE__ . ': ' . print_r($res, 1));
236
+                            if ($debug) {
237
+                                error_log(__FILE__ . ' +' . __LINE__ . ': ' . print_r($res, 1));
238
+                            }
229 239
                             $result_message[$TBL_TRACK_E_LAST_ACCESS]++;
230 240
                         }
231 241
                     }
@@ -249,13 +259,18 @@  discard block
 block discarded – undo
249 259
                     }
250 260
                 }
251 261
 
252
-                if (!empty($list))
253
-                    foreach ($list as $id=>$data) {
262
+                if (!empty($list)) {
263
+                                    foreach ($list as $id=>$data) {
254 264
                         if ($update_database) {
255 265
                             $sql = "UPDATE $TBL_LP_VIEW SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id ";
256
-                            if ($debug) var_dump($sql);
266
+                }
267
+                            if ($debug) {
268
+                                var_dump($sql);
269
+                            }
257 270
                             $res = Database::query($sql);
258
-                            if ($debug) var_dump($res);
271
+                            if ($debug) {
272
+                                var_dump($res);
273
+                            }
259 274
                             $result_message[$TBL_LP_VIEW]++;
260 275
                         } else {
261 276
                             //Getting all information of that lp_item_id
@@ -282,10 +297,11 @@  discard block
 block discarded – undo
282 297
                             $list[$row['id']] = $row;
283 298
                         }
284 299
                     }
285
-                    if (!empty($list))
286
-                        foreach ($list as $id=>$data) {
300
+                    if (!empty($list)) {
301
+                                            foreach ($list as $id=>$data) {
287 302
                             //Getting all information of that lp_item_id
288 303
                             $score    = Tracking::get_avg_student_score($user_id, $origin_course_code,        array($data['lp_id']), $new_session_id);
304
+                    }
289 305
                             $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code,     array($data['lp_id']), $new_session_id);
290 306
                             $result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress);
291 307
                         }
@@ -301,9 +317,13 @@  discard block
 block discarded – undo
301 317
                     $id = $row['ref'];
302 318
                     if ($update_database) {
303 319
                         $sql = "UPDATE $TBL_AGENDA SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id ";
304
-                        if ($debug) var_dump($sql);
320
+                        if ($debug) {
321
+                            var_dump($sql);
322
+                        }
305 323
                         $res_update = Database::query($sql);
306
-                        if ($debug) var_dump($res_update);
324
+                        if ($debug) {
325
+                            var_dump($res_update);
326
+                        }
307 327
                         $result_message['agenda']++;
308 328
                     }
309 329
                 }
@@ -315,22 +335,30 @@  discard block
 block discarded – undo
315 335
                 //echo '<h1>Student publication</h1>';
316 336
 
317 337
                 $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id";
318
-                if ($debug) echo $sql;
338
+                if ($debug) {
339
+                    echo $sql;
340
+                }
319 341
                 $res = Database::query($sql);
320 342
                 while($row = Database::fetch_array($res,'ASSOC')) {
321 343
                     $id = $row['ref'];
322 344
                     $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $id AND session_id = $origin_session_id AND c_id = $course_id";
323
-                    if ($debug) var_dump($sql);
345
+                    if ($debug) {
346
+                        var_dump($sql);
347
+                    }
324 348
                     $sub_res = Database::query($sql);
325 349
                     if (Database::num_rows($sub_res) > 0 ) {
326 350
                         $data = Database::fetch_array($sub_res,'ASSOC');
327
-                        if ($debug) var_dump($data);
351
+                        if ($debug) {
352
+                            var_dump($data);
353
+                        }
328 354
                         $parent_id = $data['parent_id'];
329 355
                         if (isset($data['parent_id']) && !empty($data['parent_id'])) {
330 356
                             $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $parent_id AND c_id = $course_id";
331 357
                             $select_res     = Database::query($sql);
332 358
                             $parent_data    = Database::fetch_array($select_res,'ASSOC');
333
-                            if ($debug)     var_dump($parent_data);
359
+                            if ($debug) {
360
+                                var_dump($parent_data);
361
+                            }
334 362
 
335 363
                             $sys_course_path = api_get_path(SYS_COURSE_PATH);
336 364
                             $course_dir = $sys_course_path . $course_info['path'];
@@ -345,7 +373,9 @@  discard block
 block discarded – undo
345 373
                             $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION
346 374
                             		WHERE description like '%$search_this%' AND url LIKE '%$search_this2%' AND session_id = $new_session_id AND c_id = $course_id
347 375
                             		ORDER BY id desc  LIMIT 1";
348
-                            if ($debug) echo $sql;
376
+                            if ($debug) {
377
+                                echo $sql;
378
+                            }
349 379
                             $sub_res = Database::query($sql);
350 380
                             $num_rows = Database::num_rows($sub_res);
351 381
 
@@ -389,7 +419,9 @@  discard block
 block discarded – undo
389 419
 
390 420
                             //Creating student_publication_assignment if exists
391 421
                             $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION_ASSIGNMENT WHERE publication_id = $parent_id AND c_id = $course_id";
392
-                            if ($debug) var_dump($sql);
422
+                            if ($debug) {
423
+                                var_dump($sql);
424
+                            }
393 425
                             $rest_select     = Database::query($sql);
394 426
                             if (Database::num_rows($rest_select) > 0 ) {
395 427
                                 if ($update_database) {
@@ -401,7 +433,9 @@  discard block
 block discarded – undo
401 433
                                        add_to_calendar      = '".$assignment_data['add_to_calendar']."',
402 434
                                        enable_qualification = '".$assignment_data['enable_qualification']."',
403 435
                                        publication_id       = '".$new_parent_id."'";
404
-                                    if ($debug) echo $sql_add_publication;
436
+                                    if ($debug) {
437
+                                        echo $sql_add_publication;
438
+                                    }
405 439
                                     $rest_select     = Database::query($sql_add_publication);
406 440
                                     $id = Database::insert_id();
407 441
 
@@ -409,11 +443,15 @@  discard block
 block discarded – undo
409 443
                                         "has_properties         = '".$id."',
410 444
                                        view_properties    = '1'
411 445
                                        WHERE id   = ".$new_parent_id;
412
-                                    if ($debug) echo $sql_update;
446
+                                    if ($debug) {
447
+                                        echo $sql_update;
448
+                                    }
413 449
                                     $rest_update     = Database::query($sql_update);
414 450
 
415 451
 
416
-                                    if ($debug) var_dump($sql_update);
452
+                                    if ($debug) {
453
+                                        var_dump($sql_update);
454
+                                    }
417 455
                                     $result_message[$TBL_STUDENT_PUBLICATION_ASSIGNMENT]++;
418 456
                                 }
419 457
                             }
@@ -454,7 +492,9 @@  discard block
 block discarded – undo
454 492
                                     if ($result) {
455 493
                                         unlink($full_file_name);
456 494
                                         $sql = "DELETE FROM $TBL_STUDENT_PUBLICATION WHERE id= ".$data['id'];
457
-                                        if ($debug) var_dump($sql);
495
+                                        if ($debug) {
496
+                                            var_dump($sql);
497
+                                        }
458 498
                                         $result_delete     = Database::query($sql);
459 499
                                         api_item_property_update($course_info, 'work', $data['id'], 'DocumentDeleted', api_get_user_id());
460 500
                                     }
@@ -470,22 +510,30 @@  discard block
 block discarded – undo
470 510
                 //10. Dropbox - not neccesary to move categories (no presence of session_id)
471 511
 
472 512
                 $sql = "SELECT id FROM $TBL_DROPBOX_FILE WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id";
473
-                if ($debug) var_dump($sql);
513
+                if ($debug) {
514
+                    var_dump($sql);
515
+                }
474 516
                 $res = Database::query($sql);
475 517
                 while($row = Database::fetch_array($res,'ASSOC')) {
476 518
                     $id = $row['id'];
477 519
                     if ($update_database) {
478 520
                         $sql = "UPDATE $TBL_DROPBOX_FILE SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id";
479
-                        if ($debug) var_dump($sql);
521
+                        if ($debug) {
522
+                            var_dump($sql);
523
+                        }
480 524
                         $res = Database::query($sql);
481
-                        if ($debug) var_dump($res);
525
+                        if ($debug) {
526
+                            var_dump($res);
527
+                        }
482 528
 
483 529
                         $sql = "UPDATE $TBL_DROPBOX_POST SET session_id = $new_session_id WHERE file_id = $id";
484
-                        if ($debug)
485
-                            var_dump($sql);
530
+                        if ($debug) {
531
+                                                    var_dump($sql);
532
+                        }
486 533
                         $res = Database::query($sql);
487
-                        if ($debug)
488
-                            var_dump($res);
534
+                        if ($debug) {
535
+                                                    var_dump($res);
536
+                        }
489 537
                         $result_message[$TBL_DROPBOX_FILE]++;
490 538
                     }
491 539
                 }
@@ -494,23 +542,30 @@  discard block
 block discarded – undo
494 542
 
495 543
                 $sql = "SELECT notebook_id FROM $TBL_NOTEBOOK
496 544
                         WHERE user_id = $user_id AND session_id = $origin_session_id AND course = '$origin_course_code' AND c_id = $course_id";
497
-                if ($debug) var_dump($sql);
545
+                if ($debug) {
546
+                    var_dump($sql);
547
+                }
498 548
                 $res = Database::query($sql);
499 549
                 while($row = Database::fetch_array($res,'ASSOC')) {
500 550
                     $id = $row['notebook_id'];
501 551
                     if ($update_database) {
502 552
                         $sql = "UPDATE $TBL_NOTEBOOK SET session_id = $new_session_id WHERE c_id = $course_id AND notebook_id = $id";
503
-                        if ($debug) var_dump($sql);
553
+                        if ($debug) {
554
+                            var_dump($sql);
555
+                        }
504 556
                         $res = Database::query($sql);
505
-                        if ($debug) var_dump($res);
557
+                        if ($debug) {
558
+                            var_dump($res);
559
+                        }
506 560
                     }
507 561
                 }
508 562
 
509 563
                 if ($update_database) {
510 564
                     echo '<h2>'.get_lang('StatsMoved').'</h2>';
511
-                    if (is_array($result_message))
512
-                        foreach ($result_message as $table=>$times) {
565
+                    if (is_array($result_message)) {
566
+                                            foreach ($result_message as $table=>$times) {
513 567
                             echo 'Table '.$table.' - '.$times.' records updated <br />';
568
+                    }
514 569
                         }
515 570
                 } else {
516 571
                     echo '<h2>'.get_lang('UserInformationOfThisCourse').'</h2>';
@@ -626,10 +681,11 @@  discard block
 block discarded – undo
626 681
 }
627 682
 $navigation .= '&nbsp;';
628 683
 $page ++;
629
-if ($page < $nro_pages)
684
+if ($page < $nro_pages) {
630 685
     $navigation .= '<a href="'.api_get_self().'?page='.$page.'">'.get_lang('Next').'</a>';
631
-else
686
+} else {
632 687
     $navigation .= get_lang('Next');
688
+}
633 689
 
634 690
 echo $navigation;
635 691
 $user_list      = UserManager::get_user_list(array(), array(), $begin, $default);
Please login to merge, or discard this patch.