Passed
Push — 1.10.x ( 63e012...25fff6 )
by Yannick
45:53
created
main/inc/lib/api.lib.php 1 patch
Spacing   +149 added lines, -149 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 */
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
 define('IS_WINDOWS_OS', api_is_windows_os());
264 264
 
265 265
 // Checks for installed optional php-extensions.
266
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
267
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
268
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
266
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
267
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
268
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
269 269
 
270 270
 // Patterns for processing paths.                                   // Examples:
271
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
272
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
273
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
271
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
272
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
273
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
274 274
 
275 275
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
276 276
 define('WEB_PATH', 'WEB_PATH');
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 define('LINK_HOTPOTATOES', 9);
375 375
 
376 376
 // Score display types constants
377
-define('SCORE_DIV', 1);    // X / Y
378
-define('SCORE_PERCENT', 2);    // XX %
379
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
380
-define('SCORE_AVERAGE', 4);    // XX %
381
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
382
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
383
-define('SCORE_SIMPLE', 7);    // X
384
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
385
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
386
-define('SCORE_CUSTOM', 10);    // Good!
387
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
388
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
389
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
377
+define('SCORE_DIV', 1); // X / Y
378
+define('SCORE_PERCENT', 2); // XX %
379
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
380
+define('SCORE_AVERAGE', 4); // XX %
381
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
382
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
383
+define('SCORE_SIMPLE', 7); // X
384
+define('SCORE_IGNORE_SPLIT', 8); //  ??
385
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
386
+define('SCORE_CUSTOM', 10); // Good!
387
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
388
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
389
+define('SCORE_ONLY_SCORE', 13); // X - Good!
390 390
 
391 391
 define('SCORE_BOTH', 1);
392 392
 define('SCORE_ONLY_DEFAULT', 2);
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 define('TIMELINE_STATUS_INACTIVE', '2');
571 571
 
572 572
 // Event email template class
573
-define ('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
574
-define ('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
573
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
574
+define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
575 575
 
576 576
 // Course home
577 577
 define('SHORTCUTS_HORIZONTAL', 0);
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 
748 748
     // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
749 749
     if ($path_type == WEB_PATH) {
750
-        if (isset($_configuration['access_url']) &&  $_configuration['access_url'] != 1) {
750
+        if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) {
751 751
             //we look into the DB the function api_get_access_url
752 752
             $url_info = api_get_access_url($_configuration['access_url']);
753 753
             $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web'];
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
                     : 'localhost')));
778 778
                 if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':')
779 779
                     && (($server_protocol == 'http'
780
-                    && $_SERVER['SERVER_PORT'] != 80 ) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443 ))) {
781
-                    $server_name .= ":" . $_SERVER['SERVER_PORT'];
780
+                    && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))) {
781
+                    $server_name .= ":".$_SERVER['SERVER_PORT'];
782 782
                 }
783 783
                 $root_web = $server_protocol.'://'.$server_name.$root_rel;
784 784
                 $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
                 $sys_course_code =
953 953
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
954 954
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
955
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
955
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
956 956
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
957 957
             }
958 958
         }
@@ -996,15 +996,15 @@  discard block
 block discarded – undo
