Completed
Pull Request — 1.11.x (#1296)
by José
132:18 queued 93:54
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.