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

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

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

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

Loading…
Cancel
Save