@@ -3948,8 +3948,9 @@ discard block |
||
3948 | 3948 | WHERE c_id = ".$course_id." |
3949 | 3949 | ORDER BY display_order"; |
3950 | 3950 | $res = Database::query($sql); |
3951 | - if ($res === false) |
|
3952 | - return false; |
|
3951 | + if ($res === false) { |
|
3952 | + return false; |
|
3953 | + } |
|
3953 | 3954 | $lps = array (); |
3954 | 3955 | $lp_order = array (); |
3955 | 3956 | $num = Database :: num_rows($res); |
@@ -4549,8 +4550,9 @@ discard block |
||
4549 | 4550 | if ($this->debug > 0) { |
4550 | 4551 | error_log('New LP - In learnpath::set_maker()', 0); |
4551 | 4552 | } |
4552 | - if (empty ($name)) |
|
4553 | - return false; |
|
4553 | + if (empty ($name)) { |
|
4554 | + return false; |
|
4555 | + } |
|
4554 | 4556 | $this->maker = $name; |
4555 | 4557 | $lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
4556 | 4558 | $course_id = api_get_course_int_id(); |
@@ -4615,8 +4617,9 @@ discard block |
||
4615 | 4617 | public function set_terms_by_prefix($terms_string, $prefix) |
4616 | 4618 | { |
4617 | 4619 | $course_id = api_get_course_int_id(); |
4618 | - if (api_get_setting('search_enabled') !== 'true') |
|
4619 | - return false; |
|
4620 | + if (api_get_setting('search_enabled') !== 'true') { |
|
4621 | + return false; |
|
4622 | + } |
|
4620 | 4623 | |
4621 | 4624 | if (!extension_loaded('xapian')) { |
4622 | 4625 | return false; |
@@ -4629,8 +4632,9 @@ discard block |
||
4629 | 4632 | $stored_terms = $this->get_common_index_terms_by_prefix($prefix); |
4630 | 4633 | |
4631 | 4634 | // Don't do anything if no change, verify only at DB, not the search engine. |
4632 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
4633 | - return false; |
|
4635 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
4636 | + return false; |
|
4637 | + } |
|
4634 | 4638 | |
4635 | 4639 | require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API. |
4636 | 4640 | require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
@@ -4822,8 +4826,9 @@ discard block |
||
4822 | 4826 | if ($this->debug > 0) { |
4823 | 4827 | error_log('New LP - In learnpath::set_proximity()', 0); |
4824 | 4828 | } |
4825 | - if (empty ($name)) |
|
4826 | - return false; |
|
4829 | + if (empty ($name)) { |
|
4830 | + return false; |
|
4831 | + } |
|
4827 | 4832 | |
4828 | 4833 | $this->proximity = $name; |
4829 | 4834 | $lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
@@ -5165,8 +5170,9 @@ discard block |
||
5165 | 5170 | |
5166 | 5171 | $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order"; |
5167 | 5172 | $res = Database::query($sql); |
5168 | - if ($res === false) |
|
5169 | - return false; |
|
5173 | + if ($res === false) { |
|
5174 | + return false; |
|
5175 | + } |
|
5170 | 5176 | |
5171 | 5177 | $num = Database :: num_rows($res); |
5172 | 5178 | // First check the order is correct, globally (might be wrong because |
@@ -5477,8 +5483,9 @@ discard block |
||
5477 | 5483 | $position[$key] = $row['display_order']; |
5478 | 5484 | } |
5479 | 5485 | |
5480 | - if (count($array) > 0) |
|
5481 | - array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array); |
|
5486 | + if (count($array) > 0) { |
|
5487 | + array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array); |
|
5488 | + } |
|
5482 | 5489 | |
5483 | 5490 | return $array; |
5484 | 5491 | } |
@@ -6043,8 +6050,9 @@ discard block |
||
6043 | 6050 | $tmp_filename = $filename; |
6044 | 6051 | |
6045 | 6052 | $i = 0; |
6046 | - while (file_exists($filepath . $tmp_filename . '.'.$extension)) |
|
6047 | - $tmp_filename = $filename . '_' . ++ $i; |
|
6053 | + while (file_exists($filepath . $tmp_filename . '.'.$extension)) { |
|
6054 | + $tmp_filename = $filename . '_' . ++ $i; |
|
6055 | + } |
|
6048 | 6056 | |
6049 | 6057 | $filename = $tmp_filename . '.'.$extension; |
6050 | 6058 | if ($extension == 'html') { |
@@ -6123,10 +6131,12 @@ discard block |
||
6123 | 6131 | if ($new_comment || $new_title) { |
6124 | 6132 | $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); |
6125 | 6133 | $ct = ''; |
6126 | - if ($new_comment) |
|
6127 | - $ct .= ", comment='" . Database::escape_string($new_comment). "'"; |
|
6128 | - if ($new_title) |
|
6129 | - $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' "; |
|
6134 | + if ($new_comment) { |
|
6135 | + $ct .= ", comment='" . Database::escape_string($new_comment). "'"; |
|
6136 | + } |
|
6137 | + if ($new_title) { |
|
6138 | + $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' "; |
|
6139 | + } |
|
6130 | 6140 | |
6131 | 6141 | $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)." |
6132 | 6142 | WHERE c_id = ".$course_id." AND id = " . $document_id; |
@@ -6150,17 +6160,21 @@ discard block |
||
6150 | 6160 | // Please, do not modify this dirname formatting. |
6151 | 6161 | $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir']; |
6152 | 6162 | |
6153 | - if (strstr($dir, '..')) |
|
6154 | - $dir = '/'; |
|
6163 | + if (strstr($dir, '..')) { |
|
6164 | + $dir = '/'; |
|
6165 | + } |
|
6155 | 6166 | |
6156 | - if ($dir[0] == '.') |
|
6157 | - $dir = substr($dir, 1); |
|
6167 | + if ($dir[0] == '.') { |
|
6168 | + $dir = substr($dir, 1); |
|
6169 | + } |
|
6158 | 6170 | |
6159 | - if ($dir[0] != '/') |
|
6160 | - $dir = '/' . $dir; |
|
6171 | + if ($dir[0] != '/') { |
|
6172 | + $dir = '/' . $dir; |
|
6173 | + } |
|
6161 | 6174 | |
6162 | - if ($dir[strlen($dir) - 1] != '/') |
|
6163 | - $dir .= '/'; |
|
6175 | + if ($dir[strlen($dir) - 1] != '/') { |
|
6176 | + $dir .= '/'; |
|
6177 | + } |
|
6164 | 6178 | |
6165 | 6179 | $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir; |
6166 | 6180 | |
@@ -6225,8 +6239,9 @@ discard block |
||
6225 | 6239 | } |
6226 | 6240 | $return .= '<div style="padding:10px;">'; |
6227 | 6241 | |
6228 | - if ($msg != '') |
|
6229 | - $return .= $msg; |
|
6242 | + if ($msg != '') { |
|
6243 | + $return .= $msg; |
|
6244 | + } |
|
6230 | 6245 | |
6231 | 6246 | $return .= '<h3>'.$row['title'].'</h3>'; |
6232 | 6247 | switch ($row['item_type']) { |
@@ -6491,10 +6506,11 @@ discard block |
||
6491 | 6506 | $item_title = Security::remove_XSS($item_title); |
6492 | 6507 | $item_description = Security::remove_XSS($item_description); |
6493 | 6508 | |
6494 | - if ($id != 0 && is_array($extra_info)) |
|
6495 | - $parent = $extra_info['parent_item_id']; |
|
6496 | - else |
|
6497 | - $parent = 0; |
|
6509 | + if ($id != 0 && is_array($extra_info)) { |
|
6510 | + $parent = $extra_info['parent_item_id']; |
|
6511 | + } else { |
|
6512 | + $parent = 0; |
|
6513 | + } |
|
6498 | 6514 | |
6499 | 6515 | $sql = "SELECT * FROM " . $tbl_lp_item . " |
6500 | 6516 | WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id; |
@@ -6767,11 +6783,13 @@ discard block |
||
6767 | 6783 | } |
6768 | 6784 | |
6769 | 6785 | $legend = '<legend>'; |
6770 | - if ($action == 'add') |
|
6771 | - $legend .= get_lang('CreateTheExercise'); |
|
6772 | - elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise'); |
|
6773 | - else |
|
6774 | - $legend .= get_lang('EditCurrentExecice'); |
|
6786 | + if ($action == 'add') { |
|
6787 | + $legend .= get_lang('CreateTheExercise'); |
|
6788 | + } elseif ($action == 'move') { |
|
6789 | + $legend .= get_lang('MoveTheCurrentExercise'); |
|
6790 | + } else { |
|
6791 | + $legend .= get_lang('EditCurrentExecice'); |
|
6792 | + } |
|
6775 | 6793 | if (isset ($_GET['edit']) && $_GET['edit'] == 'true') { |
6776 | 6794 | $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument')); |
6777 | 6795 | } |
@@ -6798,8 +6816,9 @@ discard block |
||
6798 | 6816 | $arrHide[] = $arrLP[$i]['id']; |
6799 | 6817 | } |
6800 | 6818 | } else { |
6801 | - if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') |
|
6802 | - $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>'; |
|
6819 | + if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') { |
|
6820 | + $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>'; |
|
6821 | + } |
|
6803 | 6822 | } |
6804 | 6823 | } |
6805 | 6824 | |
@@ -6817,11 +6836,13 @@ discard block |
||
6817 | 6836 | |
6818 | 6837 | for ($i = 0; $i < count($arrLP); $i++) { |
6819 | 6838 | if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { |
6820 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
6839 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
6840 | + $selected = 'selected="selected" '; |
|
6841 | + } elseif ($action == 'add') { |
|
6821 | 6842 | $selected = 'selected="selected" '; |
6822 | - elseif ($action == 'add') $selected = 'selected="selected" '; |
|
6823 | - else |
|
6824 | - $selected = ''; |
|
6843 | + } else { |
|
6844 | + $selected = ''; |
|
6845 | + } |
|
6825 | 6846 | |
6826 | 6847 | $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>'; |
6827 | 6848 | } |
@@ -6848,9 +6869,11 @@ discard block |
||
6848 | 6869 | $arrHide = array (); |
6849 | 6870 | for ($i = 0; $i < count($arrLP); $i++) { |
6850 | 6871 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
6851 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
6852 | - $s_selected_position = $arrLP[$i]['id']; |
|
6853 | - elseif ($action == 'add') $s_selected_position = 0; |
|
6872 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
6873 | + $s_selected_position = $arrLP[$i]['id']; |
|
6874 | + } elseif ($action == 'add') { |
|
6875 | + $s_selected_position = 0; |
|
6876 | + } |
|
6854 | 6877 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
6855 | 6878 | |
6856 | 6879 | } |
@@ -7047,9 +7070,11 @@ discard block |
||
7047 | 7070 | $arrHide = array(); |
7048 | 7071 | for ($i = 0; $i < count($arrLP); $i++) { |
7049 | 7072 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
7050 | - if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7051 | - $s_selected_position = $arrLP[$i]['id']; |
|
7052 | - elseif ($action == 'add') $s_selected_position = 0; |
|
7073 | + if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7074 | + $s_selected_position = $arrLP[$i]['id']; |
|
7075 | + } elseif ($action == 'add') { |
|
7076 | + $s_selected_position = 0; |
|
7077 | + } |
|
7053 | 7078 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7054 | 7079 | } |
7055 | 7080 | } |
@@ -7252,9 +7277,11 @@ discard block |
||
7252 | 7277 | |
7253 | 7278 | for ($i = 0; $i < count($arrLP); $i++) { |
7254 | 7279 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
7255 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7256 | - $s_selected_position = $arrLP[$i]['id']; |
|
7257 | - elseif ($action == 'add') $s_selected_position = 0; |
|
7280 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7281 | + $s_selected_position = $arrLP[$i]['id']; |
|
7282 | + } elseif ($action == 'add') { |
|
7283 | + $s_selected_position = 0; |
|
7284 | + } |
|
7258 | 7285 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7259 | 7286 | |
7260 | 7287 | } |
@@ -7288,8 +7315,7 @@ discard block |
||
7288 | 7315 | |
7289 | 7316 | if (is_numeric($extra_info)) { |
7290 | 7317 | $form->addHidden('path', $extra_info); |
7291 | - } |
|
7292 | - elseif (is_array($extra_info)) { |
|
7318 | + } elseif (is_array($extra_info)) { |
|
7293 | 7319 | $form->addHidden('path', $extra_info['path']); |
7294 | 7320 | } |
7295 | 7321 | |
@@ -7342,8 +7368,9 @@ discard block |
||
7342 | 7368 | lp_id = " . $this->lp_id . " AND |
7343 | 7369 | id != $id"; |
7344 | 7370 | |
7345 | - if ($item_type == 'module') |
|
7346 | - $sql .= " AND parent_item_id = 0"; |
|
7371 | + if ($item_type == 'module') { |
|
7372 | + $sql .= " AND parent_item_id = 0"; |
|
7373 | + } |
|
7347 | 7374 | |
7348 | 7375 | $result = Database::query($sql); |
7349 | 7376 | $arrLP = array (); |
@@ -7729,9 +7756,11 @@ discard block |
||
7729 | 7756 | |
7730 | 7757 | for ($i = 0; $i < count($arrLP); $i++) { |
7731 | 7758 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) { |
7732 | - if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
7759 | + if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
7760 | + $s_selected_position = $arrLP[$i]['id']; |
|
7761 | + } elseif ($action == 'add') { |
|
7733 | 7762 | $s_selected_position = $arrLP[$i]['id']; |
7734 | - elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id']; |
|
7763 | + } |
|
7735 | 7764 | |
7736 | 7765 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
7737 | 7766 | |
@@ -7742,17 +7771,18 @@ discard block |
||
7742 | 7771 | $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null; |
7743 | 7772 | $edit = isset($_GET['edit']) ? $_GET['edit'] : null; |
7744 | 7773 | if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) { |
7745 | - if (isset ($_POST['content'])) |
|
7746 | - $content = stripslashes($_POST['content']); |
|
7747 | - elseif (is_array($extra_info)) { |
|
7774 | + if (isset ($_POST['content'])) { |
|
7775 | + $content = stripslashes($_POST['content']); |
|
7776 | + } elseif (is_array($extra_info)) { |
|
7748 | 7777 | //If it's an html document or a text file |
7749 | 7778 | if (!$no_display_edit_textarea) { |
7750 | 7779 | $content = $this->display_document($extra_info['path'], false, false); |
7751 | 7780 | } |
7752 | - } elseif (is_numeric($extra_info)) |
|
7753 | - $content = $this->display_document($extra_info, false, false); |
|
7754 | - else |
|
7755 | - $content = ''; |
|
7781 | + } elseif (is_numeric($extra_info)) { |
|
7782 | + $content = $this->display_document($extra_info, false, false); |
|
7783 | + } else { |
|
7784 | + $content = ''; |
|
7785 | + } |
|
7756 | 7786 | |
7757 | 7787 | if (!$no_display_edit_textarea) { |
7758 | 7788 | // We need to calculate here some specific settings for the online editor. |
@@ -8020,9 +8050,11 @@ discard block |
||
8020 | 8050 | $arrHide = array(); |
8021 | 8051 | for ($i = 0; $i < count($arrLP); $i++) { |
8022 | 8052 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
8023 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
8024 | - $s_selected_position = $arrLP[$i]['id']; |
|
8025 | - elseif ($action == 'add') $s_selected_position = 0; |
|
8053 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
8054 | + $s_selected_position = $arrLP[$i]['id']; |
|
8055 | + } elseif ($action == 'add') { |
|
8056 | + $s_selected_position = 0; |
|
8057 | + } |
|
8026 | 8058 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
8027 | 8059 | |
8028 | 8060 | } |
@@ -8225,9 +8257,11 @@ discard block |
||
8225 | 8257 | $arrHide = array (); |
8226 | 8258 | for ($i = 0; $i < count($arrLP); $i++) { |
8227 | 8259 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
8228 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
8229 | - $s_selected_position = $arrLP[$i]['id']; |
|
8230 | - elseif ($action == 'add') $s_selected_position = 0; |
|
8260 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
8261 | + $s_selected_position = $arrLP[$i]['id']; |
|
8262 | + } elseif ($action == 'add') { |
|
8263 | + $s_selected_position = 0; |
|
8264 | + } |
|
8231 | 8265 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
8232 | 8266 | |
8233 | 8267 | } |