@@ -3939,8 +3939,9 @@ discard block |
||
| 3939 | 3939 | WHERE c_id = ".$course_id." |
| 3940 | 3940 | ORDER BY display_order"; |
| 3941 | 3941 | $res = Database::query($sql); |
| 3942 | - if ($res === false) |
|
| 3943 | - return false; |
|
| 3942 | + if ($res === false) { |
|
| 3943 | + return false; |
|
| 3944 | + } |
|
| 3944 | 3945 | $lps = array (); |
| 3945 | 3946 | $lp_order = array (); |
| 3946 | 3947 | $num = Database :: num_rows($res); |
@@ -4540,8 +4541,9 @@ discard block |
||
| 4540 | 4541 | if ($this->debug > 0) { |
| 4541 | 4542 | error_log('New LP - In learnpath::set_maker()', 0); |
| 4542 | 4543 | } |
| 4543 | - if (empty ($name)) |
|
| 4544 | - return false; |
|
| 4544 | + if (empty ($name)) { |
|
| 4545 | + return false; |
|
| 4546 | + } |
|
| 4545 | 4547 | $this->maker = $name; |
| 4546 | 4548 | $lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
| 4547 | 4549 | $course_id = api_get_course_int_id(); |
@@ -4606,8 +4608,9 @@ discard block |
||
| 4606 | 4608 | public function set_terms_by_prefix($terms_string, $prefix) |
| 4607 | 4609 | { |
| 4608 | 4610 | $course_id = api_get_course_int_id(); |
| 4609 | - if (api_get_setting('search_enabled') !== 'true') |
|
| 4610 | - return false; |
|
| 4611 | + if (api_get_setting('search_enabled') !== 'true') { |
|
| 4612 | + return false; |
|
| 4613 | + } |
|
| 4611 | 4614 | |
| 4612 | 4615 | if (!extension_loaded('xapian')) { |
| 4613 | 4616 | return false; |
@@ -4620,8 +4623,9 @@ discard block |
||
| 4620 | 4623 | $stored_terms = $this->get_common_index_terms_by_prefix($prefix); |
| 4621 | 4624 | |
| 4622 | 4625 | // Don't do anything if no change, verify only at DB, not the search engine. |
| 4623 | - if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) |
|
| 4624 | - return false; |
|
| 4626 | + if ((count(array_diff($terms, $stored_terms)) == 0) && (count(array_diff($stored_terms, $terms)) == 0)) { |
|
| 4627 | + return false; |
|
| 4628 | + } |
|
| 4625 | 4629 | |
| 4626 | 4630 | require_once 'xapian.php'; // TODO: Try catch every xapian use or make wrappers on API. |
| 4627 | 4631 | require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
@@ -4813,8 +4817,9 @@ discard block |
||
| 4813 | 4817 | if ($this->debug > 0) { |
| 4814 | 4818 | error_log('New LP - In learnpath::set_proximity()', 0); |
| 4815 | 4819 | } |
| 4816 | - if (empty ($name)) |
|
| 4817 | - return false; |
|
| 4820 | + if (empty ($name)) { |
|
| 4821 | + return false; |
|
| 4822 | + } |
|
| 4818 | 4823 | |
| 4819 | 4824 | $this->proximity = $name; |
| 4820 | 4825 | $lp_table = Database :: get_course_table(TABLE_LP_MAIN); |
@@ -5156,8 +5161,9 @@ discard block |
||
| 5156 | 5161 | |
| 5157 | 5162 | $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order"; |
| 5158 | 5163 | $res = Database::query($sql); |
| 5159 | - if ($res === false) |
|
| 5160 | - return false; |
|
| 5164 | + if ($res === false) { |
|
| 5165 | + return false; |
|
| 5166 | + } |
|
| 5161 | 5167 | |
| 5162 | 5168 | $num = Database :: num_rows($res); |
| 5163 | 5169 | // First check the order is correct, globally (might be wrong because |
@@ -5468,8 +5474,9 @@ discard block |
||
| 5468 | 5474 | $position[$key] = $row['display_order']; |
| 5469 | 5475 | } |
| 5470 | 5476 | |
| 5471 | - if (count($array) > 0) |
|
| 5472 | - array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array); |
|
| 5477 | + if (count($array) > 0) { |
|
| 5478 | + array_multisort($parent, SORT_ASC, $position, SORT_ASC, $array); |
|
| 5479 | + } |
|
| 5473 | 5480 | |
| 5474 | 5481 | return $array; |
| 5475 | 5482 | } |
@@ -6037,8 +6044,9 @@ discard block |
||
| 6037 | 6044 | $tmp_filename = $filename; |
| 6038 | 6045 | |
| 6039 | 6046 | $i = 0; |
| 6040 | - while (file_exists($filepath . $tmp_filename . '.'.$extension)) |
|
| 6041 | - $tmp_filename = $filename . '_' . ++ $i; |
|
| 6047 | + while (file_exists($filepath . $tmp_filename . '.'.$extension)) { |
|
| 6048 | + $tmp_filename = $filename . '_' . ++ $i; |
|
| 6049 | + } |
|
| 6042 | 6050 | |
| 6043 | 6051 | $filename = $tmp_filename . '.'.$extension; |
| 6044 | 6052 | if ($extension == 'html') { |
@@ -6117,10 +6125,12 @@ discard block |
||
| 6117 | 6125 | if ($new_comment || $new_title) { |
| 6118 | 6126 | $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); |
| 6119 | 6127 | $ct = ''; |
| 6120 | - if ($new_comment) |
|
| 6121 | - $ct .= ", comment='" . Database::escape_string($new_comment). "'"; |
|
| 6122 | - if ($new_title) |
|
| 6123 | - $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' "; |
|
| 6128 | + if ($new_comment) { |
|
| 6129 | + $ct .= ", comment='" . Database::escape_string($new_comment). "'"; |
|
| 6130 | + } |
|
| 6131 | + if ($new_title) { |
|
| 6132 | + $ct .= ", title='" . Database::escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset))."' "; |
|
| 6133 | + } |
|
| 6124 | 6134 | |
| 6125 | 6135 | $sql = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)." |
| 6126 | 6136 | WHERE c_id = ".$course_id." AND id = " . $document_id; |
@@ -6144,17 +6154,21 @@ discard block |
||
| 6144 | 6154 | // Please, do not modify this dirname formatting. |
| 6145 | 6155 | $dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir']; |
| 6146 | 6156 | |
| 6147 | - if (strstr($dir, '..')) |
|
| 6148 | - $dir = '/'; |
|
| 6157 | + if (strstr($dir, '..')) { |
|
| 6158 | + $dir = '/'; |
|
| 6159 | + } |
|
| 6149 | 6160 | |
| 6150 | - if ($dir[0] == '.') |
|
| 6151 | - $dir = substr($dir, 1); |
|
| 6161 | + if ($dir[0] == '.') { |
|
| 6162 | + $dir = substr($dir, 1); |
|
| 6163 | + } |
|
| 6152 | 6164 | |
| 6153 | - if ($dir[0] != '/') |
|
| 6154 | - $dir = '/' . $dir; |
|
| 6165 | + if ($dir[0] != '/') { |
|
| 6166 | + $dir = '/' . $dir; |
|
| 6167 | + } |
|
| 6155 | 6168 | |
| 6156 | - if ($dir[strlen($dir) - 1] != '/') |
|
| 6157 | - $dir .= '/'; |
|
| 6169 | + if ($dir[strlen($dir) - 1] != '/') { |
|
| 6170 | + $dir .= '/'; |
|
| 6171 | + } |
|
| 6158 | 6172 | |
| 6159 | 6173 | $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir; |
| 6160 | 6174 | |
@@ -6219,8 +6233,9 @@ discard block |
||
| 6219 | 6233 | } |
| 6220 | 6234 | $return .= '<div style="padding:10px;">'; |
| 6221 | 6235 | |
| 6222 | - if ($msg != '') |
|
| 6223 | - $return .= $msg; |
|
| 6236 | + if ($msg != '') { |
|
| 6237 | + $return .= $msg; |
|
| 6238 | + } |
|
| 6224 | 6239 | |
| 6225 | 6240 | $return .= '<h3>'.$row['title'].'</h3>'; |
| 6226 | 6241 | switch ($row['item_type']) { |
@@ -6484,10 +6499,11 @@ discard block |
||
| 6484 | 6499 | $item_title = Security::remove_XSS($item_title); |
| 6485 | 6500 | $item_description = Security::remove_XSS($item_description); |
| 6486 | 6501 | |
| 6487 | - if ($id != 0 && is_array($extra_info)) |
|
| 6488 | - $parent = $extra_info['parent_item_id']; |
|
| 6489 | - else |
|
| 6490 | - $parent = 0; |
|
| 6502 | + if ($id != 0 && is_array($extra_info)) { |
|
| 6503 | + $parent = $extra_info['parent_item_id']; |
|
| 6504 | + } else { |
|
| 6505 | + $parent = 0; |
|
| 6506 | + } |
|
| 6491 | 6507 | |
| 6492 | 6508 | $sql = "SELECT * FROM " . $tbl_lp_item . " |
| 6493 | 6509 | WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id; |
@@ -6760,11 +6776,13 @@ discard block |
||
| 6760 | 6776 | } |
| 6761 | 6777 | |
| 6762 | 6778 | $legend = '<legend>'; |
| 6763 | - if ($action == 'add') |
|
| 6764 | - $legend .= get_lang('CreateTheExercise'); |
|
| 6765 | - elseif ($action == 'move') $legend .= get_lang('MoveTheCurrentExercise'); |
|
| 6766 | - else |
|
| 6767 | - $legend .= get_lang('EditCurrentExecice'); |
|
| 6779 | + if ($action == 'add') { |
|
| 6780 | + $legend .= get_lang('CreateTheExercise'); |
|
| 6781 | + } elseif ($action == 'move') { |
|
| 6782 | + $legend .= get_lang('MoveTheCurrentExercise'); |
|
| 6783 | + } else { |
|
| 6784 | + $legend .= get_lang('EditCurrentExecice'); |
|
| 6785 | + } |
|
| 6768 | 6786 | if (isset ($_GET['edit']) && $_GET['edit'] == 'true') { |
| 6769 | 6787 | $legend .= Display :: return_warning_message(get_lang('Warning') . ' ! ' . get_lang('WarningEditingDocument')); |
| 6770 | 6788 | } |
@@ -6791,8 +6809,9 @@ discard block |
||
| 6791 | 6809 | $arrHide[] = $arrLP[$i]['id']; |
| 6792 | 6810 | } |
| 6793 | 6811 | } else { |
| 6794 | - if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') |
|
| 6795 | - $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>'; |
|
| 6812 | + if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') { |
|
| 6813 | + $return .= '<option ' . (($parent == $arrLP[$i]['id']) ? 'selected="selected" ' : '') . 'style="padding-left:' . ($arrLP[$i]['depth'] * 10) . 'px;" value="' . $arrLP[$i]['id'] . '">' . $arrLP[$i]['title'] . '</option>'; |
|
| 6814 | + } |
|
| 6796 | 6815 | } |
| 6797 | 6816 | } |
| 6798 | 6817 | |
@@ -6810,11 +6829,13 @@ discard block |
||
| 6810 | 6829 | |
| 6811 | 6830 | for ($i = 0; $i < count($arrLP); $i++) { |
| 6812 | 6831 | if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { |
| 6813 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 6832 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 6833 | + $selected = 'selected="selected" '; |
|
| 6834 | + } elseif ($action == 'add') { |
|
| 6814 | 6835 | $selected = 'selected="selected" '; |
| 6815 | - elseif ($action == 'add') $selected = 'selected="selected" '; |
|
| 6816 | - else |
|
| 6817 | - $selected = ''; |
|
| 6836 | + } else { |
|
| 6837 | + $selected = ''; |
|
| 6838 | + } |
|
| 6818 | 6839 | |
| 6819 | 6840 | $return .= '<option ' . $selected . 'value="' . $arrLP[$i]['id'] . '">' . get_lang('After') . ' "' . $arrLP[$i]['title'] . '"</option>'; |
| 6820 | 6841 | } |
@@ -6841,9 +6862,11 @@ discard block |
||
| 6841 | 6862 | $arrHide = array (); |
| 6842 | 6863 | for ($i = 0; $i < count($arrLP); $i++) { |
| 6843 | 6864 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
| 6844 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 6845 | - $s_selected_position = $arrLP[$i]['id']; |
|
| 6846 | - elseif ($action == 'add') $s_selected_position = 0; |
|
| 6865 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 6866 | + $s_selected_position = $arrLP[$i]['id']; |
|
| 6867 | + } elseif ($action == 'add') { |
|
| 6868 | + $s_selected_position = 0; |
|
| 6869 | + } |
|
| 6847 | 6870 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
| 6848 | 6871 | |
| 6849 | 6872 | } |
@@ -7040,9 +7063,11 @@ discard block |
||
| 7040 | 7063 | $arrHide = array(); |
| 7041 | 7064 | for ($i = 0; $i < count($arrLP); $i++) { |
| 7042 | 7065 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
| 7043 | - if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 7044 | - $s_selected_position = $arrLP[$i]['id']; |
|
| 7045 | - elseif ($action == 'add') $s_selected_position = 0; |
|
| 7066 | + if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 7067 | + $s_selected_position = $arrLP[$i]['id']; |
|
| 7068 | + } elseif ($action == 'add') { |
|
| 7069 | + $s_selected_position = 0; |
|
| 7070 | + } |
|
| 7046 | 7071 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
| 7047 | 7072 | } |
| 7048 | 7073 | } |
@@ -7245,9 +7270,11 @@ discard block |
||
| 7245 | 7270 | |
| 7246 | 7271 | for ($i = 0; $i < count($arrLP); $i++) { |
| 7247 | 7272 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
| 7248 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 7249 | - $s_selected_position = $arrLP[$i]['id']; |
|
| 7250 | - elseif ($action == 'add') $s_selected_position = 0; |
|
| 7273 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 7274 | + $s_selected_position = $arrLP[$i]['id']; |
|
| 7275 | + } elseif ($action == 'add') { |
|
| 7276 | + $s_selected_position = 0; |
|
| 7277 | + } |
|
| 7251 | 7278 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
| 7252 | 7279 | |
| 7253 | 7280 | } |
@@ -7281,8 +7308,7 @@ discard block |
||
| 7281 | 7308 | |
| 7282 | 7309 | if (is_numeric($extra_info)) { |
| 7283 | 7310 | $form->addHidden('path', $extra_info); |
| 7284 | - } |
|
| 7285 | - elseif (is_array($extra_info)) { |
|
| 7311 | + } elseif (is_array($extra_info)) { |
|
| 7286 | 7312 | $form->addHidden('path', $extra_info['path']); |
| 7287 | 7313 | } |
| 7288 | 7314 | |
@@ -7335,8 +7361,9 @@ discard block |
||
| 7335 | 7361 | lp_id = " . $this->lp_id . " AND |
| 7336 | 7362 | id != $id"; |
| 7337 | 7363 | |
| 7338 | - if ($item_type == 'module') |
|
| 7339 | - $sql .= " AND parent_item_id = 0"; |
|
| 7364 | + if ($item_type == 'module') { |
|
| 7365 | + $sql .= " AND parent_item_id = 0"; |
|
| 7366 | + } |
|
| 7340 | 7367 | |
| 7341 | 7368 | $result = Database::query($sql); |
| 7342 | 7369 | $arrLP = array (); |
@@ -7722,9 +7749,11 @@ discard block |
||
| 7722 | 7749 | |
| 7723 | 7750 | for ($i = 0; $i < count($arrLP); $i++) { |
| 7724 | 7751 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] !== TOOL_LP_FINAL_ITEM) { |
| 7725 | - if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 7752 | + if (isset($extra_info['previous_item_id']) && $extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 7753 | + $s_selected_position = $arrLP[$i]['id']; |
|
| 7754 | + } elseif ($action == 'add') { |
|
| 7726 | 7755 | $s_selected_position = $arrLP[$i]['id']; |
| 7727 | - elseif ($action == 'add') $s_selected_position = $arrLP[$i]['id']; |
|
| 7756 | + } |
|
| 7728 | 7757 | |
| 7729 | 7758 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
| 7730 | 7759 | |
@@ -7735,17 +7764,18 @@ discard block |
||
| 7735 | 7764 | $item_type = isset($extra_info['item_type']) ? $extra_info['item_type'] : null; |
| 7736 | 7765 | $edit = isset($_GET['edit']) ? $_GET['edit'] : null; |
| 7737 | 7766 | if (($extra_info == 'new' || $item_type == TOOL_DOCUMENT || $item_type == TOOL_LP_FINAL_ITEM || $edit == 'true')) { |
| 7738 | - if (isset ($_POST['content'])) |
|
| 7739 | - $content = stripslashes($_POST['content']); |
|
| 7740 | - elseif (is_array($extra_info)) { |
|
| 7767 | + if (isset ($_POST['content'])) { |
|
| 7768 | + $content = stripslashes($_POST['content']); |
|
| 7769 | + } elseif (is_array($extra_info)) { |
|
| 7741 | 7770 | //If it's an html document or a text file |
| 7742 | 7771 | if (!$no_display_edit_textarea) { |
| 7743 | 7772 | $content = $this->display_document($extra_info['path'], false, false); |
| 7744 | 7773 | } |
| 7745 | - } elseif (is_numeric($extra_info)) |
|
| 7746 | - $content = $this->display_document($extra_info, false, false); |
|
| 7747 | - else |
|
| 7748 | - $content = ''; |
|
| 7774 | + } elseif (is_numeric($extra_info)) { |
|
| 7775 | + $content = $this->display_document($extra_info, false, false); |
|
| 7776 | + } else { |
|
| 7777 | + $content = ''; |
|
| 7778 | + } |
|
| 7749 | 7779 | |
| 7750 | 7780 | if (!$no_display_edit_textarea) { |
| 7751 | 7781 | // We need to calculate here some specific settings for the online editor. |
@@ -8013,9 +8043,11 @@ discard block |
||
| 8013 | 8043 | $arrHide = array(); |
| 8014 | 8044 | for ($i = 0; $i < count($arrLP); $i++) { |
| 8015 | 8045 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
| 8016 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 8017 | - $s_selected_position = $arrLP[$i]['id']; |
|
| 8018 | - elseif ($action == 'add') $s_selected_position = 0; |
|
| 8046 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 8047 | + $s_selected_position = $arrLP[$i]['id']; |
|
| 8048 | + } elseif ($action == 'add') { |
|
| 8049 | + $s_selected_position = 0; |
|
| 8050 | + } |
|
| 8019 | 8051 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
| 8020 | 8052 | |
| 8021 | 8053 | } |
@@ -8218,9 +8250,11 @@ discard block |
||
| 8218 | 8250 | $arrHide = array (); |
| 8219 | 8251 | for ($i = 0; $i < count($arrLP); $i++) { |
| 8220 | 8252 | if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { |
| 8221 | - if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) |
|
| 8222 | - $s_selected_position = $arrLP[$i]['id']; |
|
| 8223 | - elseif ($action == 'add') $s_selected_position = 0; |
|
| 8253 | + if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { |
|
| 8254 | + $s_selected_position = $arrLP[$i]['id']; |
|
| 8255 | + } elseif ($action == 'add') { |
|
| 8256 | + $s_selected_position = 0; |
|
| 8257 | + } |
|
| 8224 | 8258 | $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; |
| 8225 | 8259 | |
| 8226 | 8260 | } |
@@ -9795,9 +9829,9 @@ discard block |
||
| 9795 | 9829 | $main_code_path = api_get_path(SYS_CODE_PATH).'newscorm/packaging/'; |
| 9796 | 9830 | $extra_files = scandir($main_code_path); |
| 9797 | 9831 | foreach ($extra_files as $extra_file) { |
| 9798 | - if (strpos($extra_file, '.') === 0) |
|
| 9799 | - continue; |
|
| 9800 | - else { |
|
| 9832 | + if (strpos($extra_file, '.') === 0) { |
|
| 9833 | + continue; |
|
| 9834 | + } else { |
|
| 9801 | 9835 | $dest_file = $archive_path . $temp_dir_short . '/' . $extra_file; |
| 9802 | 9836 | $this->create_path($dest_file); |
| 9803 | 9837 | copy($main_code_path.$extra_file, $dest_file); |