Completed
Push — 1.11.x ( 78f130...f6f5c2 )
by José
50:40 queued 24:26
created
main/inc/lib/api.lib.php 4 patches
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1701,7 +1701,9 @@  discard block
 block discarded – undo
1701 1701
     }
1702 1702
 
1703 1703
     global $_course;
1704
-    if ($_course == '-1') $_course = array();
1704
+    if ($_course == '-1') {
1705
+        $_course = array();
1706
+    }
1705 1707
     return $_course;
1706 1708
 }
1707 1709
 
@@ -4154,18 +4156,21 @@  discard block
 block discarded – undo
4154 4156
     switch ($lang_type) {
4155 4157
         case 'platform_lang':
4156 4158
             $temp_lang = api_get_setting('platformLanguage');
4157
-            if (!empty($temp_lang))
4158
-                $return = $temp_lang;
4159
+            if (!empty($temp_lang)) {
4160
+                            $return = $temp_lang;
4161
+            }
4159 4162
             break;
4160 4163
         case 'user_profil_lang':
4161 4164
             $_user = api_get_user_info();
4162 4165
 
4163
-            if (isset($_user['language']) && !empty($_user['language']))
4164
-                $return = $_user['language'];
4166
+            if (isset($_user['language']) && !empty($_user['language'])) {
4167
+                            $return = $_user['language'];
4168
+            }
4165 4169
             break;
4166 4170
         case 'user_selected_lang':
4167
-            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice']))
4168
-                $return = $_SESSION['user_language_choice'];
4171
+            if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) {
4172
+                            $return = $_SESSION['user_language_choice'];
4173
+            }
4169 4174
             break;
4170 4175
         case 'course_lang':
4171 4176
             global $_course;
@@ -5434,8 +5439,7 @@  discard block
 block discarded – undo
5434 5439
             $is_courseAdmin = false;
5435 5440
             $is_courseCoach = true;
5436 5441
             $is_sessionAdmin = false;
5437
-        }
5438
-        elseif ($row[0]['session_admin_id'] == $userid) {
5442
+        } elseif ($row[0]['session_admin_id'] == $userid) {
5439 5443
             $is_courseMember = false;
5440 5444
             $is_courseTutor = false;
5441 5445
             $is_courseAdmin = false;
@@ -5778,8 +5782,7 @@  discard block
 block discarded – undo
5778 5782
     elseif (isset($_ENV['OS'])) {
5779 5783
         // Sometimes $_ENV['OS'] may not be present (bugs?)
5780 5784
         $os = $_ENV['OS'];
5781
-    }
5782
-    elseif (defined('PHP_OS')) {
5785
+    } elseif (defined('PHP_OS')) {
5783 5786
         // PHP_OS means on which OS PHP was compiled, this is why
5784 5787
         // using PHP_OS is the last choice for detection.
5785 5788
         $os = PHP_OS;
@@ -5843,12 +5846,10 @@  discard block
 block discarded – undo
5843 5846
     if ($delta_width > $delta_height) {
5844 5847
         $result['width'] = ceil($image_width * $resize_factor_height);
5845 5848
         $result['height'] = ceil($image_height * $resize_factor_height);
5846
-    }
5847
-    elseif ($delta_width < $delta_height) {
5849
+    } elseif ($delta_width < $delta_height) {
5848 5850
         $result['width'] = ceil($image_width * $resize_factor_width);
5849 5851
         $result['height'] = ceil($image_height * $resize_factor_width);
5850
-    }
5851
-    else {
5852
+    } else {
5852 5853
         $result['width'] = ceil($target_width);
5853 5854
         $result['height'] = ceil($target_height);
5854 5855
     }
@@ -6629,7 +6630,9 @@  discard block
 block discarded – undo
6629 6630
         }
6630 6631
         $ip = trim($ip1);
6631 6632
     }
6632
-    if (!empty($debug)) error_log('Real IP: '.$ip);
6633
+    if (!empty($debug)) {
6634
+        error_log('Real IP: '.$ip);
6635
+    }
6633 6636
     return $ip;
6634 6637
 }
6635 6638
 
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1240,6 +1240,7 @@  discard block
 block discarded – undo
1240 1240
  * Gets the list of courses a specific user is subscribed to
1241 1241
  * @param int       User ID
1242 1242
  * @param boolean   $fetch_session Whether to get session courses or not - NOT YET IMPLEMENTED
1243
+ * @param integer $userid
1243 1244
  * @return array    Array of courses in the form [0]=>('code'=>xxx,'db'=>xxx,'dir'=>xxx,'status'=>d)
1244 1245
  */
1245 1246
 function api_get_user_courses($userid, $fetch_session = true)
@@ -2955,7 +2956,7 @@  discard block
 block discarded – undo
2955 2956
 * on the session visibility
2956 2957
 * @param bool $tutor  Whether to check if the user has the tutor role
2957 2958
 * @param bool  $coach Whether to check if the user has the coach role
2958
-* @return boolean true: the user has the rights to edit, false: he does not
2959
+* @return boolean|null true: the user has the rights to edit, false: he does not
2959 2960
 */
2960 2961
 function api_is_allowed_to_session_edit($tutor = false, $coach = false)
2961 2962
 {
@@ -5188,6 +5189,7 @@  discard block
 block discarded – undo
5188 5189
  * @param string    Whether we want a simple list (display a category) or
5189 5190
  * a grouped list (group by variable as in settings.php default). Values: 'list' or 'group'
5190 5191
  * @param int       Access URL's ID. Optional. Uses 1 by default, which is the unique URL
5192
+ * @param string $cat
5191 5193
  * @return array    Array of database results for the current settings of the current access URL
5192 5194
  */
5193 5195
 function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0)
@@ -6614,7 +6616,7 @@  discard block
 block discarded – undo
6614 6616
 /**
6615 6617
  * Returns an array of global configuration settings which should be ignored
6616 6618
  * when printing the configuration settings screens
6617
- * @return array Array of strings, each identifying one of the excluded settings
6619
+ * @return string[] Array of strings, each identifying one of the excluded settings
6618 6620
  */
6619 6621
 function api_get_locked_settings() {
6620 6622
     return array(
@@ -6655,6 +6657,7 @@  discard block
 block discarded – undo
6655 6657
  * false if he isn't. If the user ID is given and is an integer, then the same
6656 6658
  * ID is simply returned
6657 6659
  * @param  integer User ID
6660
+ * @param integer $user_id
6658 6661
  * @return boolean Integer User ID is logged in, or false otherwise
6659 6662
  */
6660 6663
 function api_user_is_login($user_id = null) {
@@ -7099,6 +7102,7 @@  discard block
 block discarded – undo
7099 7102
 /**
7100 7103
  * Gets memory limit in bytes
7101 7104
  * @param string The memory size (128M, 1G, 1000K, etc)
7105
+ * @param string $mem
7102 7106
  * @return int
7103 7107
  * @assert (null) === false
7104 7108
  * @assert ('1t')  === 1099511627776
Please login to merge, or discard this patch.
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -626,7 +626,6 @@  discard block
 block discarded – undo
626 626
  * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too.
627 627
  *
628 628
  * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
629
-
630 629
  * @param string $path (optional)   A path which type is to be converted. Also, it may be a defined constant for a path.
631 630
  * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored.
632 631
  * @return string                   The requested path or the converted path.
@@ -1733,7 +1732,6 @@  discard block
 block discarded – undo
1733 1732
 
1734 1733
 /**
1735 1734
  * Returns the current course info array.
1736
-
1737 1735
  * Now if the course_code is given, the returned array gives info about that
1738 1736
  * particular course, not specially the current one.
1739 1737
  * @param int $id Numeric ID of the course
@@ -6210,7 +6208,7 @@  discard block
 block discarded – undo
6210 6208
 function api_get_jquery_ui_js($include_jqgrid = false) {
6211 6209
     $libraries = array();
6212 6210
     if ($include_jqgrid) {
6213
-       $libraries[]='jqgrid';
6211
+        $libraries[]='jqgrid';
6214 6212
     }
6215 6213
     return api_get_jquery_libraries_js($libraries);
6216 6214
 }
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
 define('PLATFORM_ADMIN', 11);
41 41
 define('SESSION_COURSE_COACH', 12);
42 42
 define('SESSION_GENERAL_COACH', 13);
43
-define('COURSE_STUDENT', 14);   //student subscribed in a course
44
-define('SESSION_STUDENT', 15);  //student subscribed in a session course
43
+define('COURSE_STUDENT', 14); //student subscribed in a course
44
+define('SESSION_STUDENT', 15); //student subscribed in a session course
45 45
 define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
46 46
 define('STUDENT_BOSS', 17); // student is boss
47 47
 define('INVITEE', 20);
48 48
 
49 49
 // Table of status
50
-$_status_list[COURSEMANAGER] = 'teacher';        // 1
51
-$_status_list[SESSIONADMIN] = 'session_admin';  // 3
52
-$_status_list[DRH] = 'drh';            // 4
53
-$_status_list[STUDENT] = 'user';           // 5
54
-$_status_list[ANONYMOUS] = 'anonymous';      // 6
55
-$_status_list[INVITEE] = 'invited';        // 20
50
+$_status_list[COURSEMANAGER] = 'teacher'; // 1
51
+$_status_list[SESSIONADMIN] = 'session_admin'; // 3
52
+$_status_list[DRH] = 'drh'; // 4
53
+$_status_list[STUDENT] = 'user'; // 5
54
+$_status_list[ANONYMOUS] = 'anonymous'; // 6
55
+$_status_list[INVITEE] = 'invited'; // 20
56 56
 
57 57
 // COURSE VISIBILITY CONSTANTS
58 58
 /** only visible for course admin */
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 define('IS_WINDOWS_OS', api_is_windows_os());
267 267
 
268 268
 // Checks for installed optional php-extensions.
269
-define('INTL_INSTALLED', function_exists('intl_get_error_code'));   // intl extension (from PECL), it is installed by default as of PHP 5.3.0
270
-define('ICONV_INSTALLED', function_exists('iconv'));                // iconv extension, for PHP5 on Windows it is installed by default.
271
-define('MBSTRING_INSTALLED', function_exists('mb_strlen'));         // mbstring extension.
269
+define('INTL_INSTALLED', function_exists('intl_get_error_code')); // intl extension (from PECL), it is installed by default as of PHP 5.3.0
270
+define('ICONV_INSTALLED', function_exists('iconv')); // iconv extension, for PHP5 on Windows it is installed by default.
271
+define('MBSTRING_INSTALLED', function_exists('mb_strlen')); // mbstring extension.
272 272
 
273 273
 // Patterns for processing paths.                                   // Examples:
274
-define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/');                    // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
275
-define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i');            // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
276
-define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i');            // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
274
+define('REPEATED_SLASHES_PURIFIER', '/\/{2,}/'); // $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path);
275
+define('VALID_WEB_PATH', '/https?:\/\/[^\/]*(\/.*)?/i'); // $is_valid_path = preg_match(VALID_WEB_PATH, $path);
276
+define('VALID_WEB_SERVER_BASE', '/https?:\/\/[^\/]*/i'); // $new_path = preg_replace(VALID_WEB_SERVER_BASE, $new_base, $path);
277 277
 
278 278
 // Constants for api_get_path() and api_get_path_type(), etc. - registered path types.
279 279
 // basic (leaf elements)
@@ -365,19 +365,19 @@  discard block
 block discarded – undo
365 365
 define('LINK_HOTPOTATOES', 9);
366 366
 
367 367
 // Score display types constants
368
-define('SCORE_DIV', 1);    // X / Y
369
-define('SCORE_PERCENT', 2);    // XX %
370
-define('SCORE_DIV_PERCENT', 3);    // X / Y (XX %)
371
-define('SCORE_AVERAGE', 4);    // XX %
372
-define('SCORE_DECIMAL', 5);    // 0.50  (X/Y)
373
-define('SCORE_BAR', 6);    // Uses the Display::bar_progress function
374
-define('SCORE_SIMPLE', 7);    // X
375
-define('SCORE_IGNORE_SPLIT', 8);    //  ??
376
-define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9);    // X / Y (XX %) - Good!
377
-define('SCORE_CUSTOM', 10);    // Good!
378
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11);    // X - Good!
379
-define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12);    // X - Good!
380
-define('SCORE_ONLY_SCORE', 13);    // X - Good!
368
+define('SCORE_DIV', 1); // X / Y
369
+define('SCORE_PERCENT', 2); // XX %
370
+define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
371
+define('SCORE_AVERAGE', 4); // XX %
372
+define('SCORE_DECIMAL', 5); // 0.50  (X/Y)
373
+define('SCORE_BAR', 6); // Uses the Display::bar_progress function
374
+define('SCORE_SIMPLE', 7); // X
375
+define('SCORE_IGNORE_SPLIT', 8); //  ??
376
+define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
377
+define('SCORE_CUSTOM', 10); // Good!
378
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
379
+define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
380
+define('SCORE_ONLY_SCORE', 13); // X - Good!
381 381
 