996 996
 {
997 997
     global $_configuration;
998 998
     $web_root = api_get_path(WEB_PATH);
999
-    $ext = substr($web_path,strrpos($web_path,'.'));
999
+    $ext = substr($web_path, strrpos($web_path, '.'));
1000 1000
     if (isset($ext[2])) { // faster version of strlen to check if len>2
1001 1001
         // Check for CDN definitions
1002 1002
         if (!empty($_configuration['cdn_enable']) && !empty($ext)) {
1003 1003
             foreach ($_configuration['cdn'] as $host => $exts) {
1004
-                if (in_array($ext,$exts)) {
1004
+                if (in_array($ext, $exts)) {
1005 1005
                     //Use host as defined in $_configuration['cdn'], without
1006 1006
                     // trailing slash
1007
-                    return str_replace($web_root,$host.'/',$web_path);
1007
+                    return str_replace($web_root, $host.'/', $web_path);
1008 1008
                 }
1009 1009
             }
1010 1010
         }
@@ -1453,10 +1453,10 @@  discard block
 block discarded – undo
1453 1453
 
1454 1454
     if (isset($user['email'])) {
1455 1455
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1456
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1456
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1457 1457
     } else {
1458 1458
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1459
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1459
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1460 1460
     }
1461 1461
     $user_id = intval($user['user_id']);
1462 1462
     // Maintain the user_id index for backwards compatibility
@@ -1932,7 +1932,7 @@  discard block
 block discarded – undo
1932 1932
         foreach ($param_list1 as $key => $enreg) {
1933 1933
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1934 1934
         }
1935
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1935
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1936 1936
         foreach ($param_list2 as $enreg) {
1937 1937
             $enreg = explode('=', $enreg);
1938 1938
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1962,7 +1962,7 @@  discard block
 block discarded – undo
1962 1962
         $length = 2;
1963 1963
     }
1964 1964
     $password = '';
1965
-    for ($i = 0; $i < $length; $i ++) {
1965
+    for ($i = 0; $i < $length; $i++) {
1966 1966
         $password .= $characters[rand() % strlen($characters)];
1967 1967
     }
1968 1968
     return $password;
@@ -1989,10 +1989,10 @@  discard block
 block discarded – undo
1989 1989
     $digits = 0;
1990 1990
     $consequent_characters = 0;
1991 1991
     $previous_character_code = 0;
1992
-    for ($i = 0; $i < $password_length; $i ++) {
1992
+    for ($i = 0; $i < $password_length; $i++) {
1993 1993
         $current_character_code = api_ord(api_substr($password, $i, 1));
1994 1994
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
1995
-            $consequent_characters ++;
1995
+            $consequent_characters++;
1996 1996
             if ($consequent_characters == 3) {
1997 1997
                 return false;
1998 1998
             }
@@ -2000,9 +2000,9 @@  discard block
 block discarded – undo
2000 2000
             $consequent_characters = 1;
2001 2001
         }
2002 2002
         if ($current_character_code >= 97 && $current_character_code <= 122) {
2003
-            $letters ++;
2003
+            $letters++;
2004 2004
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
2005
-            $digits ++;
2005
+            $digits++;
2006 2006
         } else {
2007 2007
             return false;
2008 2008
         }
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
         if (empty($session_id)) { return null; }
2199 2199
     }
2200 2200
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2201
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2201
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2202 2202
     $r = Database::query($s);
2203 2203
     $c = Database::num_rows($r);
2204 2204
     if ($c > 0) {
@@ -2223,7 +2223,7 @@  discard block
 block discarded – undo
2223 2223
         $sql = "SELECT * FROM $tbl_session WHERE id = $session_id";
2224 2224
         $result = Database::query($sql);
2225 2225
 
2226
-        if (Database::num_rows($result)>0) {
2226
+        if (Database::num_rows($result) > 0) {
2227 2227
             $data = Database::fetch_array($result, 'ASSOC');
2228 2228
         }
2229 2229
     }
@@ -2383,9 +2383,9 @@  discard block
 block discarded – undo
2383 2383
  */
2384 2384
 function api_get_session_image($session_id, $status_id)
2385 2385
 {
2386
-    $session_id = (int)$session_id;
2386
+    $session_id = (int) $session_id;
2387 2387
     $session_img = '';
2388
-    if ((int)$status_id != 5) { //check whether is not a student
2388
+    if ((int) $status_id != 5) { //check whether is not a student
2389 2389
         if ($session_id > 0) {
2390 2390
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2391 2391
                 'star.png',
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
         $filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
2501 2501
         if (file_exists($filename)) {
2502 2502
             $value = file_get_contents($filename);
2503
-            return $value ;
2503
+            return $value;
2504 2504
         } else {
2505 2505
             return '';
2506 2506
         }
@@ -2509,7 +2509,7 @@  discard block
 block discarded – undo
2509 2509
         $filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
2510 2510
         if (file_exists($filename)) {
2511 2511
             $value = file_get_contents($filename);
2512
-            return $value ;
2512
+            return $value;
2513 2513
         } else {
2514 2514
             return '';
2515 2515
         }
@@ -2703,7 +2703,7 @@  discard block
 block discarded – undo
2703 2703
     }
2704 2704
     $group_id   = api_get_group_id();
2705 2705
     $course_id  = api_get_course_int_id();
2706
-    $course_code= api_get_course_id();
2706
+    $course_code = api_get_course_id();
2707 2707
     $session_id = api_get_session_id();
2708 2708
 
2709 2709
     //Group (in course)
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
         $group_status = array();
2712 2712
         $is_subscribed = GroupManager::is_subscribed($user_id, $group_id);
2713 2713
         if ($is_subscribed) {
2714
-            $group_status = array('id'=> $group_id , 'status' => 'student');
2714
+            $group_status = array('id'=> $group_id, 'status' => 'student');
2715 2715
             $is_tutor = GroupManager::is_tutor_of_group($user_id, $group_id);
2716 2716
             if ($is_tutor) {
2717 2717
                 $group_status['status'] = 'tutor';
@@ -2745,7 +2745,7 @@  discard block
 block discarded – undo
2745 2745
         }
2746 2746
         $status['session'] = $session_status;
2747 2747
 
2748
-    } elseif($course_id) {
2748
+    } elseif ($course_id) {
2749 2749
         //Course
2750 2750
         $course_status = array();
2751 2751
         if ($course_id) {
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
 
2754 2754
             if ($user_course_status) {
2755 2755
                 $course_status = array('id'=> $course_id);
2756
-                switch($user_course_status) {
2756
+                switch ($user_course_status) {
2757 2757
                     case 1;
2758 2758
                         $course_status['status'] = 'teacher';
2759 2759
                     break;
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2784 2784
 {
2785 2785
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2786
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2786
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2787 2787
 
2788 2788
     $user_id = intval($user_id);
2789 2789
     $session_id = intval($session_id);
@@ -2857,7 +2857,7 @@  discard block
 block discarded – undo
2857 2857
                 ORDER BY access_start_date, access_end_date, name";
2858 2858
         $result = Database::query($sql);
2859 2859
         if (!empty($sessionIsCoach)) {
2860
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2860
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2861 2861
         } else {
2862 2862
             $sessionIsCoach = Database::store_result($result);
2863 2863
         }
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
             return '';
3035 3035
         }
3036 3036
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
3037
-        $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);
3037
+        $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);
3038 3038
         //showinframes doesn't handle student view anyway...
3039 3039
         //return '';
3040 3040
         $is_framed = true;
@@ -3433,7 +3433,7 @@  discard block
 block discarded – undo
3433 3433
         }
3434 3434
         $content .= '<div class="well_login">';
3435 3435
         $content .= $form->return_form();
3436
-        $content .='</div>';
3436
+        $content .= '</div>';
3437 3437
         if (api_is_cas_activated()) {
3438 3438
             $content .= "</div>";
3439 3439
         }
@@ -3452,7 +3452,7 @@  discard block
 block discarded – undo
3452 3452
         exit;
3453 3453
     }
3454 3454
 
3455
-    if ($user_id !=0 && !api_is_anonymous()) {
3455
+    if ($user_id != 0 && !api_is_anonymous()) {
3456 3456
         $tpl->display_one_col_template();
3457 3457
         exit;
3458 3458
     }
@@ -3483,7 +3483,7 @@  discard block
 block discarded – undo
3483 3483
         }
3484 3484
         $msg .= '<div class="well">';
3485 3485
         $msg .= $form->return_form();
3486
-        $msg .='</div>';
3486
+        $msg .= '</div>';
3487 3487
         if (api_is_cas_activated()) {
3488 3488
             $msg .= "</div>";
3489 3489
         }
@@ -3519,7 +3519,7 @@  discard block
 block discarded – undo
3519 3519
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3520 3520
     list ($year, $month, $day) = explode('-', $last_post_date);
3521 3521
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3522
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3522
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3523 3523
 }
3524 3524
 
3525 3525
 /**
@@ -3970,7 +3970,7 @@  discard block
 block discarded – undo
3970 3970
                 c_id = $course_id AND
3971 3971
                 tool = '$tool'
3972 3972
                 $session_condition ";
3973
-    $rs  = Database::query($sql);
3973
+    $rs = Database::query($sql);
3974 3974
     $list = array();
3975 3975
     if (Database::num_rows($rs) > 0) {
3976 3976
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -4050,7 +4050,7 @@  discard block
 block discarded – undo
4050 4050
                 tool = '$tool' AND
4051 4051
                 ref = $ref
4052 4052
                 $sessionCondition";
4053
-    $rs  = Database::query($sql);
4053
+    $rs = Database::query($sql);
4054 4054
     $item_property_id = '';
4055 4055
     if (Database::num_rows($rs) > 0) {
4056 4056
         $row = Database::fetch_array($rs);
@@ -4108,7 +4108,7 @@  discard block
 block discarded – undo
4108 4108
             WHERE item_property_id = $item_property_id AND course_id = $course_id
4109 4109
             ORDER BY lastedit_date DESC";
4110 4110
     $result = Database::query($sql);
4111
-    $result = Database::store_result($result,'ASSOC');
4111
+    $result = Database::store_result($result, 'ASSOC');
4112 4112
     return $result;
4113 4113
 }
4114 4114
 
@@ -4158,7 +4158,7 @@  discard block
 block discarded – undo
4158 4158
     $rs  = Database::query($sql);
4159 4159
     $row = array();
4160 4160
     if (Database::num_rows($rs) > 0) {
4161
-        $row = Database::fetch_array($rs,'ASSOC');
4161
+        $row = Database::fetch_array($rs, 'ASSOC');
4162 4162
     }
4163 4163
 
4164 4164
     return $row;
@@ -4194,7 +4194,7 @@  discard block
 block discarded – undo
4194 4194
     $languages  = $language_list['name'];
4195 4195
     $folder     = $language_list['folder'];
4196 4196
 
4197
-    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
4197
+    $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
4198 4198
     foreach ($languages as $key => $value) {
4199 4199
         if ($folder[$key] == $default) {
4200 4200
             $selected = ' selected="selected"';
@@ -4247,8 +4247,8 @@  discard block
 block discarded – undo
4247 4247
     //-->
4248 4248
     </script>';
4249 4249
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4250
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4251
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4250
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4251
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4252 4252
 
4253 4253
     foreach ($original_languages as $key => $value) {
4254 4254
         if ($folder[$key] == $user_selected_language) {
@@ -4256,13 +4256,13 @@  discard block
 block discarded – undo
4256 4256
         } else {
4257 4257
             $option_end = '>';
4258 4258
         }
4259
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4259
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4260 4260
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4261
-        $html .=  $value.'</option>';
4261
+        $html .= $value.'</option>';
4262 4262
     }
4263
-    $html .=  '</select>';
4264
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4265
-    $html .=  '</form>';
4263
+    $html .= '</select>';
4264
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4265
+    $html .= '</form>';
4266 4266
     return $html;
4267 4267
 }
4268 4268
 
@@ -4379,7 +4379,7 @@  discard block
 block discarded – undo
4379 4379
     $rs = Database::query($sql);
4380 4380
     $language_info = array();
4381 4381
     if (Database::num_rows($rs)) {
4382
-        $language_info = Database::fetch_array($rs,'ASSOC');
4382
+        $language_info = Database::fetch_array($rs, 'ASSOC');
4383 4383
     }
4384 4384
     return $language_info;
4385 4385
 }
@@ -4457,7 +4457,7 @@  discard block
 block discarded – undo
4457 4457
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4458 4458
  */
4459 4459
 function api_get_themes() {
4460
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4460
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4461 4461
     $list_dir = array();
4462 4462
     $list_name = array();
4463 4463
 
@@ -4648,7 +4648,7 @@  discard block
 block discarded – undo
4648 4648
     if (is_file($dirname) || is_link($dirname)) {
4649 4649
         $res = unlink($dirname);
4650 4650
         if ($res === false) {
4651
-            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);
4651
+            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);
4652 4652
         }
4653 4653
         return $res;
4654 4654
     }
@@ -4685,7 +4685,7 @@  discard block
 block discarded – undo
4685 4685
     if ($delete_only_content_in_folder == false) {
4686 4686
         $res = rmdir($dirname);
4687 4687
         if ($res === false) {
4688
-            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);
4688
+            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);
4689 4689
         }
4690 4690
     }
4691 4691
     return $res;
@@ -4763,7 +4763,7 @@  discard block
 block discarded – undo
4763 4763
 
4764 4764
     $course_id = $course_info['real_id'];
4765 4765
 
4766
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4766
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4767 4767
 
4768 4768
     $new_pathname = $base_path_document;
4769 4769
     $path = '';
@@ -4781,7 +4781,7 @@  discard block
 block discarded – undo
4781 4781
                         path = '$path' AND
4782 4782
                         filetype = 'folder' AND
4783 4783
                         session_id = '$session_id'";
4784
-            $rs1  = Database::query($sql);
4784
+            $rs1 = Database::query($sql);
4785 4785
             $num_rows = Database::num_rows($rs1);
4786 4786
 
4787 4787
             if ($num_rows == 0) {
@@ -4938,7 +4938,7 @@  discard block
 block discarded – undo
4938 4938
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4939 4939
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4940 4940
             }
4941
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4941
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4942 4942
 
4943 4943
             // Parse array syntax.
4944 4944
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -4978,7 +4978,7 @@  discard block
 block discarded – undo
4978 4978
  */
4979 4979
 function api_get_version() {
4980 4980
     global $_configuration;
4981
-    return (string)$_configuration['system_version'];
4981
+    return (string) $_configuration['system_version'];
4982 4982
 }
4983 4983
 
4984 4984
 /**
@@ -5104,7 +5104,7 @@  discard block
 block discarded – undo
5104 5104
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5105 5105
     $var = Database::escape_string($var);
5106 5106
     $value = Database::escape_string($value);
5107
-    $access_url = (int)$access_url;
5107
+    $access_url = (int) $access_url;
5108 5108
     if (empty($access_url)) { $access_url = 1; }
5109 5109
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
5110 5110
     if (!empty($subvar)) {
@@ -5126,7 +5126,7 @@  discard block
 block discarded – undo
5126 5126
         // Found item for this access_url.
5127 5127
         $row = Database::fetch_array($res);
5128 5128
         $sql = "UPDATE $t_settings SET selected_value = '$value'
5129
-                WHERE id = ".$row['id'] ;
5129
+                WHERE id = ".$row['id'];
5130 5130
         Database::query($sql);
5131 5131
     } else {
5132 5132
         // Item not found for this access_url, we have to check if it exist with access_url = 1
@@ -5147,11 +5147,11 @@  discard block
 block discarded – undo
5147 5147
                 $row = Database::fetch_array($res);
5148 5148
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
5149 5149
                         VALUES
5150
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5151
-                        "'".$row['type']."','".$row['category']."'," .
5152
-                        "'$value','".$row['title']."'," .
5153
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5154
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
5150
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5151
+                        "'".$row['type']."','".$row['category']."',".
5152
+                        "'$value','".$row['title']."',".
5153
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5154
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
5155 5155
                 Database::query($insert);
5156 5156
             } else { // Such a setting does not exist.
5157 5157
                 error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0);
@@ -5171,16 +5171,16 @@  discard block
 block discarded – undo
5171 5171
                 if ($row['access_url_changeable'] == 1) {
5172 5172
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
5173 5173
                             ('".$row['variable']."',".
5174
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5175
-                            "'".$row['type']."','".$row['category']."'," .
5176
-                            "'$value','".$row['title']."'," .
5174
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5175
+                            "'".$row['type']."','".$row['category']."',".
5176
+                            "'$value','".$row['title']."',".
5177 5177
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
5178
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5178
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5179 5179
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
5180 5180
                     Database::query($insert);
5181 5181
                 }
5182 5182
             } else { // Such a setting does not exist.
5183
-                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
5183
+                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ', 0);
5184 5184
             }
5185 5185
         }
5186 5186
     }
@@ -5206,10 +5206,10 @@  discard block
 block discarded – undo
5206 5206
         $value = Database::escape_string($value);
5207 5207
         $sql = "UPDATE $t_s SET selected_value = '$value'
5208 5208
                 WHERE category = '$category' AND access_url = $access_url";
5209
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5209
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5210 5210
             $sql .= " AND ( ";
5211 5211
             $i = 0;
5212
-            foreach ($fieldtype as $type){
5212
+            foreach ($fieldtype as $type) {
5213 5213
                 if ($i > 0) {
5214 5214
                     $sql .= ' OR ';
5215 5215
                 }
@@ -5224,10 +5224,10 @@  discard block
 block discarded – undo
5224 5224
     } else {
5225 5225
         $sql = "UPDATE $t_s SET selected_value = NULL
5226 5226
                 WHERE category = '$category' AND access_url = $access_url";
5227
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5227
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5228 5228
             $sql .= " AND ( ";
5229 5229
             $i = 0;
5230
-            foreach ($fieldtype as $type){
5230
+            foreach ($fieldtype as $type) {
5231 5231
                 if ($i > 0) {
5232 5232
                     $sql .= ' OR ';
5233 5233
                 }
@@ -5372,7 +5372,7 @@  discard block
 block discarded – undo
5372 5372
 function & api_get_settings_categories($exceptions = array(), $access_url = 1) {
5373 5373
     $access_url = (int) $access_url;
5374 5374
     $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5375
-    $list = "'".implode("','",$exceptions)."'";
5375
+    $list = "'".implode("','", $exceptions)."'";
5376 5376
     $sql = "SELECT DISTINCT category FROM $t_cs WHERE category is NOT NULL ";
5377 5377
     if ($list != "'',''" && $list != "''" && !empty($list)) {
5378 5378
         $sql .= " AND category NOT IN ($list) ";
@@ -5468,12 +5468,12 @@  discard block
 block discarded – undo
5468 5468
 
5469 5469
     // Item not found for this access_url, we have to check if the whole thing is missing
5470 5470
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5471
-    $insert = "INSERT INTO $t_settings " .
5472
-                "(variable,selected_value," .
5473
-                "type,category," .
5474
-                "subkey,title," .
5475
-                "comment,scope," .
5476
-                "subkeytext,access_url,access_url_changeable)" .
5471
+    $insert = "INSERT INTO $t_settings ".
5472
+                "(variable,selected_value,".
5473
+                "type,category,".
5474
+                "subkey,title,".
5475
+                "comment,scope,".
5476
+                "subkeytext,access_url,access_url_changeable)".
5477 5477
                 " VALUES ('$var','$val',";
5478 5478
     if (isset($type)) {
5479 5479
         $type = Database::escape_string($type);
@@ -5639,7 +5639,7 @@  discard block
 block discarded – undo
5639 5639
             $result = Database::query($sql);
5640 5640
 
5641 5641
             //if ($row = Database::fetch_array($result)) {
5642
-            if (Database::num_rows($result) > 0 ) {
5642
+            if (Database::num_rows($result) > 0) {
5643 5643
                 $is_courseMember = true;
5644 5644
                 $is_courseTutor = true;
5645 5645
                 $is_courseCoach = true;
@@ -5860,8 +5860,8 @@  discard block
 block discarded – undo
5860 5860
 {
5861 5861
     $tbl_rel_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
5862 5862
     if (!empty($user_id) && !empty($courseId)) {
5863
-        $user_id        = intval($user_id);
5864
-        $courseId    = intval($courseId);
5863
+        $user_id = intval($user_id);
5864
+        $courseId = intval($courseId);
5865 5865
         $sql = 'SELECT status
5866 5866
                 FROM '.$tbl_rel_course_user.'
5867 5867
                 WHERE user_id='.$user_id.' AND c_id = '.$courseId;
@@ -5967,7 +5967,7 @@  discard block
 block discarded – undo
5967 5967
     } else {
5968 5968
         return false;
5969 5969
     }
5970
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5970
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5971 5971
 }
5972 5972
 
5973 5973
 /**
@@ -6492,7 +6492,7 @@  discard block
 block discarded – undo
6492 6492
 function api_get_jquery_ui_js($include_jqgrid = false) {
6493 6493
     $libraries = array();
6494 6494
     if ($include_jqgrid) {
6495
-       $libraries[]='jqgrid';
6495
+       $libraries[] = 'jqgrid';
6496 6496
     }
6497 6497
     return api_get_jquery_libraries_js($libraries);
6498 6498
 }
@@ -6516,12 +6516,12 @@  discard block
 block discarded – undo
6516 6516
 
6517 6517
     //jqgrid js and css
6518 6518
     if (in_array('jqgrid', $libraries)) {
6519
-        $languaje   = 'en';
6519
+        $languaje = 'en';
6520 6520
         $platform_isocode = strtolower(api_get_language_isocode());
6521 6521
 
6522 6522
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6523 6523
         $jqgrid_langs = array(
6524
-            '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'
6524
+            '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'
6525 6525
         );
6526 6526
 
6527 6527
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6552,7 +6552,7 @@  discard block
 block discarded – undo
6552 6552
 
6553 6553
     // jquery datepicker
6554 6554
     if (in_array('datepicker', $libraries)) {
6555
-        $languaje   = 'en-GB';
6555
+        $languaje = 'en-GB';
6556 6556
         $platform_isocode = strtolower(api_get_language_isocode());
6557 6557
 
6558 6558
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6654,7 +6654,7 @@  discard block
 block discarded – undo
6654 6654
         $clean_url = str_replace('/', '-', $clean_url);
6655 6655
         $clean_url .= '/';
6656 6656
 
6657
-        $home = 'app/home/' . $clean_url;
6657
+        $home = 'app/home/'.$clean_url;
6658 6658
     }
6659 6659
 
6660 6660
     return $home;
@@ -6714,7 +6714,7 @@  discard block
 block discarded – undo
6714 6714
  * @return void
6715 6715
  */
6716 6716
 function api_check_php_version($my_inc_path = null) {
6717
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6717
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6718 6718
         $global_error_code = 1;
6719 6719
         // Incorrect PHP version
6720 6720
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6730,7 +6730,7 @@  discard block
 block discarded – undo
6730 6730
  */
6731 6731
 function api_check_archive_dir() {
6732 6732
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6733
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6733
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6734 6734
         api_not_allowed(true, $message);
6735 6735
     }
6736 6736
 }
@@ -6795,7 +6795,7 @@  discard block
 block discarded – undo
6795 6795
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6796 6796
  * @version CEV CHANGE 24APR2012
6797 6797
  */
6798
-function api_get_real_ip(){
6798
+function api_get_real_ip() {
6799 6799
     // Guess the IP if behind a reverse proxy
6800 6800
     global $debug;
6801 6801
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6820,23 +6820,23 @@  discard block
 block discarded – undo
6820 6820
  * @author Yannick Warnier for improvements and managment of multiple ranges
6821 6821
  * @todo check for IPv6 support
6822 6822
  */
6823
-function api_check_ip_in_range($ip,$range)
6823
+function api_check_ip_in_range($ip, $range)
6824 6824
 {
6825 6825
     if (empty($ip) or empty($range)) {
6826 6826
         return false;
6827 6827
     }
6828
-    $ip_ip = ip2long ($ip);
6828
+    $ip_ip = ip2long($ip);
6829 6829
     // divide range param into array of elements
6830
-    if (strpos($range,',')!==false) {
6831
-        $ranges = explode(',',$range);
6830
+    if (strpos($range, ',') !== false) {
6831
+        $ranges = explode(',', $range);
6832 6832
     } else {
6833 6833
         $ranges = array($range);
6834 6834
     }
6835 6835
     foreach ($ranges as $range) {
6836 6836
         $range = trim($range);
6837 6837
         if (empty($range)) { continue; }
6838
-        if (strpos($range,'/')===false) {
6839
-            if (strcmp($ip,$range)===0) {
6838
+        if (strpos($range, '/') === false) {
6839
+            if (strcmp($ip, $range) === 0) {
6840 6840
                 return true; // there is a direct IP match, return OK
6841 6841
             }
6842 6842
             continue; //otherwise, get to the next range
@@ -6844,7 +6844,7 @@  discard block
 block discarded – undo
6844 6844
         // the range contains a "/", so analyse completely
6845 6845
         list ($net, $mask) = explode("/", $range);
6846 6846
 
6847
-        $ip_net = ip2long ($net);
6847
+        $ip_net = ip2long($net);
6848 6848
         // mask binary magic
6849 6849
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6850 6850
 
@@ -7205,14 +7205,14 @@  discard block
 block discarded – undo
7205 7205
  * @assert (0) === true
7206 7206
  * @assert ('1G') === true
7207 7207
  */
7208
-function api_set_memory_limit($mem){
7208
+function api_set_memory_limit($mem) {
7209 7209
     //if ini_set() not available, this function is useless
7210 7210
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
7211 7211
         return false;
7212 7212
     }
7213 7213
 
7214 7214
     $memory_limit = ini_get('memory_limit');
7215
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
7215
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
7216 7216
         ini_set('memory_limit', $mem);
7217 7217
         return true;
7218 7218
     }
@@ -7229,21 +7229,21 @@  discard block
 block discarded – undo
7229 7229
  * @assert ('1m')  === 1048576
7230 7230
  * @assert ('100k') === 102400
7231 7231
  */
7232
-function api_get_bytes_memory_limit($mem){
7233
-    $size = strtolower(substr($mem,-1));
7232
+function api_get_bytes_memory_limit($mem) {
7233
+    $size = strtolower(substr($mem, -1));
7234 7234
 
7235 7235
     switch ($size) {
7236 7236
         case 't':
7237
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
7237
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
7238 7238
             break;
7239 7239
         case 'g':
7240
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
7240
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
7241 7241
             break;
7242 7242
         case 'm':
7243
-            $mem = intval(substr($mem,0,-1))*1024*1024;
7243
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
7244 7244
             break;
7245 7245
         case 'k':
7246
-            $mem = intval(substr($mem,0,-1))*1024;
7246
+            $mem = intval(substr($mem, 0, -1)) * 1024;
7247 7247
             break;
7248 7248
         default:
7249 7249
             // we assume it's integer only
@@ -7298,7 +7298,7 @@  discard block
 block discarded – undo
7298 7298
         get_lang('PasswordVeryStrong'),
7299 7299
     );
7300 7300
     $js = api_get_js('strength/strength.js');
7301
-    $js .=  "<script>
7301
+    $js .= "<script>
7302 7302
 
7303 7303
     var verdicts = ['".implode("','", $verdicts)."'];
7304 7304
     var errorMessages = {
@@ -7354,7 +7354,7 @@  discard block
 block discarded – undo
7354 7354
         return false;
7355 7355
     }
7356 7356
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7357
-    $time = time() + $minutesToBlock*60;
7357
+    $time = time() + $minutesToBlock * 60;
7358 7358
     UserManager::update_extra_field_value(
7359 7359
         $userInfo['user_id'],
7360 7360
         'captcha_blocked_until_date',
@@ -7427,7 +7427,7 @@  discard block
 block discarded – undo
7427 7427
         $out_res = str_replace('"', "''", $out_res);
7428 7428
     }
7429 7429
     // avoid text stuck together when tags are removed, adding a space after >
7430
-    $out_res = str_replace (">", "> ", $out_res);
7430
+    $out_res = str_replace(">", "> ", $out_res);
7431 7431
     $out_res = strip_tags($out_res);
7432 7432
 
7433 7433
     return $out_res;
@@ -7537,12 +7537,12 @@  discard block
 block discarded – undo
7537 7537
 {
7538 7538
     // Clean query
7539 7539
     $bt = debug_backtrace();
7540
-    $caller = array_shift($bt);;
7540
+    $caller = array_shift($bt); ;
7541 7541
     if ($dump == 1) {
7542 7542
         $string = print_r($string, 1);
7543 7543
     } else {
7544 7544
         $string = str_replace(array("\r", "\n", "\t", "\10"), '', $string);
7545
-        $string = str_replace('    ',' ', $string);
7545
+        $string = str_replace('    ', ' ', $string);
7546 7546
     }
7547 7547
 
7548 7548
     error_log("-------------------------------------");
@@ -7652,7 +7652,7 @@  discard block
 block discarded – undo
7652 7652
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7653 7653
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7654 7654
         if (isset($hostingParams[$limitName])) {
7655
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7655
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7656 7656
         }
7657 7657
         api_mail_html(null, $email, $subject, $body);
7658 7658
     }
@@ -7780,7 +7780,7 @@  discard block
 block discarded – undo
7780 7780
  */
7781 7781
 function api_set_site_use_cookie_warning_cookie()
7782 7782
 {
7783
-    setcookie("ChamiloUsesCookies", "ok", time()+31556926);
7783
+    setcookie("ChamiloUsesCookies", "ok", time() + 31556926);
7784 7784
 }
7785 7785
 
7786 7786
 /**
@@ -7828,10 +7828,10 @@  discard block
 block discarded – undo
7828 7828
         return false;
7829 7829
     }
7830 7830
 
7831
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7831
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7832 7832
 
7833 7833
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7834
-        $fp = fopen($fullPath . '/index.html', 'w');
7834
+        $fp = fopen($fullPath.'/index.html', 'w');
7835 7835
 
7836 7836
         if ($fp) {
7837 7837
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7896,7 +7896,7 @@  discard block
 block discarded – undo
7896 7896
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
7897 7897
         }
7898 7898
     }
7899
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
7899
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
7900 7900
 
7901 7901
     // 5 = low, 1 = high
7902 7902
     $mail->Priority = 3;
@@ -8048,11 +8048,11 @@  discard block
 block discarded – undo
8048 8048
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
8049 8049
         if ($mail->SMTPDebug) {
8050 8050
             error_log(
8051
-                "Connection details :: " .
8052
-                "Protocol: " . $mail->Mailer . ' :: ' .
8053
-                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
8054
-                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
8055
-                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
8051
+                "Connection details :: ".
8052
+                "Protocol: ".$mail->Mailer.' :: '.
8053
+                "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '.
8054
+                "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '.
8055
+                ($mail->SMTPAuth ? "  User/Pass: ".$mail->Username.':'.$mail->Password : '')
8056 8056
             );
8057 8057
         }
8058 8058
         return 0;
@@ -8100,13 +8100,13 @@  discard block
 block discarded – undo
8100 8100
  * @param int $key key to find to compare
8101 8101
  *
8102 8102
  */
8103
-function api_unique_multidim_array($array, $key){
8103
+function api_unique_multidim_array($array, $key) {
8104 8104
     $temp_array = array();
8105 8105
     $i = 0;
8106 8106
     $key_array = array();
8107 8107
 
8108
-    foreach($array as $val){
8109
-        if(!in_array($val[$key],$key_array)){
8108
+    foreach ($array as $val) {
8109
+        if (!in_array($val[$key], $key_array)) {
8110 8110
             $key_array[$i] = $val[$key];
8111 8111
             $temp_array[$i] = $val;
8112 8112
         }
Please login to merge, or discard this patch.