|
@@ -1,47 +1,48 @@
|
|
|
-<?php // $Id: index.php 22253 2009-07-20 17:03:48Z ivantcholakov $
|
|
|
+<?php
|
|
|
/* For licensing terms, see /dokeos_license.txt */
|
|
|
+
|
|
|
/**
|
|
|
-==============================================================================
|
|
|
-* This script edits the course description.
|
|
|
-* This script is reserved for users with write access on the course.
|
|
|
-*
|
|
|
-* @author Thomas Depraetere
|
|
|
-* @author Hugues Peeters
|
|
|
-* @author Christophe Gesché
|
|
|
-* @author Olivier brouckaert
|
|
|
-* @package dokeos.course_description
|
|
|
-==============================================================================
|
|
|
+* Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action
|
|
|
+* @package dokeos.course_description
|
|
|
+* @author Christian Fasanando <christian1827@gmail.com>
|
|
|
*/
|
|
|
|
|
|
-/*
|
|
|
-==============================================================================
|
|
|
- INIT SECTION
|
|
|
-==============================================================================
|
|
|
-*/
|
|
|
// name of the language file that needs to be included
|
|
|
$language_file = array ('course_description', 'pedaSuggest', 'accessibility');
|
|
|
|
|
|
-include '../inc/global.inc.php';
|
|
|
-$this_section = SECTION_COURSES;
|
|
|
-$session_id = api_get_session_id();
|
|
|
+// including files
|
|
|
+require_once '../inc/global.inc.php';
|
|
|
|
|
|
-include api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
|
|
|
+require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
|
|
|
+require_once api_get_path(LIBRARY_PATH).'app_view.php';
|
|
|
+require_once api_get_path(LIBRARY_PATH).'app_controller.php';
|
|
|
+require_once 'course_description_controller.php';
|
|
|
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
|
|
|
+require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
|
|
|
|
|
|
-include_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
|
|
|
-/*
|
|
|
------------------------------------------------------------
|
|
|
- Header
|
|
|
------------------------------------------------------------
|
|
|
-*/
|
|
|
+// defining constants
|
|
|
+define('ADD_BLOCK', 9);
|
|
|
+define('THEMATIC_ADVANCE', 8);
|
|
|
|
|
|
-$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
|
|
|
+// current section
|
|
|
+$this_section = SECTION_COURSES;
|
|
|
+
|
|
|
+api_protect_course_script(true);
|
|
|
+
|
|
|
+// get actions
|
|
|
+$actions = array('listing', 'add', 'edit', 'delete', 'history');
|
|
|
+$action = 'listing';
|
|
|
+if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
|
|
|
+ $action = $_GET['action'];
|
|
|
+}
|
|
|
|
|
|
-$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']):'';
|
|
|
+$description_type = '';
|
|
|
+if (isset($_GET['description_type'])) {
|
|
|
+ $description_type = intval($_GET['description_type']);
|
|
|
+}
|
|
|
|
|
|
+// interbreadcrumb
|
|
|
+$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
|
|
|
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'));
|
|
@@ -49,316 +50,36 @@ if(intval($description_type) == 4) $interbreadcrumb[] = array ("url" => "#", "na
|
|
|
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');
|
|
|
-Display :: display_header('');
|
|
|
-//api_display_tool_title($nameTools);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-/*
|
|
|
------------------------------------------------------------
|
|
|
- Constants and variables
|
|
|
------------------------------------------------------------
|
|
|
-*/
|
|
|
-$nameTools = get_lang(TOOL_COURSE_DESCRIPTION);
|
|
|
-
|
|
|
-
|
|
|
-/*
|
|
|
------------------------------------------------------------
|
|
|
- Introduction section
|
|
|
------------------------------------------------------------
|
|
|
-*/
|
|
|
-Display::display_introduction_section(TOOL_COURSE_DESCRIPTION);
|
|
|
-
|
|
|
-
|
|
|
-$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
|
|
|
-$show_description_list = true;
|
|
|
-$show_peda_suggest = true;
|
|
|
-define('ADD_BLOCK', 8);
|
|
|
-// Default descriptions
|
|
|
-$default_description_titles = array();
|
|
|
-$default_description_titles[1]= get_lang('GeneralDescription');
|
|
|
-$default_description_titles[2]= get_lang('Objectives');
|
|
|
-$default_description_titles[3]= get_lang('Topics');
|
|
|
-$default_description_titles[4]= get_lang('Methodology');
|
|
|
-$default_description_titles[5]= get_lang('CourseMaterial');
|
|
|
-$default_description_titles[6]= get_lang('HumanAndTechnicalResources');
|
|
|
-$default_description_titles[7]= get_lang('Assessment');
|
|
|
-$default_description_titles[8]= get_lang('Other');
|
|
|
-$default_description_icon = array();
|
|
|
-$default_description_icon[1]= 'edu_miscellaneous.gif';
|
|
|
-$default_description_icon[2]= 'spire.gif';
|
|
|
-$default_description_icon[3]= 'kcmdf_big.gif';
|
|
|
-$default_description_icon[4]= 'misc.gif';
|
|
|
-$default_description_icon[5]= 'laptop.gif';
|
|
|
-$default_description_icon[6]= 'personal.gif';
|
|
|
-$default_description_icon[7]= 'korganizer.gif';
|
|
|
-$default_description_icon[8]= 'ktip.gif';
|
|
|
-$question = array();
|
|
|
-$question[1]= get_lang('GeneralDescriptionQuestions');
|
|
|
-$question[2]= get_lang('ObjectivesQuestions');
|
|
|
-$question[3]= get_lang('TopicsQuestions');
|
|
|
-$question[4]= get_lang('MethodologyQuestions');
|
|
|
-$question[5]= get_lang('CourseMaterialQuestions');
|
|
|
-$question[6]= get_lang('HumanAndTechnicalResourcesQuestions');
|
|
|
-$question[7]= get_lang('AssessmentQuestions');
|
|
|
-$information = array();
|
|
|
-$information[1]= get_lang('GeneralDescriptionInformation');
|
|
|
-$information[2]= get_lang('ObjectivesInformation');
|
|
|
-$information[3]= get_lang('TopicsInformation');
|
|
|
-$information[4]= get_lang('MethodologyInformation');
|
|
|
-$information[5]= get_lang('CourseMaterialInformation');
|
|
|
-$information[6]= get_lang('HumanAndTechnicalResourcesInformation');
|
|
|
-$information[7]= get_lang('AssessmentInformation');
|
|
|
-$default_description_title_editable = array();
|
|
|
-$default_description_title_editable[1] = true;
|
|
|
-$default_description_title_editable[2] = true;
|
|
|
-$default_description_title_editable[3] = true;
|
|
|
-$default_description_title_editable[4] = true;
|
|
|
-$default_description_title_editable[5] = true;
|
|
|
-$default_description_title_editable[6] = true;
|
|
|
-$default_description_title_editable[7] = true;
|
|
|
-
|
|
|
-/*
|
|
|
------------------------------------------------------------
|
|
|
- Tracking
|
|
|
------------------------------------------------------------
|
|
|
-*/
|
|
|
-event_access_tool(TOOL_COURSE_DESCRIPTION);
|
|
|
-
|
|
|
-/*
|
|
|
-==============================================================================
|
|
|
- MAIN CODE
|
|
|
-==============================================================================
|
|
|
-*/
|
|
|
-
|
|
|
-$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 ";
|
|
|
-
|
|
|
-$result = Database::query($sql, __FILE__, __LINE__);
|
|
|
-while ($row = Database::fetch_array($result)) {
|
|
|
- $default_description_titles[$row['description_type']] = $row['title'];
|
|
|
-}
|
|
|
-
|
|
|
-$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') {
|
|
|
- $sql = "DELETE FROM $tbl_course_description WHERE id='".$description_id."'";
|
|
|
- Database::query($sql, __FILE__, __LINE__);
|
|
|
- //update item_property (delete)
|
|
|
- api_item_property_update(api_get_course_info(), TOOL_COURSE_DESCRIPTION, Database::escape_string($description_id), 'delete', api_get_user_id());
|
|
|
- Display :: display_confirmation_message(get_lang('CourseDescriptionDeleted'));
|
|
|
- }
|
|
|
- // Add or edit a description block
|
|
|
- else {
|
|
|
-
|
|
|
- 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_type] = $description['title'];
|
|
|
- $description_content = $description['content'];
|
|
|
-
|
|
|
- } else {
|
|
|
- $current_title = $default_description_titles[$description_type];
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- $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_type = $max['MAX']+1;
|
|
|
- if ($description_type < ADD_BLOCK) {
|
|
|
- $description_type=8;
|
|
|
- }
|
|
|
- }
|
|
|
- //Se borro: echo ' <style> .row{} <\style> por que hacia conflicto en apartado personalizado con los estilos propios del formvalidator
|
|
|
- // Build the form
|
|
|
- $form = new FormValidator('course_description','POST','index.php?'.api_get_cidreq(),'','style="width: 100%;"');
|
|
|
- $form->addElement('header', '', $default_description_titles[$description_type]);
|
|
|
- $form->addElement('hidden', 'description_type');
|
|
|
-
|
|
|
- if ($action == 'edit' || intval($edit) == 1 ) {
|
|
|
- $form->addElement('hidden', 'edit','1');
|
|
|
- }
|
|
|
-
|
|
|
- if ($action == 'add' || intval($add) == 1 ) {
|
|
|
- $form->addElement('hidden', 'add','1');
|
|
|
- }
|
|
|
-
|
|
|
- if (($description_type >= ADD_BLOCK) || $default_description_title_editable[$description_type] || $action == 'add' || intval($edit) == 1) {
|
|
|
- $form->add_textfield('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
|
|
|
- $form->applyFilter('title','html_filter');
|
|
|
- }
|
|
|
-
|
|
|
- if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
|
|
|
- WCAG_rendering::prepare_admin_form($description_content, $form);
|
|
|
- } else {
|
|
|
- $form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
|
|
|
- }
|
|
|
- $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
|
|
|
- // Set some default values
|
|
|
- $default['title'] = $default_description_titles[$description_type];
|
|
|
- $default['contentDescription'] = $description_content;
|
|
|
- $default['description_id'] = $description_id;
|
|
|
- $default['description_type'] = $description_type;
|
|
|
- //if ($description_id >= ADD_BLOCK) {
|
|
|
- //$default['description_id'] = ADD_BLOCK;
|
|
|
- //}
|
|
|
- $form->setDefaults($default);
|
|
|
- // If form validates: save the description block
|
|
|
- if ($form->validate()) {
|
|
|
- $description = $form->exportValues();
|
|
|
- if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
|
|
|
- $content = WCAG_Rendering::prepareXHTML();
|
|
|
- } else {
|
|
|
- $content = $description['contentDescription'];
|
|
|
- }
|
|
|
- $title = $description['title'];
|
|
|
- if ($description['description_type'] >= ADD_BLOCK) {
|
|
|
- if ($description['add']=='1') { //if this element has been submitted for addition
|
|
|
- $result = Database::query($sql, __FILE__, __LINE__);
|
|
|
- $sql = "INSERT IGNORE INTO $tbl_course_description SET description_type='$description_type', title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."', session_id = '$current_session_id' ";
|
|
|
- Database::query($sql, __FILE__, __LINE__);
|
|
|
- } else {
|
|
|
- $sql = "UPDATE $tbl_course_description SET title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."' WHERE description_type='$description_type' AND session_id = '$current_session_id'";
|
|
|
- Database::query($sql, __FILE__, __LINE__);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //if title is not editable, then use default title
|
|
|
- if (!$default_description_title_editable[$description_type]) {
|
|
|
- $title = $default_description_titles[$description_type];
|
|
|
- }
|
|
|
- $sql = "DELETE FROM $tbl_course_description WHERE description_type = '".$description_type."' AND session_id = '$current_session_id'";
|
|
|
- Database::query($sql, __FILE__, __LINE__);
|
|
|
- $sql = "INSERT INTO $tbl_course_description SET description_type = '".$description_type."', title = '".Database::escape_string(Security::remove_XSS($title,COURSEMANAGERLOWSECURITY))."', content = '".Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY))."', session_id = '$current_session_id' ";
|
|
|
- Database::query($sql, __FILE__, __LINE__);
|
|
|
- }
|
|
|
- $id = Database::insert_id();
|
|
|
- if ($id > 0) {
|
|
|
- //insert into item_property
|
|
|
- api_item_property_update(api_get_course_info(), TOOL_COURSE_DESCRIPTION, $id, 'CourseDescriptionAdded', api_get_user_id());
|
|
|
- }
|
|
|
- Display :: display_confirmation_message(get_lang('CourseDescriptionUpdated'));
|
|
|
- }
|
|
|
- // Show the form
|
|
|
- else {
|
|
|
- // menu top
|
|
|
- //***********************************
|
|
|
- if (api_is_allowed_to_edit(null,true)) {
|
|
|
- $categories = array ();
|
|
|
-
|
|
|
- foreach ($default_description_titles as $id => $title) {
|
|
|
- $categories[$id] = $title;
|
|
|
- }
|
|
|
- $categories[ADD_BLOCK] = get_lang('NewBloc');
|
|
|
-
|
|
|
- $i=1;
|
|
|
- echo '<div class="actions">';
|
|
|
- ksort($categories);
|
|
|
- foreach ($categories as $id => $title) {
|
|
|
- if ($i==8) {
|
|
|
- echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
|
|
|
+if(intval($description_type) == 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('ThematicAdvance'));
|
|
|
+if(intval($description_type) >= 9) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Others'));
|
|
|
+
|
|
|
+// course description controller object
|
|
|
+$course_description_controller = new CourseDescriptionController();
|
|
|
+
|
|
|
+// distpacher actions to controller
|
|
|
+switch ($action) {
|
|
|
+ case 'listing':
|
|
|
+ $course_description_controller->listing();
|
|
|
+ break;
|
|
|
+ case 'history':
|
|
|
+ $course_description_controller->listing(true);
|
|
|
break;
|
|
|
- } else {
|
|
|
- echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_type='.$id.'">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a> ';
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- echo '</div>';
|
|
|
- }
|
|
|
- //***********************************
|
|
|
- if ($show_peda_suggest) {
|
|
|
- if (isset ($question[$description_id])) {
|
|
|
- $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
|
|
|
- $message .= $question[$description_id];
|
|
|
- Display::display_normal_message($message, false);
|
|
|
- }
|
|
|
- }
|
|
|
- if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
|
|
|
- echo (WCAG_Rendering::editor_header());
|
|
|
- }
|
|
|
- $form->display();
|
|
|
- if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
|
|
|
- echo (WCAG_Rendering::editor_footer());
|
|
|
- }
|
|
|
- $show_description_list = false;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// Show the list of all description blocks
|
|
|
-if ($show_description_list) {
|
|
|
- $sql = "SELECT * FROM $tbl_course_description $condition_session ORDER BY id ";
|
|
|
- $result = Database::query($sql, __FILE__, __LINE__);
|
|
|
- $descriptions = array();
|
|
|
- while ($description = Database::fetch_object($result)) {
|
|
|
- $descriptions[$description->description_type] = $description;
|
|
|
- //reload titles to ensure we have the last version (after edition)
|
|
|
- $default_description_titles[$description->description_type] = $description->title;
|
|
|
- }
|
|
|
- if (api_is_allowed_to_edit(null,true)) {
|
|
|
- $categories = array ();
|
|
|
-
|
|
|
- foreach ($default_description_titles as $id => $title) {
|
|
|
- $categories[$id] = $title;
|
|
|
- }
|
|
|
- $categories[ADD_BLOCK] = get_lang('NewBloc');
|
|
|
-
|
|
|
- $i=1;
|
|
|
- echo '<div class="actions" style="margin-bottom:30px">';
|
|
|
- ksort($categories);
|
|
|
- foreach ($categories as $id => $title) {
|
|
|
- if ($i==8) {
|
|
|
- echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
|
|
|
- break;
|
|
|
- } else {
|
|
|
- echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_type='.$id.'">'.Display::return_icon($default_description_icon[$id], $title, array('height'=>'22')).' '.$title.'</a> ';
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
- echo '</div>';
|
|
|
- }
|
|
|
- if (isset($descriptions) && count($descriptions) > 0) {
|
|
|
- foreach ($descriptions as $id => $description) {
|
|
|
- echo '<div class="sectiontitle">';
|
|
|
- if (api_is_allowed_to_edit(null,true)) {
|
|
|
- //delete
|
|
|
- echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&description_id='.$description->id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
|
|
|
- echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'));
|
|
|
- echo '</a> ';
|
|
|
-
|
|
|
- //edit
|
|
|
- echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&description_id='.$description->id.'&description_type='.$description->description_type.'">';
|
|
|
- echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'));
|
|
|
- echo '</a> ';
|
|
|
- }
|
|
|
- echo $description->title;
|
|
|
- echo '</div>';
|
|
|
- echo '<div class="sectioncomment">';
|
|
|
- echo text_filter($description->content);
|
|
|
- echo '</div>';
|
|
|
- }
|
|
|
- } else {
|
|
|
- echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
|
|
|
- }
|
|
|
+ case 'add' :
|
|
|
+ if (api_is_allowed_to_edit(null,true)) {
|
|
|
+ $course_description_controller->add();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'edit' :
|
|
|
+ if (api_is_allowed_to_edit(null,true)) {
|
|
|
+ $course_description_controller->edit($description_type);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'delete' :
|
|
|
+ if (api_is_allowed_to_edit(null,true)) {
|
|
|
+ $course_description_controller->destroy($description_type);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default :
|
|
|
+ $course_description_controller->listing();
|
|
|
}
|
|
|
-/*
|
|
|
-==============================================================================
|
|
|
- FOOTER
|
|
|
-==============================================================================
|
|
|
-*/
|
|
|
-Display :: display_footer();
|
|
|
-?>
|
|
|
+?>
|