Passed
Push — 1.10.x ( a2cc02...b21e58 )
by Yannick
608:36 queued 565:17
created
main/inc/lib/api.lib.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 define('PLATFORM_ADMIN', 11);
40 40
 define('SESSION_COURSE_COACH', 12);
41 41
 define('SESSION_GENERAL_COACH', 13);
42
-define('COURSE_STUDENT', 14);   //student subscribed in a course
43
-define('SESSION_STUDENT', 15);  //student subscribed in a session course
42
+define('COURSE_STUDENT', 14); //student subscribed in a course
43
+define('SESSION_STUDENT', 15); //student subscribed in a session course
44 44
 define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
45 45
 define('STUDENT_BOSS', 17); // student is boss
46 46
 define('INVITEE', 20);
47 47
 
48 48
 // Table of status
49
-$_status_list[COURSEMANAGER] = 'teacher';        // 1
50
-$_status_list[SESSIONADMIN] = 'session_admin';  // 3
51
-$_status_list[DRH] = 'drh';            // 4
52
-$_status_list[STUDENT] = 'user';           // 5
53
-$_status_list[ANONYMOUS] = 'anonymous';      // 6
54
-$_status_list[INVITEE] = 'invited';        // 20
49
+$_status_list[COURSEMANAGER] = 'teacher'; // 1
50
+$_status_list[SESSIONADMIN] = 'session_admin'; // 3
51
+$_status_list[DRH] = 'drh'; // 4
52
+$_status_list[STUDENT] = 'user'; // 5
53
+$_status_list[ANONYMOUS] = 'anonymous'; // 6
54
+$_status_list[INVITEE] = 'invited'; // 20
55 55
 
56 56
 // COURSE VISIBILITY CONSTANTS
57 57
 /** only visible for course admin */
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 define('IS_WINDOWS_OS', api_is_windows_os());
265 265
 
266 266
 // Checks for installed optional php-extensions.
267
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
268
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
269
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
267
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
268
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
269
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
270 270
 
271 271
 // Patterns for processing paths.                                   // Examples:
272
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
273
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
274
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
272
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
273
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
274
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
275 275
 
276 276
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
277 277
 define('WEB_PATH', 'WEB_PATH');
@@ -375,19 +375,19 @@  discard block
 block discarded – undo
375 375
 define('LINK_HOTPOTATOES', 9);
376 376
 
377 377
 // Score display types constants
378
-define('SCORE_DIV', 1);    // X / Y
379
-define('SCORE_PERCENT', 2);    // XX %
380
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
381
-define('SCORE_AVERAGE', 4);    // XX %
382
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
383
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
384
-define('SCORE_SIMPLE', 7);    // X
385
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
386
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
387
-define('SCORE_CUSTOM', 10);    // Good!
388
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
389
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
390
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
378
+define('SCORE_DIV', 1); // X / Y
379
+define('SCORE_PERCENT', 2); // XX %
380
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
381
+define('SCORE_AVERAGE', 4); // XX %
382
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
383
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
384
+define('SCORE_SIMPLE', 7); // X
385
+define('SCORE_IGNORE_SPLIT', 8); //  ??
386
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
387
+define('SCORE_CUSTOM', 10); // Good!
388
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
389
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
390
+define('SCORE_ONLY_SCORE', 13); // X - Good!
391 391
 
392 392
 define('SCORE_BOTH', 1);
393 393
 define('SCORE_ONLY_DEFAULT', 2);
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 define('TIMELINE_STATUS_INACTIVE', '2');
556 556
 
557 557
 // Event email template class
558
-define ('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
559
-define ('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
558
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
559
+define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
560 560
 
561 561
 // Course home
562 562
 define('SHORTCUTS_HORIZONTAL', 0);
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
     // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
734 734
     if ($path_type == WEB_PATH) {
735
-        if (isset($_configuration['access_url']) &&  $_configuration['access_url'] != 1) {
735
+        if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) {
736 736
             //we look into the DB the function api_get_access_url
737 737
             $url_info = api_get_access_url($_configuration['access_url']);
738 738
             $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web'];
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
                     : 'localhost')));
763 763
                 if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':')
764 764
                     && (($server_protocol == 'http'
765
-                    && $_SERVER['SERVER_PORT'] != 80 ) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443 ))) {
766
-                    $server_name .= ":" . $_SERVER['SERVER_PORT'];
765
+                    && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))) {
766
+                    $server_name .= ":".$_SERVER['SERVER_PORT'];
767 767
                 }
768 768
                 $root_web = $server_protocol.'://'.$server_name.$root_rel;
769 769
                 $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
                 $sys_course_code =
938 938
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
939 939
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
940
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
940
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
941 941
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
942 942
             }