382 382
 define('SCORE_BOTH', 1);
383 383
 define('SCORE_ONLY_DEFAULT', 2);
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 define('TIMELINE_STATUS_INACTIVE', '2');
561 561
 
562 562
 // Event email template class
563
-define('EVENT_EMAIL_TEMPLATE_ACTIVE',  1);
563
+define('EVENT_EMAIL_TEMPLATE_ACTIVE', 1);
564 564
 define('EVENT_EMAIL_TEMPLATE_INACTIVE', 0);
565 565
 
566 566
 // Course home
@@ -576,8 +576,8 @@  discard block
 block discarded – undo
576 576
 define('FILE_OVERWRITE', 3);
577 577
 define('UTF8_CONVERT', false); //false by default
578 578
 
579
-define('DOCUMENT','file');
580
-define('FOLDER','folder');
579
+define('DOCUMENT', 'file');
580
+define('FOLDER', 'folder');
581 581
 
582 582
 define('RESOURCE_DOCUMENT', 'document');
583 583
 define('RESOURCE_GLOSSARY', 'glossary');
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
                     : 'localhost')));
681 681
                 if (isset($_SERVER['SERVER_PORT']) && !strpos($server_name, ':')
682 682
                     && (($server_protocol == 'http'
683
-                    && $_SERVER['SERVER_PORT'] != 80 ) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443 ))) {
684
-                    $server_name .= ":" . $_SERVER['SERVER_PORT'];
683
+                    && $_SERVER['SERVER_PORT'] != 80) || ($server_protocol == 'https' && $_SERVER['SERVER_PORT'] != 443))) {
684
+                    $server_name .= ":".$_SERVER['SERVER_PORT'];
685 685
                 }
686 686
                 $root_web = $server_protocol.'://'.$server_name.$root_rel;
687 687
                 $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
                 $sys_course_code =
862 862
                     isset($_SESSION['_course']['sysCode'])  // User is inside a course?
863 863
                         ? $_SESSION['_course']['sysCode']   // Yes, then use course's directory name.
864
-                        : '{SYS_COURSE_CODE}';              // No, then use a fake code, it may be processed later.
864
+                        : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later.
865 865
                 $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]);
866 866
             }
867 867
         }
@@ -886,15 +886,15 @@  discard block
 block discarded – undo
