@@ -184,7 +184,8 @@ |
||
184 | 184 | * @param int End date, in YYYYMMDD format |
185 | 185 | * @return array Events list |
186 | 186 | */ |
187 | -function WSEventsList($username, $signature, $datestart = 0, $dateend = 0) { |
|
187 | +function WSEventsList($username, $signature, $datestart = 0, $dateend = 0) |
|
188 | +{ |
|
188 | 189 | |
189 | 190 | if (empty($username) or empty($signature)) { return -1; } |
190 | 191 |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | define('WS_ERROR_SECRET_KEY', 1); |
22 | 22 | |
23 | -function return_error($code) { |
|
23 | +function return_error($code) |
|
24 | +{ |
|
24 | 25 | $fault = null; |
25 | 26 | switch ($code) { |
26 | 27 | case WS_ERROR_SECRET_KEY: |
@@ -48,19 +49,22 @@ discard block |
||
48 | 49 | list($ip1) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); |
49 | 50 | $ip = trim($ip1); |
50 | 51 | } |
51 | - if ($debug) |
|
52 | - error_log("ip: $ip"); |
|
52 | + if ($debug) { |
|
53 | + error_log("ip: $ip"); |
|
54 | + } |
|
53 | 55 | // Check if a file that limits access from webservices exists and contains |
54 | 56 | // the restraining check |
55 | 57 | if (is_file('webservice-auth-ip.conf.php')) { |
56 | 58 | include 'webservice-auth-ip.conf.php'; |
57 | - if ($debug) |
|
58 | - error_log("webservice-auth-ip.conf.php file included"); |
|
59 | + if ($debug) { |
|
60 | + error_log("webservice-auth-ip.conf.php file included"); |
|
61 | + } |
|
59 | 62 | if (!empty($ws_auth_ip)) { |
60 | 63 | $check_ip = true; |
61 | 64 | $ip_matches = api_check_ip_in_range($ip, $ws_auth_ip); |
62 | - if ($debug) |
|
63 | - error_log("ip_matches: $ip_matches"); |
|
65 | + if ($debug) { |
|
66 | + error_log("ip_matches: $ip_matches"); |
|
67 | + } |
|
64 | 68 | } |
65 | 69 | } |
66 | 70 | |
@@ -76,8 +80,9 @@ discard block |
||
76 | 80 | } |
77 | 81 | $result = api_is_valid_secret_key($secret_key, $security_key); |
78 | 82 | //error_log($secret_key.'-'.$security_key); |
79 | - if ($debug) |
|
80 | - error_log('WSHelperVerifyKey result: '.intval($result)); |
|
83 | + if ($debug) { |
|
84 | + error_log('WSHelperVerifyKey result: '.intval($result)); |
|
85 | + } |
|
81 | 86 | return $result; |
82 | 87 | } |
83 | 88 | |
@@ -140,7 +145,9 @@ discard block |
||
140 | 145 | if (!WSHelperVerifyKey($params)) { |
141 | 146 | return return_error(WS_ERROR_SECRET_KEY); |
142 | 147 | } |
143 | - if ($debug) error_log('WSImportLP'); |
|
148 | + if ($debug) { |
|
149 | + error_log('WSImportLP'); |
|
150 | + } |
|
144 | 151 | |
145 | 152 | $courseIdName = $params['course_id_name']; |
146 | 153 | $courseIdValue = $params['course_id_value']; |
@@ -156,7 +163,9 @@ discard block |
||
156 | 163 | $courseId = $courseInfo['real_id']; |
157 | 164 | |
158 | 165 | if (empty($courseInfo)) { |
159 | - if ($debug) error_log('Course not found'); |
|
166 | + if ($debug) { |
|
167 | + error_log('Course not found'); |
|
168 | + } |
|
160 | 169 | return 'Course not found'; |
161 | 170 | } |
162 | 171 | |
@@ -169,7 +178,9 @@ discard block |
||
169 | 178 | |
170 | 179 | if (empty($sessionId)) { |
171 | 180 | |
172 | - if ($debug) error_log('Session not found'); |
|
181 | + if ($debug) { |
|
182 | + error_log('Session not found'); |
|
183 | + } |
|
173 | 184 | return 'Session not found'; |
174 | 185 | } |
175 | 186 | } |
@@ -196,7 +207,9 @@ discard block |
||
196 | 207 | $manifest = $oScorm->import_package($fileInfo, '', $courseInfo); |
197 | 208 | |
198 | 209 | if (!$manifest) { |
199 | - if ($debug) error_log('manifest.xml file not found'); |
|
210 | + if ($debug) { |
|
211 | + error_log('manifest.xml file not found'); |
|
212 | + } |
|
200 | 213 | return 'manifest.xml file not found'; |
201 | 214 | } |
202 | 215 | |
@@ -214,10 +227,14 @@ discard block |
||
214 | 227 | $oScorm->set_maker($maker, $courseId); |
215 | 228 | //$oScorm->set_jslib('scorm_api.php'); |
216 | 229 | |
217 | - if ($debug) error_log('scorm was added'); |
|
230 | + if ($debug) { |
|
231 | + error_log('scorm was added'); |
|
232 | + } |
|
218 | 233 | return 1; |
219 | 234 | } else { |
220 | - if ($debug) error_log('manifest data empty'); |
|
235 | + if ($debug) { |
|
236 | + error_log('manifest data empty'); |
|
237 | + } |
|
221 | 238 | return 'manifest data empty'; |
222 | 239 | } |
223 | 240 | } |
@@ -310,7 +327,9 @@ discard block |
||
310 | 327 | ); |
311 | 328 | |
312 | 329 | if (empty($courseInfo)) { |
313 | - if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); |
|
330 | + if ($debug) { |
|
331 | + error_log("Course not found: $courseIdName : $courseIdValue"); |
|
332 | + } |
|
314 | 333 | return 'Course not found'; |
315 | 334 | } |
316 | 335 | |
@@ -324,7 +343,9 @@ discard block |
||
324 | 343 | ); |
325 | 344 | |
326 | 345 | if (empty($sessionId)) { |
327 | - if ($debug) error_log('Session not found'); |
|
346 | + if ($debug) { |
|
347 | + error_log('Session not found'); |
|
348 | + } |
|
328 | 349 | return 'Session not found'; |
329 | 350 | } |
330 | 351 | } |
@@ -405,7 +426,9 @@ discard block |
||
405 | 426 | ); |
406 | 427 | |
407 | 428 | if (empty($courseInfo)) { |
408 | - if ($debug) error_log("Course not found: $courseIdName : $courseIdValue"); |
|
429 | + if ($debug) { |
|
430 | + error_log("Course not found: $courseIdName : $courseIdValue"); |
|
431 | + } |
|
409 | 432 | return 'Course not found'; |
410 | 433 | } |
411 | 434 | $courseId = $courseInfo['real_id']; |
@@ -430,7 +453,9 @@ discard block |
||
430 | 453 | |
431 | 454 | $lp = new learnpath($courseCode, $lpId, null); |
432 | 455 | if ($lp) { |
433 | - if ($debug) error_log("LP deleted $lpId"); |
|
456 | + if ($debug) { |
|
457 | + error_log("LP deleted $lpId"); |
|
458 | + } |
|
434 | 459 | |
435 | 460 | $course_dir = $courseInfo['directory'].'/document'; |
436 | 461 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
@@ -446,7 +471,9 @@ discard block |
||
446 | 471 | if ($item) { |
447 | 472 | $documentId = $item->get_path(); |
448 | 473 | |
449 | - if ($debug) error_log("lp item id found #$itemId"); |
|
474 | + if ($debug) { |
|
475 | + error_log("lp item id found #$itemId"); |
|
476 | + } |
|
450 | 477 | |
451 | 478 | $documentInfo = DocumentManager::get_document_data_by_id( |
452 | 479 | $documentId, |
@@ -472,7 +499,9 @@ discard block |
||
472 | 499 | } |
473 | 500 | } |
474 | 501 | } else { |
475 | - if ($debug) error_log("Document not found #$itemId"); |
|
502 | + if ($debug) { |
|
503 | + error_log("Document not found #$itemId"); |
|
504 | + } |
|
476 | 505 | } |
477 | 506 | } |
478 | 507 | } |
@@ -545,8 +545,9 @@ |
||
545 | 545 | $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); |
546 | 546 | $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'); |
547 | 547 | $scoreinfo = get_lang('StatsStudent').' :<b> '.$user['complete_name'].'</b><br />'; |
548 | - if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) |
|
549 | - $scoreinfo .= '<br />'.get_lang('TotalForThisCategory').' : <b>'.$scorecourse_display.'</b>'; |
|
548 | + if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) { |
|
549 | + $scoreinfo .= '<br />'.get_lang('TotalForThisCategory').' : <b>'.$scorecourse_display.'</b>'; |
|
550 | + } |
|
550 | 551 | $scoreinfo .= '<br />'.get_lang('Total').' : <b>'.$scoretotal_display.'</b>'; |
551 | 552 | Display::addFlash( |
552 | 553 | Display::return_message($scoreinfo, 'normal', false) |
@@ -3964,7 +3964,8 @@ discard block |
||
3964 | 3964 | if ($num > 0) { |
3965 | 3965 | $i = 1; |
3966 | 3966 | while ($row = Database::fetch_array($res)) { |
3967 | - if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it. |
|
3967 | + if ($row['display_order'] != $i) { |
|
3968 | +// If we find a gap in the order, we need to fix it. |
|
3968 | 3969 | $sql = "UPDATE $lp_table SET display_order = $i |
3969 | 3970 | WHERE c_id = $courseId AND id = ".$row['id']; |
3970 | 3971 | Database::query($sql); |
@@ -3975,9 +3976,11 @@ discard block |
||
3975 | 3976 | $i++; |
3976 | 3977 | } |
3977 | 3978 | } |
3978 | - if ($num > 1) { // If there's only one element, no need to sort. |
|
3979 | + if ($num > 1) { |
|
3980 | +// If there's only one element, no need to sort. |
|
3979 | 3981 | $order = $lps[$lp_id]['display_order']; |
3980 | - if ($order > 1) { // If it's the first element, no need to move up. |
|
3982 | + if ($order > 1) { |
|
3983 | +// If it's the first element, no need to move up. |
|
3981 | 3984 | $sql = "UPDATE $lp_table SET display_order = $order |
3982 | 3985 | WHERE c_id = $courseId AND id = ".$lp_order[$order - 1]; |
3983 | 3986 | Database::query($sql); |
@@ -4037,9 +4040,11 @@ discard block |
||
4037 | 4040 | $i++; |
4038 | 4041 | } |
4039 | 4042 | } |
4040 | - if ($num > 1) { // If there's only one element, no need to sort. |
|
4043 | + if ($num > 1) { |
|
4044 | +// If there's only one element, no need to sort. |
|
4041 | 4045 | $order = $lps[$lp_id]['display_order']; |
4042 | - if ($order < $max) { // If it's the first element, no need to move up. |
|
4046 | + if ($order < $max) { |
|
4047 | +// If it's the first element, no need to move up. |
|
4043 | 4048 | $sql_u1 = "UPDATE $lp_table SET display_order = $order |
4044 | 4049 | WHERE c_id = ".$courseId." AND id = ".$lp_order[$order + 1]; |
4045 | 4050 | Database::query($sql_u1); |
@@ -4842,8 +4847,9 @@ discard block |
||
4842 | 4847 | if ($this->debug > 0) { |
4843 | 4848 | error_log('New LP - In learnpath::set_maker()', 0); |
4844 | 4849 | } |
4845 | - if (empty ($name)) |
|
4846 | - return false; |
|
4850 | + if (empty ($name)) { |
|
4851 | + return false; |
|
4852 | + } |
|
4847 | 4853 | $this->maker = $name; |
4848 | 4854 | $lp_table = Database::get_course_table(TABLE_LP_MAIN); |
4849 | 4855 | $course_id = api_get_course_int_id(); |
@@ -4908,8 +4914,9 @@ discard block |
||
4908 | 4914 | public function set_terms_by_prefix($terms_string, $prefix) |
4909 | 4915 | { |
4910 | 4916 | $course_id = api_get_course_int_id(); |
4911 | - if (api_get_setting('search_enabled') !== 'true') |
|
4912 | - return false; |
|
4917 | + if (api_get_setting('search_enabled') !== 'true') { |
|
4918 | + return false; |
|
4919 | + } |
|
4913 | 4920 | |
4914 | 4921 | if (!extension_loaded('xapian')) { |
4915 | 4922 | return false; |
@@ -4922,8 +4929,9 @@ discard block |
||
4922 | 4929 | $stored_terms = $this->get_common_index_terms_by_prefix($prefix); |
4923 | 4930 | |
4924 | 4931 | // Don't do anything if no change, verify only at DB, not the search engine. |
4925 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
4926 | - return false; |
|
4932 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
4933 | + return false; |
|
4934 | + } |
|
4927 | 4935 | |
4928 | 4936 | require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API. |
4929 | 4937 | require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
@@ -5112,8 +5120,9 @@ discard block |
||
5112 | 5120 | if ($this->debug > 0) { |
5113 | 5121 | error_log('New LP - In learnpath::set_proximity()', 0); |
5114 | 5122 | } |
5115 | - if (empty ($name)) |
|
5116 | - return false; |
|
5123 | + if (empty ($name)) { |
|
5124 | + return false; |
|
5125 | + } |
|
5117 | 5126 | |
5118 | 5127 | $this->proximity = $name; |
5119 | 5128 | $lp_table = Database::get_course_table(TABLE_LP_MAIN); |
@@ -6708,10 +6717,12 @@ discard block |
||
6708 | 6717 | if ($new_comment || $new_title) { |
6709 | 6718 | $tbl_doc = Database::get_course_table(TABLE_DOCUMENT); |
6710 | 6719 | $ct = ''; |
6711 | - if ($new_comment) |
|
6712 | - $ct .= ", comment='".Database::escape_string($new_comment)."'"; |
|
6713 | - if ($new_title) |
|
6714 | - $ct .= ", title='".Database::escape_string($new_title)."' "; |
|
6720 | + if ($new_comment) { |
|
6721 | + $ct .= ", comment='".Database::escape_string($new_comment)."'"; |
|
6722 | + } |
|
6723 | + if ($new_title) { |
|
6724 | + $ct .= ", title='".Database::escape_string($new_title)."' "; |
|
6725 | + } |
|
6715 | 6726 | |
6716 | 6727 | $sql = "UPDATE ".$tbl_doc." SET ".substr($ct, 1)." |
6717 | 6728 | WHERE c_id = ".$course_id." AND id = ".$document_id; |
@@ -7443,8 +7454,9 @@ discard block |
||
7443 | 7454 | $arrHide[] = $arrLP[$i]['id']; |
7444 | 7455 | } |
7445 | 7456 | } else { |
7446 | - if ($arrLP[$i]['item_type'] == 'dir') |
|
7447 | - $return .= '<option '.(($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '').'style="padding-left:'.($arrLP[$i]['depth'] * 10).'px;" value="'.$arrLP[$i]['id'].'">'.$arrLP[$i]['title'].'</option>'; |
|
7457 | + if ($arrLP[$i]['item_type'] == 'dir') { |
|
7458 | + $return .= '<option '.(($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '').'style="padding-left:'.($arrLP[$i]['depth'] * 10).'px;" value="'.$arrLP[$i]['id'].'">'.$arrLP[$i]['title'].'</option>'; |
|
7459 | + } |
|
7448 | 7460 | } |
7449 | 7461 | } |
7450 | 7462 | reset($arrLP); |
@@ -7461,11 +7473,13 @@ discard block |
||
7461 | 7473 | |
7462 | 7474 | for ($i = 0; $i < count($arrLP); $i++) { |
7463 | 7475 | if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { |
7464 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7476 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7477 | + $selected = 'selected="selected" '; |
|
7478 | + } elseif ($action == 'add') { |
|
7465 | 7479 | $selected = 'selected="selected" '; |
7466 | - elseif ($action == 'add') $selected = 'selected="selected" '; |
|
7467 | - else |
|
7468 | - $selected = ''; |
|
7480 | + } else { |
|
7481 | + $selected = ''; |
|
7482 | + } |
|
7469 | 7483 | |
7470 | 7484 | $return .= '<option '.$selected.'value="'.$arrLP[$i]['id'].'">'.get_lang('After').' "'.$arrLP[$i]['title'].'"</option>'; |
7471 | 7485 | } |
@@ -7492,9 +7506,11 @@ discard block |
||
7492 | 7506 | $arrHide = array(); |
7493 | 7507 | for ($i = 0; $i < count($arrLP); $i++) { |
7494 | 7508 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
7495 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7496 | - $s_selected_position = $arrLP[$i]['id']; |
|
7497 | - elseif ($action == 'add') $s_selected_position = 0; |
|
7509 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7510 | + $s_selected_position = $arrLP[$i]['id']; |
|
7511 | + } elseif ($action == 'add') { |
|
7512 | + $s_selected_position = 0; |
|
7513 | + } |
|
7498 | 7514 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7499 | 7515 | } |
7500 | 7516 | } |
@@ -7917,9 +7933,11 @@ discard block |
||
7917 | 7933 | $s_selected_position = 0; |
7918 | 7934 | for ($i = 0; $i < count($arrLP); $i++) { |
7919 | 7935 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
7920 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7921 | - $s_selected_position = $arrLP[$i]['id']; |
|
7922 | - elseif ($action == 'add') $s_selected_position = 0; |
|
7936 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7937 | + $s_selected_position = $arrLP[$i]['id']; |
|
7938 | + } elseif ($action == 'add') { |
|
7939 | + $s_selected_position = 0; |
|
7940 | + } |
|
7923 | 7941 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7924 | 7942 | |
7925 | 7943 | } |
@@ -7953,8 +7971,7 @@ discard block |
||
7953 | 7971 | |
7954 | 7972 | if (is_numeric($extra_info)) { |
7955 | 7973 | $form->addHidden('path', $extra_info); |
7956 | - } |
|
7957 | - elseif (is_array($extra_info)) { |
|
7974 | + } elseif (is_array($extra_info)) { |
|
7958 | 7975 | $form->addHidden('path', $extra_info['path']); |
7959 | 7976 | } |
7960 | 7977 | |
@@ -8818,9 +8835,11 @@ discard block |
||
8818 | 8835 | $arrHide = array(); |
8819 | 8836 | for ($i = 0; $i < count($arrLP); $i++) { |
8820 | 8837 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
8821 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
8822 | - $s_selected_position = $arrLP[$i]['id']; |
|
8823 | - elseif ($action == 'add') $s_selected_position = 0; |
|
8838 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
8839 | + $s_selected_position = $arrLP[$i]['id']; |
|
8840 | + } elseif ($action == 'add') { |
|
8841 | + $s_selected_position = 0; |
|
8842 | + } |
|
8824 | 8843 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
8825 | 8844 | |
8826 | 8845 | } |
@@ -9020,9 +9039,11 @@ discard block |
||
9020 | 9039 | $arrHide = array(); |
9021 | 9040 | for ($i = 0; $i < count($arrLP); $i++) { |
9022 | 9041 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dir') { |
9023 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
9024 | - $s_selected_position = $arrLP[$i]['id']; |
|
9025 | - elseif ($action == 'add') $s_selected_position = 0; |
|
9042 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
9043 | + $s_selected_position = $arrLP[$i]['id']; |
|
9044 | + } elseif ($action == 'add') { |
|
9045 | + $s_selected_position = 0; |
|
9046 | + } |
|
9026 | 9047 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
9027 | 9048 | |
9028 | 9049 | } |
@@ -10232,10 +10253,11 @@ discard block |
||
10232 | 10253 | |
10233 | 10254 | // Dependency to other files - not yet supported. |
10234 | 10255 | $i = 1; |
10235 | - if ($inc_docs) |
|
10236 | - foreach ($inc_docs as $doc_info) { |
|
10256 | + if ($inc_docs) { |
|
10257 | + foreach ($inc_docs as $doc_info) { |
|
10237 | 10258 | if (count($doc_info) < 1 || empty($doc_info[0])) { |
10238 | 10259 | continue; |
10260 | + } |
|
10239 | 10261 | } |
10240 | 10262 | $my_dep = $xmldoc->createElement('resource'); |
10241 | 10263 | $res_id = 'RESOURCE_'.$item->get_id().'_'.$i; |
@@ -10686,7 +10708,8 @@ discard block |
||
10686 | 10708 | |
10687 | 10709 | // File path is courses/CHAMILO/document/.... |
10688 | 10710 | $info_file_path = explode('/', $file_path); |
10689 | - if ($info_file_path[0] == 'courses') { // Add character "/" in file path. |
|
10711 | + if ($info_file_path[0] == 'courses') { |
|
10712 | +// Add character "/" in file path. |
|
10690 | 10713 | $file_path_dest = 'document/'.$file_path; |
10691 | 10714 | } |
10692 | 10715 |
@@ -198,7 +198,8 @@ discard block |
||
198 | 198 | $sf_terms, |
199 | 199 | $op, |
200 | 200 | $prefilter_prefix = null |
201 | -) { |
|
201 | +) |
|
202 | +{ |
|
202 | 203 | $thesaurus_icon = Display::return_icon('thesaurus.gif', get_lang('SearchAdvancedOptions'), array('id'=>'thesaurus-icon')); |
203 | 204 | $advanced_options = '<a id="tags-toggle" href="#">'.get_lang('SearchAdvancedOptions').'</a>'; |
204 | 205 | $display_thesaurus = ($show_thesaurus == true ? 'block' : 'none'); |
@@ -336,7 +337,8 @@ discard block |
||
336 | 337 | $specific_fields = get_specific_field_list(); |
337 | 338 | $url_params = array(); |
338 | 339 | |
339 | - if (($cid = api_get_course_id()) != -1) { // with cid |
|
340 | + if (($cid = api_get_course_id()) != -1) { |
|
341 | +// with cid |
|
340 | 342 | |
341 | 343 | // get search engine terms |
342 | 344 | $course_filter = chamilo_get_boolean_query(XAPIAN_PREFIX_COURSEID.$cid); |
@@ -354,7 +356,8 @@ discard block |
||
354 | 356 | $url_params[] = 'sf_'.$specific_field['code']; |
355 | 357 | unset($temp); |
356 | 358 | } |
357 | - } else { // without cid |
|
359 | + } else { |
|
360 | +// without cid |
|
358 | 361 | // prepare specific fields names (and also get possible URL param names) |
359 | 362 | foreach ($specific_fields as $specific_field) { |
360 | 363 | //get Xapian terms for a specific term prefix, in ISO, apparently |
@@ -366,9 +369,10 @@ discard block |
||
366 | 369 | |
367 | 370 | // Tool introduction |
368 | 371 | // TODO: Settings for the online editor to be checked (insert an image for example). Probably this is a special case here. |
369 | - if (api_get_course_id() !== -1) |
|
370 | - if (!empty($groupId)) { |
|
372 | + if (api_get_course_id() !== -1) { |
|
373 | + if (!empty($groupId)) { |
|
371 | 374 | Display::display_introduction_section(TOOL_SEARCH.$groupId); |
375 | + } |
|
372 | 376 | } else { |
373 | 377 | Display::display_introduction_section(TOOL_SEARCH); |
374 | 378 | } |
@@ -2440,8 +2440,9 @@ discard block |
||
2440 | 2440 | if (empty($user_id)) { |
2441 | 2441 | $user_id = 0; |
2442 | 2442 | } else { |
2443 | - if ($user_id != strval(intval($user_id))) |
|
2444 | - return array(); |
|
2443 | + if ($user_id != strval(intval($user_id))) { |
|
2444 | + return array(); |
|
2445 | + } |
|
2445 | 2446 | } |
2446 | 2447 | $extra_data = array(); |
2447 | 2448 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
@@ -2533,8 +2534,9 @@ discard block |
||
2533 | 2534 | if (empty($user_id)) { |
2534 | 2535 | $user_id = 0; |
2535 | 2536 | } else { |
2536 | - if ($user_id != strval(intval($user_id))) |
|
2537 | - return array(); |
|
2537 | + if ($user_id != strval(intval($user_id))) { |
|
2538 | + return array(); |
|
2539 | + } |
|
2538 | 2540 | } |
2539 | 2541 | $extra_data = array(); |
2540 | 2542 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
@@ -2651,7 +2653,7 @@ discard block |
||
2651 | 2653 | * @return array with extra data info of a user i.e array('field_variable'=>'value'); |
2652 | 2654 | */ |
2653 | 2655 | public static function get_extra_user_data_by_value($variable, $value, $all_visibility = true) |
2654 | - { |
|
2656 | + { |
|
2655 | 2657 | $extraFieldValue = new ExtraFieldValue('user'); |
2656 | 2658 | $extraField = new ExtraField('user'); |
2657 | 2659 | |
@@ -3354,13 +3356,15 @@ discard block |
||
3354 | 3356 | */ |
3355 | 3357 | public static function get_api_keys($user_id = null, $api_service = 'dokeos') |
3356 | 3358 | { |
3357 | - if ($user_id != strval(intval($user_id))) |
|
3358 | - return false; |
|
3359 | + if ($user_id != strval(intval($user_id))) { |
|
3360 | + return false; |
|
3361 | + } |
|
3359 | 3362 | if (empty($user_id)) { |
3360 | 3363 | $user_id = api_get_user_id(); |
3361 | 3364 | } |
3362 | - if ($user_id === false) |
|
3363 | - return false; |
|
3365 | + if ($user_id === false) { |
|
3366 | + return false; |
|
3367 | + } |
|
3364 | 3368 | $service_name = Database::escape_string($api_service); |
3365 | 3369 | if (is_string($service_name) === false) { |
3366 | 3370 | return false; |
@@ -3368,11 +3372,14 @@ discard block |
||
3368 | 3372 | $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
3369 | 3373 | $sql = "SELECT * FROM $t_api WHERE user_id = $user_id AND api_service='$api_service';"; |
3370 | 3374 | $res = Database::query($sql); |
3371 | - if ($res === false) |
|
3372 | - return false; //error during query |
|
3375 | + if ($res === false) { |
|
3376 | + return false; |
|
3377 | + } |
|
3378 | + //error during query |
|
3373 | 3379 | $num = Database::num_rows($res); |
3374 | - if ($num == 0) |
|
3375 | - return false; |
|
3380 | + if ($num == 0) { |
|
3381 | + return false; |
|
3382 | + } |
|
3376 | 3383 | $list = array(); |
3377 | 3384 | while ($row = Database::fetch_array($res)) { |
3378 | 3385 | $list[$row['id']] = $row['api_key']; |
@@ -3387,13 +3394,15 @@ discard block |
||
3387 | 3394 | */ |
3388 | 3395 | public static function add_api_key($user_id = null, $api_service = 'dokeos') |
3389 | 3396 | { |
3390 | - if ($user_id != strval(intval($user_id))) |
|
3391 | - return false; |
|
3397 | + if ($user_id != strval(intval($user_id))) { |
|
3398 | + return false; |
|
3399 | + } |
|
3392 | 3400 | if (empty($user_id)) { |
3393 | 3401 | $user_id = api_get_user_id(); |
3394 | 3402 | } |
3395 | - if ($user_id === false) |
|
3396 | - return false; |
|
3403 | + if ($user_id === false) { |
|
3404 | + return false; |
|
3405 | + } |
|
3397 | 3406 | $service_name = Database::escape_string($api_service); |
3398 | 3407 | if (is_string($service_name) === false) { |
3399 | 3408 | return false; |
@@ -3402,8 +3411,10 @@ discard block |
||
3402 | 3411 | $md5 = md5((time() + ($user_id * 5)) - rand(10000, 10000)); //generate some kind of random key |
3403 | 3412 | $sql = "INSERT INTO $t_api (user_id, api_key,api_service) VALUES ($user_id,'$md5','$service_name')"; |
3404 | 3413 | $res = Database::query($sql); |
3405 | - if ($res === false) |
|
3406 | - return false; //error during query |
|
3414 | + if ($res === false) { |
|
3415 | + return false; |
|
3416 | + } |
|
3417 | + //error during query |
|
3407 | 3418 | $num = Database::insert_id(); |
3408 | 3419 | return ($num == 0) ? false : $num; |
3409 | 3420 | } |
@@ -3415,22 +3426,29 @@ discard block |
||
3415 | 3426 | */ |
3416 | 3427 | public static function delete_api_key($key_id) |
3417 | 3428 | { |
3418 | - if ($key_id != strval(intval($key_id))) |
|
3419 | - return false; |
|
3420 | - if ($key_id === false) |
|
3421 | - return false; |
|
3429 | + if ($key_id != strval(intval($key_id))) { |
|
3430 | + return false; |
|
3431 | + } |
|
3432 | + if ($key_id === false) { |
|
3433 | + return false; |
|
3434 | + } |
|
3422 | 3435 | $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
3423 | 3436 | $sql = "SELECT * FROM $t_api WHERE id = ".$key_id; |
3424 | 3437 | $res = Database::query($sql); |
3425 | - if ($res === false) |
|
3426 | - return false; //error during query |
|
3438 | + if ($res === false) { |
|
3439 | + return false; |
|
3440 | + } |
|
3441 | + //error during query |
|
3427 | 3442 | $num = Database::num_rows($res); |
3428 | - if ($num !== 1) |
|
3429 | - return false; |
|
3443 | + if ($num !== 1) { |
|
3444 | + return false; |
|
3445 | + } |
|
3430 | 3446 | $sql = "DELETE FROM $t_api WHERE id = ".$key_id; |
3431 | 3447 | $res = Database::query($sql); |
3432 | - if ($res === false) |
|
3433 | - return false; //error during query |
|
3448 | + if ($res === false) { |
|
3449 | + return false; |
|
3450 | + } |
|
3451 | + //error during query |
|
3434 | 3452 | return true; |
3435 | 3453 | } |
3436 | 3454 | |
@@ -3442,10 +3460,12 @@ discard block |
||
3442 | 3460 | */ |
3443 | 3461 | public static function update_api_key($user_id, $api_service) |
3444 | 3462 | { |
3445 | - if ($user_id != strval(intval($user_id))) |
|
3446 | - return false; |
|
3447 | - if ($user_id === false) |
|
3448 | - return false; |
|
3463 | + if ($user_id != strval(intval($user_id))) { |
|
3464 | + return false; |
|
3465 | + } |
|
3466 | + if ($user_id === false) { |
|
3467 | + return false; |
|
3468 | + } |
|
3449 | 3469 | $service_name = Database::escape_string($api_service); |
3450 | 3470 | if (is_string($service_name) === false) { |
3451 | 3471 | return false; |
@@ -3472,12 +3492,15 @@ discard block |
||
3472 | 3492 | */ |
3473 | 3493 | public static function get_api_key_id($user_id, $api_service) |
3474 | 3494 | { |
3475 | - if ($user_id != strval(intval($user_id))) |
|
3476 | - return false; |
|
3477 | - if ($user_id === false) |
|
3478 | - return false; |
|
3479 | - if (empty($api_service)) |
|
3480 | - return false; |
|
3495 | + if ($user_id != strval(intval($user_id))) { |
|
3496 | + return false; |
|
3497 | + } |
|
3498 | + if ($user_id === false) { |
|
3499 | + return false; |
|
3500 | + } |
|
3501 | + if (empty($api_service)) { |
|
3502 | + return false; |
|
3503 | + } |
|
3481 | 3504 | $t_api = Database::get_main_table(TABLE_MAIN_USER_API_KEY); |
3482 | 3505 | $api_service = Database::escape_string($api_service); |
3483 | 3506 | $sql = "SELECT id FROM $t_api |
@@ -5418,8 +5441,9 @@ discard block |
||
5418 | 5441 | $url .= "?s=$s&d=$d&r=$r"; |
5419 | 5442 | if ($img) { |
5420 | 5443 | $url = '<img src="'.$url.'"'; |
5421 | - foreach ($atts as $key => $val) |
|
5422 | - $url .= ' '.$key.'="'.$val.'"'; |
|
5444 | + foreach ($atts as $key => $val) { |
|
5445 | + $url .= ' '.$key.'="'.$val.'"'; |
|
5446 | + } |
|
5423 | 5447 | $url .= ' />'; |
5424 | 5448 | } |
5425 | 5449 | return $url; |
@@ -1045,7 +1045,8 @@ discard block |
||
1045 | 1045 | $id, |
1046 | 1046 | $current_visibility_status, |
1047 | 1047 | $additional_url_parameters = '' |
1048 | -) { |
|
1048 | +) |
|
1049 | +{ |
|
1049 | 1050 | $html = ''; |
1050 | 1051 | $id = (int) $id; |
1051 | 1052 | $current_visibility_status = (int) $current_visibility_status; |
@@ -1513,7 +1514,8 @@ discard block |
||
1513 | 1514 | $course_code = '', |
1514 | 1515 | $includeGroupsForum = true, |
1515 | 1516 | $sessionId = 0 |
1516 | -) { |
|
1517 | +) |
|
1518 | +{ |
|
1517 | 1519 | $course_info = api_get_course_info($course_code); |
1518 | 1520 | |
1519 | 1521 | $table_forums = Database::get_course_table(TABLE_FORUM); |
@@ -1992,7 +1994,8 @@ discard block |
||
1992 | 1994 | $recursive = false, |
1993 | 1995 | $postId = null, |
1994 | 1996 | $depth = -1 |
1995 | -) { |
|
1997 | +) |
|
1998 | +{ |
|
1996 | 1999 | $em = Database::getManager(); |
1997 | 2000 | |
1998 | 2001 | if (api_is_allowed_to_edit(false, true)) { |
@@ -2577,7 +2580,8 @@ discard block |
||
2577 | 2580 | $showMessage = true, |
2578 | 2581 | $userId = 0, |
2579 | 2582 | $sessionId = 0 |
2580 | -) { |
|
2583 | +) |
|
2584 | +{ |
|
2581 | 2585 | $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo; |
2582 | 2586 | $userId = $userId ?: api_get_user_id(); |
2583 | 2587 | $course_id = $courseInfo['real_id']; |
@@ -3138,7 +3142,8 @@ discard block |
||
3138 | 3142 | $thread_qualify = 0, |
3139 | 3143 | $qualify_time, |
3140 | 3144 | $session_id = 0 |
3141 | -) { |
|
3145 | +) |
|
3146 | +{ |
|
3142 | 3147 | $table_threads_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
3143 | 3148 | $table_threads = Database::get_course_table(TABLE_FORUM_THREAD); |
3144 | 3149 | |
@@ -3327,7 +3332,8 @@ discard block |
||
3327 | 3332 | $course_id, |
3328 | 3333 | $user_id, |
3329 | 3334 | $thread_id |
3330 | -) { |
|
3335 | +) |
|
3336 | +{ |
|
3331 | 3337 | $table_threads_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); |
3332 | 3338 | $table_threads_qualify_log = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY_LOG); |
3333 | 3339 | |
@@ -3549,7 +3555,8 @@ discard block |
||
3549 | 3555 | $current_forum, |
3550 | 3556 | $form_values = '', |
3551 | 3557 | $id_attach = 0 |
3552 | -) { |
|
3558 | +) |
|
3559 | +{ |
|
3553 | 3560 | // Initialize the object. |
3554 | 3561 | $form = new FormValidator( |
3555 | 3562 | 'edit_post', |
@@ -5706,7 +5713,8 @@ discard block |
||
5706 | 5713 | * @param null $courseId Course ID to find row to update. |
5707 | 5714 | * @return int Number of affected rows. |
5708 | 5715 | */ |
5709 | -function editAttachedFile($array, $id, $courseId = null) { |
|
5716 | +function editAttachedFile($array, $id, $courseId = null) |
|
5717 | +{ |
|
5710 | 5718 | // Init variables |
5711 | 5719 | $setString = ''; |
5712 | 5720 | $id = intval($id); |
@@ -5835,7 +5843,8 @@ discard block |
||
5835 | 5843 | $postId = 0, |
5836 | 5844 | $attachId = 0, |
5837 | 5845 | $courseId = 0 |
5838 | -) { |
|
5846 | +) |
|
5847 | +{ |
|
5839 | 5848 | $forumId = intval($forumId); |
5840 | 5849 | $courseId = intval($courseId); |
5841 | 5850 | $attachId = intval($attachId); |
@@ -871,7 +871,8 @@ |
||
871 | 871 | WHERE dokeos_folder = "'.$event_message_language.'" |
872 | 872 | )'; |
873 | 873 | Database::query($sql); |
874 | - } else { // else we create a new record |
|
874 | + } else { |
|
875 | +// else we create a new record |
|
875 | 876 | // gets the language_-_id |
876 | 877 | $lang_id = '(SELECT id FROM '.Database::get_main_table(TABLE_MAIN_LANGUAGE).' |
877 | 878 | WHERE dokeos_folder = "'.$event_message_language.'")'; |
@@ -906,7 +906,8 @@ discard block |
||
906 | 906 | // becomes |
907 | 907 | // http://localhost/chamilo/courses/TEST/document/image.png |
908 | 908 | // TEST is a course directory name, so called "system course code". |
909 | - if (strpos($path, 'download.php') !== false) { // Fast detection first. |
|
909 | + if (strpos($path, 'download.php') !== false) { |
|
910 | +// Fast detection first. |
|
910 | 911 | $path = urldecode($path); |
911 | 912 | if (preg_match('/(.*)main\/document\/download.php\?doc_url=\/(.*)&cDir=\/(.*)?/', $path, $matches)) { |
912 | 913 | $sys_course_code = |
@@ -938,7 +939,8 @@ discard block |
||
938 | 939 | global $_configuration; |
939 | 940 | $web_root = api_get_path(WEB_PATH); |
940 | 941 | $ext = substr($web_path, strrpos($web_path, '.')); |
941 | - if (isset($ext[2])) { // faster version of strlen to check if len>2 |
|
942 | + if (isset($ext[2])) { |
|
943 | +// faster version of strlen to check if len>2 |
|
942 | 944 | // Check for CDN definitions |
943 | 945 | if (!empty($_configuration['cdn_enable']) && !empty($ext)) { |
944 | 946 | foreach ($_configuration['cdn'] as $host => $exts) { |
@@ -957,7 +959,8 @@ discard block |
||
957 | 959 | * @return bool Return true if CAS authentification is activated |
958 | 960 | * |
959 | 961 | */ |
960 | -function api_is_cas_activated() { |
|
962 | +function api_is_cas_activated() |
|
963 | +{ |
|
961 | 964 | return api_get_setting('cas_activate') == "true"; |
962 | 965 | } |
963 | 966 | |
@@ -965,7 +968,8 @@ discard block |
||
965 | 968 | * @return bool Return true if LDAP authentification is activated |
966 | 969 | * |
967 | 970 | */ |
968 | -function api_is_ldap_activated() { |
|
971 | +function api_is_ldap_activated() |
|
972 | +{ |
|
969 | 973 | global $extAuthSource; |
970 | 974 | return is_array($extAuthSource[LDAP_AUTH_SOURCE]); |
971 | 975 | } |
@@ -1012,7 +1016,8 @@ discard block |
||
1012 | 1016 | * Note: The built-in function filter_var($urs, FILTER_VALIDATE_URL) has a bug for some versions of PHP. |
1013 | 1017 | * @link http://bugs.php.net/51192 |
1014 | 1018 | */ |
1015 | -function api_valid_url($url, $absolute = false) { |
|
1019 | +function api_valid_url($url, $absolute = false) |
|
1020 | +{ |
|
1016 | 1021 | if ($absolute) { |
1017 | 1022 | if (preg_match(" |
1018 | 1023 | /^ # Start at the beginning of the text |
@@ -1208,7 +1213,8 @@ discard block |
||
1208 | 1213 | /** |
1209 | 1214 | * @return array with the navigator name and version |
1210 | 1215 | */ |
1211 | -function api_get_navigator() { |
|
1216 | +function api_get_navigator() |
|
1217 | +{ |
|
1212 | 1218 | $navigator = 'Unknown'; |
1213 | 1219 | $version = 0; |
1214 | 1220 | |
@@ -1327,10 +1333,12 @@ discard block |
||
1327 | 1333 | |
1328 | 1334 | $result['firstname'] = null; |
1329 | 1335 | $result['lastname'] = null; |
1330 | - if (isset($user['firstname']) && isset($user['lastname'])) { // with only lowercase |
|
1336 | + if (isset($user['firstname']) && isset($user['lastname'])) { |
|
1337 | +// with only lowercase |
|
1331 | 1338 | $result['firstname'] = $user['firstname']; |
1332 | 1339 | $result['lastname'] = $user['lastname']; |
1333 | - } elseif (isset($user['firstName']) && isset($user['lastName'])) { // with uppercase letters |
|
1340 | + } elseif (isset($user['firstName']) && isset($user['lastName'])) { |
|
1341 | +// with uppercase letters |
|
1334 | 1342 | $result['firstname'] = isset($user['firstName']) ? $user['firstName'] : null; |
1335 | 1343 | $result['lastname'] = isset($user['lastName']) ? $user['lastName'] : null; |
1336 | 1344 | } |
@@ -1489,7 +1497,8 @@ discard block |
||
1489 | 1497 | $loadOnlyVisibleExtraData = false, |
1490 | 1498 | $loadAvatars = true, |
1491 | 1499 | $updateCache = false |
1492 | -) { |
|
1500 | +) |
|
1501 | +{ |
|
1493 | 1502 | $apcVar = null; |
1494 | 1503 | $user = false; |
1495 | 1504 | $cacheAvailable = api_get_configuration_value('apc'); |
@@ -2270,7 +2279,8 @@ discard block |
||
2270 | 2279 | $session_id, |
2271 | 2280 | $courseId = null, |
2272 | 2281 | $ignore_visibility_for_admins = true |
2273 | -) { |
|
2282 | +) |
|
2283 | +{ |
|
2274 | 2284 | if (api_is_platform_admin()) { |
2275 | 2285 | if ($ignore_visibility_for_admins) { |
2276 | 2286 | return SESSION_AVAILABLE; |
@@ -2377,7 +2387,8 @@ discard block |
||
2377 | 2387 | { |
2378 | 2388 | $session_id = (int) $session_id; |
2379 | 2389 | $session_img = ''; |
2380 | - if ((int) $status_id != 5) { //check whether is not a student |
|
2390 | + if ((int) $status_id != 5) { |
|
2391 | +//check whether is not a student |
|
2381 | 2392 | if ($session_id > 0) { |
2382 | 2393 | $session_img = " ".Display::return_icon( |
2383 | 2394 | 'star.png', |
@@ -2403,7 +2414,8 @@ discard block |
||
2403 | 2414 | $and = true, |
2404 | 2415 | $with_base_content = false, |
2405 | 2416 | $session_field = 'session_id' |
2406 | -) { |
|
2417 | +) |
|
2418 | +{ |
|
2407 | 2419 | $session_id = intval($session_id); |
2408 | 2420 | |
2409 | 2421 | if (empty($session_field)) { |
@@ -2977,7 +2989,8 @@ discard block |
||
2977 | 2989 | $coach = false, |
2978 | 2990 | $session_coach = false, |
2979 | 2991 | $check_student_view = true |
2980 | -) { |
|
2992 | +) |
|
2993 | +{ |
|
2981 | 2994 | $sessionId = api_get_session_id(); |
2982 | 2995 | $is_allowed_coach_to_edit = api_is_coach(null, null, $check_student_view); |
2983 | 2996 | $session_visibility = api_get_session_visibility($sessionId); |
@@ -3279,7 +3292,8 @@ discard block |
||
3279 | 3292 | function api_not_allowed( |
3280 | 3293 | $print_headers = false, |
3281 | 3294 | $message = null |
3282 | -) { |
|
3295 | +) |
|
3296 | +{ |
|
3283 | 3297 | if (api_get_setting('sso_authentication') === 'true') { |
3284 | 3298 | global $osso; |
3285 | 3299 | if ($osso) { |
@@ -3534,7 +3548,8 @@ discard block |
||
3534 | 3548 | $user_id = null, |
3535 | 3549 | $type = null, |
3536 | 3550 | $group_id = null |
3537 | -) { |
|
3551 | +) |
|
3552 | +{ |
|
3538 | 3553 | if (!is_array($_course) || count($_course) == 0 || empty($tool) || empty($id)) { |
3539 | 3554 | return -1; |
3540 | 3555 | } |
@@ -3601,7 +3616,8 @@ discard block |
||
3601 | 3616 | $userId, |
3602 | 3617 | $groupId = 0, |
3603 | 3618 | $sessionId = 0 |
3604 | -) { |
|
3619 | +) |
|
3620 | +{ |
|
3605 | 3621 | if (empty($courseInfo)) { |
3606 | 3622 | return false; |
3607 | 3623 | } |
@@ -3676,7 +3692,8 @@ discard block |
||
3676 | 3692 | $start_visible = '', |
3677 | 3693 | $end_visible = '', |
3678 | 3694 | $session_id = 0 |
3679 | -) { |
|
3695 | +) |
|
3696 | +{ |
|
3680 | 3697 | if (empty($_course)) { |
3681 | 3698 | return false; |
3682 | 3699 | } |
@@ -4006,7 +4023,8 @@ discard block |
||
4006 | 4023 | $tool, |
4007 | 4024 | $courseId, |
4008 | 4025 | $session_id = 0 |
4009 | -) { |
|
4026 | +) |
|
4027 | +{ |
|
4010 | 4028 | $userId = intval($userId); |
4011 | 4029 | $tool = Database::escape_string($tool); |
4012 | 4030 | $session_id = intval($session_id); |
@@ -4461,18 +4479,21 @@ discard block |
||
4461 | 4479 | switch ($lang_type) { |
4462 | 4480 | case 'platform_lang': |
4463 | 4481 | $temp_lang = api_get_setting('platformLanguage'); |
4464 | - if (!empty($temp_lang)) |
|
4465 | - $return = $temp_lang; |
|
4482 | + if (!empty($temp_lang)) { |
|
4483 | + $return = $temp_lang; |
|
4484 | + } |
|
4466 | 4485 | break; |
4467 | 4486 | case 'user_profil_lang': |
4468 | 4487 | $_user = api_get_user_info(); |
4469 | 4488 | |
4470 | - if (isset($_user['language']) && !empty($_user['language'])) |
|
4471 | - $return = $_user['language']; |
|
4489 | + if (isset($_user['language']) && !empty($_user['language'])) { |
|
4490 | + $return = $_user['language']; |
|
4491 | + } |
|
4472 | 4492 | break; |
4473 | 4493 | case 'user_selected_lang': |
4474 | - if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) |
|
4475 | - $return = $_SESSION['user_language_choice']; |
|
4494 | + if (isset($_SESSION['user_language_choice']) && !empty($_SESSION['user_language_choice'])) { |
|
4495 | + $return = $_SESSION['user_language_choice']; |
|
4496 | + } |
|
4476 | 4497 | break; |
4477 | 4498 | case 'course_lang': |
4478 | 4499 | global $_course; |
@@ -4774,7 +4795,8 @@ discard block |
||
4774 | 4795 | * @author Yannick Warnier, adaptation for the Chamilo LMS, April, 2008 |
4775 | 4796 | * @author Ivan Tcholakov, a sanity check about Directory class creation has been added, September, 2009 |
4776 | 4797 | */ |
4777 | -function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = false) { |
|
4798 | +function rmdirr($dirname, $delete_only_content_in_folder = false, $strict = false) |
|
4799 | +{ |
|
4778 | 4800 | $res = true; |
4779 | 4801 | // A sanity check. |
4780 | 4802 | if (!file_exists($dirname)) { |
@@ -4839,7 +4861,8 @@ discard block |
||
4839 | 4861 | * @param string $source |
4840 | 4862 | * @param string $dest |
4841 | 4863 | */ |
4842 | -function copyr($source, $dest, $exclude = array(), $copied_files = array()) { |
|
4864 | +function copyr($source, $dest, $exclude = array(), $copied_files = array()) |
|
4865 | +{ |
|
4843 | 4866 | if (empty($dest)) { return false; } |
4844 | 4867 | // Simple copy for a file |
4845 | 4868 | if (is_file($source)) { |
@@ -4889,7 +4912,8 @@ discard block |
||
4889 | 4912 | $course_info, |
4890 | 4913 | $document, |
4891 | 4914 | $source_course_id |
4892 | -) { |
|
4915 | +) |
|
4916 | +{ |
|
4893 | 4917 | $table = Database::get_course_table(TABLE_DOCUMENT); |
4894 | 4918 | $session_id = intval($session_id); |
4895 | 4919 | $source_course_id = intval($source_course_id); |
@@ -4970,7 +4994,8 @@ discard block |
||
4970 | 4994 | /** |
4971 | 4995 | * @param string $path |
4972 | 4996 | */ |
4973 | -function api_chmod_R($path, $filemode) { |
|
4997 | +function api_chmod_R($path, $filemode) |
|
4998 | +{ |
|
4974 | 4999 | if (!is_dir($path)) { |
4975 | 5000 | return chmod($path, $filemode); |
4976 | 5001 | } |
@@ -5057,7 +5082,8 @@ discard block |
||
5057 | 5082 | * @return |
5058 | 5083 | * The info array. |
5059 | 5084 | */ |
5060 | -function api_parse_info_file($filename) { |
|
5085 | +function api_parse_info_file($filename) |
|
5086 | +{ |
|
5061 | 5087 | $info = array(); |
5062 | 5088 | |
5063 | 5089 | if (!file_exists($filename)) { |
@@ -5146,7 +5172,8 @@ discard block |
||
5146 | 5172 | * @param mixed the status (can be either int either string) |
5147 | 5173 | * @return boolean if the status exists, else returns false |
5148 | 5174 | */ |
5149 | -function api_status_exists($status_asked) { |
|
5175 | +function api_status_exists($status_asked) |
|
5176 | +{ |
|
5150 | 5177 | global $_status_list; |
5151 | 5178 | return in_array($status_asked, $_status_list) ? true : isset($_status_list[$status_asked]); |
5152 | 5179 | } |
@@ -5159,7 +5186,8 @@ discard block |
||
5159 | 5186 | * @param mixed The status (can be either int or string) |
5160 | 5187 | * @return mixed Status ID if exists, false otherwise |
5161 | 5188 | */ |
5162 | -function api_status_key($status) { |
|
5189 | +function api_status_key($status) |
|
5190 | +{ |
|
5163 | 5191 | global $_status_list; |
5164 | 5192 | return isset($_status_list[$status]) ? $status : array_search($status, $_status_list); |
5165 | 5193 | } |
@@ -5168,7 +5196,8 @@ discard block |
||
5168 | 5196 | * Gets the status langvars list |
5169 | 5197 | * @return string[] the list of status with their translations |
5170 | 5198 | */ |
5171 | -function api_get_status_langvars() { |
|
5199 | +function api_get_status_langvars() |
|
5200 | +{ |
|
5172 | 5201 | return array( |
5173 | 5202 | COURSEMANAGER => get_lang('Teacher', ''), |
5174 | 5203 | SESSIONADMIN => get_lang('SessionsAdmin', ''), |
@@ -5184,7 +5213,8 @@ discard block |
||
5184 | 5213 | * The function that retrieves all the possible settings for a certain config setting |
5185 | 5214 | * @author Patrick Cool <[email protected]>, Ghent University |
5186 | 5215 | */ |
5187 | -function api_get_settings_options($var) { |
|
5216 | +function api_get_settings_options($var) |
|
5217 | +{ |
|
5188 | 5218 | $table_settings_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS); |
5189 | 5219 | $var = Database::escape_string($var); |
5190 | 5220 | $sql = "SELECT * FROM $table_settings_options |
@@ -5331,7 +5361,8 @@ discard block |
||
5331 | 5361 | "".(!empty($row['subkeytext']) ? "'".$row['subkeytext']."'" : "NULL").",$access_url,".$row['access_url_changeable'].")"; |
5332 | 5362 | Database::query($insert); |
5333 | 5363 | } |
5334 | - } else { // Such a setting does not exist. |
|
5364 | + } else { |
|
5365 | +// Such a setting does not exist. |
|
5335 | 5366 | //error_log(__FILE__.':'.__LINE__.': Attempting to update setting '.$var.' ('.$subvar.') which does not exist at all. The access_url is: '.$access_url.' ',0); |
5336 | 5367 | } |
5337 | 5368 | } |
@@ -5529,7 +5560,8 @@ discard block |
||
5529 | 5560 | $subKeyText = '', |
5530 | 5561 | $accessUrlId = 1, |
5531 | 5562 | $visibility = 0 |
5532 | -) { |
|
5563 | +) |
|
5564 | +{ |
|
5533 | 5565 | $em = Database::getManager(); |
5534 | 5566 | $settingRepo = $em->getRepository('ChamiloCoreBundle:SettingsCurrent'); |
5535 | 5567 | $accessUrlId = (int) $accessUrlId ?: 1; |
@@ -5588,7 +5620,8 @@ discard block |
||
5588 | 5620 | * @param int $cid Course id to check whether the user is allowed. |
5589 | 5621 | * @return bool |
5590 | 5622 | */ |
5591 | -function api_is_course_visible_for_user($userid = null, $cid = null) { |
|
5623 | +function api_is_course_visible_for_user($userid = null, $cid = null) |
|
5624 | +{ |
|
5592 | 5625 | if ($userid === null) { |
5593 | 5626 | $userid = api_get_user_id(); |
5594 | 5627 | } |
@@ -5675,8 +5708,7 @@ discard block |
||
5675 | 5708 | if ($row[0]['id_coach'] == $userid) { |
5676 | 5709 | $is_courseMember = true; |
5677 | 5710 | $is_courseAdmin = false; |
5678 | - } |
|
5679 | - elseif ($row[0]['session_admin_id'] == $userid) { |
|
5711 | + } elseif ($row[0]['session_admin_id'] == $userid) { |
|
5680 | 5712 | $is_courseMember = false; |
5681 | 5713 | $is_courseAdmin = false; |
5682 | 5714 | } else { |
@@ -5749,7 +5781,8 @@ discard block |
||
5749 | 5781 | * @param string $tool |
5750 | 5782 | * @return boolean true if the element is in the session, false else |
5751 | 5783 | */ |
5752 | -function api_is_element_in_the_session($tool, $element_id, $session_id = null) { |
|
5784 | +function api_is_element_in_the_session($tool, $element_id, $session_id = null) |
|
5785 | +{ |
|
5753 | 5786 | if (is_null($session_id)) { |
5754 | 5787 | $session_id = api_get_session_id(); |
5755 | 5788 | } |
@@ -5815,7 +5848,8 @@ discard block |
||
5815 | 5848 | * Fixes the $_SERVER['REQUEST_URI'] that is empty in IIS6. |
5816 | 5849 | * @author Ivan Tcholakov, 28-JUN-2006. |
5817 | 5850 | */ |
5818 | -function api_request_uri() { |
|
5851 | +function api_request_uri() |
|
5852 | +{ |
|
5819 | 5853 | if (!empty($_SERVER['REQUEST_URI'])) { |
5820 | 5854 | return $_SERVER['REQUEST_URI']; |
5821 | 5855 | } |
@@ -5832,7 +5866,8 @@ discard block |
||
5832 | 5866 | * @author Julio Montoya <[email protected]> |
5833 | 5867 | * @return int access_url_id of the current Chamilo Installation |
5834 | 5868 | */ |
5835 | -function api_get_current_access_url_id() { |
|
5869 | +function api_get_current_access_url_id() |
|
5870 | +{ |
|
5836 | 5871 | $access_url_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL); |
5837 | 5872 | $path = Database::escape_string(api_get_path(WEB_PATH)); |
5838 | 5873 | $sql = "SELECT id FROM $access_url_table WHERE url = '".$path."'"; |
@@ -5853,7 +5888,8 @@ discard block |
||
5853 | 5888 | * @author Julio Montoya <[email protected]> |
5854 | 5889 | * @return int user id |
5855 | 5890 | */ |
5856 | -function api_get_access_url_from_user($user_id) { |
|
5891 | +function api_get_access_url_from_user($user_id) |
|
5892 | +{ |
|
5857 | 5893 | $user_id = intval($user_id); |
5858 | 5894 | $table_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
5859 | 5895 | $table_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL); |
@@ -5971,8 +6007,7 @@ discard block |
||
5971 | 6007 | elseif (isset($_ENV['OS'])) { |
5972 | 6008 | // Sometimes $_ENV['OS'] may not be present (bugs?) |
5973 | 6009 | $os = $_ENV['OS']; |
5974 | - } |
|
5975 | - elseif (defined('PHP_OS')) { |
|
6010 | + } elseif (defined('PHP_OS')) { |
|
5976 | 6011 | // PHP_OS means on which OS PHP was compiled, this is why |
5977 | 6012 | // using PHP_OS is the last choice for detection. |
5978 | 6013 | $os = PHP_OS; |
@@ -6038,7 +6073,8 @@ discard block |
||
6038 | 6073 | $image_height, |
6039 | 6074 | $target_width, |
6040 | 6075 | $target_height |
6041 | -) { |
|
6076 | +) |
|
6077 | +{ |
|
6042 | 6078 | // Only maths is here. |
6043 | 6079 | $result = array('width' => $image_width, 'height' => $image_height); |
6044 | 6080 | if ($image_width <= 0 || $image_height <= 0) { |
@@ -6203,7 +6239,8 @@ discard block |
||
6203 | 6239 | $admin_id_to_check, |
6204 | 6240 | $my_user_id = null, |
6205 | 6241 | $allow_session_admin = false |
6206 | -) { |
|
6242 | +) |
|
6243 | +{ |
|
6207 | 6244 | if (empty($my_user_id)) { |
6208 | 6245 | $my_user_id = api_get_user_id(); |
6209 | 6246 | } |
@@ -6256,7 +6293,8 @@ discard block |
||
6256 | 6293 | * |
6257 | 6294 | * @author Julio Montoya |
6258 | 6295 | */ |
6259 | -function api_protect_global_admin_script() { |
|
6296 | +function api_protect_global_admin_script() |
|
6297 | +{ |
|
6260 | 6298 | if (!api_is_global_platform_admin()) { |
6261 | 6299 | api_not_allowed(); |
6262 | 6300 | return false; |
@@ -6490,7 +6528,8 @@ discard block |
||
6490 | 6528 | * |
6491 | 6529 | * @author Juan Carlos Raña Trabado |
6492 | 6530 | */ |
6493 | -function api_check_browscap() { |
|
6531 | +function api_check_browscap() |
|
6532 | +{ |
|
6494 | 6533 | $setting = ini_get('browscap'); |
6495 | 6534 | if ($setting) { |
6496 | 6535 | $browser = get_browser($_SERVER['HTTP_USER_AGENT'], true); |
@@ -6504,7 +6543,8 @@ discard block |
||
6504 | 6543 | /** |
6505 | 6544 | * Returns the <script> HTML tag |
6506 | 6545 | */ |
6507 | -function api_get_js($file) { |
|
6546 | +function api_get_js($file) |
|
6547 | +{ |
|
6508 | 6548 | return '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$file.'"></script>'."\n"; |
6509 | 6549 | } |
6510 | 6550 | |
@@ -6530,7 +6570,8 @@ discard block |
||
6530 | 6570 | * Returns the <link> HTML tag |
6531 | 6571 | * @param string $file |
6532 | 6572 | */ |
6533 | -function api_get_css($file, $media = 'screen') { |
|
6573 | +function api_get_css($file, $media = 'screen') |
|
6574 | +{ |
|
6534 | 6575 | return '<link href="'.$file.'" rel="stylesheet" media="'.$media.'" type="text/css" />'."\n"; |
6535 | 6576 | } |
6536 | 6577 | |
@@ -6573,7 +6614,8 @@ discard block |
||
6573 | 6614 | * @return string html tags |
6574 | 6615 | * |
6575 | 6616 | */ |
6576 | -function api_get_jquery_ui_js($include_jqgrid = false) { |
|
6617 | +function api_get_jquery_ui_js($include_jqgrid = false) |
|
6618 | +{ |
|
6577 | 6619 | $libraries = array(); |
6578 | 6620 | if ($include_jqgrid) { |
6579 | 6621 | $libraries[] = 'jqgrid'; |
@@ -6581,7 +6623,8 @@ discard block |
||
6581 | 6623 | return api_get_jquery_libraries_js($libraries); |
6582 | 6624 | } |
6583 | 6625 | |
6584 | -function api_get_jqgrid_js() { |
|
6626 | +function api_get_jqgrid_js() |
|
6627 | +{ |
|
6585 | 6628 | return api_get_jquery_libraries_js(array('jqgrid')); |
6586 | 6629 | } |
6587 | 6630 | |
@@ -6593,7 +6636,8 @@ discard block |
||
6593 | 6636 | * @return string html tags |
6594 | 6637 | * |
6595 | 6638 | */ |
6596 | -function api_get_jquery_libraries_js($libraries) { |
|
6639 | +function api_get_jquery_libraries_js($libraries) |
|
6640 | +{ |
|
6597 | 6641 | $js = ''; |
6598 | 6642 | $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
6599 | 6643 | |
@@ -6836,7 +6880,8 @@ discard block |
||
6836 | 6880 | * when printing the configuration settings screens |
6837 | 6881 | * @return array Array of strings, each identifying one of the excluded settings |
6838 | 6882 | */ |
6839 | -function api_get_locked_settings() { |
|
6883 | +function api_get_locked_settings() |
|
6884 | +{ |
|
6840 | 6885 | return array( |
6841 | 6886 | 'server_type', |
6842 | 6887 | 'permanently_remove_deleted_files', |
@@ -6877,7 +6922,8 @@ discard block |
||
6877 | 6922 | * @param integer User ID |
6878 | 6923 | * @return boolean Integer User ID is logged in, or false otherwise |
6879 | 6924 | */ |
6880 | -function api_user_is_login($user_id = null) { |
|
6925 | +function api_user_is_login($user_id = null) |
|
6926 | +{ |
|
6881 | 6927 | $user_id = empty($user_id) ? api_get_user_id() : intval($user_id); |
6882 | 6928 | return $user_id && !api_is_anonymous(); |
6883 | 6929 | } |
@@ -6903,7 +6949,9 @@ discard block |
||
6903 | 6949 | } |
6904 | 6950 | $ip = trim($ip1); |
6905 | 6951 | } |
6906 | - if (!empty($debug)) error_log('Real IP: '.$ip); |
|
6952 | + if (!empty($debug)) { |
|
6953 | + error_log('Real IP: '.$ip); |
|
6954 | + } |
|
6907 | 6955 | return $ip; |
6908 | 6956 | } |
6909 | 6957 | |
@@ -6991,7 +7039,8 @@ discard block |
||
6991 | 7039 | $courseInfo = array(), |
6992 | 7040 | $sessionId = 0, |
6993 | 7041 | $userId = 0 |
6994 | -) { |
|
7042 | +) |
|
7043 | +{ |
|
6995 | 7044 | $courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo; |
6996 | 7045 | $courseId = $courseInfo['real_id']; |
6997 | 7046 | $courseCode = $courseInfo['code']; |
@@ -7788,7 +7837,8 @@ discard block |
||
7788 | 7837 | * @param bool $listCampus Whether we authorize |
7789 | 7838 | * @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also. |
7790 | 7839 | */ |
7791 | -function api_register_campus($listCampus = true) { |
|
7840 | +function api_register_campus($listCampus = true) |
|
7841 | +{ |
|
7792 | 7842 | $tbl_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
7793 | 7843 | |
7794 | 7844 | $sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'"; |
@@ -7978,7 +8028,8 @@ discard block |
||
7978 | 8028 | $data_file = array(), |
7979 | 8029 | $embedded_image = false, |
7980 | 8030 | $additionalParameters = array() |
7981 | -) { |
|
8031 | +) |
|
8032 | +{ |
|
7982 | 8033 | global $platform_email; |
7983 | 8034 | |
7984 | 8035 | $mail = new PHPMailer(); |