943 943
         }
@@ -981,15 +981,15 @@  discard block
 block discarded – undo
981 981
 {
982 982
     global $_configuration;
983 983
     $web_root = api_get_path(WEB_PATH);
984
-    $ext = substr($web_path,strrpos($web_path,'.'));
984
+    $ext = substr($web_path, strrpos($web_path, '.'));
985 985
     if (isset($ext[2])) { // faster version of strlen to check if len>2
986 986
         // Check for CDN definitions
987 987
         if (!empty($_configuration['cdn_enable']) && !empty($ext)) {
988 988
             foreach ($_configuration['cdn'] as $host => $exts) {
989
-                if (in_array($ext,$exts)) {
989
+                if (in_array($ext, $exts)) {
990 990
                     //Use host as defined in $_configuration['cdn'], without
991 991
                     // trailing slash
992
-                    return str_replace($web_root,$host.'/',$web_path);
992
+                    return str_replace($web_root, $host.'/', $web_path);
993 993
                 }
994 994
             }
995 995
         }
@@ -1438,10 +1438,10 @@  discard block
 block discarded – undo
1438 1438
 
1439 1439
     if (isset($user['email'])) {
1440 1440
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1441
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1441
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1442 1442
     } else {
1443 1443
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1444
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1444
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1445 1445
     }
1446 1446
     $user_id = intval($user['user_id']);
1447 1447
     // Maintain the user_id index for backwards compatibility
@@ -1917,7 +1917,7 @@  discard block
 block discarded – undo
1917 1917
         foreach ($param_list1 as $key => $enreg) {
1918 1918
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1919 1919
         }
1920
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1920
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1921 1921
         foreach ($param_list2 as $enreg) {
1922 1922
             $enreg = explode('=', $enreg);
1923 1923
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
         $length = 2;
1948 1948
     }
1949 1949
     $password = '';
1950
-    for ($i = 0; $i < $length; $i ++) {
1950
+    for ($i = 0; $i < $length; $i++) {
1951 1951
         $password .= $characters[rand() % strlen($characters)];
1952 1952
     }
1953 1953
     return $password;
@@ -1974,10 +1974,10 @@  discard block
 block discarded – undo
1974 1974
     $digits = 0;
1975 1975
     $consequent_characters = 0;
1976 1976
     $previous_character_code = 0;
1977
-    for ($i = 0; $i < $password_length; $i ++) {
1977
+    for ($i = 0; $i < $password_length; $i++) {
1978 1978
         $current_character_code = api_ord(api_substr($password, $i, 1));
1979 1979
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
1980
-            $consequent_characters ++;
1980
+            $consequent_characters++;
1981 1981
             if ($consequent_characters == 3) {
1982 1982
                 return false;
1983 1983
             }
@@ -1985,9 +1985,9 @@  discard block
 block discarded – undo
1985 1985
             $consequent_characters = 1;
1986 1986
         }
1987 1987
         if ($current_character_code >= 97 && $current_character_code <= 122) {
1988
-            $letters ++;
1988
+            $letters++;
1989 1989
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
1990
-            $digits ++;
1990
+            $digits++;
1991 1991
         } else {
1992 1992
             return false;
1993 1993
         }
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
         if (empty($session_id)) { return null; }
2184 2184
     }
2185 2185
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2186
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2186
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2187 2187
     $r = Database::query($s);
2188 2188
     $c = Database::num_rows($r);
2189 2189
     if ($c > 0) {
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
         $sql = "SELECT * FROM $tbl_session WHERE id = $session_id";
2209 2209
         $result = Database::query($sql);
2210 2210
 
2211
-        if (Database::num_rows($result)>0) {
2211
+        if (Database::num_rows($result) > 0) {
2212 2212
             $data = Database::fetch_array($result, 'ASSOC');
2213 2213
         }
2214 2214
     }
@@ -2368,9 +2368,9 @@  discard block
 block discarded – undo
2368 2368
  */
2369 2369
 function api_get_session_image($session_id, $status_id)
2370 2370
 {
2371
-    $session_id = (int)$session_id;
2371
+    $session_id = (int) $session_id;
2372 2372
     $session_img = '';
2373
-    if ((int)$status_id != 5) { //check whether is not a student
2373
+    if ((int) $status_id != 5) { //check whether is not a student
2374 2374
         if ($session_id > 0) {
2375 2375
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2376 2376
                 'star.png',
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
         $filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
2486 2486
         if (file_exists($filename)) {
2487 2487
             $value = file_get_contents($filename);
2488
-            return $value ;
2488
+            return $value;
2489 2489
         } else {
2490 2490
             return '';
2491 2491
         }
@@ -2494,7 +2494,7 @@  discard block
 block discarded – undo
2494 2494
         $filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
2495 2495
         if (file_exists($filename)) {
2496 2496
             $value = file_get_contents($filename);
2497
-            return $value ;
2497
+            return $value;
2498 2498
         } else {
2499 2499
             return '';
2500 2500
         }
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
     }
2689 2689
     $group_id   = api_get_group_id();
2690 2690
     $course_id  = api_get_course_int_id();
2691
-    $course_code= api_get_course_id();
2691
+    $course_code = api_get_course_id();
2692 2692
     $session_id = api_get_session_id();
2693 2693
 
2694 2694
     //Group (in course)
@@ -2696,7 +2696,7 @@  discard block
 block discarded – undo
2696 2696
         $group_status = array();
2697 2697
         $is_subscribed = GroupManager::is_subscribed($user_id, $group_id);
2698 2698
         if ($is_subscribed) {
2699
-            $group_status = array('id'=> $group_id , 'status' => 'student');
2699
+            $group_status = array('id'=> $group_id, 'status' => 'student');
2700 2700
             $is_tutor = GroupManager::is_tutor_of_group($user_id, $group_id);
2701 2701
             if ($is_tutor) {
2702 2702
                 $group_status['status'] = 'tutor';
@@ -2730,7 +2730,7 @@  discard block
 block discarded – undo
2730 2730
         }
2731 2731
         $status['session'] = $session_status;
2732 2732
 
2733
-    } elseif($course_id) {
2733
+    } elseif ($course_id) {
2734 2734
         //Course
2735 2735
         $course_status = array();
2736 2736
         if ($course_id) {
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
 
2739 2739
             if ($user_course_status) {
2740 2740
                 $course_status = array('id'=> $course_id);
2741
-                switch($user_course_status) {
2741
+                switch ($user_course_status) {
2742 2742
                     case 1;
2743 2743
                         $course_status['status'] = 'teacher';
2744 2744
                     break;
@@ -2768,7 +2768,7 @@  discard block
 block discarded – undo
2768 2768
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2769 2769
 {
2770 2770
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2771
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2771
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2772 2772
 
2773 2773
     $user_id = intval($user_id);
2774 2774
     $session_id = intval($session_id);
@@ -2842,7 +2842,7 @@  discard block
 block discarded – undo
2842 2842
                 ORDER BY access_start_date, access_end_date, name";
2843 2843
         $result = Database::query($sql);
2844 2844
         if (!empty($sessionIsCoach)) {
2845
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2845
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2846 2846
         } else {
2847 2847
             $sessionIsCoach = Database::store_result($result);
2848 2848
         }
@@ -3019,7 +3019,7 @@  discard block
 block discarded – undo
3019 3019
             return '';
3020 3020
         }
3021 3021
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
3022
-        $sourceurl = str_replace('newscorm/lp_header.php', 'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl);
3022
+        $sourceurl = str_replace('newscorm/lp_header.php', 'newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl);
3023 3023
         //showinframes doesn't handle student view anyway...
3024 3024
         //return '';
3025 3025
         $is_framed = true;
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
         }
3419 3419
         $content .= '<div class="well_login">';
3420 3420
         $content .= $form->return_form();
3421
-        $content .='</div>';
3421
+        $content .= '</div>';
3422 3422
         if (api_is_cas_activated()) {
3423 3423
             $content .= "</div>";
3424 3424
         }
@@ -3437,7 +3437,7 @@  discard block
 block discarded – undo
3437 3437
         exit;
3438 3438
     }
3439 3439
 
3440
-    if ($user_id !=0 && !api_is_anonymous()) {
3440
+    if ($user_id != 0 && !api_is_anonymous()) {
3441 3441
         $tpl->display_one_col_template();
3442 3442
         exit;
3443 3443
     }
@@ -3468,7 +3468,7 @@  discard block
 block discarded – undo
3468 3468
         }
3469 3469
         $msg .= '<div class="well">';
3470 3470
         $msg .= $form->return_form();
3471
-        $msg .='</div>';
3471
+        $msg .= '</div>';
3472 3472
         if (api_is_cas_activated()) {
3473 3473
             $msg .= "</div>";
3474 3474
         }
@@ -3504,7 +3504,7 @@  discard block
 block discarded – undo
3504 3504
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3505 3505
     list ($year, $month, $day) = explode('-', $last_post_date);
3506 3506
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3507
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3507
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3508 3508
 }
3509 3509
 
3510 3510
 /**
@@ -3955,7 +3955,7 @@  discard block
 block discarded – undo
3955 3955
                 c_id = $course_id AND
3956 3956
                 tool = '$tool'
3957 3957
                 $session_condition ";
3958
-    $rs  = Database::query($sql);
3958
+    $rs = Database::query($sql);
3959 3959
     $list = array();
3960 3960
     if (Database::num_rows($rs) > 0) {
3961 3961
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -4035,7 +4035,7 @@  discard block
 block discarded – undo
4035 4035
                 tool = '$tool' AND
4036 4036
                 ref = $ref
4037 4037
                 $sessionCondition";
4038
-    $rs  = Database::query($sql);
4038
+    $rs = Database::query($sql);
4039 4039
     $item_property_id = '';
4040 4040
     if (Database::num_rows($rs) > 0) {
4041 4041
         $row = Database::fetch_array($rs);
@@ -4093,7 +4093,7 @@  discard block
 block discarded – undo
4093 4093
             WHERE item_property_id = $item_property_id AND course_id = $course_id
4094 4094
             ORDER BY lastedit_date DESC";
4095 4095
     $result = Database::query($sql);
4096
-    $result = Database::store_result($result,'ASSOC');
4096
+    $result = Database::store_result($result, 'ASSOC');
4097 4097
     return $result;
4098 4098
 }
4099 4099
 
@@ -4143,7 +4143,7 @@  discard block
 block discarded – undo
4143 4143
     $rs  = Database::query($sql);
4144 4144
     $row = array();
4145 4145
     if (Database::num_rows($rs) > 0) {
4146
-        $row = Database::fetch_array($rs,'ASSOC');
4146
+        $row = Database::fetch_array($rs, 'ASSOC');
4147 4147
     }
4148 4148
 
4149 4149
     return $row;
@@ -4179,7 +4179,7 @@  discard block
 block discarded – undo
4179 4179
     $languages  = $language_list['name'];
4180 4180
     $folder     = $language_list['folder'];
4181 4181
 
4182
-    $ret .= '<select name="' . $name . '" id="language_chosen">';
4182
+    $ret .= '<select name="'.$name.'" id="language_chosen">';
4183 4183
     foreach ($languages as $key => $value) {
4184 4184
         if ($folder[$key] == $default) {
4185 4185
             $selected = ' selected="selected"';
@@ -4232,8 +4232,8 @@  discard block
 block discarded – undo
4232 4232
     //-->
4233 4233
     </script>';
4234 4234
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4235
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4236
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4235
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4236
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4237 4237
 
4238 4238
     foreach ($original_languages as $key => $value) {
4239 4239
         if ($folder[$key] == $user_selected_language) {
@@ -4241,13 +4241,13 @@  discard block
 block discarded – undo
4241 4241
         } else {
4242 4242
             $option_end = '>';
4243 4243
         }
4244
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4244
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4245 4245
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4246
-        $html .=  $value.'</option>';
4246
+        $html .= $value.'</option>';
4247 4247
     }
4248
-    $html .=  '</select>';
4249
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4250
-    $html .=  '</form>';
4248
+    $html .= '</select>';
4249
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4250
+    $html .= '</form>';
4251 4251
     return $html;
4252 4252
 }
4253 4253
 
@@ -4364,7 +4364,7 @@  discard block
 block discarded – undo
4364 4364
     $rs = Database::query($sql);
4365 4365
     $language_info = array();
4366 4366
     if (Database::num_rows($rs)) {
4367
-        $language_info = Database::fetch_array($rs,'ASSOC');
4367
+        $language_info = Database::fetch_array($rs, 'ASSOC');
4368 4368
     }
4369 4369
     return $language_info;
4370 4370
 }
@@ -4442,7 +4442,7 @@  discard block
 block discarded – undo
4442 4442
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4443 4443
  */
4444 4444
 function api_get_themes() {
4445
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4445
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4446 4446
     $list_dir = array();
4447 4447
     $list_name = array();
4448 4448
 
@@ -4633,7 +4633,7 @@  discard block
 block discarded – undo
4633 4633
     if (is_file($dirname) || is_link($dirname)) {
4634 4634
         $res = unlink($dirname);
4635 4635
         if ($res === false) {
4636
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4636
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'Error not recorded because track_errors is off in your php.ini'), 0);
4637 4637
         }
4638 4638
         return $res;
4639 4639
     }
@@ -4670,7 +4670,7 @@  discard block
 block discarded – undo
4670 4670
     if ($delete_only_content_in_folder == false) {
4671 4671
         $res = rmdir($dirname);
4672 4672
         if ($res === false) {
4673
-            error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4673
+            error_log(__FILE__.' line '.__LINE__.': '.((bool) ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);
4674 4674
         }
4675 4675
     }
4676 4676
     return $res;
@@ -4748,7 +4748,7 @@  discard block
 block discarded – undo
4748 4748
 
4749 4749
     $course_id = $course_info['real_id'];
4750 4750
 
4751
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4751
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4752 4752
 
4753 4753
     $new_pathname = $base_path_document;
4754 4754
     $path = '';
@@ -4766,7 +4766,7 @@  discard block
 block discarded – undo
4766 4766
                         path = '$path' AND
4767 4767
                         filetype = 'folder' AND
4768 4768
                         session_id = '$session_id'";
4769
-            $rs1  = Database::query($sql);
4769
+            $rs1 = Database::query($sql);
4770 4770
             $num_rows = Database::num_rows($rs1);
4771 4771
 
4772 4772
             if ($num_rows == 0) {
@@ -4923,7 +4923,7 @@  discard block
 block discarded – undo
4923 4923
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4924 4924
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4925 4925
             }
4926
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4926
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4927 4927
 
4928 4928
             // Parse array syntax.
4929 4929
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -4963,7 +4963,7 @@  discard block
 block discarded – undo
4963 4963
  */
4964 4964
 function api_get_version() {
4965 4965
     global $_configuration;
4966
-    return (string)$_configuration['system_version'];
4966
+    return (string) $_configuration['system_version'];
4967 4967
 }
4968 4968
 
4969 4969
 /**
@@ -5089,7 +5089,7 @@  discard block
 block discarded – undo
5089 5089
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5090 5090
     $var = Database::escape_string($var);
5091 5091
     $value = Database::escape_string($value);
5092
-    $access_url = (int)$access_url;
5092
+    $access_url = (int) $access_url;
5093 5093
     if (empty($access_url)) { $access_url = 1; }
5094 5094
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
5095 5095
     if (!empty($subvar)) {
@@ -5111,7 +5111,7 @@  discard block
 block discarded – undo
5111 5111
         // Found item for this access_url.
5112 5112
         $row = Database::fetch_array($res);
5113 5113
         $sql = "UPDATE $t_settings SET selected_value = '$value'
5114
-                WHERE id = ".$row['id'] ;
5114
+                WHERE id = ".$row['id'];
5115 5115
         Database::query($sql);
5116 5116
     } else {
5117 5117
         // Item not found for this access_url, we have to check if it exist with access_url = 1
@@ -5132,11 +5132,11 @@  discard block
 block discarded – undo
5132 5132
                 $row = Database::fetch_array($res);
5133 5133
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
5134 5134
                         VALUES
5135
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5136
-                        "'".$row['type']."','".$row['category']."'," .
5137
-                        "'$value','".$row['title']."'," .
5138
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5139
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
5135
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5136
+                        "'".$row['type']."','".$row['category']."',".
5137
+                        "'$value','".$row['title']."',".
5138
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5139
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
5140 5140
                 Database::query($insert);
5141 5141
             } else { // Such a setting does not exist.
5142 5142
                 error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0);
@@ -5156,16 +5156,16 @@  discard block
 block discarded – undo
5156 5156
                 if ($row['access_url_changeable'] == 1) {
5157 5157
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
5158 5158
                             ('".$row['variable']."',".
5159
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5160
-                            "'".$row['type']."','".$row['category']."'," .
5161
-                            "'$value','".$row['title']."'," .
5159
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5160
+                            "'".$row['type']."','".$row['category']."',".
5161
+                            "'$value','".$row['title']."',".
5162 5162
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
5163
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5163
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5164 5164
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
5165 5165
                     Database::query($insert);
5166 5166
                 }
5167 5167
             } else { // Such a setting does not exist.
5168
-                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
5168
+                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ', 0);
5169 5169
             }
5170 5170
         }
5171 5171
     }
@@ -5191,10 +5191,10 @@  discard block
 block discarded – undo
5191 5191
         $value = Database::escape_string($value);
5192 5192
         $sql = "UPDATE $t_s SET selected_value = '$value'
5193 5193
                 WHERE category = '$category' AND access_url = $access_url";
5194
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5194
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5195 5195
             $sql .= " AND ( ";
5196 5196
             $i = 0;
5197
-            foreach ($fieldtype as $type){
5197
+            foreach ($fieldtype as $type) {
5198 5198
                 if ($i > 0) {
5199 5199
                     $sql .= ' OR ';
5200 5200
                 }
@@ -5209,10 +5209,10 @@  discard block
 block discarded – undo
5209 5209
     } else {
5210 5210
         $sql = "UPDATE $t_s SET selected_value = NULL
5211 5211
                 WHERE category = '$category' AND access_url = $access_url";
5212
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5212
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5213 5213
             $sql .= " AND ( ";
5214 5214
             $i = 0;
5215
-            foreach ($fieldtype as $type){
5215
+            foreach ($fieldtype as $type) {
5216 5216
                 if ($i > 0) {
5217 5217
                     $sql .= ' OR ';
5218 5218
                 }
@@ -5357,7 +5357,7 @@  discard block
 block discarded – undo
5357 5357
 function & api_get_settings_categories($exceptions = array(), $access_url = 1) {
5358 5358
     $access_url = (int) $access_url;
5359 5359
     $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5360
-    $list = "'".implode("','",$exceptions)."'";
5360
+    $list = "'".implode("','", $exceptions)."'";
5361 5361
     $sql = "SELECT DISTINCT category FROM $t_cs WHERE category is NOT NULL ";
5362 5362
     if ($list != "'',''" && $list != "''" && !empty($list)) {
5363 5363
         $sql .= " AND category NOT IN ($list) ";
@@ -5453,12 +5453,12 @@  discard block
 block discarded – undo
5453 5453
 
5454 5454
     // Item not found for this access_url, we have to check if the whole thing is missing
5455 5455
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5456
-    $insert = "INSERT INTO $t_settings " .
5457
-                "(variable,selected_value," .
5458
-                "type,category," .
5459
-                "subkey,title," .
5460
-                "comment,scope," .
5461
-                "subkeytext,access_url,access_url_changeable)" .
5456
+    $insert = "INSERT INTO $t_settings ".
5457
+                "(variable,selected_value,".
5458
+                "type,category,".
5459
+                "subkey,title,".
5460
+                "comment,scope,".
5461
+                "subkeytext,access_url,access_url_changeable)".
5462 5462
                 " VALUES ('$var','$val',";
5463 5463
     if (isset($type)) {
5464 5464
         $type = Database::escape_string($type);
@@ -5624,7 +5624,7 @@  discard block
 block discarded – undo
5624 5624
             $result = Database::query($sql);
5625 5625
 
5626 5626
             //if ($row = Database::fetch_array($result)) {
5627
-            if (Database::num_rows($result) > 0 ) {
5627
+            if (Database::num_rows($result) > 0) {
5628 5628
                 $is_courseMember = true;
5629 5629
                 $is_courseTutor = true;
5630 5630
                 $is_courseCoach = true;
@@ -5845,8 +5845,8 @@  discard block
 block discarded – undo
5845 5845
 {
5846 5846
     $tbl_rel_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
5847 5847
     if (!empty($user_id) && !empty($courseId)) {
5848
-        $user_id        = intval($user_id);
5849
-        $courseId    = intval($courseId);
5848
+        $user_id = intval($user_id);
5849
+        $courseId = intval($courseId);
5850 5850
         $sql = 'SELECT status
5851 5851
                 FROM '.$tbl_rel_course_user.'
5852 5852
                 WHERE user_id='.$user_id.' AND c_id = '.$courseId;
@@ -5952,7 +5952,7 @@  discard block
 block discarded – undo
5952 5952
     } else {
5953 5953
         return false;
5954 5954
     }
5955
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5955
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5956 5956
 }
5957 5957
 
5958 5958
 /**
@@ -6477,7 +6477,7 @@  discard block
 block discarded – undo
6477 6477
 function api_get_jquery_ui_js($include_jqgrid = false) {
6478 6478
     $libraries = array();
6479 6479
     if ($include_jqgrid) {
6480
-       $libraries[]='jqgrid';
6480
+       $libraries[] = 'jqgrid';
6481 6481
     }
6482 6482
     return api_get_jquery_libraries_js($libraries);
6483 6483
 }
@@ -6501,12 +6501,12 @@  discard block
 block discarded – undo
6501 6501
 
6502 6502
     //jqgrid js and css
6503 6503
     if (in_array('jqgrid', $libraries)) {
6504
-        $languaje   = 'en';
6504
+        $languaje = 'en';
6505 6505
         $platform_isocode = strtolower(api_get_language_isocode());
6506 6506
 
6507 6507
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6508 6508
         $jqgrid_langs = array(
6509
-            'bg', 'bg1251', 'cat','cn','cs','da','de','el','en','es','fa','fi','fr','gl','he','hu','is','it','ja','nl','no','pl','pt-br','pt','ro','ru','sk','sr','sv','tr','ua'
6509
+            'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua'
6510 6510
         );
6511 6511
 
6512 6512
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6537,7 +6537,7 @@  discard block
 block discarded – undo
6537 6537
 
6538 6538
     // jquery datepicker
6539 6539
     if (in_array('datepicker', $libraries)) {
6540
-        $languaje   = 'en-GB';
6540
+        $languaje = 'en-GB';
6541 6541
         $platform_isocode = strtolower(api_get_language_isocode());
6542 6542
 
6543 6543
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6639,7 +6639,7 @@  discard block
 block discarded – undo
6639 6639
         $clean_url = str_replace('/', '-', $clean_url);
6640 6640
         $clean_url .= '/';
6641 6641
 
6642
-        $home = 'app/home/' . $clean_url;
6642
+        $home = 'app/home/'.$clean_url;
6643 6643
 
6644 6644
     }
6645 6645
 
@@ -6700,7 +6700,7 @@  discard block
 block discarded – undo
6700 6700
  * @return void
6701 6701
  */
6702 6702
 function api_check_php_version($my_inc_path = null) {
6703
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6703
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6704 6704
         $global_error_code = 1;
6705 6705
         // Incorrect PHP version
6706 6706
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6716,7 +6716,7 @@  discard block
 block discarded – undo
6716 6716
  */
6717 6717
 function api_check_archive_dir() {
6718 6718
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6719
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6719
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6720 6720
         api_not_allowed(true, $message);
6721 6721
     }
6722 6722
 }
@@ -6781,7 +6781,7 @@  discard block
 block discarded – undo
6781 6781
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6782 6782
  * @version CEV CHANGE 24APR2012
6783 6783
  */
6784
-function api_get_real_ip(){
6784
+function api_get_real_ip() {
6785 6785
     // Guess the IP if behind a reverse proxy
6786 6786
     global $debug;
6787 6787
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6806,23 +6806,23 @@  discard block
 block discarded – undo
6806 6806
  * @author Yannick Warnier for improvements and managment of multiple ranges
6807 6807
  * @todo check for IPv6 support
6808 6808
  */
6809
-function api_check_ip_in_range($ip,$range)
6809
+function api_check_ip_in_range($ip, $range)
6810 6810
 {
6811 6811
     if (empty($ip) or empty($range)) {
6812 6812
         return false;
6813 6813
     }
6814
-    $ip_ip = ip2long ($ip);
6814
+    $ip_ip = ip2long($ip);
6815 6815
     // divide range param into array of elements
6816
-    if (strpos($range,',')!==false) {
6817
-        $ranges = explode(',',$range);
6816
+    if (strpos($range, ',') !== false) {
6817
+        $ranges = explode(',', $range);
6818 6818
     } else {
6819 6819
         $ranges = array($range);
6820 6820
     }
6821 6821
     foreach ($ranges as $range) {
6822 6822
         $range = trim($range);
6823 6823
         if (empty($range)) { continue; }
6824
-        if (strpos($range,'/')===false) {
6825
-            if (strcmp($ip,$range)===0) {
6824
+        if (strpos($range, '/') === false) {
6825
+            if (strcmp($ip, $range) === 0) {
6826 6826
                 return true; // there is a direct IP match, return OK
6827 6827
             }
6828 6828
             continue; //otherwise, get to the next range
@@ -6830,7 +6830,7 @@  discard block
 block discarded – undo
6830 6830
         // the range contains a "/", so analyse completely
6831 6831
         list ($net, $mask) = explode("/", $range);
6832 6832
 
6833
-        $ip_net = ip2long ($net);
6833
+        $ip_net = ip2long($net);
6834 6834
         // mask binary magic
6835 6835
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6836 6836
 
@@ -7190,14 +7190,14 @@  discard block
 block discarded – undo
7190 7190
  * @assert (0) === true
7191 7191
  * @assert ('1G') === true
7192 7192
  */
7193
-function api_set_memory_limit($mem){
7193
+function api_set_memory_limit($mem) {
7194 7194
     //if ini_set() not available, this function is useless
7195 7195
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
7196 7196
         return false;
7197 7197
     }
7198 7198
 
7199 7199
     $memory_limit = ini_get('memory_limit');
7200
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
7200
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
7201 7201
         ini_set('memory_limit', $mem);
7202 7202
         return true;
7203 7203
     }
@@ -7214,21 +7214,21 @@  discard block
 block discarded – undo
7214 7214
  * @assert ('1m')  === 1048576
7215 7215
  * @assert ('100k') === 102400
7216 7216
  */
7217
-function api_get_bytes_memory_limit($mem){
7218
-    $size = strtolower(substr($mem,-1));
7217
+function api_get_bytes_memory_limit($mem) {
7218
+    $size = strtolower(substr($mem, -1));
7219 7219
 
7220 7220
     switch ($size) {
7221 7221
         case 't':
7222
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
7222
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
7223 7223
             break;
7224 7224
         case 'g':
7225
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
7225
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
7226 7226
             break;
7227 7227
         case 'm':
7228
-            $mem = intval(substr($mem,0,-1))*1024*1024;
7228
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
7229 7229
             break;
7230 7230
         case 'k':
7231
-            $mem = intval(substr($mem,0,-1))*1024;
7231
+            $mem = intval(substr($mem, 0, -1)) * 1024;
7232 7232
             break;
7233 7233
         default:
7234 7234
             // we assume it's integer only
@@ -7283,7 +7283,7 @@  discard block
 block discarded – undo
7283 7283
         get_lang('PasswordVeryStrong'),
7284 7284
     );
7285 7285
     $js = api_get_js('strength/strength.js');
7286
-    $js .=  "<script>
7286
+    $js .= "<script>
7287 7287
 
7288 7288
     var verdicts = ['".implode("','", $verdicts)."'];
7289 7289
     var errorMessages = {
@@ -7339,7 +7339,7 @@  discard block
 block discarded – undo
7339 7339
         return false;
7340 7340
     }
7341 7341
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7342
-    $time = time() + $minutesToBlock*60;
7342
+    $time = time() + $minutesToBlock * 60;
7343 7343
     UserManager::update_extra_field_value(
7344 7344
         $userInfo['user_id'],
7345 7345
         'captcha_blocked_until_date',
@@ -7412,7 +7412,7 @@  discard block
 block discarded – undo
7412 7412
         $out_res = str_replace('"', "''", $out_res);
7413 7413
     }
7414 7414
     // avoid text stuck together when tags are removed, adding a space after >
7415
-    $out_res = str_replace (">", "> ", $out_res);
7415
+    $out_res = str_replace(">", "> ", $out_res);
7416 7416
     $out_res = strip_tags($out_res);
7417 7417
 
7418 7418
     return $out_res;
@@ -7522,12 +7522,12 @@  discard block
 block discarded – undo
7522 7522
 {
7523 7523
     // Clean query
7524 7524
     $bt = debug_backtrace();
7525
-    $caller = array_shift($bt);;
7525
+    $caller = array_shift($bt); ;
7526 7526
     if ($dump == 1) {
7527 7527
         $string = print_r($string, 1);
7528 7528
     } else {
7529 7529
         $string = str_replace(array("\r", "\n", "\t", "\10"), '', $string);
7530
-        $string = str_replace('    ',' ', $string);
7530
+        $string = str_replace('    ', ' ', $string);
7531 7531
     }
7532 7532
 
7533 7533
     error_log("-------------------------------------");
@@ -7637,7 +7637,7 @@  discard block
 block discarded – undo
7637 7637
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7638 7638
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7639 7639
         if (isset($hostingParams[$limitName])) {
7640
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7640
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7641 7641
         }
7642 7642
         api_mail_html(null, $email, $subject, $body);
7643 7643
     }
@@ -7765,7 +7765,7 @@  discard block
 block discarded – undo
7765 7765
  */
7766 7766
 function api_set_site_use_cookie_warning_cookie()
7767 7767
 {
7768
-    setcookie("ChamiloUsesCookies", "ok", time()+31556926);
7768
+    setcookie("ChamiloUsesCookies", "ok", time() + 31556926);
7769 7769
 }
7770 7770
 
7771 7771
 /**
@@ -7813,10 +7813,10 @@  discard block
 block discarded – undo
7813 7813
         return false;
7814 7814
     }
7815 7815
 
7816
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7816
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7817 7817
 
7818 7818
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7819
-        $fp = fopen($fullPath . '/index.html', 'w');
7819
+        $fp = fopen($fullPath.'/index.html', 'w');
7820 7820
 
7821 7821
         if ($fp) {
7822 7822
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7881,7 +7881,7 @@  discard block
 block discarded – undo
7881 7881
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
7882 7882
         }
7883 7883
     }
7884
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
7884
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
7885 7885
 
7886 7886
     // 5 = low, 1 = high
7887 7887
     $mail->Priority = 3;
@@ -8061,13 +8061,13 @@  discard block
 block discarded – undo
8061 8061
  * @param int $key key to find to compare
8062 8062
  *
8063 8063
  */
8064
-function api_unique_multidim_array($array, $key){
8064
+function api_unique_multidim_array($array, $key) {
8065 8065
     $temp_array = array();
8066 8066
     $i = 0;
8067 8067
     $key_array = array();
8068 8068
 
8069
-    foreach($array as $val){
8070
-        if(!in_array($val[$key],$key_array)){
8069
+    foreach ($array as $val) {
8070
+        if (!in_array($val[$key], $key_array)) {
8071 8071
             $key_array[$i] = $val[$key];
8072 8072
             $temp_array[$i] = $val;
8073 8073
         }
Please login to merge, or discard this patch.