diff --git a/main/course_description/index.php b/main/course_description/index.php index 6223cadbdc..58d1dd2113 100644 --- a/main/course_description/index.php +++ b/main/course_description/index.php @@ -36,19 +36,20 @@ include_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php'; $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram')); +$description_type = isset ($_REQUEST['description_type']) ? Security::remove_XSS($_REQUEST['description_type']) : null; $description_id = isset ($_REQUEST['description_id']) ? Security::remove_XSS($_REQUEST['description_id']) : null; $action = isset($_GET['action'])?Security::remove_XSS($_GET['action']):''; $edit = isset($_POST['edit'])?Security::remove_XSS($_POST['edit']):''; $add = isset($_POST['add'])?Security::remove_XSS($_POST['add']):''; -if(intval($description_id) == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription')); -if(intval($description_id) == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives')); -if(intval($description_id) == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics')); -if(intval($description_id) == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology')); -if(intval($description_id) == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial')); -if(intval($description_id) == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources')); -if(intval($description_id) == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment')); -if(intval($description_id) >= 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('NewBloc')); +if(intval($description_type) == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription')); +if(intval($description_type) == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives')); +if(intval($description_type) == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics')); +if(intval($description_type) == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology')); +if(intval($description_type) == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial')); +if(intval($description_type) == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources')); +if(intval($description_type) == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment')); +if(intval($description_type) >= 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('NewBloc')); api_protect_course_script(true); $nameTools = get_lang('CourseProgram'); @@ -129,17 +130,25 @@ $default_description_title_editable[7] = true; */ $condition_session = api_get_session_condition($session_id, false); +$current_session_id = api_get_session_id(); + + +$sql = "SELECT description_type,title FROM $tbl_course_description $condition_session ORDER BY description_type "; -$sql = "SELECT id,title FROM $tbl_course_description $condition_session ORDER BY id "; $result = Database::query($sql, __FILE__, __LINE__); while ($row = Database::fetch_array($result)) { - $default_description_titles[$row['id']] = $row['title']; + $default_description_titles[$row['description_type']] = $row['title']; } -if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action =='add') { +$actions = array('add','delete','edit'); + +if ((api_is_allowed_to_edit(null,true) && !is_null($description_type)) || in_array($action,$actions)) { + $description_id = intval($description_id); + $description_type = intval($description_type); + // Delete a description block - if ($action == 'delete') { + if ($action == 'delete') { $sql = "DELETE FROM $tbl_course_description WHERE id='".$description_id."'"; Database::query($sql, __FILE__, __LINE__); //update item_property (delete) @@ -148,31 +157,32 @@ if (api_is_allowed_to_edit(null,true) && !is_null($description_id) || $action == } // Add or edit a description block else { - if (!empty($description_id)) { - $sql = "SELECT * FROM $tbl_course_description WHERE id='".$description_id."'"; - $result = Database::query($sql, __FILE__, __LINE__); + + if (!empty($description_type)) { + $sql = "SELECT * FROM $tbl_course_description WHERE description_type='$description_type' AND session_id='$current_session_id'"; + $result = Database::query($sql, __FILE__, __LINE__); if ($description = Database::fetch_array($result)) { - $default_description_titles[$description_id] = $description['title']; + $default_description_titles[$description_type] = $description['title']; $description_content = $description['content']; } else { - $current_title = $default_description_titles[$description_id]; + $current_title = $default_description_titles[$description_type]; } } else { - $sql = "SELECT MAX(id) as MAX FROM $tbl_course_description $condition_session"; + $sql = "SELECT MAX(description_type) as MAX FROM $tbl_course_description $condition_session"; $result = Database::query($sql, __FILE__, __LINE__); $max= Database::fetch_array($result); - $description_id = $max['MAX']+1; - if ($description_id < ADD_BLOCK) { - $description_id=8; - } + $description_type = $max['MAX']+1; + if ($description_type < ADD_BLOCK) { + $description_type=8; + } } //Se borro: echo '