diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index f01affff5a..13457dab14 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -399,6 +399,11 @@ ALTER TABLE c_tool CHANGE name name LONGTEXT NOT NULL; -- Only with allow_portfolio_tool enabled ALTER TABLE portfolio CHANGE title title LONGTEXT NOT NULL; ALTER TABLE portfolio_category CHANGE title title LONGTEXT NOT NULL; + +New changes: + +ALTER TABLE c_lp CHANGE name name LONGTEXT NOT NULL; +ALTER TABLE c_lp_item CHANGE title title LONGTEXT NOT NULL; -- */ // $_configuration['save_titles_as_html'] = false; diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 9c565a6ac4..3befff3ca3 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -253,11 +253,6 @@ class learnpath ORDER BY parent_item_id, display_order"; $res = Database::query($sql); - if ($debug) { - error_log('learnpath::__construct() '.__LINE__.' - query lp items: '.$sql); - error_log('-- Start while--'); - } - $lp_item_id_list = []; while ($row = Database::fetch_array($res)) { $lp_item_id_list[] = $row['iid']; @@ -342,10 +337,6 @@ class learnpath } } - if ($debug) { - error_log('learnpath::__construct() '.__LINE__.' ----- end while ----'); - } - if (!empty($lp_item_id_list)) { $lp_item_id_list_to_string = implode("','", $lp_item_id_list); if (!empty($lp_item_id_list_to_string)) { @@ -359,14 +350,6 @@ class learnpath lp_view_id = ".$this->lp_view_id." AND lp_item_id IN ('".$lp_item_id_list_to_string."') ORDER BY view_count DESC "; - - if ($debug) { - error_log( - 'learnpath::__construct() - Selecting item_views: '.$sql, - 0 - ); - } - $status_list = []; $res = Database::query($sql); while ($row = Database:: fetch_array($res)) { @@ -503,9 +486,6 @@ class learnpath $userId = 0 ) { $course_id = $this->course_info['real_id']; - if ($this->debug > 0) { - error_log('In learnpath::add_item('.$parent.','.$previous.','.$type.','.$id.','.$title.')'); - } if (empty($course_id)) { // Sometimes Oogie doesn't catch the course info but sets $this->cc $this->course_info = api_get_course_info($this->cc); @@ -527,7 +507,7 @@ class learnpath WHERE c_id = $course_id AND lp_id = ".$this->get_id()." AND - parent_item_id = ".$parent; + parent_item_id = $parent "; $res_count = Database::query($sql); $row = Database::fetch_array($res_count); @@ -618,9 +598,6 @@ class learnpath $new_item_id = Database::insert($tbl_lp_item, $params); if ($new_item_id) { - if ($this->debug > 2) { - error_log('Inserting dir/chapter: '.$new_item_id, 0); - } $sql = "UPDATE $tbl_lp_item SET id = iid WHERE iid = $new_item_id"; Database::query($sql); @@ -3201,14 +3178,8 @@ class learnpath */ public function get_toc() { - if ($this->debug > 0) { - error_log('learnpath::get_toc()', 0); - } $toc = []; foreach ($this->ordered_items as $item_id) { - if ($this->debug > 2) { - error_log('learnpath::get_toc(): getting info for item '.$item_id, 0); - } // TODO: Change this link generation and use new function instead. $toc[] = [ 'id' => $item_id, @@ -3221,9 +3192,6 @@ class learnpath 'parent' => $this->items[$item_id]->get_parent(), ]; } - if ($this->debug > 2) { - error_log('In learnpath::get_toc() - TOC array: '.print_r($toc, true), 0); - } return $toc; } @@ -3452,7 +3420,7 @@ class learnpath } $dirTypes = self::getChapterTypes(); - $mycurrentitemid = $this->get_current_item_id(); + $currentItemId = $this->get_current_item_id(); $list = []; $classStatus = [ 'not attempted' => 'scorm_not_attempted', @@ -3496,7 +3464,7 @@ class learnpath $subtree['title'] = $title; $subtree['class'] = $classStyle.' '.$cssStatus; $subtree['url'] = $this->get_link('http', $subtree['id'], $tree); - $subtree['current_id'] = $mycurrentitemid; + $subtree['current_id'] = $currentItemId; } $list[] = $subtree; } @@ -3514,14 +3482,11 @@ class learnpath */ public function getListArrayToc($toc_list = []) { - if ($this->debug > 0) { - error_log('In learnpath::get_html_toc()', 0); - } if (empty($toc_list)) { $toc_list = $this->get_toc(); } // Temporary variables. - $mycurrentitemid = $this->get_current_item_id(); + $currentItemId = $this->get_current_item_id(); $list = []; $arrayList = []; $classStatus = [ @@ -3585,7 +3550,7 @@ class learnpath } else { $list['title'] = stripslashes($title); $list['url'] = $this->get_link('http', $item['id'], $toc_list); - $list['current_id'] = $mycurrentitemid; + $list['current_id'] = $currentItemId; } $arrayList[] = $list; } @@ -6197,9 +6162,6 @@ class learnpath */ public function tree_array($array) { - if ($this->debug > 1) { - error_log('In learnpath::tree_array()', 0); - } $array = $this->sort_tree_array($array); $this->create_tree_array($array); } @@ -6354,34 +6316,7 @@ class learnpath public function processBuildMenuElements($update_audio = 'false') { $is_allowed_to_edit = api_is_allowed_to_edit(null, true); - $course_id = api_get_course_int_id(); - $table = Database::get_course_table(TABLE_LP_ITEM); - - $sql = "SELECT * FROM $table - WHERE c_id = $course_id AND lp_id = ".$this->lp_id; - - $result = Database::query($sql); - $arrLP = []; - while ($row = Database::fetch_array($result)) { - $arrLP[] = [ - 'id' => $row['iid'], - 'item_type' => $row['item_type'], - 'title' => Security::remove_XSS($row['title']), - 'path' => $row['path'], - 'description' => Security::remove_XSS($row['description']), - 'parent_item_id' => $row['parent_item_id'], - 'previous_item_id' => $row['previous_item_id'], - 'next_item_id' => $row['next_item_id'], - 'max_score' => $row['max_score'], - 'min_score' => $row['min_score'], - 'mastery_score' => $row['mastery_score'], - 'prerequisite' => $row['prerequisite'], - 'display_order' => $row['display_order'], - 'audio' => $row['audio'], - 'prerequisite_max_score' => $row['prerequisite_max_score'], - 'prerequisite_min_score' => $row['prerequisite_min_score'], - ]; - } + $arrLP = $this->getItemsForForm(); $this->tree_array($arrLP); $arrLP = isset($this->arrMenu) ? $this->arrMenu : []; @@ -6812,7 +6747,6 @@ class learnpath */ public function return_new_tree($update_audio = 'false', $drop_element_here = false) { - $return = ''; $result = $this->processBuildMenuElements($update_audio); $list = ''; - $return .= Display::panelCollapse( + $return = Display::panelCollapse( $this->name, $list, 'scorm-list', @@ -6863,7 +6797,7 @@ class learnpath $item['type'] = $default_content[$item['load_data']]['item_type']; } $sub_list = ''; - if (isset($item['type']) && $item['type'] == 'dir') { + if (isset($item['type']) && $item['type'] === 'dir') { // empty value $sub_list = Display::tag('li', '', ['class' => 'sub_item empty']); } @@ -7215,9 +7149,9 @@ class learnpath $originalTitle = !empty($title) ? $title : $_POST['title']; if (!empty($title)) { - $title = api_replace_dangerous_char(stripslashes($title)); + $title = api_replace_dangerous_char(strip_tags(stripslashes($title))); } else { - $title = api_replace_dangerous_char(stripslashes($_POST['title'])); + $title = api_replace_dangerous_char(strip_tags(stripslashes($_POST['title']))); } $title = disable_dangerous_file($title); @@ -7786,7 +7720,6 @@ class learnpath { $course_id = api_get_course_int_id(); $id = (int) $id; - $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST); if ($id != 0 && is_array($extra_info)) { @@ -7813,30 +7746,7 @@ class learnpath $parent = $extra_info['parent_item_id']; } - $sql = "SELECT * FROM $tbl_lp_item - WHERE c_id = $course_id AND lp_id = ".$this->lp_id; - - $result = Database::query($sql); - $arrLP = []; - while ($row = Database::fetch_array($result)) { - $arrLP[] = [ - 'id' => $row['iid'], - 'item_type' => $row['item_type'], - 'title' => $row['title'], - 'path' => $row['path'], - 'description' => $row['description'], - 'parent_item_id' => $row['parent_item_id'], - 'previous_item_id' => $row['previous_item_id'], - 'next_item_id' => $row['next_item_id'], - 'display_order' => $row['display_order'], - 'max_score' => $row['max_score'], - 'min_score' => $row['min_score'], - 'mastery_score' => $row['mastery_score'], - 'prerequisite' => $row['prerequisite'], - 'max_time_allowed' => $row['max_time_allowed'], - ]; - } - + $arrLP = $this->getItemsForForm(); $this->tree_array($arrLP); $arrLP = isset($this->arrMenu) ? $this->arrMenu : []; unset($this->arrMenu); @@ -7863,7 +7773,7 @@ class learnpath $form->addHeader($legend); if ($action != 'move') { - $form->addText('title', get_lang('Title'), true, ['id' => 'idTitle']); + $this->setItemTitle($form); $defaults['title'] = $item_title; } @@ -7959,7 +7869,7 @@ class learnpath $form->addButtonSave(get_lang('EditCurrentExecice'), 'submit_button'); } - if ($action == 'move') { + if ($action === 'move') { $form->addHidden('title', $item_title); $form->addHidden('description', $item_description); } @@ -7989,8 +7899,7 @@ class learnpath public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '') { $course_id = api_get_course_int_id(); - $uploadPath = DIR_HOTPOTATOES; //defined in main_api - $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); + $uploadPath = DIR_HOTPOTATOES; if ($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); @@ -8025,29 +7934,7 @@ class learnpath $parent = 0; } - $sql = "SELECT * FROM $tbl_lp_item - WHERE c_id = $course_id AND lp_id = ".$this->lp_id; - $result = Database::query($sql); - $arrLP = []; - while ($row = Database::fetch_array($result)) { - $arrLP[] = [ - 'id' => $row['id'], - 'item_type' => $row['item_type'], - 'title' => $row['title'], - 'path' => $row['path'], - 'description' => $row['description'], - 'parent_item_id' => $row['parent_item_id'], - 'previous_item_id' => $row['previous_item_id'], - 'next_item_id' => $row['next_item_id'], - 'display_order' => $row['display_order'], - 'max_score' => $row['max_score'], - 'min_score' => $row['min_score'], - 'mastery_score' => $row['mastery_score'], - 'prerequisite' => $row['prerequisite'], - 'max_time_allowed' => $row['max_time_allowed'], - ]; - } - + $arrLP = $this->getItemsForForm(); $legend = ''; if ($action == 'add') { $legend .= get_lang('CreateTheExercise'); @@ -8071,9 +7958,7 @@ class learnpath $return .= ''; $return .= '