Minor - format code, remove token, if session_id is empty set to 0

1.10.x
jmontoya 10 years ago
parent 9111c61ce6
commit a48a2093d6
  1. 9
      main/course_description/add.php
  2. 10
      main/course_description/course_description_controller.php
  3. 44
      main/course_description/index.php
  4. 7
      main/coursecopy/classes/CourseRestorer.class.php

@ -24,7 +24,7 @@ echo '<a href="index.php?'.api_get_cidreq().'">'.
'</a>';
ksort($categories);
foreach ($categories as $id => $title) {
if ($i==ADD_BLOCK) {
if ($i == ADD_BLOCK) {
echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
Display::return_icon($default_description_icon[$id], $title, '',ICON_SIZE_MEDIUM).'</a>';
break;
@ -38,7 +38,7 @@ echo '</div>';
// error messages
if (isset($error) && intval($error) == 1) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
}
// default header title form
@ -48,9 +48,6 @@ if ($description_type >= ADD_BLOCK) {
$header = $default_description_titles[ADD_BLOCK];
}
if (!$error) {
$token = Security::get_token();
}
// display form
$form = new FormValidator(
'course_description',
@ -61,7 +58,7 @@ $form->addElement('header', '', $header);
$form->addElement('hidden', 'description_type', $description_type);
$form->addElement('hidden', 'sec_token', $token);
$form->addText('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
$form->applyFilter('title','html_filter');
$form->applyFilter('title', 'html_filter');
$form->addHtmlEditor(
'contentDescription',
get_lang('Content'),

@ -76,11 +76,9 @@ class CourseDescriptionController
$data = array();
$data['id'] = $id;
$affected_rows = null;
$message = array();
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
$check = Security::check_token();
if ($check) {
if (1) {
$title = $_POST['title'];
$content = $_POST['contentDescription'];
$description_type = $_POST['description_type'];
@ -108,7 +106,6 @@ class CourseDescriptionController
} else {
$course_description->insert();
}
Security::clear_token();
Display::addFlash(
Display::return_message(
@ -193,9 +190,7 @@ class CourseDescriptionController
$data = array();
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (!empty($_POST['title']) && !empty($_POST['contentDescription'])) {
$check = Security::check_token();
if ($check) {
if (1) {
$title = $_POST['title'];
$content = $_POST['contentDescription'];
$description_type = $_POST['description_type'];
@ -205,7 +200,6 @@ class CourseDescriptionController
$course_description->set_content($content);
$course_description->insert(api_get_course_int_id());
}
Security::clear_token();
Display::addFlash(
Display::return_message(

@ -34,29 +34,47 @@ if (isset($_GET['description_type'])) {
$id = null;
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
$id = intval($_GET['id']);
}
if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
$action = 'listing';
$action = 'listing';
}
// interbreadcrumb
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
if ($description_type == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
if ($description_type == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
if ($description_type == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics'));
if ($description_type == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology'));
if ($description_type == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial'));
if ($description_type == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
if ($description_type == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment'));
if ($description_type == 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('ThematicAdvance'));
if ($description_type >= 9) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Others'));
$interbreadcrumb[] = array ("url" => "index.php?".api_get_cidreq(), "name" => get_lang('CourseProgram'));
if ($description_type == 1) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('GeneralDescription'));
}
if ($description_type == 2) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Objectives'));
}
if ($description_type == 3) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Topics'));
}
if ($description_type == 4) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Methodology'));
}
if ($description_type == 5) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('CourseMaterial'));
}
if ($description_type == 6) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
}
if ($description_type == 7) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Assessment'));
}
if ($description_type == 8) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('ThematicAdvance'));
}
if ($description_type >= 9) {
$interbreadcrumb[] = array("url" => "#", "name" => get_lang('Others'));
}
// course description controller object
$course_description_controller = new CourseDescriptionController();
// distpacher actions to controller
// Actions to controller
switch ($action) {
case 'listing':
$course_description_controller->listing();

@ -1536,10 +1536,9 @@ class CourseRestorer
);
$params = [];
if (!empty($session_id)) {
$session_id = intval($session_id);
$params['session_id'] = $session_id;
}
$session_id = intval($session_id);
$params['session_id'] = $session_id;
$params['c_id'] = $this->destination_course_id;
$params['description_type'] = self::DBUTF8($descriptionType);
$params['title'] = self::DBUTF8($title);

Loading…
Cancel
Save