Completed
Push — 1.10.x ( 840f49...e914b1 )
by Yannick
44:20
created
main/inc/lib/api.lib.php 2 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1359,6 +1359,7 @@  discard block
 block discarded – undo
1359 1359
  * Gets the list of courses a specific user is subscribed to
1360 1360
  * @param int       User ID
1361 1361
  * @param boolean   $fetch_session Whether to get session courses or not - NOT YET IMPLEMENTED
1362
+ * @param integer $userid
1362 1363
  * @return array    Array of courses in the form [0]=>('code'=>xxx,'db'=>xxx,'dir'=>xxx,'status'=>d)
1363 1364
  */
1364 1365
 function api_get_user_courses($userid, $fetch_session = true)
@@ -6733,7 +6734,7 @@  discard block
 block discarded – undo
6733 6734
 /**
6734 6735
  * Returns an array of global configuration settings which should be ignored
6735 6736
  * when printing the configuration settings screens
6736
- * @return array Array of strings, each identifying one of the excluded settings
6737
+ * @return string[] Array of strings, each identifying one of the excluded settings
6737 6738
  */
6738 6739
 function api_get_locked_settings() {
6739 6740
     return array(
@@ -6776,6 +6777,7 @@  discard block
 block discarded – undo
6776 6777
  * false if he isn't. If the user ID is given and is an integer, then the same
6777 6778
  * ID is simply returned
6778 6779
  * @param  integer User ID
6780
+ * @param integer $user_id
6779 6781
  * @return boolean Integer User ID is logged in, or false otherwise
6780 6782
  */
6781 6783
 function api_user_is_login($user_id = null) {
@@ -7220,6 +7222,7 @@  discard block
 block discarded – undo
7220 7222
 /**
7221 7223
  * Gets memory limit in bytes
7222 7224
  * @param string The memory size (128M, 1G, 1000K, etc)
7225
+ * @param string $mem
7223 7226
  * @return int
7224 7227
  * @assert (null) === false
7225 7228
  * @assert ('1t')  === 1099511627776
@@ -8131,7 +8134,7 @@  discard block
 block discarded – undo
8131 8134
 /**
8132 8135
  * Like strip_tags(), but leaves an additional space and removes only the given tags
8133 8136
  * @param string $string
8134
- * @param array $tags Tags to be removed
8137
+ * @param string[] $tags Tags to be removed
8135 8138
  * @return  string The original string without the given tags
8136 8139
  */
8137 8140
 function stripGivenTags($string, $tags) {
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 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);
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 define('TIMELINE_STATUS_INACTIVE', '2');
573 573
 
574 574
 // Event email template class
575
-define ('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
576
-define ('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
575
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
576
+define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
577 577
 
578 578
 // Course home
579 579
 define('SHORTCUTS_HORIZONTAL', 0);
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 
749 749
     // To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
750 750
     if ($path_type == WEB_PATH) {
751
-        if (isset($_configuration['access_url']) &&  $_configuration['access_url'] != 1) {
751
+        if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) {
752 752
             //we look into the DB the function api_get_access_url
753 753
             $url_info = api_get_access_url($_configuration['access_url']);
754 754
             $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web'];
@@ -778,8 +778,8 @@  discard block
 block discarded – undo
778 778
                     : 'localhost')));
779 779
                 if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':')
780 780
                     && (($server_protocol == 'http'
781
-                    && $_SERVER['SERVER_PORT'] != 80 ) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443 ))) {
782
-                    $server_name .= ":" . $_SERVER['SERVER_PORT'];
781
+                    && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))) {
782
+                    $server_name .= ":".$_SERVER['SERVER_PORT'];
783 783
                 }
784 784
                 $root_web = $server_protocol.'://'.$server_name.$root_rel;
785 785
                 $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                 $sys_course_code =
954 954
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
955 955
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
956
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
956
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
957 957
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
958 958
             }
959 959
         }
@@ -997,15 +997,15 @@  discard block
 block discarded – undo