886 886
 {
887 887
     global $_configuration;
888 888
     $web_root = api_get_path(WEB_PATH);
889
-    $ext = substr($web_path,strrpos($web_path,'.'));
889
+    $ext = substr($web_path, strrpos($web_path, '.'));
890 890
     if (isset($ext[2])) { // faster version of strlen to check if len>2
891 891
         // Check for CDN definitions
892 892
         if (!empty($_configuration['cdn_enable']) && !empty($ext)) {
893 893
             foreach ($_configuration['cdn'] as $host => $exts) {
894
-                if (in_array($ext,$exts)) {
894
+                if (in_array($ext, $exts)) {
895 895
                     //Use host as defined in $_configuration['cdn'], without
896 896
                     // trailing slash
897
-                    return str_replace($web_root,$host.'/',$web_path);
897
+                    return str_replace($web_root, $host.'/', $web_path);
898 898
                 }
899 899
             }
900 900
         }
@@ -1341,10 +1341,10 @@  discard block
 block discarded – undo
1341 1341
 
1342 1342
     if (isset($user['email'])) {
1343 1343
         $result['mail'] = isset($user['email']) ? $user['email'] : null;
1344
-        $result['email'] = isset($user['email'])? $user['email'] : null;
1344
+        $result['email'] = isset($user['email']) ? $user['email'] : null;
1345 1345
     } else {
1346 1346
         $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
1347
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
1347
+        $result['email'] = isset($user['mail']) ? $user['mail'] : null;
1348 1348
     }
1349 1349
     $user_id = intval($user['user_id']);
1350 1350
     // Maintain the user_id index for backwards compatibility
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
         foreach ($param_list1 as $key => $enreg) {
1863 1863
             list ($param_list1_keys[$key], $param_list1_vals[$key]) = explode('=', $enreg);
1864 1864
         }
1865
-        $param_list1 = array ('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1865
+        $param_list1 = array('keys' => $param_list1_keys, 'vals' => $param_list1_vals);
1866 1866
         foreach ($param_list2 as $enreg) {
1867 1867
             $enreg = explode('=', $enreg);
1868 1868
             $key = array_search($enreg[0], $param_list1['keys']);
@@ -1895,12 +1895,12 @@  discard block
 block discarded – undo
1895 1895
         $length = 2;
1896 1896
     }
1897 1897
     $password = '';
1898
-    for ($i = 0; $i < $length; $i ++) {
1898
+    for ($i = 0; $i < $length; $i++) {
1899 1899
         $password .= $characters[rand() % strlen($characters)];
1900 1900
     }
1901 1901
 
1902 1902
     // At least 2 digits
1903
-    for ($i = 0; $i < 2; $i ++) {
1903
+    for ($i = 0; $i < 2; $i++) {
1904 1904
         $password .= $numbers[rand() % strlen($numbers)];
1905 1905
     }
1906 1906
 
@@ -1928,10 +1928,10 @@  discard block
 block discarded – undo
1928 1928
     $digits = 0;
1929 1929
     $consequent_characters = 0;
1930 1930
     $previous_character_code = 0;
1931
-    for ($i = 0; $i < $password_length; $i ++) {
1931
+    for ($i = 0; $i < $password_length; $i++) {
1932 1932
         $current_character_code = api_ord(api_substr($password, $i, 1));
1933 1933
         if ($i && abs($current_character_code - $previous_character_code) <= 1) {
1934
-            $consequent_characters ++;
1934
+            $consequent_characters++;
1935 1935
             if ($consequent_characters == 3) {
1936 1936
                 return false;
1937 1937
             }
@@ -1939,9 +1939,9 @@  discard block
 block discarded – undo
1939 1939
             $consequent_characters = 1;
1940 1940
         }
1941 1941
         if ($current_character_code >= 97 && $current_character_code <= 122) {
1942
-            $letters ++;
1942
+            $letters++;
1943 1943
         } elseif ($current_character_code >= 48 && $current_character_code <= 57) {
1944
-            $digits ++;
1944
+            $digits++;
1945 1945
         } else {
1946 1946
             return false;
1947 1947
         }
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
         if (empty($session_id)) { return null; }
2047 2047
     }
2048 2048
     $t = Database::get_main_table(TABLE_MAIN_SESSION);
2049
-    $s = "SELECT name FROM $t WHERE id = ".(int)$session_id;
2049
+    $s = "SELECT name FROM $t WHERE id = ".(int) $session_id;
2050 2050
     $r = Database::query($s);
2051 2051
     $c = Database::num_rows($r);
2052 2052
     if ($c > 0) {
@@ -2216,9 +2216,9 @@  discard block
 block discarded – undo
2216 2216
  */
2217 2217
 function api_get_session_image($session_id, $status_id)
2218 2218
 {
2219
-    $session_id = (int)$session_id;
2219
+    $session_id = (int) $session_id;
2220 2220
     $session_img = '';
2221
-    if ((int)$status_id != 5) { //check whether is not a student
2221
+    if ((int) $status_id != 5) { //check whether is not a student
2222 2222
         if ($session_id > 0) {
2223 2223
             $session_img = "&nbsp;&nbsp;".Display::return_icon(
2224 2224
                 'star.png',
@@ -2485,7 +2485,7 @@  discard block
 block discarded – undo
2485 2485
 function api_is_course_session_coach($user_id, $courseId, $session_id)
2486 2486
 {
2487 2487
     $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
2488
-    $session_rel_course_rel_user_table  = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2488
+    $session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
2489 2489
 
2490 2490
     $user_id = intval($user_id);
2491 2491
     $session_id = intval($session_id);
@@ -2559,7 +2559,7 @@  discard block
 block discarded – undo
2559 2559
                 ORDER BY access_start_date, access_end_date, name";
2560 2560
         $result = Database::query($sql);
2561 2561
         if (!empty($sessionIsCoach)) {
2562
-            $sessionIsCoach = array_merge($sessionIsCoach , Database::store_result($result));
2562
+            $sessionIsCoach = array_merge($sessionIsCoach, Database::store_result($result));
2563 2563
         } else {
2564 2564
             $sessionIsCoach = Database::store_result($result);
2565 2565
         }
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
             return '';
2734 2734
         }
2735 2735
         $sourceurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
2736
-        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview']=='studentview' ? 'false' : 'true'), $sourceurl);
2736
+        $sourceurl = str_replace('lp/lp_header.php', 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.intval($_GET['lp_id']).'&isStudentView='.($_SESSION['studentview'] == 'studentview' ? 'false' : 'true'), $sourceurl);
2737 2737
         //showinframes doesn't handle student view anyway...
2738 2738
         //return '';
2739 2739
         $is_framed = true;
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
         }
3217 3217
         $content .= '<div class="well">';
3218 3218
         $content .= $form->returnForm();
3219
-        $content .='</div>';
3219
+        $content .= '</div>';
3220 3220
         if (api_is_cas_activated()) {
3221 3221
             $content .= "</div>";
3222 3222
         }
@@ -3268,7 +3268,7 @@  discard block
 block discarded – undo
3268 3268
         }
3269 3269
         $msg .= '<div class="well">';
3270 3270
         $msg .= $form->returnForm();
3271
-        $msg .='</div>';
3271
+        $msg .= '</div>';
3272 3272
         if ($casEnabled) {
3273 3273
             $msg .= "</div>";
3274 3274
         }
@@ -3298,7 +3298,7 @@  discard block
 block discarded – undo
3298 3298
     list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime);
3299 3299
     list ($year, $month, $day) = explode('-', $last_post_date);
3300 3300
     list ($hour, $min, $sec) = explode(':', $last_post_time);
3301
-    return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
3301
+    return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year);
3302 3302
 }
3303 3303
 
3304 3304
 /**
@@ -3768,7 +3768,7 @@  discard block
 block discarded – undo
3768 3768
                 c_id = $course_id AND
3769 3769
                 tool = '$tool'
3770 3770
                 $session_condition ";
3771
-    $rs  = Database::query($sql);
3771
+    $rs = Database::query($sql);
3772 3772
     $list = array();
3773 3773
     if (Database::num_rows($rs) > 0) {
3774 3774
         while ($row = Database::fetch_array($rs, 'ASSOC')) {
@@ -3849,7 +3849,7 @@  discard block
 block discarded – undo
3849 3849
                 tool = '$tool' AND
3850 3850
                 ref = $ref
3851 3851
                 $sessionCondition";
3852
-    $rs  = Database::query($sql);
3852
+    $rs = Database::query($sql);
3853 3853
     $item_property_id = '';
3854 3854
     if (Database::num_rows($rs) > 0) {
3855 3855
         $row = Database::fetch_array($rs);
@@ -3910,7 +3910,7 @@  discard block
 block discarded – undo
3910 3910
     if ($result == false) {
3911 3911
         $result = array();
3912 3912
     } else {
3913
-        $result = Database::store_result($result,'ASSOC');
3913
+        $result = Database::store_result($result, 'ASSOC');
3914 3914
     }
3915 3915
 
3916 3916
     return $result;
@@ -3962,7 +3962,7 @@  discard block
 block discarded – undo
3962 3962
     $rs  = Database::query($sql);
3963 3963
     $row = array();
3964 3964
     if (Database::num_rows($rs) > 0) {
3965
-        $row = Database::fetch_array($rs,'ASSOC');
3965
+        $row = Database::fetch_array($rs, 'ASSOC');
3966 3966
     }
3967 3967
 
3968 3968
     return $row;
@@ -3997,7 +3997,7 @@  discard block
 block discarded – undo
3997 3997
     $languages  = $language_list['name'];
3998 3998
     $folder     = $language_list['folder'];
3999 3999
 
4000
-    $ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
4000
+    $ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
4001 4001
     foreach ($languages as $key => $value) {
4002 4002
         if ($folder[$key] == $default) {
4003 4003
             $selected = ' selected="selected"';
@@ -4047,8 +4047,8 @@  discard block
 block discarded – undo
4047 4047
     }
4048 4048
     </script>';
4049 4049
     $html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
4050
-    $html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
4051
-    $html .=  '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4050
+    $html .= '<label style="display: none;" for="language_list">'.get_lang('Language').'</label>';
4051
+    $html .= '<select id="language_list" class="selectpicker show-tick form-control" name="language_list" >';
4052 4052
 
4053 4053
     foreach ($original_languages as $key => $value) {
4054 4054
         if ($folder[$key] == $user_selected_language) {
@@ -4056,13 +4056,13 @@  discard block
 block discarded – undo
4056 4056
         } else {
4057 4057
             $option_end = '>';
4058 4058
         }
4059
-        $html .=  '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4059
+        $html .= '<option value="'.api_get_self().'?language='.$folder[$key].'"'.$option_end;
4060 4060
         //echo substr($value, 0, 16); // Cut string to keep 800x600 aspect.
4061
-        $html .=  $value.'</option>';
4061
+        $html .= $value.'</option>';
4062 4062
     }
4063
-    $html .=  '</select>';
4064
-    $html .=  '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4065
-    $html .=  '</form>';
4063
+    $html .= '</select>';
4064
+    $html .= '<noscript><input type="submit" name="user_select_language" value="'.get_lang('Ok').'" /></noscript>';
4065
+    $html .= '</form>';
4066 4066
     return $html;
4067 4067
 }
4068 4068
 
@@ -4280,7 +4280,7 @@  discard block
 block discarded – undo
4280 4280
  * Note: Directory names (names of themes) in the file system should contain ASCII-characters only.
4281 4281
  */
4282 4282
 function api_get_themes() {
4283
-    $cssdir = api_get_path(SYS_CSS_PATH) . 'themes/';
4283
+    $cssdir = api_get_path(SYS_CSS_PATH).'themes/';
4284 4284
     $list_dir = array();
4285 4285
     $list_name = array();
4286 4286
 
@@ -4441,7 +4441,7 @@  discard block
 block discarded – undo
4441 4441
     if (is_file($dirname) || is_link($dirname)) {
4442 4442
         $res = unlink($dirname);
4443 4443
         if ($res === false) {
4444
-            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);
4444
+            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);
4445 4445
         }
4446 4446
         return $res;
4447 4447
     }
@@ -4478,7 +4478,7 @@  discard block
 block discarded – undo
4478 4478
     if ($delete_only_content_in_folder == false) {
4479 4479
         $res = rmdir($dirname);
4480 4480
         if ($res === false) {
4481
-            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);
4481
+            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);
4482 4482
         }
4483 4483
     }
4484 4484
     return $res;
@@ -4563,7 +4563,7 @@  discard block
 block discarded – undo
4563 4563
 
4564 4564
     $course_id = $course_info['real_id'];
4565 4565
 
4566
-    $folders = explode(DIRECTORY_SEPARATOR,str_replace($base_path_document.DIRECTORY_SEPARATOR,'',$pathname));
4566
+    $folders = explode(DIRECTORY_SEPARATOR, str_replace($base_path_document.DIRECTORY_SEPARATOR, '', $pathname));
4567 4567
 
4568 4568
     $new_pathname = $base_path_document;
4569 4569
     $path = '';
@@ -4581,7 +4581,7 @@  discard block
 block discarded – undo
4581 4581
                         path = '$path' AND
4582 4582
                         filetype = 'folder' AND
4583 4583
                         session_id = '$session_id'";
4584
-            $rs1  = Database::query($sql);
4584
+            $rs1 = Database::query($sql);
4585 4585
             $num_rows = Database::num_rows($rs1);
4586 4586
 
4587 4587
             if ($num_rows == 0) {
@@ -4741,7 +4741,7 @@  discard block
 block discarded – undo
4741 4741
             foreach (array('key', 'value1', 'value2', 'value3') as $var) {
4742 4742
                 $$var = isset($match[++$i]) ? $match[$i] : '';
4743 4743
             }
4744
-            $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
4744
+            $value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3;
4745 4745
 
4746 4746
             // Parse array syntax.
4747 4747
             $keys = preg_split('/\]?\[/', rtrim($key, ']'));
@@ -4907,7 +4907,7 @@  discard block
 block discarded – undo
4907 4907
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
4908 4908
     $var = Database::escape_string($var);
4909 4909
     $value = Database::escape_string($value);
4910
-    $access_url = (int)$access_url;
4910
+    $access_url = (int) $access_url;
4911 4911
     if (empty($access_url)) { $access_url = 1; }
4912 4912
     $select = "SELECT id FROM $t_settings WHERE variable = '$var' ";
4913 4913
     if (!empty($subvar)) {
@@ -4948,11 +4948,11 @@  discard block
 block discarded – undo
4948 4948
                 $row = Database::fetch_array($res);
4949 4949
                 $insert = "INSERT INTO $t_settings (variable, subkey, type,category, selected_value, title, comment, scope, subkeytext, access_url)
4950 4950
                         VALUES
4951
-                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
4952
-                        "'".$row['type']."','".$row['category']."'," .
4953
-                        "'$value','".$row['title']."'," .
4954
-                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
4955
-                        "".(!empty($row['subkeytext'])?"'".$row['subkeytext']."'":"NULL").",$access_url)";
4951
+                        ('".$row['variable']."',".(!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
4952
+                        "'".$row['type']."','".$row['category']."',".
4953
+                        "'$value','".$row['title']."',".
4954
+                        "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".(!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
4955
+                        "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url)";
4956 4956
                 Database::query($insert);
4957 4957
             } else {
4958 4958
                 // Such a setting does not exist.
@@ -4974,11 +4974,11 @@  discard block
 block discarded – undo
4974 4974
                 if ($row['access_url_changeable'] == 1) {
4975 4975
                     $insert = "INSERT INTO $t_settings (variable,subkey, type,category, selected_value,title, comment,scope, subkeytext,access_url, access_url_changeable) VALUES
4976 4976
                             ('".$row['variable']."',".
4977
-                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL")."," .
4978
-                            "'".$row['type']."','".$row['category']."'," .
4979
-                            "'$value','".$row['title']."'," .
4977
+                            (!empty($row['subkey']) ? "'".$row['subkey']."'" : "NULL").",".
4978
+                            "'".$row['type']."','".$row['category']."',".
4979
+                            "'$value','".$row['title']."',".
4980 4980
                             "".(!empty($row['comment']) ? "'".$row['comment']."'" : "NULL").",".
4981
-                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL")."," .
4981
+                            (!empty($row['scope']) ? "'".$row['scope']."'" : "NULL").",".
4982 4982
                             "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")";
4983 4983
                     Database::query($insert);
4984 4984
                 }
@@ -5011,10 +5011,10 @@  discard block
 block discarded – undo
5011 5011
         $value = Database::escape_string($value);
5012 5012
         $sql = "UPDATE $t_s SET selected_value = '$value'
5013 5013
                 WHERE category = '$category' AND access_url = $access_url";
5014
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5014
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5015 5015
             $sql .= " AND ( ";
5016 5016
             $i = 0;
5017
-            foreach ($fieldtype as $type){
5017
+            foreach ($fieldtype as $type) {
5018 5018
                 if ($i > 0) {
5019 5019
                     $sql .= ' OR ';
5020 5020
                 }
@@ -5029,10 +5029,10 @@  discard block
 block discarded – undo
5029 5029
     } else {
5030 5030
         $sql = "UPDATE $t_s SET selected_value = NULL
5031 5031
                 WHERE category = '$category' AND access_url = $access_url";
5032
-        if (is_array($fieldtype) && count($fieldtype)>0) {
5032
+        if (is_array($fieldtype) && count($fieldtype) > 0) {
5033 5033
             $sql .= " AND ( ";
5034 5034
             $i = 0;
5035
-            foreach ($fieldtype as $type){
5035
+            foreach ($fieldtype as $type) {
5036 5036
                 if ($i > 0) {
5037 5037
                     $sql .= ' OR ';
5038 5038
                 }
@@ -5137,7 +5137,7 @@  discard block
 block discarded – undo
5137 5137
         $sql .= " ORDER BY 1,2 ASC";
5138 5138
     }
5139 5139
     $result = Database::query($sql);
5140
-    $result = Database::store_result($result,'ASSOC');
5140
+    $result = Database::store_result($result, 'ASSOC');
5141 5141
 
5142 5142
     return $result;
5143 5143
 }
@@ -5204,12 +5204,12 @@  discard block
 block discarded – undo
5204 5204
 
5205 5205
     // Item not found for this access_url, we have to check if the whole thing is missing
5206 5206
     // (in which case we ignore the insert) or if there *is* a record but just for access_url = 1
5207
-    $insert = "INSERT INTO $t_settings " .
5208
-                "(variable,selected_value," .
5209
-                "type,category," .
5210
-                "subkey,title," .
5211
-                "comment,scope," .
5212
-                "subkeytext,access_url,access_url_changeable)" .
5207
+    $insert = "INSERT INTO $t_settings ".
5208
+                "(variable,selected_value,".
5209
+                "type,category,".
5210
+                "subkey,title,".
5211
+                "comment,scope,".
5212
+                "subkeytext,access_url,access_url_changeable)".
5213 5213
                 " VALUES ('$var','$val',";
5214 5214
     if (isset($type)) {
5215 5215
         $type = Database::escape_string($type);
@@ -5375,7 +5375,7 @@  discard block
 block discarded – undo
5375 5375
             $result = Database::query($sql);
5376 5376
 
5377 5377
             //if ($row = Database::fetch_array($result)) {
5378
-            if (Database::num_rows($result) > 0 ) {
5378
+            if (Database::num_rows($result) > 0) {
5379 5379
                 $is_courseMember = true;
5380 5380
                 $is_courseTutor = true;
5381 5381
                 $is_courseCoach = true;
@@ -5656,7 +5656,7 @@  discard block
 block discarded – undo
5656 5656
     } else {
5657 5657
         return false;
5658 5658
     }
5659
-    return strtolower(substr((string)$os, 0, 3 )) == 'win';
5659
+    return strtolower(substr((string) $os, 0, 3)) == 'win';
5660 5660
 }
5661 5661
 
5662 5662
 /**
@@ -6210,7 +6210,7 @@  discard block
 block discarded – undo
6210 6210
 function api_get_jquery_ui_js($include_jqgrid = false) {
6211 6211
     $libraries = array();
6212 6212
     if ($include_jqgrid) {
6213
-       $libraries[]='jqgrid';
6213
+       $libraries[] = 'jqgrid';
6214 6214
     }
6215 6215
     return api_get_jquery_libraries_js($libraries);
6216 6216
 }
@@ -6233,12 +6233,12 @@  discard block
 block discarded – undo
6233 6233
 
6234 6234
     //jqgrid js and css
6235 6235
     if (in_array('jqgrid', $libraries)) {
6236
-        $languaje   = 'en';
6236
+        $languaje = 'en';
6237 6237
         $platform_isocode = strtolower(api_get_language_isocode());
6238 6238
 
6239 6239
         //languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
6240 6240
         $jqgrid_langs = array(
6241
-            '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'
6241
+            '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'
6242 6242
         );
6243 6243
 
6244 6244
         if (in_array($platform_isocode, $jqgrid_langs)) {
@@ -6269,7 +6269,7 @@  discard block
 block discarded – undo
6269 6269
 
6270 6270
     // jquery datepicker
6271 6271
     if (in_array('datepicker', $libraries)) {
6272
-        $languaje   = 'en-GB';
6272
+        $languaje = 'en-GB';
6273 6273
         $platform_isocode = strtolower(api_get_language_isocode());
6274 6274
 
6275 6275
         // languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n
@@ -6435,7 +6435,7 @@  discard block
 block discarded – undo
6435 6435
  * @return void
6436 6436
  */
6437 6437
 function api_check_php_version($my_inc_path = null) {
6438
-    if (!function_exists('version_compare') || version_compare( phpversion(), REQUIRED_PHP_VERSION, '<')) {
6438
+    if (!function_exists('version_compare') || version_compare(phpversion(), REQUIRED_PHP_VERSION, '<')) {
6439 6439
         $global_error_code = 1;
6440 6440
         // Incorrect PHP version
6441 6441
         $global_page = $my_inc_path.'global_error_message.inc.php';
@@ -6451,7 +6451,7 @@  discard block
 block discarded – undo
6451 6451
  */
6452 6452
 function api_check_archive_dir() {
6453 6453
     if (is_dir(api_get_path(SYS_ARCHIVE_PATH)) && !is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
6454
-        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'),'warning');
6454
+        $message = Display::return_message(get_lang('ArchivesDirectoryNotWriteableContactAdmin'), 'warning');
6455 6455
         api_not_allowed(true, $message);
6456 6456
     }
6457 6457
 }
@@ -6514,7 +6514,7 @@  discard block
 block discarded – undo
6514 6514
  * @author Jorge Frisancho Jibaja <[email protected]>, USIL - Some changes to allow the use of real IP using reverse proxy
6515 6515
  * @version CEV CHANGE 24APR2012
6516 6516
  */
6517
-function api_get_real_ip(){
6517
+function api_get_real_ip() {
6518 6518
     // Guess the IP if behind a reverse proxy
6519 6519
     global $debug;
6520 6520
     $ip = trim($_SERVER['REMOTE_ADDR']);
@@ -6540,23 +6540,23 @@  discard block
 block discarded – undo
6540 6540
  * @author Yannick Warnier for improvements and managment of multiple ranges
6541 6541
  * @todo check for IPv6 support
6542 6542
  */
6543
-function api_check_ip_in_range($ip,$range)
6543
+function api_check_ip_in_range($ip, $range)
6544 6544
 {
6545 6545
     if (empty($ip) or empty($range)) {
6546 6546
         return false;
6547 6547
     }
6548
-    $ip_ip = ip2long ($ip);
6548
+    $ip_ip = ip2long($ip);
6549 6549
     // divide range param into array of elements
6550
-    if (strpos($range,',')!==false) {
6551
-        $ranges = explode(',',$range);
6550
+    if (strpos($range, ',') !== false) {
6551
+        $ranges = explode(',', $range);
6552 6552
     } else {
6553 6553
         $ranges = array($range);
6554 6554
     }
6555 6555
     foreach ($ranges as $range) {
6556 6556
         $range = trim($range);
6557 6557
         if (empty($range)) { continue; }
6558
-        if (strpos($range,'/')===false) {
6559
-            if (strcmp($ip,$range)===0) {
6558
+        if (strpos($range, '/') === false) {
6559
+            if (strcmp($ip, $range) === 0) {
6560 6560
                 return true; // there is a direct IP match, return OK
6561 6561
             }
6562 6562
             continue; //otherwise, get to the next range
@@ -6564,7 +6564,7 @@  discard block
 block discarded – undo
6564 6564
         // the range contains a "/", so analyse completely
6565 6565
         list ($net, $mask) = explode("/", $range);
6566 6566
 
6567
-        $ip_net = ip2long ($net);
6567
+        $ip_net = ip2long($net);
6568 6568
         // mask binary magic
6569 6569
         $ip_mask = ~((1 << (32 - $mask)) - 1);
6570 6570
 
@@ -6902,14 +6902,14 @@  discard block
 block discarded – undo
6902 6902
  * @assert (0) === true
6903 6903
  * @assert ('1G') === true
6904 6904
  */
6905
-function api_set_memory_limit($mem){
6905
+function api_set_memory_limit($mem) {
6906 6906
     //if ini_set() not available, this function is useless
6907 6907
     if (!function_exists('ini_set') || is_null($mem) || $mem == -1) {
6908 6908
         return false;
6909 6909
     }
6910 6910
 
6911 6911
     $memory_limit = ini_get('memory_limit');
6912
-    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)){
6912
+    if (api_get_bytes_memory_limit($mem) > api_get_bytes_memory_limit($memory_limit)) {
6913 6913
         ini_set('memory_limit', $mem);
6914 6914
         return true;
6915 6915
     }
@@ -6926,21 +6926,21 @@  discard block
 block discarded – undo
6926 6926
  * @assert ('1m')  === 1048576
6927 6927
  * @assert ('100k') === 102400
6928 6928
  */
6929
-function api_get_bytes_memory_limit($mem){
6930
-    $size = strtolower(substr($mem,-1));
6929
+function api_get_bytes_memory_limit($mem) {
6930
+    $size = strtolower(substr($mem, -1));
6931 6931
 
6932 6932
     switch ($size) {
6933 6933
         case 't':
6934
-            $mem = intval(substr($mem,-1))*1024*1024*1024*1024;
6934
+            $mem = intval(substr($mem, -1)) * 1024 * 1024 * 1024 * 1024;
6935 6935
             break;
6936 6936
         case 'g':
6937
-            $mem = intval(substr($mem,0,-1))*1024*1024*1024;
6937
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024 * 1024;
6938 6938
             break;
6939 6939
         case 'm':
6940
-            $mem = intval(substr($mem,0,-1))*1024*1024;
6940
+            $mem = intval(substr($mem, 0, -1)) * 1024 * 1024;
6941 6941
             break;
6942 6942
         case 'k':
6943
-            $mem = intval(substr($mem,0,-1))*1024;
6943
+            $mem = intval(substr($mem, 0, -1)) * 1024;
6944 6944
             break;
6945 6945
         default:
6946 6946
             // we assume it's integer only
@@ -7003,7 +7003,7 @@  discard block
 block discarded – undo
7003 7003
     ];
7004 7004
 
7005 7005
     $js = api_get_asset('pwstrength-bootstrap/dist/pwstrength-bootstrap.min.js');
7006
-    $js .=  "<script>    
7006
+    $js .= "<script>    
7007 7007
     var errorMessages = {
7008 7008
         password_to_short : \"" . get_lang('PasswordIsTooShort')."\",
7009 7009
         same_as_username : \"".get_lang('YourPasswordCannotBeTheSameAsYourUsername')."\"
@@ -7050,7 +7050,7 @@  discard block
 block discarded – undo
7050 7050
         return false;
7051 7051
     }
7052 7052
     $minutesToBlock = api_get_setting('captcha_time_to_block');
7053
-    $time = time() + $minutesToBlock*60;
7053
+    $time = time() + $minutesToBlock * 60;
7054 7054
     UserManager::update_extra_field_value(
7055 7055
         $userInfo['user_id'],
7056 7056
         'captcha_blocked_until_date',
@@ -7124,7 +7124,7 @@  discard block
 block discarded – undo
7124 7124
         $out_res = str_replace('"', "''", $out_res);
7125 7125
     }
7126 7126
     // avoid text stuck together when tags are removed, adding a space after >
7127
-    $out_res = str_replace (">", "> ", $out_res);
7127
+    $out_res = str_replace(">", "> ", $out_res);
7128 7128
     $out_res = strip_tags($out_res);
7129 7129
 
7130 7130
     return $out_res;
@@ -7329,7 +7329,7 @@  discard block
 block discarded – undo
7329 7329
         $body = get_lang('PortalName').': '.api_get_path(WEB_PATH)." \n ";
7330 7330
         $body .= get_lang('PortalLimitType').': '.$limitName." \n ";
7331 7331
         if (isset($hostingParams[$limitName])) {
7332
-            $body .= get_lang('Value') . ': ' . $hostingParams[$limitName];
7332
+            $body .= get_lang('Value').': '.$hostingParams[$limitName];
7333 7333
         }
7334 7334
         api_mail_html(null, $email, $subject, $body);
7335 7335
     }
@@ -7461,7 +7461,7 @@  discard block
 block discarded – undo
7461 7461
  */
7462 7462
 function api_set_site_use_cookie_warning_cookie()
7463 7463
 {
7464
-    setcookie('ChamiloUsesCookies', 'ok', time()+31556926);
7464
+    setcookie('ChamiloUsesCookies', 'ok', time() + 31556926);
7465 7465
 }
7466 7466
 
7467 7467
 /**
@@ -7509,10 +7509,10 @@  discard block
 block discarded – undo
7509 7509
         return false;
7510 7510
     }
7511 7511
 
7512
-    $fullPath = $parentDirectory . api_replace_dangerous_char($name);
7512
+    $fullPath = $parentDirectory.api_replace_dangerous_char($name);
7513 7513
 
7514 7514
     if (mkdir($fullPath, api_get_permissions_for_new_directories(), true)) {
7515
-        $fp = fopen($fullPath . '/index.html', 'w');
7515
+        $fp = fopen($fullPath.'/index.html', 'w');
7516 7516
 
7517 7517
         if ($fp) {
7518 7518
             if (fwrite($fp, '<html><head></head><body></body></html>')) {
@@ -7577,7 +7577,7 @@  discard block
 block discarded – undo
7577 7577
             $mail->SMTPSecure = $platform_email['SMTP_SECURE'];
7578 7578
         }
7579 7579
     }
7580
-    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG'])?$platform_email['SMTP_DEBUG']:0;
7580
+    $mail->SMTPDebug = isset($platform_email['SMTP_DEBUG']) ? $platform_email['SMTP_DEBUG'] : 0;
7581 7581
 
7582 7582
     // 5 = low, 1 = high
7583 7583
     $mail->Priority = 3;
@@ -7724,11 +7724,11 @@  discard block
 block discarded – undo
7724 7724
         error_log('ERROR: mail not sent to '.$recipient_name.' ('.$recipient_email.') because of '.$mail->ErrorInfo.'<br />');
7725 7725
         if ($mail->SMTPDebug) {
7726 7726
             error_log(
7727
-                "Connection details :: " .
7728
-                "Protocol: " . $mail->Mailer . ' :: ' .
7729
-                "Host/Port: " . $mail->Host . ':' . $mail->Port . ' :: ' .
7730
-                "Authent/Open: " . ($mail->SMTPAuth?'Authent':'Open') . ' :: ' .
7731
-                ($mail->SMTPAuth?"  User/Pass: " . $mail->Username . ':' . $mail->Password:'')
7727
+                "Connection details :: ".
7728
+                "Protocol: ".$mail->Mailer.' :: '.
7729
+                "Host/Port: ".$mail->Host.':'.$mail->Port.' :: '.
7730
+                "Authent/Open: ".($mail->SMTPAuth ? 'Authent' : 'Open').' :: '.
7731
+                ($mail->SMTPAuth ? "  User/Pass: ".$mail->Username.':'.$mail->Password : '')
7732 7732
             );
7733 7733
         }
7734 7734
         return 0;
@@ -7804,13 +7804,13 @@  discard block
 block discarded – undo
7804 7804
  * @return array
7805 7805
  *
7806 7806
  */
7807
-function api_unique_multidim_array($array, $key){
7807
+function api_unique_multidim_array($array, $key) {
7808 7808
     $temp_array = [];
7809 7809
     $i = 0;
7810 7810
     $key_array = [];
7811 7811
 
7812
-    foreach($array as $val){
7813
-        if(!in_array($val[$key],$key_array)){
7812
+    foreach ($array as $val) {
7813
+        if (!in_array($val[$key], $key_array)) {
7814 7814
             $key_array[$i] = $val[$key];
7815 7815
             $temp_array[$i] = $val;
7816 7816
         }
@@ -7854,7 +7854,7 @@  discard block
 block discarded – undo
7854 7854
         // No "dangerous" files
7855 7855
         $name = disable_dangerous_file($name);
7856 7856
 
7857
-        $pathId = '/'.substr((string)$itemId, 0, 1).'/'.$itemId.'/';
7857
+        $pathId = '/'.substr((string) $itemId, 0, 1).'/'.$itemId.'/';
7858 7858
         $path = api_get_path(SYS_UPLOAD_PATH).$type.$pathId;
7859 7859
 
7860 7860
         if (!is_dir($path)) {
Please login to merge, or discard this patch.
main/dropbox/dropbox_class.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -267,7 +267,7 @@
 block discarded – undo
267 267
 	 * @param string $author
268 268
 	 * @param string $filename
269 269
 	 * @param int $filesize
270
-	 * @param array $recipient_ids
270
+	 * @param unknown_type|null $recipient_ids
271 271
 	 */
272 272
 	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
273 273
     {
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -496,13 +496,19 @@
 block discarded – undo
496 496
 		$id = intval($id);
497 497
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_file']."
498 498
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
499
-		if (!Database::query($sql)) return false;
499
+		if (!Database::query($sql)) {
500
+		    return false;
501
+		}
500 502
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_category']."
501 503
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
502
-		if (!Database::query($sql)) return false;
504
+		if (!Database::query($sql)) {
505
+		    return false;
506
+		}
503 507
 		$sql = "DELETE FROM ".$dropbox_cnf['tbl_post']."
504 508
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
505
-		if (!Database::query($sql)) return false;
509
+		if (!Database::query($sql)) {
510
+		    return false;
511
+		}
506 512
 		return true;
507 513
 	}
508 514
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         // Check if object exists already. If it does, the old object is used
105 105
         // with updated information (authors, description, upload_date)
106 106
         $this->isOldWork = false;
107
-		$sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
107
+		$sql = "SELECT id, upload_date FROM ".Database::get_course_table(TABLE_DROPBOX_FILE)."
108 108
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
109 109
         $result = Database::query($sql);
110 110
 		$res = Database::fetch_array($result);
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 
149 149
 			$this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150 150
 			if ($this->id) {
151
-				$sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
151
+				$sql = "UPDATE ".Database::get_course_table(TABLE_DROPBOX_FILE)." SET id = iid WHERE iid = {$this->id}";
152 152
 				Database::query($sql);
153 153
 			}
154 154
 		}
155 155
 
156 156
         $sql = "SELECT count(file_id) as count
157
-        		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
157
+        		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON)."
158 158
 				WHERE c_id = $course_id AND file_id = ".intval($this->id)." AND user_id = ".$this->uploader_id;
159 159
         $result = Database::query($sql);
160 160
         $row = Database::fetch_array($result);
161 161
         if ($row['count'] == 0) {
162 162
 
163 163
             // Insert entries into person table
164
-            $sql = "INSERT INTO ". Database::get_course_table(TABLE_DROPBOX_PERSON) ." (c_id, file_id, user_id)
164
+            $sql = "INSERT INTO ".Database::get_course_table(TABLE_DROPBOX_PERSON)." (c_id, file_id, user_id)
165 165
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
166 166
             Database::query($sql);
167 167
         }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
         $action = isset($_GET['action']) ? $_GET['action'] : null;
180 180
 
181 181
         // Do some sanity checks
182
-        $id	= intval($id);
182
+        $id = intval($id);
183 183
 
184 184
         // Get the data from DB
185 185
         $sql = "SELECT uploader_id, filename, filesize, title, description, author, upload_date, last_upload_date, cat_id
186
-                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
186
+                FROM ". Database::get_course_table(TABLE_DROPBOX_FILE)."
187 187
                 WHERE c_id = $course_id AND id = ".$id."";
188 188
         $result = Database::query($sql);
189 189
         $res = Database::fetch_array($result, 'ASSOC');
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         // Getting the feedback on the work.
213 213
         if ($action == 'viewfeedback' AND $this->id == $_GET['id']) {
214 214
             $feedback2 = array();
215
-            $sql = "SELECT * FROM ". Database::get_course_table(TABLE_DROPBOX_FEEDBACK) ."
215
+            $sql = "SELECT * FROM ".Database::get_course_table(TABLE_DROPBOX_FEEDBACK)."
216 216
                     WHERE c_id = $course_id AND file_id='".$id."' 
217 217
                     ORDER BY feedback_id ASC";
218 218
             $result = Database::query($sql);
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
                 $row_feedback['feedback'] = Security::remove_XSS($row_feedback['feedback']);
221 221
                 $feedback2[] = $row_feedback;
222 222
             }
223
-            $this->feedback2= $feedback2;
223
+            $this->feedback2 = $feedback2;
224 224
         }
225 225
 	}
226 226
 }
227 227
 
228 228
 class Dropbox_SentWork extends Dropbox_Work
229 229
 {
230
-	public $recipients;	//array of ['id']['name'] arrays
230
+	public $recipients; //array of ['id']['name'] arrays
231 231
 
232 232
 	/**
233 233
 	 * Constructor calls private functions to create a new work or retreive an existing work from DB
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			$recipient_ids = array($uploader_id);
293 293
 		}
294 294
 
295
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
295
+		if (!is_array($recipient_ids) || count($recipient_ids) == 0) {
296 296
 			die(get_lang('GeneralError').' (code 209)');
297 297
 		}
298 298
 
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
         $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
309 309
         $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
310 310
         $session_id = api_get_session_id();
311
-        $user  = api_get_user_id();
311
+        $user = api_get_user_id();
312 312
         $now = api_get_utc_datetime();
313 313
 
314 314
 		// Insert data in dropbox_post and dropbox_person table for each recipient
315 315
 		foreach ($this->recipients as $rec) {
316
-            $file_id = (int)$this->id;
317
-            $user_id = (int)$rec['id'];
316
+            $file_id = (int) $this->id;
317
+            $user_id = (int) $rec['id'];
318 318
 			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
319 319
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
320 320
 	        Database::query($sql);
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
                 // Do not add recipient in person table if mailing zip or just upload.
332 332
                 if (!$justSubmit) {
333
-                    Database::query($sql);	// If work already exists no error is generated
333
+                    Database::query($sql); // If work already exists no error is generated
334 334
                 }
335 335
             }
336 336
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 			    $ownerid = getUserOwningThisMailing($ownerid);
340 340
 			}
341 341
 			if (($recipid = $rec["id"]) > $dropbox_cnf['mailingIdBase']) {
342
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
342
+			    $recipid = $ownerid; // mailing file recipient = mailing id, not a person
343 343
 			}
344 344
             api_item_property_update(
345 345
                 $_course,
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
 class Dropbox_Person
397 397
 {
398 398
 	// The receivedWork and the sentWork arrays are sorted.
399
-	public $receivedWork;	// an array of Dropbox_Work objects
400
-	public $sentWork;		// an array of Dropbox_SentWork objects
399
+	public $receivedWork; // an array of Dropbox_Work objects
400
+	public $sentWork; // an array of Dropbox_SentWork objects
401 401
 
402 402
 	public $userId = 0;
403 403
 	public $isCourseAdmin = false;
404 404
 	public $isCourseTutor = false;
405
-	public $_orderBy = '';	// private property that determines by which field
405
+	public $_orderBy = ''; // private property that determines by which field
406 406
 
407 407
 	/**
408 408
 	 * Constructor for recreating the Dropbox_Person object
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	    $course_id = api_get_course_int_id();
472 472
 		// Delete entries in person table concerning received works
473 473
 		foreach ($this->receivedWork as $w) {
474
-            $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
474
+            $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
475 475
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
476 476
 			Database::query($sql);
477 477
 		}
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
         $course_id = api_get_course_int_id();
489 489
 
490 490
 		$id = intval($id);
491
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
491
+		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_FILE)."
492 492
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
493 493
 		if (!Database::query($sql)) return false;
494
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
494
+		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_CATEGORY)."
495 495
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
496 496
 		if (!Database::query($sql)) return false;
497 497
 		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 			}
526 526
 		}
527 527
 		// Delete entries in person table concerning received works
528
-        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
528
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
529 529
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
530 530
 		Database::query($sql);
531
-		removeUnusedFiles();	// Check for unused files
531
+		removeUnusedFiles(); // Check for unused files
532 532
 	}
533 533
 
534 534
 	/**
@@ -539,12 +539,12 @@  discard block
 block discarded – undo
539 539
 	    $course_id = api_get_course_int_id();
540 540
 		//delete entries in person table concerning sent works
541 541
 		foreach ($this->sentWork as $w) {
542
-            $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
542
+            $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
543 543
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
544 544
 			Database::query($sql);
545 545
 			removeMoreIfMailing($w->id);
546 546
 		}
547
-		removeUnusedFiles();	// Check for unused files
547
+		removeUnusedFiles(); // Check for unused files
548 548
 	}
549 549
 
550 550
 	/**
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
 		}
574 574
 		//$file_id = $this->sentWork[$index]->id;
575 575
 		// Delete entries in person table concerning sent works
576
-        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
576
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_PERSON)."
577 577
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
578 578
 		Database::query($sql);
579 579
 		removeMoreIfMailing($id);
580
-		removeUnusedFiles();	// Check for unused files
580
+		removeUnusedFiles(); // Check for unused files
581 581
 	}
582 582
 
583 583
 	/**
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 		$wi = -1;
600 600
 		foreach ($this->receivedWork as $w) {
601 601
 			$wi++;
602
-			if ($w->id == $id){
602
+			if ($w->id == $id) {
603 603
 			   $found = true;
604 604
 			   break;
605 605
 			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
Please login to merge, or discard this patch.
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
         }
77 77
     }
78 78
 
79
-	/**
80
-	 * private function creating a new work object
81
-	 *
82
-	 * @param int $uploader_id
83
-	 * @param string $title
84
-	 * @param string $description
85
-	 * @param string $author
86
-	 * @param string $filename
87
-	 * @param int $filesize
88
-	 *
89
-	 * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
90
-	 * 			As a consequence this parameter can be removed
91
-	 */
92
-	public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
79
+    /**
80
+     * private function creating a new work object
81
+     *
82
+     * @param int $uploader_id
83
+     * @param string $title
84
+     * @param string $description
85
+     * @param string $author
86
+     * @param string $filename
87
+     * @param int $filesize
88
+     *
89
+     * @todo 	$author was originally a field but this has now been replaced by the first and lastname of the uploader (to prevent anonymous uploads)
90
+     * 			As a consequence this parameter can be removed
91
+     */
92
+    public function _createNewWork($uploader_id, $title, $description, $author, $filename, $filesize)
93 93
     {
94 94
         // Fill in the properties
95 95
         $this->uploader_id = intval($uploader_id);
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
         // Check if object exists already. If it does, the old object is used
105 105
         // with updated information (authors, description, upload_date)
106 106
         $this->isOldWork = false;
107
-		$sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
107
+        $sql = "SELECT id, upload_date FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
108 108
 				WHERE c_id = $course_id AND filename = '".Database::escape_string($this->filename)."'";
109 109
         $result = Database::query($sql);
110
-		$res = Database::fetch_array($result);
111
-		if ($res) {
112
-			$this->isOldWork = true;
113
-		}
114
-		// Insert or update the dropbox_file table and set the id property
115
-		if ($this->isOldWork) {
116
-			$this->id = $res['id'];
117
-			$this->upload_date = $res['upload_date'];
110
+        $res = Database::fetch_array($result);
111
+        if ($res) {
112
+            $this->isOldWork = true;
113
+        }
114
+        // Insert or update the dropbox_file table and set the id property
115
+        if ($this->isOldWork) {
116
+            $this->id = $res['id'];
117
+            $this->upload_date = $res['upload_date'];
118 118
 
119 119
             $params = [
120 120
                 'filesize' => $this->filesize,
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
                 $params,
131 131
                 ['c_id = ? AND id = ?' => [$course_id, $this->id]]
132 132
             );
133
-		} else {
134
-			$this->upload_date = $this->last_upload_date;
135
-			$params = [
133
+        } else {
134
+            $this->upload_date = $this->last_upload_date;
135
+            $params = [
136 136
                 'c_id' => $course_id,
137 137
                 'uploader_id' => $this->uploader_id,
138 138
                 'filename' => $this->filename,
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
                 'last_upload_date' => $this->last_upload_date,
145 145
                 'session_id' => api_get_session_id(),
146 146
                 'cat_id' => 0
147
-			];
147
+            ];
148 148
 
149
-			$this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150
-			if ($this->id) {
151
-				$sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
152
-				Database::query($sql);
153
-			}
154
-		}
149
+            $this->id = Database::insert(Database::get_course_table(TABLE_DROPBOX_FILE), $params);
150
+            if ($this->id) {
151
+                $sql = "UPDATE ". Database::get_course_table(TABLE_DROPBOX_FILE) ." SET id = iid WHERE iid = {$this->id}";
152
+                Database::query($sql);
153
+            }
154
+        }
155 155
 
156 156
         $sql = "SELECT count(file_id) as count
157 157
         		FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
@@ -165,16 +165,16 @@  discard block
 block discarded – undo
165 165
                     VALUES ($course_id, ".intval($this->id)." , ".intval($this->uploader_id).")";
166 166
             Database::query($sql);
167 167
         }
168
-	}
169
-
170
-	/**
171
-	 * private function creating existing object by retreiving info from db
172
-	 *
173
-	 * @param int $id
174
-	 */
175
-	public function _createExistingWork($id)
168
+    }
169
+
170
+    /**
171
+     * private function creating existing object by retreiving info from db
172
+     *
173
+     * @param int $id
174
+     */
175
+    public function _createExistingWork($id)
176 176
     {
177
-	    $course_id = api_get_course_int_id();
177
+        $course_id = api_get_course_int_id();
178 178
 
179 179
         $action = isset($_GET['action']) ? $_GET['action'] : null;
180 180
 
@@ -222,52 +222,52 @@  discard block
 block discarded – undo
222 222
             }
223 223
             $this->feedback2= $feedback2;
224 224
         }
225
-	}
225
+    }
226 226
 }
227 227
 
228 228
 class Dropbox_SentWork extends Dropbox_Work
229 229
 {
230
-	public $recipients;	//array of ['id']['name'] arrays
231
-
232
-	/**
233
-	 * Constructor calls private functions to create a new work or retreive an existing work from DB
234
-	 * depending on the number of parameters
235
-	 *
236
-	 * @param unknown_type $arg1
237
-	 * @param unknown_type $arg2
238
-	 * @param unknown_type $arg3
239
-	 * @param unknown_type $arg4
240
-	 * @param unknown_type $arg5
241
-	 * @param unknown_type $arg6
242
-	 * @param unknown_type $arg7
243
-	 * @return Dropbox_SentWork
244
-	 */
245
-	public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
230
+    public $recipients;	//array of ['id']['name'] arrays
231
+
232
+    /**
233
+     * Constructor calls private functions to create a new work or retreive an existing work from DB
234
+     * depending on the number of parameters
235
+     *
236
+     * @param unknown_type $arg1
237
+     * @param unknown_type $arg2
238
+     * @param unknown_type $arg3
239
+     * @param unknown_type $arg4
240
+     * @param unknown_type $arg5
241
+     * @param unknown_type $arg6
242
+     * @param unknown_type $arg7
243
+     * @return Dropbox_SentWork
244
+     */
245
+    public function __construct($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null, $arg6 = null, $arg7 = null)
246 246
     {
247
-		if (func_num_args() > 1) {
248
-		    $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
249
-		} else {
250
-			$this->_createExistingSentWork($arg1);
251
-		}
252
-	}
253
-
254
-	/**
255
-	 * private function creating a new SentWork object
256
-	 *
257
-	 * @param int $uploader_id
258
-	 * @param string $title
259
-	 * @param string $description
260
-	 * @param string $author
261
-	 * @param string $filename
262
-	 * @param int $filesize
263
-	 * @param array $recipient_ids
264
-	 */
265
-	public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
247
+        if (func_num_args() > 1) {
248
+            $this->_createNewSentWork($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);
249
+        } else {
250
+            $this->_createExistingSentWork($arg1);
251
+        }
252
+    }
253
+
254
+    /**
255
+     * private function creating a new SentWork object
256
+     *
257
+     * @param int $uploader_id
258
+     * @param string $title
259
+     * @param string $description
260
+     * @param string $author
261
+     * @param string $filename
262
+     * @param int $filesize
263
+     * @param array $recipient_ids
264
+     */
265
+    public function _createNewSentWork($uploader_id, $title, $description, $author, $filename, $filesize, $recipient_ids)
266 266
     {
267 267
         $dropbox_cnf = getDropboxConf();
268 268
         $_course = api_get_course_info();
269 269
 
270
-		// Call constructor of Dropbox_Work object
270
+        // Call constructor of Dropbox_Work object
271 271
         parent::__construct(
272 272
             $uploader_id,
273 273
             $title,
@@ -277,33 +277,33 @@  discard block
 block discarded – undo
277 277
             $filesize
278 278
         );
279 279
 
280
-		$course_id = api_get_course_int_id();
281
-
282
-		// Do sanity checks on recipient_ids array & property fillin
283
-		// The sanity check for ex-coursemembers is already done in base constructor
284
-		$uploader_id = (int) $uploader_id;
280
+        $course_id = api_get_course_int_id();
285 281
 
286
-		$justSubmit = false;
287
-		if (is_int($recipient_ids)) {
288
-			$justSubmit = true;
289
-			$recipient_ids = array($recipient_ids + $this->id);
290
-		} elseif (count($recipient_ids) == 0) {
291
-			$justSubmit = true;
292
-			$recipient_ids = array($uploader_id);
293
-		}
282
+        // Do sanity checks on recipient_ids array & property fillin
283
+        // The sanity check for ex-coursemembers is already done in base constructor
284
+        $uploader_id = (int) $uploader_id;
285
+
286
+        $justSubmit = false;
287
+        if (is_int($recipient_ids)) {
288
+            $justSubmit = true;
289
+            $recipient_ids = array($recipient_ids + $this->id);
290
+        } elseif (count($recipient_ids) == 0) {
291
+            $justSubmit = true;
292
+            $recipient_ids = array($uploader_id);
293
+        }
294 294
 
295
-		if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
296
-			die(get_lang('GeneralError').' (code 209)');
297
-		}
295
+        if (! is_array($recipient_ids) || count($recipient_ids) == 0) {
296
+            die(get_lang('GeneralError').' (code 209)');
297
+        }
298 298
 
299
-		foreach ($recipient_ids as $rec) {
300
-			if (empty($rec)) {
301
-			    continue;
299
+        foreach ($recipient_ids as $rec) {
300
+            if (empty($rec)) {
301
+                continue;
302 302
             }
303 303
 
304 304
             //this check is done when validating submitted data
305
-			$this->recipients[] = array('id' => $rec);
306
-		}
305
+            $this->recipients[] = array('id' => $rec);
306
+        }
307 307
 
308 308
         $table_post = Database::get_course_table(TABLE_DROPBOX_POST);
309 309
         $table_person = Database::get_course_table(TABLE_DROPBOX_PERSON);
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
         $mailId = get_mail_id_base();
314 314
 
315 315
         // Insert data in dropbox_post and dropbox_person table for each recipient
316
-		foreach ($this->recipients as $rec) {
316
+        foreach ($this->recipients as $rec) {
317 317
             $file_id = (int)$this->id;
318 318
             $user_id = (int)$rec['id'];
319
-			$sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
319
+            $sql = "INSERT INTO $table_post (c_id, file_id, dest_user_id, session_id, feedback_date, cat_id)
320 320
                     VALUES ($course_id, $file_id, $user_id, $session_id, '$now', 0)";
321
-	        Database::query($sql);
321
+            Database::query($sql);
322 322
             // If work already exists no error is generated
323 323
 
324 324
             /**
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
                 }
336 336
             }
337 337
 
338
-			// Update item_property table for each recipient
339
-			if (($ownerid = $this->uploader_id) > $mailId) {
340
-			    $ownerid = getUserOwningThisMailing($ownerid);
341
-			}
342
-			if (($recipid = $rec["id"]) > $mailId) {
343
-			    $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
344
-			}
338
+            // Update item_property table for each recipient
339
+            if (($ownerid = $this->uploader_id) > $mailId) {
340
+                $ownerid = getUserOwningThisMailing($ownerid);
341
+            }
342
+            if (($recipid = $rec["id"]) > $mailId) {
343
+                $recipid = $ownerid;  // mailing file recipient = mailing id, not a person
344
+            }
345 345
             api_item_property_update(
346 346
                 $_course,
347 347
                 TOOL_DROPBOX,
@@ -351,90 +351,90 @@  discard block
 block discarded – undo
351 351
                 null,
352 352
                 $recipid
353 353
             );
354
-		}
355
-	}
356
-
357
-	/**
358
-	 * private function creating existing object by retreiving info from db
359
-	 *
360
-	 * @param unknown_type $id
361
-	 */
362
-	public function _createExistingSentWork($id)
354
+        }
355
+    }
356
+
357
+    /**
358
+     * private function creating existing object by retreiving info from db
359
+     *
360
+     * @param unknown_type $id
361
+     */
362
+    public function _createExistingSentWork($id)
363 363
     {
364 364
         $id = intval($id);
365 365
 
366
-		$course_id = api_get_course_int_id();
366
+        $course_id = api_get_course_int_id();
367 367
 
368
-		// Call constructor of Dropbox_Work object
369
-		parent::__construct($id);
368
+        // Call constructor of Dropbox_Work object
369
+        parent::__construct($id);
370 370
 
371
-		// Fill in recipients array
372
-		$this->recipients = array();
373
-		$sql = "SELECT dest_user_id, feedback_date, feedback
371
+        // Fill in recipients array
372
+        $this->recipients = array();
373
+        $sql = "SELECT dest_user_id, feedback_date, feedback
374 374
 				FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
375 375
 				WHERE c_id = $course_id AND file_id = ".intval($id)."";
376 376
         $result = Database::query($sql);
377
-		while ($res = Database::fetch_array($result, 'ASSOC')) {
378
-			// Check for deleted users
379
-			$dest_user_id = $res['dest_user_id'];
380
-			$user_info = api_get_user_info($dest_user_id);
381
-			//$this->category = $res['cat_id'];
382
-			if (!$user_info) {
383
-				$this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
384
-			} else {
385
-				$this->recipients[] = array(
377
+        while ($res = Database::fetch_array($result, 'ASSOC')) {
378
+            // Check for deleted users
379
+            $dest_user_id = $res['dest_user_id'];
380
+            $user_info = api_get_user_info($dest_user_id);
381
+            //$this->category = $res['cat_id'];
382
+            if (!$user_info) {
383
+                $this->recipients[] = array('id' => -1, 'name' => get_lang('Unknown', ''));
384
+            } else {
385
+                $this->recipients[] = array(
386 386
                     'id' => $dest_user_id,
387 387
                     'name' => $user_info['complete_name'],
388 388
                     'user_id' => $dest_user_id,
389
-				    'feedback_date' => $res['feedback_date'],
389
+                    'feedback_date' => $res['feedback_date'],
390 390
                     'feedback' => $res['feedback']
391 391
                 );
392
-			}
393
-		}
394
-	}
392
+            }
393
+        }
394
+    }
395 395
 }
396 396
 
397 397
 class Dropbox_Person
398 398
 {
399
-	// The receivedWork and the sentWork arrays are sorted.
400
-	public $receivedWork;	// an array of Dropbox_Work objects
401
-	public $sentWork;		// an array of Dropbox_SentWork objects
402
-
403
-	public $userId = 0;
404
-	public $isCourseAdmin = false;
405
-	public $isCourseTutor = false;
406
-	public $_orderBy = '';	// private property that determines by which field
407
-
408
-	/**
409
-	 * Constructor for recreating the Dropbox_Person object
410
-	 *
411
-	 * @param int $userId
412
-	 * @param bool $isCourseAdmin
413
-	 * @param bool $isCourseTutor
414
-	 * @return Dropbox_Person
415
-	 */
416
-	public function __construct($userId, $isCourseAdmin, $isCourseTutor)
399
+    // The receivedWork and the sentWork arrays are sorted.
400
+    public $receivedWork;	// an array of Dropbox_Work objects
401
+    public $sentWork;		// an array of Dropbox_SentWork objects
402
+
403
+    public $userId = 0;
404
+    public $isCourseAdmin = false;
405
+    public $isCourseTutor = false;
406
+    public $_orderBy = '';	// private property that determines by which field
407
+
408
+    /**
409
+     * Constructor for recreating the Dropbox_Person object
410
+     *
411
+     * @param int $userId
412
+     * @param bool $isCourseAdmin
413
+     * @param bool $isCourseTutor
414
+     * @return Dropbox_Person
415
+     */
416
+    public function __construct($userId, $isCourseAdmin, $isCourseTutor)
417 417
     {
418
-	    $course_id = api_get_course_int_id();
418
+        $course_id = api_get_course_int_id();
419 419
 
420
-		// Fill in properties
420
+        // Fill in properties
421 421
         $this->userId = $userId;
422 422
         $this->isCourseAdmin = $isCourseAdmin;
423 423
         $this->isCourseTutor = $isCourseTutor;
424 424
         $this->receivedWork = array();
425 425
         $this->sentWork = array();
426 426
 
427
-		// Note: perhaps include an ex coursemember check to delete old files
427
+        // Note: perhaps include an ex coursemember check to delete old files
428 428
 
429
-		$session_id = api_get_session_id();
430
-		$condition_session = api_get_session_condition($session_id);
429
+        $session_id = api_get_session_id();
430
+        $condition_session = api_get_session_condition($session_id);
431 431
 
432
-		$post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
433
-		$person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
434
-		$file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
432
+        $post_tbl = Database::get_course_table(TABLE_DROPBOX_POST);
433
+        $person_tbl = Database::get_course_table(TABLE_DROPBOX_PERSON);
434
+        $file_tbl = Database::get_course_table(TABLE_DROPBOX_FILE);
435 435
 
436 436
         // Find all entries where this person is the recipient
437
-		$sql = "SELECT DISTINCT r.file_id, r.cat_id
437
+        $sql = "SELECT DISTINCT r.file_id, r.cat_id
438 438
                 FROM $post_tbl r
439 439
                 INNER JOIN $person_tbl p
440 440
                     ON (r.file_id = p.file_id AND r.c_id = $course_id AND p.c_id = $course_id )
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
                      r.dest_user_id = ".intval($this->userId)." $condition_session ";
444 444
 
445 445
         $result = Database::query($sql);
446
-		while ($res = Database::fetch_array($result)) {
447
-			$temp = new Dropbox_Work($res['file_id']);
448
-			$temp->category = $res['cat_id'];
449
-			$this->receivedWork[] = $temp;
450
-		}
451
-		// Find all entries where this person is the sender/uploader
446
+        while ($res = Database::fetch_array($result)) {
447
+            $temp = new Dropbox_Work($res['file_id']);
448
+            $temp->category = $res['cat_id'];
449
+            $this->receivedWork[] = $temp;
450
+        }
451
+        // Find all entries where this person is the sender/uploader
452 452
         $sql = "SELECT DISTINCT f.id
453 453
 				FROM $file_tbl f
454 454
 				INNER JOIN $person_tbl p
@@ -459,160 +459,160 @@  discard block
 block discarded – undo
459 459
                     $condition_session
460 460
                 ";
461 461
         $result = Database::query($sql);
462
-		while ($res = Database::fetch_array($result)) {
463
-			$this->sentWork[] = new Dropbox_SentWork($res['id']);
464
-		}
465
-	}
466
-
467
-	/**
468
-	 * Deletes all the received work of this person
469
-	 */
470
-	public function deleteAllReceivedWork()
462
+        while ($res = Database::fetch_array($result)) {
463
+            $this->sentWork[] = new Dropbox_SentWork($res['id']);
464
+        }
465
+    }
466
+
467
+    /**
468
+     * Deletes all the received work of this person
469
+     */
470
+    public function deleteAllReceivedWork()
471 471
     {
472
-	    $course_id = api_get_course_int_id();
473
-		// Delete entries in person table concerning received works
474
-		foreach ($this->receivedWork as $w) {
472
+        $course_id = api_get_course_int_id();
473
+        // Delete entries in person table concerning received works
474
+        foreach ($this->receivedWork as $w) {
475 475
             $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
476 476
 			        WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
477
-			Database::query($sql);
478
-		}
477
+            Database::query($sql);
478
+        }
479 479
         // Check for unused files
480
-		removeUnusedFiles();
481
-	}
482
-
483
-	/**
484
-	 * Deletes all the received categories and work of this person
485
-	 * @param integer $id
486
-	 */
487
-	public function deleteReceivedWorkFolder($id)
480
+        removeUnusedFiles();
481
+    }
482
+
483
+    /**
484
+     * Deletes all the received categories and work of this person
485
+     * @param integer $id
486
+     */
487
+    public function deleteReceivedWorkFolder($id)
488 488
     {
489 489
         $course_id = api_get_course_int_id();
490 490
 
491
-		$id = intval($id);
492
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
491
+        $id = intval($id);
492
+        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_FILE) ."
493 493
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
494
-		if (!Database::query($sql)) return false;
495
-		$sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
494
+        if (!Database::query($sql)) return false;
495
+        $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_CATEGORY) ."
496 496
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
497
-		if (!Database::query($sql)) return false;
498
-		$sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
497
+        if (!Database::query($sql)) return false;
498
+        $sql = "DELETE FROM ".Database::get_course_table(TABLE_DROPBOX_POST)."
499 499
 		        WHERE c_id = $course_id AND cat_id = '".$id."' ";
500
-		if (!Database::query($sql)) return false;
501
-		return true;
502
-	}
503
-
504
-	/**
505
-	 * Deletes a received dropbox file of this person with id=$id
506
-	 *
507
-	 * @param integer $id
508
-	 */
509
-	public function deleteReceivedWork($id)
500
+        if (!Database::query($sql)) return false;
501
+        return true;
502
+    }
503
+
504
+    /**
505
+     * Deletes a received dropbox file of this person with id=$id
506
+     *
507
+     * @param integer $id
508
+     */
509
+    public function deleteReceivedWork($id)
510 510
     {
511
-	    $course_id = api_get_course_int_id();
512
-		$id = intval($id);
513
-
514
-		// index check
515
-		$found = false;
516
-		foreach ($this->receivedWork as $w) {
517
-			if ($w->id == $id) {
518
-			   $found = true;
519
-			   break;
520
-			}
521
-		}
522
-
523
-		if (!$found) {
524
-			if (!$this->deleteReceivedWorkFolder($id)) {
525
-				die(get_lang('GeneralError').' (code 216)');
526
-			}
527
-		}
528
-		// Delete entries in person table concerning received works
511
+        $course_id = api_get_course_int_id();
512
+        $id = intval($id);
513
+
514
+        // index check
515
+        $found = false;
516
+        foreach ($this->receivedWork as $w) {
517
+            if ($w->id == $id) {
518
+                $found = true;
519
+                break;
520
+            }
521
+        }
522
+
523
+        if (!$found) {
524
+            if (!$this->deleteReceivedWorkFolder($id)) {
525
+                die(get_lang('GeneralError').' (code 216)');
526
+            }
527
+        }
528
+        // Delete entries in person table concerning received works
529 529
         $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
530 530
                 WHERE c_id = $course_id AND user_id = '".$this->userId."' AND file_id ='".$id."'";
531
-		Database::query($sql);
532
-		removeUnusedFiles();	// Check for unused files
533
-	}
534
-
535
-	/**
536
-	 * Deletes all the sent dropbox files of this person
537
-	 */
538
-	public function deleteAllSentWork()
531
+        Database::query($sql);
532
+        removeUnusedFiles();	// Check for unused files
533
+    }
534
+
535
+    /**
536
+     * Deletes all the sent dropbox files of this person
537
+     */
538
+    public function deleteAllSentWork()
539 539
     {
540
-	    $course_id = api_get_course_int_id();
541
-		//delete entries in person table concerning sent works
542
-		foreach ($this->sentWork as $w) {
540
+        $course_id = api_get_course_int_id();
541
+        //delete entries in person table concerning sent works
542
+        foreach ($this->sentWork as $w) {
543 543
             $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
544 544
                     WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$w->id."'";
545
-			Database::query($sql);
546
-			removeMoreIfMailing($w->id);
547
-		}
548
-		removeUnusedFiles();	// Check for unused files
549
-	}
550
-
551
-	/**
552
-	 * Deletes a sent dropbox file of this person with id=$id
553
-	 *
554
-	 * @param unknown_type $id
555
-	 */
556
-	public function deleteSentWork($id)
545
+            Database::query($sql);
546
+            removeMoreIfMailing($w->id);
547
+        }
548
+        removeUnusedFiles();	// Check for unused files
549
+    }
550
+
551
+    /**
552
+     * Deletes a sent dropbox file of this person with id=$id
553
+     *
554
+     * @param unknown_type $id
555
+     */
556
+    public function deleteSentWork($id)
557 557
     {
558
-	    $course_id = api_get_course_int_id();
559
-
560
-		$id = intval($id);
561
-
562
-		// index check
563
-		$found = false;
564
-		foreach ($this->sentWork as $w) {
565
-			if ($w->id == $id) {
566
-			   $found = true;
567
-			   break;
568
-			}
569
-		}
570
-		if (!$found) {
571
-			if (!$this->deleteReceivedWorkFolder($id)) {
572
-				die(get_lang('GeneralError').' (code 219)');
573
-			}
574
-		}
575
-		//$file_id = $this->sentWork[$index]->id;
576
-		// Delete entries in person table concerning sent works
558
+        $course_id = api_get_course_int_id();
559
+
560
+        $id = intval($id);
561
+
562
+        // index check
563
+        $found = false;
564
+        foreach ($this->sentWork as $w) {
565
+            if ($w->id == $id) {
566
+                $found = true;
567
+                break;
568
+            }
569
+        }
570
+        if (!$found) {
571
+            if (!$this->deleteReceivedWorkFolder($id)) {
572
+                die(get_lang('GeneralError').' (code 219)');
573
+            }
574
+        }
575
+        //$file_id = $this->sentWork[$index]->id;
576
+        // Delete entries in person table concerning sent works
577 577
         $sql = "DELETE FROM ". Database::get_course_table(TABLE_DROPBOX_PERSON) ."
578 578
                 WHERE c_id = $course_id AND user_id='".$this->userId."' AND file_id='".$id."'";
579
-		Database::query($sql);
580
-		removeMoreIfMailing($id);
581
-		removeUnusedFiles();	// Check for unused files
582
-	}
583
-
584
-	/**
585
-	 * Updates feedback for received work of this person with id=$id
586
-	 *
587
-	 * @param string $id
588
-	 * @param string $text
589
-	 */
590
-	public function updateFeedback($id, $text)
579
+        Database::query($sql);
580
+        removeMoreIfMailing($id);
581
+        removeUnusedFiles();	// Check for unused files
582
+    }
583
+
584
+    /**
585
+     * Updates feedback for received work of this person with id=$id
586
+     *
587
+     * @param string $id
588
+     * @param string $text
589
+     */
590
+    public function updateFeedback($id, $text)
591 591
     {
592
-	    $course_id = api_get_course_int_id();
592
+        $course_id = api_get_course_int_id();
593 593
         $_course = api_get_course_info();
594 594
         $dropbox_cnf = getDropboxConf();
595 595
 
596
-		$id = intval($id);
596
+        $id = intval($id);
597 597
 
598
-		// index check
599
-		$found = false;
600
-		$wi = -1;
601
-		foreach ($this->receivedWork as $w) {
602
-			$wi++;
603
-			if ($w->id == $id){
604
-			   $found = true;
605
-			   break;
606
-			}  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
607
-		}
598
+        // index check
599
+        $found = false;
600
+        $wi = -1;
601
+        foreach ($this->receivedWork as $w) {
602
+            $wi++;
603
+            if ($w->id == $id){
604
+                $found = true;
605
+                break;
606
+            }  // foreach (... as $wi -> $w) gives error 221! (no idea why...)
607
+        }
608 608
 
609
-		if (!$found) {
610
-			return false;
611
-		}
609
+        if (!$found) {
610
+            return false;
611
+        }
612 612
 
613
-		$feedback_date = api_get_utc_datetime();
614
-		$this->receivedWork[$wi]->feedback_date = $feedback_date;
615
-		$this->receivedWork[$wi]->feedback = $text;
613
+        $feedback_date = api_get_utc_datetime();
614
+        $this->receivedWork[$wi]->feedback_date = $feedback_date;
615
+        $this->receivedWork[$wi]->feedback = $text;
616 616
 
617 617
         $params = [
618 618
             'feedback_date' => $feedback_date,
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
             ]
631 631
         );
632 632
 
633
-		// Update item_property table
633
+        // Update item_property table
634 634
         $mailId = get_mail_id_base();
635
-		if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
636
-		    $ownerid = getUserOwningThisMailing($ownerid);
637
-		}
635
+        if (($ownerid = $this->receivedWork[$wi]->uploader_id) > $mailId) {
636
+            $ownerid = getUserOwningThisMailing($ownerid);
637
+        }
638 638
 
639 639
         api_item_property_update(
640 640
             $_course,
@@ -646,33 +646,33 @@  discard block
 block discarded – undo
646 646
             $ownerid
647 647
         );
648 648
 
649
-	}
649
+    }
650 650
 
651
-	/**
652
-	 * Filter the received work
653
-	 * @param string $type
654
-	 * @param string $value
655
-	 */
656
-	public function filter_received_work($type, $value)
651
+    /**
652
+     * Filter the received work
653
+     * @param string $type
654
+     * @param string $value
655
+     */
656
+    public function filter_received_work($type, $value)
657 657
     {
658 658
         $dropbox_cnf = getDropboxConf();
659
-    	$new_received_work = array();
659
+        $new_received_work = array();
660 660
         $mailId = get_mail_id_base();
661 661
         foreach ($this->receivedWork as $work) {
662
-			switch ($type) {
663
-				case 'uploader_id':
664
-					if ($work->uploader_id == $value ||
665
-						($work->uploader_id > $mailId &&
662
+            switch ($type) {
663
+                case 'uploader_id':
664
+                    if ($work->uploader_id == $value ||
665
+                        ($work->uploader_id > $mailId &&
666 666
                         getUserOwningThisMailing($work->uploader_id) == $value)
667 667
                     ) {
668
-						$new_received_work[] = $work;
669
-					}
670
-					break;
671
-				default:
672
-					$new_received_work[] = $work;
668
+                        $new_received_work[] = $work;
669
+                    }
670
+                    break;
671
+                default:
672
+                    $new_received_work[] = $work;
673 673
                     break;
674
-			}
675
-		}
676
-		$this->receivedWork = $new_received_work;
677
-	}
674
+            }
675
+        }
676
+        $this->receivedWork = $new_received_work;
677
+    }
678 678
 }
Please login to merge, or discard this patch.
main/inc/lib/chat.lib.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
     }
40 40
 
41 41
     /**
42
-    * Set user chat status
43
-    * @param int 0 if disconnected, 1 if connected
44
-    * @param integer $status
42
+     * Set user chat status
43
+     * @param int 0 if disconnected, 1 if connected
44
+     * @param integer $status
45 45
      *
46
-    * @return void
47
-    */
46
+     * @return void
47
+     */
48 48
     public function setUserStatus($status)
49 49
     {
50 50
         UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status);
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
     }
149 149
 
150 150
     /**
151
-    * Returns an array of messages inside a chat session with a specific user
152
-    * @param int The ID of the user with whom the current user is chatting
153
-    * @return array Messages list
154
-    */
151
+     * Returns an array of messages inside a chat session with a specific user
152
+     * @param int The ID of the user with whom the current user is chatting
153
+     * @return array Messages list
154
+     */
155 155
     public function box_session($user_id)
156 156
     {
157 157
         $items = array();
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
             }
300 300
         }
301 301
          
302
-         return false;
302
+            return false;
303 303
     }
304 304
     
305 305
     public function is_chat_blocked_by_exercises()
Please login to merge, or discard this patch.
plugin/courselegal/plugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,6 +5,6 @@
 block discarded – undo
5 5
  * @author Imanol Losada Oriol <[email protected]>
6 6
  * @package chamilo.plugin.skype
7 7
  */
8
-require_once __DIR__ . '/config.php';
8
+require_once __DIR__.'/config.php';
9 9
 
10 10
 Skype::create()->install();
Please login to merge, or discard this patch.
plugin/courseblock/plugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,6 +5,6 @@
 block discarded – undo
5 5
  * @author Imanol Losada Oriol <[email protected]>
6 6
  * @package chamilo.plugin.skype
7 7
  */
8
-require_once __DIR__ . '/config.php';
8
+require_once __DIR__.'/config.php';
9 9
 
10 10
 Skype::create()->install();
Please login to merge, or discard this patch.
plugin/courseblock/install.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 /* For license terms, see /license.txt */
3 3
 
4
-require_once dirname(__FILE__) . '/config.php';
4
+require_once dirname(__FILE__).'/config.php';
5 5
 
6 6
 if (!api_is_platform_admin()) {
7 7
     die ('You must have admin permissions to install plugins');
Please login to merge, or discard this patch.
plugin/courseblock/config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @package chamilo.plugin.clockworksms
8 8
  * @author  Imanol Losada <[email protected]>
9 9
  */
10
-require_once __DIR__ . '/../../main/inc/global.inc.php';
10
+require_once __DIR__.'/../../main/inc/global.inc.php';
11 11
 
12 12
 require_once 'lib/clockworksms.lib.php';
13 13
 require_once 'vendor/clockworksms_api.php';
Please login to merge, or discard this patch.
main/admin/configure_plugin.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 $message = '';
29 29
 $content = '';
30 30
 
31
-$currentUrl = api_get_self() . "?name=$pluginName";
31
+$currentUrl = api_get_self()."?name=$pluginName";
32 32
 
33 33
 if (isset($pluginInfo['settings_form'])) {
34 34
     /** @var FormValidator $form */
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         foreach ($values as $key => $value) {
70 70
             api_add_setting(
71 71
                 $value,
72
-                Database::escape_string($pluginName . '_' . $key),
72
+                Database::escape_string($pluginName.'_'.$key),
73 73
                 $pluginName,
74 74
                 'setting',
75 75
                 'Plugins',
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 }
100 100
 
101 101
 $interbreadcrumb[] = array(
102
-    'url' => api_get_path(WEB_CODE_PATH) . 'admin/index.php',
102
+    'url' => api_get_path(WEB_CODE_PATH).'admin/index.php',
103 103
     'name' => get_lang('PlatformAdmin')
104 104
 );
105 105
 $interbreadcrumb[] = array(
106
-    'url' => api_get_path(WEB_CODE_PATH) . 'admin/settings.php?category=Plugins',
106
+    'url' => api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins',
107 107
     'name' => get_lang('Plugins')
108 108
 );
109 109
 
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/Message.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@
 block discarded – undo
314 314
      * Set votes
315 315
      *
316 316
      * @param integer $votes
317
-     * @return integer
317
+     * @return Message
318 318
      */
319 319
     public function setVotes($votes)
320 320
     {
Please login to merge, or discard this patch.