Fix justification set course BT#16387

pull/3052/head
Julio 6 years ago
parent c4f198c452
commit ff603f43dc
  1. 3
      plugin/justification/lang/english.php
  2. 2
      plugin/justification/list.php
  3. 11
      plugin/justification/set_course.php

@ -14,7 +14,8 @@ $strings['Justification'] = "Justification";
$strings['MyJustifications'] = "My justifications";
$strings['JustificationSaved'] = "Justification saved";
$strings['default_course_id'] = "Course id";
$strings['SetCourse'] = "Set course";
$strings['SetNewCourse'] = "Set new course";
$strings['SubscribeToASession'] = "Subscribe to a session";

@ -47,7 +47,7 @@ if (api_is_platform_admin()) {
);
$actionLinks .= Display::toolbarButton(
$plugin->get_lang('SetCourse'),
$plugin->get_lang('SetNewCourse'),
api_get_path(WEB_PLUGIN_PATH).'justification/set_course.php',
'book',
'primary'

@ -12,7 +12,14 @@ $tpl = new Template($tool);
$fields = [];
$form = new FormValidator('add');
$form->addHeader($plugin->get_lang('SetCourse'));
$form->addHeader($plugin->get_lang('SetNewCourse'));
$currentCourse = api_get_setting('justification_default_course_id', 'justification');
if (!empty($currentCourse)) {
$courseInfo = api_get_course_info_by_id($currentCourse);
Display::addFlash(Display::return_message(get_lang('Course').': '.$courseInfo['title']));
}
$form->addSelectAjax(
'course_id',
get_lang('Course'),
@ -25,7 +32,7 @@ $form->addButtonSave(get_lang('Save'));
if ($form->validate()) {
$values = $form->getSubmitValues();
api_set_setting('justification_default_course_id', $values['course_id'], 'justification');
api_set_setting('justification_default_course_id', $values['course_id']);
Display::addFlash(Display::return_message(get_lang('Saved')));
$url = api_get_path(WEB_PLUGIN_PATH).'justification/list.php?';
header('Location: '.$url);

Loading…
Cancel
Save