997 997
 {
998 998
     global $_configuration;
999 999
     $web_root = api_get_path(WEB_PATH);
1000
-    $ext = substr($web_path,strrpos($web_path,'.'));
1000
+    $ext = substr($web_path, strrpos($web_path, '.'));
1001 1001
     if (isset($ext[2])) { // faster version of strlen to check if len>2
1002 1002
         // Check for CDN definitions
1003 1003
         if (!empty($_configuration['cdn_enable']) && !empty($ext)) {
1004 1004
             foreach ($_configuration['cdn'] as $host => $exts) {
1005
-                if (in_array($ext,$exts)) {
1005
+                if (in_array($ext, $exts)) {
1006 1006
                     //Use host as defined in $_configuration['cdn'], without
1007 1007
                     // trailing slash
1008
-                    return str_replace($web_root,$host.'/',$web_path);
1008
+                    return str_replace($web_root, $host.'/', $web_path);
1009 1009
                 }
1010 1010
             }
1011 1011
         }
@@ -1454,10 +1454,10 @@  discard block
 block discarded – undo
1454 1454
 
1455 1455
     if (isset($user['email'])) {
1456 1456
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1457
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1457
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1458 1458
     } else {
1459 1459
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1460
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1460
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1461 1461
     }
1462 1462
     $user_id = intval($user['user_id']);
1463 1463
     // Maintain the user_id index for backwards compatibility
@@ -1937,7 +1937,7 @@  discard block
 block discarded – undo
1937 1937
         foreach ($param_list1 as $key => $enreg) {
1938 1938
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1939 1939
         }
1940
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1940
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1941 1941
         foreach ($param_list2 as $enreg) {
1942 1942
             $enreg = explode('=', $enreg);
1943 1943
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
         $length = 2;
1968 1968
     }
1969 1969
     $password = '';
1970
-    for ($i = 0; $i < $length; $i ++) {
1970
+    for ($i = 0; $i < $length; $i++) {
1971 1971
         $password .= $characters[rand() % strlen($characters)];
1972 1972
     }
1973 1973
     return $password;
@@ -1994,10 +1994,10 @@  discard block
 block discarded – undo
1994 1994
     $digits = 0;
1995 1995
     $consequent_characters = 0;
1996 1996
     $previous_character_code = 0;
1997
-    for ($i = 0; $i < $password_length; $i ++) {
1997
+    for ($i = 0; $i < $password_length; $i++) {
1998 1998
         $current_character_code = api_ord(api_substr($password, $i, 1));
1999 1999
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
2000
-            $consequent_characters ++;
2000
+            $consequent_characters++;
2001 2001
             if ($consequent_characters == 3) {
2002 2002
                 return false;
2003 2003
             }
@@ -2005,9 +2005,9 @@  discard block
 block discarded – undo
2005 2005
             $consequent_characters = 1;
2006 2006
         }
2007 2007
         if ($current_character_code >= 97 && $current_character_code <= 122) {
2008
-            $letters ++;
2008
+            $letters++;
2009 2009
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
2010
-            $digits ++;
2010
+            $digits++;
2011 2011
         } else {
2012 2012
             return false;
2013 2013
         }
@@ -2203,7 +2203,7 @@  discard block
 block discarded – undo
2203 2203
         if (empty($session_id)) { return null; }
2204 2204
     }
2205 2205
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2206
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2206
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2207 2207
     $r = Database::query($s);
2208 2208
     $c = Database::num_rows($r);
2209 2209
     if ($c > 0) {
@@ -2228,7 +2228,7 @@  discard block
 block discarded – undo
2228 2228
         $sql = "SELECT * FROM $tbl_session WHERE id = $session_id";
2229 2229
         $result = Database::query($sql);
2230 2230
 
2231
-        if (Database::num_rows($result)>0) {
2231
+        if (Database::num_rows($result) > 0) {
2232 2232
             $data = Database::fetch_array($result, 'ASSOC');
2233 2233
         }
2234 2234
     }
@@ -2388,9 +2388,9 @@  discard block
 block discarded – undo
2388 2388
  */
2389 2389
 function api_get_session_image($session_id, $status_id)
2390 2390
 {
2391
-    $session_id = (int)$session_id;
2391
+    $session_id = (int) $session_id;
2392 2392
     $session_img = '';
2393
-    if ((int)$status_id != 5) { //check whether is not a student
2393
+    if ((int) $status_id != 5) { //check whether is not a student
2394 2394
         if ($session_id > 0) {
2395 2395
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2396 2396
                 'star.png',
@@ -2505,7 +2505,7 @@  discard block
 block discarded – undo
2505 2505
         $filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
2506 2506
         if (file_exists($filename)) {
2507 2507
             $value = file_get_contents($filename);
2508
-            return $value ;
2508
+            return $value;
2509 2509
         } else {
2510 2510
             return '';
2511 2511
         }
@@ -2514,7 +2514,7 @@  discard block
 block discarded – undo
2514 2514
         $filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
2515 2515
         if (file_exists($filename)) {
2516 2516
             $value = file_get_contents($filename);
2517
-            return $value ;
2517
+            return $value;
2518 2518
         } else {
2519 2519
             return '';
2520 2520
         }
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
     }
2709 2709
     $group_id   = api_get_group_id();
2710 2710
     $course_id  = api_get_course_int_id();
2711
-    $course_code= api_get_course_id();
2711
+    $course_code = api_get_course_id();
2712 2712
     $session_id = api_get_session_id();
2713 2713
 
2714 2714
     //Group (in course)
@@ -2716,7 +2716,7 @@  discard block
 block discarded – undo
2716 2716
         $group_status = array();
2717 2717
         $is_subscribed = GroupManager::is_subscribed($user_id, $group_id);
2718 2718
         if ($is_subscribed) {
2719
-            $group_status = array('id'=> $group_id , 'status' => 'student');
2719
+            $group_status = array('id'=> $group_id, 'status' => 'student');
2720 2720
             $is_tutor = GroupManager::is_tutor_of_group($user_id, $group_id);
2721 2721
             if ($is_tutor) {
2722 2722
                 $group_status['status'] = 'tutor';
@@ -2750,7 +2750,7 @@  discard block
 block discarded – undo
2750 2750
         }
2751 2751
         $status['session'] = $session_status;
2752 2752
 
2753
-    } elseif($course_id) {
2753
+    } elseif ($course_id) {
2754 2754
         //Course
2755 2755
         $course_status = array();
2756 2756
         if ($course_id) {
@@ -2758,7 +2758,7 @@  discard block
 block discarded – undo
2758 2758
 
2759 2759
             if ($user_course_status) {
2760 2760
                 $course_status = array('id'=> $course_id);
2761
-                switch($user_course_status) {
2761
+                switch ($user_course_status) {
2762 2762
                     case 1;
2763 2763
                         $course_status['status'] = 'teacher';
2764 2764
                     break;
@@ -2788,7 +2788,7 @@  discard block
 block discarded – undo
2788 2788
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2789 2789
 {
2790 2790
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2791
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2791
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2792 2792
 
2793 2793
     $user_id = intval($user_id);
2794 2794
     $session_id = intval($session_id);
@@ -2862,7 +2862,7 @@  discard block
 block discarded – undo
2862 2862
                 ORDER BY access_start_date, access_end_date, name";
2863 2863
         $result = Database::query($sql);
2864 2864
         if (!empty($sessionIsCoach)) {
2865
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2865
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2866 2866
         } else {
2867 2867
             $sessionIsCoach = Database::store_result($result);
2868 2868
         }
@@ -3039,7 +3039,7 @@  discard block
 block discarded – undo
3039 3039
             return '';
3040 3040
         }
3041 3041
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
3042
-        $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);
3042
+        $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);
3043 3043
         //showinframes doesn't handle student view anyway...
3044 3044
         //return '';
3045 3045
         $is_framed = true;
@@ -3448,7 +3448,7 @@  discard block
 block discarded – undo
3448 3448
         }
3449 3449
         $content .= '<div class="well_login">';
3450 3450
         $content .= $form->return_form();
3451
-        $content .='</div>';
3451
+        $content .= '</div>';
3452 3452
         if (api_is_cas_activated()) {
3453 3453
             $content .= "</div>";
3454 3454
         }
@@ -3467,7 +3467,7 @@  discard block
 block discarded – undo
3467 3467
         exit;
3468 3468
     }
3469 3469
 
3470
-    if ($user_id !=0 && !api_is_anonymous()) {
3470
+    if ($user_id != 0 && !api_is_anonymous()) {
3471 3471
         $tpl->display_one_col_template();
3472 3472
         exit;
3473 3473
     }
@@ -3498,7 +3498,7 @@  discard block
 block discarded – undo
3498 3498
         }
3499 3499
         $msg .= '<div class="well">';
3500 3500
         $msg .= $form->return_form();
3501
-        $msg .='</div>';
3501
+        $msg .= '</div>';
3502 3502
         if (api_is_cas_activated()) {
3503 3503
             $msg .= "</div>";
3504 3504
         }
@@ -3534,7 +3534,7 @@  discard block
 block discarded – undo
3534 3534
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3535 3535
     list ($year, $month, $day) = explode('-', $last_post_date);
3536 3536
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3537
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3537
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3538 3538
 }
3539 3539
 
3540 3540
 /**
@@ -3990,7 +3990,7 @@  discard block
 block discarded – undo
3990 3990
                 c_id = $course_id AND
3991 3991
                 tool = '$tool'
3992 3992
                 $session_condition ";
3993
-    $rs  = Database::query($sql);
3993
+    $rs = Database::query($sql);
3994 3994
     $list = array();
3995 3995
     if (Database::num_rows($rs) > 0) {
3996 3996
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -4070,7 +4070,7 @@  discard block
 block discarded – undo
4070 4070
                 tool = '$tool' AND
4071 4071
                 ref = $ref
4072 4072
                 $sessionCondition";
4073
-    $rs  = Database::query($sql);
4073
+    $rs = Database::query($sql);
4074 4074
     $item_property_id = '';
4075 4075
     if (Database::num_rows($rs) > 0) {
4076 4076
         $row = Database::fetch_array($rs);
@@ -4128,7 +4128,7 @@  discard block
 block discarded – undo
4128 4128
             WHERE item_property_id = $item_property_id AND course_id = $course_id
4129 4129
             ORDER BY lastedit_date DESC";
4130 4130
     $result = Database::query($sql);
4131
-    $result = Database::store_result($result,'ASSOC');
4131
+    $result = Database::store_result($result, 'ASSOC');
4132 4132
     return $result;
4133 4133
 }
4134 4134
 
@@ -4178,7 +4178,7 @@  discard block
 block discarded – undo
4178 4178
     $rs  = Database::query($sql);
4179 4179
     $row = array();
4180 4180
     if (Database::num_rows($rs) > 0) {
4181
-        $row = Database::fetch_array($rs,'ASSOC');
4181
+        $row = Database::fetch_array($rs, 'ASSOC');
4182 4182
     }
4183 4183
 
4184 4184
     return $row;
@@ -4214,7 +4214,7 @@  discard block
 block discarded – undo
4214 4214
     $languages  = $language_list['name'];
4215 4215
     $folder     = $language_list['folder'];
4216 4216
 
4217
-    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
4217
+    $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
4218 4218
     foreach ($languages as $key => $value) {
4219 4219
         if ($folder[$key] == $default) {
4220 4220
             $selected = ' selected="selected"';
@@ -4267,8 +4267,8 @@  discard block
 block discarded – undo
4267 4267
     //-->
4268 4268
     </script>';
4269 4269
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4270
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4271
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4270
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4271
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4272 4272
 
4273 4273
     foreach ($original_languages as $key => $value) {
4274 4274
         if ($folder[$key] == $user_selected_language) {
@@ -4276,13 +4276,13 @@  discard block
 block discarded – undo
4276 4276
         } else {
4277 4277
             $option_end = '>';
4278 4278
         }
4279
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4279
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4280 4280
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4281
-        $html .=  $value.'</option>';
4281
+        $html .= $value.'</option>';
4282 4282
     }
4283
-    $html .=  '</select>';
4284
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4285
-    $html .=  '</form>';
4283
+    $html .= '</select>';
4284
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4285
+    $html .= '</form>';
4286 4286
     return $html;
4287 4287
 }
4288 4288
 
@@ -4399,7 +4399,7 @@  discard block
 block discarded – undo
4399 4399
     $rs = Database::query($sql);
4400 4400
     $language_info = array();
4401 4401
     if (Database::num_rows($rs)) {
4402
-        $language_info = Database::fetch_array($rs,'ASSOC');
4402
+        $language_info = Database::fetch_array($rs, 'ASSOC');
4403 4403
     }
4404 4404
     return $language_info;
4405 4405
 }
@@ -4477,7 +4477,7 @@  discard block
 block discarded – undo
4477 4477
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4478 4478
  */
4479 4479
 function api_get_themes() {
4480
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4480
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4481 4481
     $list_dir = array();
4482 4482
     $list_name = array();
4483 4483
 
@@ -4654,7 +4654,7 @@  discard block
 block discarded – undo
4654 4654
     if (is_file($dirname) || is_link($dirname)) {
4655 4655
         $res = unlink($dirname);
4656 4656
         if ($res === false) {
4657
-            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);
4657
+            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);
4658 4658
         }
4659 4659
         return $res;
4660 4660
     }
@@ -4691,7 +4691,7 @@  discard block
 block discarded – undo
4691 4691
     if ($delete_only_content_in_folder == false) {
4692 4692
         $res = rmdir($dirname);
4693 4693
         if ($res === false) {
4694
-            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);
4694
+            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);
4695 4695
         }
4696 4696
     }
4697 4697
     return $res;
@@ -4776,7 +4776,7 @@  discard block
 block discarded – undo
4776 4776
 
4777 4777
     $course_id = $course_info['real_id'];
4778 4778
 
4779
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4779
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4780 4780
 
4781 4781
     $new_pathname = $base_path_document;
4782 4782
     $path = '';
@@ -4794,7 +4794,7 @@  discard block
 block discarded – undo
4794 4794
                         path = '$path' AND
4795 4795
                         filetype = 'folder' AND
4796 4796
                         session_id = '$session_id'";
4797
-            $rs1  = Database::query($sql);
4797
+            $rs1 = Database::query($sql);
4798 4798
             $num_rows = Database::num_rows($rs1);
4799 4799
 
4800 4800
             if ($num_rows == 0) {
@@ -4954,7 +4954,7 @@  discard block
 block discarded – undo
4954 4954
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4955 4955
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4956 4956
             }
4957
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4957
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4958 4958
 
4959 4959
             // Parse array syntax.
4960 4960
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -4994,7 +4994,7 @@  discard block
 block discarded – undo
4994 4994
  */
4995 4995
 function api_get_version() {
4996 4996
     global $_configuration;
4997
-    return (string)$_configuration['system_version'];
4997
+    return (string) $_configuration['system_version'];
4998 4998
 }
4999 4999
 
5000 5000
 /**
@@ -5121,7 +5121,7 @@  discard block
 block discarded – undo
5121 5121
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5122 5122
     $var = Database::escape_string($var);
5123 5123
     $value = Database::escape_string($value);
5124
-    $access_url = (int)$access_url;
5124
+    $access_url = (int) $access_url;
5125 5125
     if (empty($access_url)) { $access_url = 1; }
5126 5126
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
5127 5127
     if (!empty($subvar)) {
@@ -5143,7 +5143,7 @@  discard block
 block discarded – undo
5143 5143
         // Found item for this access_url.
5144 5144
         $row = Database::fetch_array($res);
5145 5145
         $sql = "UPDATE $t_settings SET selected_value = '$value'
5146
-                WHERE id = ".$row['id'] ;
5146
+                WHERE id = ".$row['id'];
5147 5147
         Database::query($sql);
5148 5148
     } else {
5149 5149
         // Item not found for this access_url, we have to check if it exist with access_url = 1
@@ -5164,11 +5164,11 @@  discard block
 block discarded – undo
5164 5164
                 $row = Database::fetch_array($res);
5165 5165
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
5166 5166
                         VALUES
5167
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5168
-                        "'".$row['type']."','".$row['category']."'," .
5169
-                        "'$value','".$row['title']."'," .
5170
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5171
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
5167
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5168
+                        "'".$row['type']."','".$row['category']."',".
5169
+                        "'$value','".$row['title']."',".
5170
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5171
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
5172 5172
                 Database::query($insert);
5173 5173
             } else { // Such a setting does not exist.
5174 5174
                 error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all', 0);
@@ -5188,16 +5188,16 @@  discard block
 block discarded – undo
5188 5188
                 if ($row['access_url_changeable'] == 1) {
5189 5189
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
5190 5190
                             ('".$row['variable']."',".
5191
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
5192
-                            "'".$row['type']."','".$row['category']."'," .
5193
-                            "'$value','".$row['title']."'," .
5191
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
5192
+                            "'".$row['type']."','".$row['category']."',".
5193
+                            "'$value','".$row['title']."',".
5194 5194
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
5195
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
5195
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
5196 5196
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
5197 5197
                     Database::query($insert);
5198 5198
                 }
5199 5199
             } else { // Such a setting does not exist.
5200
-                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0);
5200
+                error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ', 0);
5201 5201
             }
5202 5202
         }
5203 5203
     }
@@ -5225,10 +5225,10 @@  discard block
 block discarded – undo
5225 5225
         $value = Database::escape_string($value);
5226 5226
         $sql = "UPDATE $t_s SET selected_value = '$value'
5227 5227
                 WHERE category = '$category' AND access_url = $access_url";
5228
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5228
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5229 5229
             $sql .= " AND ( ";
5230 5230
             $i = 0;
5231
-            foreach ($fieldtype as $type){
5231
+            foreach ($fieldtype as $type) {
5232 5232
                 if ($i > 0) {
5233 5233
                     $sql .= ' OR ';
5234 5234
                 }
@@ -5243,10 +5243,10 @@  discard block
 block discarded – undo
5243 5243
     } else {
5244 5244
         $sql = "UPDATE $t_s SET selected_value = NULL
5245 5245
                 WHERE category = '$category' AND access_url = $access_url";
5246
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5246
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5247 5247
             $sql .= " AND ( ";
5248 5248
             $i = 0;
5249
-            foreach ($fieldtype as $type){
5249
+            foreach ($fieldtype as $type) {
5250 5250
                 if ($i > 0) {
5251 5251
                     $sql .= ' OR ';
5252 5252
                 }
@@ -5391,7 +5391,7 @@  discard block
 block discarded – undo
5391 5391
 function & api_get_settings_categories($exceptions = array(), $access_url = 1) {
5392 5392
     $access_url = (int) $access_url;
5393 5393
     $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
5394
-    $list = "'".implode("','",$exceptions)."'";
5394
+    $list = "'".implode("','", $exceptions)."'";
5395 5395
     $sql = "SELECT DISTINCT category FROM $t_cs WHERE category is NOT NULL ";
5396 5396
     if ($list != "'',''" && $list != "''" && !empty($list)) {
5397 5397
         $sql .= " AND category NOT IN ($list) ";
@@ -5491,12 +5491,12 @@  discard block
 block discarded – undo
5491 5491
 
5492 5492
     // Item not found for this access_url, we have to check if the whole thing is missing
5493 5493
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5494
-    $insert = "INSERT INTO $t_settings " .
5495
-                "(variable,selected_value," .
5496
-                "type,category," .
5497
-                "subkey,title," .
5498
-                "comment,scope," .
5499
-                "subkeytext,access_url,access_url_changeable)" .
5494
+    $insert = "INSERT INTO $t_settings ".
5495
+                "(variable,selected_value,".
5496
+                "type,category,".
5497
+                "subkey,title,".
5498
+                "comment,scope,".
5499
+                "subkeytext,access_url,access_url_changeable)".
5500 5500
                 " VALUES ('$var','$val',";
5501 5501
     if (isset($type)) {
5502 5502
         $type = Database::escape_string($type);
@@ -5662,7 +5662,7 @@  discard block
 block discarded – undo
5662 5662
             $result = Database::query($sql);
5663 5663
 
5664 5664
             //if ($row = Database::fetch_array($result)) {
5665
-            if (Database::num_rows($result) > 0 ) {
5665
+            if (Database::num_rows($result) > 0) {
5666 5666
                 $is_courseMember = true;
5667 5667
                 $is_courseTutor = true;
5668 5668
                 $is_courseCoach = true;
@@ -5846,8 +5846,8 @@  discard block
 block discarded – undo
5846 5846
 {
5847 5847
     $tbl_rel_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
5848 5848
     if (!empty($user_id) && !empty($courseId)) {
5849
-        $user_id        = intval($user_id);
5850
-        $courseId    = intval($courseId);
5849
+        $user_id = intval($user_id);
5850
+        $courseId = intval($courseId);
5851 5851
         $sql = 'SELECT status
5852 5852
                 FROM '.$tbl_rel_course_user.'
5853 5853
                 WHERE user_id='.$user_id.' AND c_id = '.$courseId;
@@ -5959,7 +5959,7 @@  discard block
 block discarded – undo
5959 5959
     } else {
5960 5960
         return false;
5961 5961
     }
5962
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5962
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5963 5963
 }
5964 5964
 
5965 5965
 /**
@@ -6487,7 +6487,7 @@  discard block
 block discarded – undo
6487 6487
 function api_get_jquery_ui_js($include_jqgrid = false) {
6488 6488
     $libraries = array();
6489 6489
     if ($include_jqgrid) {
6490
-       $libraries[]='jqgrid';
6490
+       $libraries[] = 'jqgrid';
6491 6491
     }
6492 6492
     return api_get_jquery_libraries_js($libraries);
6493 6493
 }
@@ -6511,12 +6511,12 @@  discard block
 block discarded – undo
6511 6511
 
6512 6512
     //jqgrid js and css
6513 6513
     if (in_array('jqgrid', $libraries)) {
6514
-        $languaje   = 'en';
6514
+        $languaje = 'en';
6515 6515
         $platform_isocode = strtolower(api_get_language_isocode());
6516 6516
 
6517 6517
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6518 6518
         $jqgrid_langs = array(
6519
-            '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'
6519
+            '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'
6520 6520
         );
6521 6521
 
6522 6522
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6547,7 +6547,7 @@  discard block
 block discarded – undo
6547 6547
 
6548 6548
     // jquery datepicker
6549 6549
     if (in_array('datepicker', $libraries)) {
6550
-        $languaje   = 'en-GB';
6550
+        $languaje = 'en-GB';
6551 6551
         $platform_isocode = strtolower(api_get_language_isocode());
6552 6552
 
6553 6553
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6650,7 +6650,7 @@  discard block
 block discarded – undo
6650 6650
         $clean_url = str_replace('/', '-', $clean_url);
6651 6651
         $clean_url .= '/';
6652 6652
 
6653
-        $home = 'app/home/' . $clean_url;
6653
+        $home = 'app/home/'.$clean_url;
6654 6654
     }
6655 6655
 
6656 6656
     return $home;
@@ -6710,7 +6710,7 @@  discard block
 block discarded – undo
6710 6710
  * @return void
6711 6711
  */
6712 6712
 function api_check_php_version($my_inc_path = null) {
6713
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6713
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6714 6714
         $global_error_code = 1;
6715 6715
         // Incorrect PHP version
6716 6716
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6726,7 +6726,7 @@  discard block
 block discarded – undo
6726 6726
  */
6727 6727
 function api_check_archive_dir() {
6728 6728
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6729
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6729
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6730 6730
         api_not_allowed(true, $message);
6731 6731
     }
6732 6732
 }
@@ -6791,7 +6791,7 @@  discard block
 block discarded – undo
6791 6791
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6792 6792
  * @version CEV CHANGE 24APR2012
6793 6793
  */
6794
-function api_get_real_ip(){
6794
+function api_get_real_ip() {
6795 6795
     // Guess the IP if behind a reverse proxy
6796 6796
     global $debug;
6797 6797
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6817,23 +6817,23 @@  discard block
 block discarded – undo
6817 6817
  * @author Yannick Warnier for improvements and managment of multiple ranges
6818 6818
  * @todo check for IPv6 support
6819 6819
  */
6820
-function api_check_ip_in_range($ip,$range)
6820
+function api_check_ip_in_range($ip, $range)
6821 6821
 {
6822 6822
     if (empty($ip) or empty($range)) {
6823 6823
         return false;
6824 6824
     }
6825
-    $ip_ip = ip2long ($ip);
6825
+    $ip_ip = ip2long($ip);
6826 6826
     // divide range param into array of elements
6827
-    if (strpos($range,',')!==false) {
6828
-        $ranges = explode(',',$range);
6827
+    if (strpos($range, ',') !== false) {
6828
+        $ranges = explode(',', $range);
6829 6829
     } else {
6830 6830
         $ranges = array($range);
6831 6831
     }
6832 6832
     foreach ($ranges as $range) {
6833 6833
         $range = trim($range);
6834 6834
         if (empty($range)) { continue; }
6835
-        if (strpos($range,'/')===false) {
6836
-            if (strcmp($ip,$range)===0) {
6835
+        if (strpos($range, '/') === false) {
6836
+            if (strcmp($ip, $range) === 0) {
6837 6837
                 return true; // there is a direct IP match, return OK
6838 6838
             }
6839 6839
             continue; //otherwise, get to the next range
@@ -6841,7 +6841,7 @@  discard block
 block discarded – undo
6841 6841
         // the range contains a "/", so analyse completely
6842 6842
         list ($net, $mask) = explode("/", $range);
6843 6843
 
6844
-        $ip_net = ip2long ($net);
6844
+        $ip_net = ip2long($net);
6845 6845
         // mask binary magic
6846 6846
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6847 6847
 
@@ -7203,14 +7203,14 @@  discard block
 block discarded – undo
7203 7203
  * @assert (0) === true
7204 7204
  * @assert ('1G') === true
7205 7205
  */
7206
-function api_set_memory_limit($mem){
7206
+function api_set_memory_limit($mem) {
7207 7207
     //if ini_set() not available, this function is useless
7208 7208
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
7209 7209
         return false;
7210 7210
     }
7211 7211
 
7212 7212
     $memory_limit = ini_get('memory_limit');
7213
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
7213
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
7214 7214
         ini_set('memory_limit', $mem);
7215 7215
         return true;
7216 7216
     }
@@ -7227,21 +7227,21 @@  discard block
 block discarded – undo
7227 7227
  * @assert ('1m')  === 1048576
7228 7228
  * @assert ('100k') === 102400
7229 7229
  */
7230
-function api_get_bytes_memory_limit($mem){
7231
-    $size = strtolower(substr($mem,-1));
7230
+function api_get_bytes_memory_limit($mem) {
7231
+    $size = strtolower(substr($mem, -1));
7232 7232
 
7233 7233
     switch ($size) {
7234 7234
         case 't':
7235
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
7235
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
7236 7236
             break;
7237 7237
         case 'g':
7238
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
7238
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
7239 7239
             break;
7240 7240
         case 'm':
7241
-            $mem = intval(substr($mem,0,-1))*1024*1024;
7241
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
7242 7242
             break;
7243 7243
         case 'k':
7244
-            $mem = intval(substr($mem,0,-1))*1024;
7244
+            $mem = intval(substr($mem, 0, -1)) * 1024;
7245 7245
             break;
7246 7246
         default:
7247 7247
             // we assume it's integer only
@@ -7294,7 +7294,7 @@  discard block
 block discarded – undo
7294 7294
         get_lang('PasswordVeryStrong'),
7295 7295
     );
7296 7296
     $js = api_get_js('strength/strength.js');
7297
-    $js .=  "<script>
7297
+    $js .= "<script>
7298 7298
 
7299 7299
     var verdicts = ['".implode("','", $verdicts)."'];
7300 7300
     var errorMessages = {
@@ -7350,7 +7350,7 @@  discard block
 block discarded – undo
7350 7350
         return false;
7351 7351
     }
7352 7352
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7353
-    $time = time() + $minutesToBlock*60;
7353
+    $time = time() + $minutesToBlock * 60;
7354 7354
     UserManager::update_extra_field_value(
7355 7355
         $userInfo['user_id'],
7356 7356
         'captcha_blocked_until_date',
@@ -7424,7 +7424,7 @@  discard block
 block discarded – undo
7424 7424
         $out_res = str_replace('"', "''", $out_res);
7425 7425
     }
7426 7426
     // avoid text stuck together when tags are removed, adding a space after >
7427
-    $out_res = str_replace (">", "> ", $out_res);
7427
+    $out_res = str_replace(">", "> ", $out_res);
7428 7428
     $out_res = strip_tags($out_res);
7429 7429
 
7430 7430
     return $out_res;
@@ -7534,12 +7534,12 @@  discard block
 block discarded – undo
7534 7534
 {
7535 7535
     // Clean query
7536 7536
     $bt = debug_backtrace();
7537
-    $caller = array_shift($bt);;
7537
+    $caller = array_shift($bt); ;
7538 7538
     if ($dump == 1) {
7539 7539
         $string = print_r($string, 1);
7540 7540
     } else {
7541 7541
         $string = str_replace(array("\r", "\n", "\t", "\10"), '', $string);
7542
-        $string = str_replace('    ',' ', $string);
7542
+        $string = str_replace('    ', ' ', $string);
7543 7543
     }
7544 7544
 
7545 7545
     error_log("-------------------------------------");
@@ -7649,7 +7649,7 @@  discard block
 block discarded – undo
7649 7649
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7650 7650
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7651 7651
         if (isset($hostingParams[$limitName])) {
7652
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7652
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7653 7653
         }
7654 7654
         api_mail_html(null, $email, $subject, $body);
7655 7655
     }
@@ -7777,7 +7777,7 @@  discard block
 block discarded – undo
7777 7777
  */
7778 7778
 function api_set_site_use_cookie_warning_cookie()
7779 7779
 {
7780
-    setcookie("ChamiloUsesCookies", "ok", time()+31556926);
7780
+    setcookie("ChamiloUsesCookies", "ok", time() + 31556926);
7781 7781
 }
7782 7782
 
7783 7783
 /**
@@ -7825,10 +7825,10 @@  discard block
 block discarded – undo
7825 7825
         return false;
7826 7826
     }
7827 7827
 
7828
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7828
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7829 7829
 
7830 7830
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7831
-        $fp = fopen($fullPath . '/index.html', 'w');
7831
+        $fp = fopen($fullPath.'/index.html', 'w');
7832 7832
 
7833 7833
         if ($fp) {
7834 7834
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7893,7 +7893,7 @@  discard block
 block discarded – undo
7893 7893
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
7894 7894
         }
7895 7895
     }
7896
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
7896
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
7897 7897
 
7898 7898
     // 5 = low, 1 = high
7899 7899
     $mail->Priority = 3;
@@ -8045,11 +8045,11 @@  discard block
 block discarded – undo
8045 8045
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
8046 8046
         if ($mail->SMTPDebug) {
8047 8047
             error_log(
8048
-                "Connection details :: " .
8049
-                "Protocol: " . $mail->Mailer . ' :: ' .
8050
-                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
8051
-                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
8052
-                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
8048
+                "Connection details :: ".
8049
+                "Protocol: ".$mail->Mailer.' :: '.
8050
+                "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '.
8051
+                "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '.
8052
+                ($mail->SMTPAuth ? "  User/Pass: ".$mail->Username.':'.$mail->Password : '')
8053 8053
             );
8054 8054
         }
8055 8055
         return 0;
@@ -8097,13 +8097,13 @@  discard block
 block discarded – undo
8097 8097
  * @param int $key key to find to compare
8098 8098
  *
8099 8099
  */
8100
-function api_unique_multidim_array($array, $key){
8100
+function api_unique_multidim_array($array, $key) {
8101 8101
     $temp_array = array();
8102 8102
     $i = 0;
8103 8103
     $key_array = array();
8104 8104
 
8105
-    foreach($array as $val){
8106
-        if(!in_array($val[$key],$key_array)){
8105
+    foreach ($array as $val) {
8106
+        if (!in_array($val[$key], $key_array)) {
8107 8107
             $key_array[$i] = $val[$key];
8108 8108
             $temp_array[$i] = $val;
8109 8109
         }
@@ -8136,9 +8136,9 @@  discard block
 block discarded – undo
8136 8136
  */
8137 8137
 function stripGivenTags($string, $tags) {
8138 8138
     foreach ($tags as $tag) {
8139
-        $string2 = preg_replace('#</' . $tag . '[^>]*>#i', ' ', $string);
8139
+        $string2 = preg_replace('#</'.$tag.'[^>]*>#i', ' ', $string);
8140 8140
         if ($string2 != $string) {
8141
-            $string = preg_replace('/<' . $tag . '[^>]*>/i', ' ', $string2);
8141
+            $string = preg_replace('/<'.$tag.'[^>]*>/i', ' ', $string2);
8142 8142
         }
8143 8143
     }
8144 8144
     return $string;
Please login to merge, or discard this patch.
main/exercice/export/exercise_import.inc.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     // used to specify the question directory where files could be found in relation in any question
77 77
     global $questionTempDir;
78 78
 
79
-    $archive_path = api_get_path(SYS_ARCHIVE_PATH) . 'qti2';
79
+    $archive_path = api_get_path(SYS_ARCHIVE_PATH).'qti2';
80 80
     $baseWorkDir = $archive_path;
81 81
 
82 82
     if (!is_dir($baseWorkDir)) {
@@ -119,25 +119,25 @@  discard block
 block discarded – undo
119 119
 
120 120
     // parse every subdirectory to search xml question files
121 121
     while (false !== ($file = readdir($exerciseHandle))) {
122
-        if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") {
122
+        if (is_dir($baseWorkDir.'/'.$file) && $file != "." && $file != "..") {
123 123
             // Find each manifest for each question repository found
124
-            $questionHandle = opendir($baseWorkDir . '/' . $file);
124
+            $questionHandle = opendir($baseWorkDir.'/'.$file);
125 125
             while (false !== ($questionFile = readdir($questionHandle))) {
126 126
                 if (preg_match('/.xml$/i', $questionFile)) {
127
-                    $isQti = isQtiQuestionBank($baseWorkDir . '/' . $file . '/' . $questionFile);
127
+                    $isQti = isQtiQuestionBank($baseWorkDir.'/'.$file.'/'.$questionFile);
128 128
                     if ($isQti) {
129 129
                         $result = qti_parse_file($baseWorkDir, $file, $questionFile);
130
-                        $filePath = $baseWorkDir . $file;
130
+                        $filePath = $baseWorkDir.$file;
131 131
                         $file_found = true;
132 132
                     }
133 133
                 }
134 134
             }
135 135
         } elseif (preg_match('/.xml$/i', $file)) {
136
-            $isQti = isQtiQuestionBank($baseWorkDir . '/' . $file);
136
+            $isQti = isQtiQuestionBank($baseWorkDir.'/'.$file);
137 137
             //$isManifest = isQtiManifest($baseWorkDir . '/' . $file);
138 138
             if ($isQti) {
139 139
                 $result = qti_parse_file($baseWorkDir, '', $file);
140
-                $filePath = $baseWorkDir . '/' . $file;
140
+                $filePath = $baseWorkDir.'/'.$file;
141 141
                 $file_found = true;
142 142
             }
143 143
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             $question->type = $question_array['type'];
171 171
             $question->setAnswer();
172 172
             if (strlen($question_array['title']) < 50) {
173
-                $question->updateTitle(formatText(strip_tags($question_array['title'])) . '...');
173
+                $question->updateTitle(formatText(strip_tags($question_array['title'])).'...');
174 174
             } else {
175 175
                 $question->updateTitle(formatText(substr(strip_tags($question_array['title']), 0, 50)));
176 176
                 $question->updateDescription($question_array['title']);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         }
217 217
 
218 218
         // delete the temp dir where the exercise was unzipped
219
-        my_delete($baseWorkDir . $uploadPath);
219
+        my_delete($baseWorkDir.$uploadPath);
220 220
         return $last_exercise_id;
221 221
     }
222 222
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
     global $record_item_body;
245 245
     global $questionTempDir;
246 246
 
247
-    $questionTempDir = $exercisePath . '/' . $file . '/';
248
-    $questionFilePath = $questionTempDir . $questionFile;
247
+    $questionTempDir = $exercisePath.'/'.$file.'/';
248
+    $questionFilePath = $questionTempDir.$questionFile;
249 249
 
250 250
     if (!($fp = fopen($questionFilePath, 'r'))) {
251 251
         Display::addFlash(Display::return_message(get_lang('Error opening question\'s XML file'), 'error'));
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         $error = xml_get_error_code();
301 301
         Display::addFlash(
302 302
             Display::return_message(
303
-                get_lang('Error reading XML file') . sprintf('[%d:%d]', xml_get_current_line_number($xml_parser), xml_get_current_column_number($xml_parser)),
303
+                get_lang('Error reading XML file').sprintf('[%d:%d]', xml_get_current_line_number($xml_parser), xml_get_current_column_number($xml_parser)),
304 304
                 'error'
305 305
             )
306 306
         );
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
     if ($record_item_body) {
367 367
 
368 368
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
369
-            $current_question_item_body .= "<" . $name;
369
+            $current_question_item_body .= "<".$name;
370 370
             foreach ($attributes as $attribute_name => $attribute_value) {
371
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
371
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
372 372
             }
373 373
             $current_question_item_body .= ">";
374 374
         } else {
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
             //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced
377 377
 
378 378
             if ($current_element == 'INLINECHOICEINTERACTION') {
379
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
379
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
380 380
             }
381 381
             if ($current_element == 'TEXTENTRYINTERACTION') {
382 382
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
383
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
383
+                $current_question_item_body .= "[".$correct_answer_value."]";
384 384
 
385 385
             }
386 386
             if ($current_element == 'BR') {
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     //treat the record of the full content of itembody tag :
498 498
 
499 499
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
500
-        $current_question_item_body .= "</" . $name . ">";
500
+        $current_question_item_body .= "</".$name.">";
501 501
     }
502 502
 
503 503
     switch ($name) {
@@ -554,14 +554,14 @@  discard block
 block discarded – undo
554 554
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) {
555 555
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data);
556 556
             } else {
557
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= '' . trim($data);
557
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data);
558 558
             }
559 559
             break;
560 560
         case 'FEEDBACKINLINE':
561 561
             if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) {
562 562
                 $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data);
563 563
             } else {
564
-                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data);
564
+                $exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' '.trim($data);
565 565
             }
566 566
             break;
567 567
         case 'SIMPLEASSOCIABLECHOICE':
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
             $answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
585 585
             if ($current_inlinechoice_id == $answer_identifier) {
586 586
                 $current_question_item_body = str_replace(
587
-                    "**claroline_start**" . $current_answer_id . "**claroline_end**",
588
-                    "[" . $data . "]",
587
+                    "**claroline_start**".$current_answer_id."**claroline_end**",
588
+                    "[".$data."]",
589 589
                     $current_question_item_body
590 590
                 );
591 591
             } else {
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
     if ($record_item_body) {
645 645
 
646 646
         if ((!in_array($current_element, $non_HTML_tag_to_avoid))) {
647
-            $current_question_item_body .= "<" . $name;
647
+            $current_question_item_body .= "<".$name;
648 648
             foreach ($attributes as $attribute_name => $attribute_value) {
649
-                $current_question_item_body .= " " . $attribute_name . "=\"" . $attribute_value . "\"";
649
+                $current_question_item_body .= " ".$attribute_name."=\"".$attribute_value."\"";
650 650
             }
651 651
             $current_question_item_body .= ">";
652 652
         } else {
@@ -654,11 +654,11 @@  discard block
 block discarded – undo
654 654
             //we first save with claroline tags ,then when the answer will be parsed, the claroline tags will be replaced
655 655
 
656 656
             if ($current_element == 'INLINECHOICEINTERACTION') {
657
-                $current_question_item_body .= "**claroline_start**" . $attributes['RESPONSEIDENTIFIER'] . "**claroline_end**";
657
+                $current_question_item_body .= "**claroline_start**".$attributes['RESPONSEIDENTIFIER']."**claroline_end**";
658 658
             }
659 659
             if ($current_element == 'TEXTENTRYINTERACTION') {
660 660
                 $correct_answer_value = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id];
661
-                $current_question_item_body .= "[" . $correct_answer_value . "]";
661
+                $current_question_item_body .= "[".$correct_answer_value."]";
662 662
 
663 663
             }
664 664
             if ($current_element == 'BR') {
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
     //treat the record of the full content of itembody tag :
783 783
 
784 784
     if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
785
-        $current_question_item_body .= "</" . $name . ">";
785
+        $current_question_item_body .= "</".$name.">";
786 786
     }
787 787
 
788 788
     switch ($name) {
Please login to merge, or discard this patch.