Merge pull request #5980 from christianbeeznest/rna-22252

Course: Fix undefined 'name' key error in course category edit - refs BT#22252
pull/5981/head
christianbeeznest 9 months ago committed by GitHub
commit 44c7cce55d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      public/main/admin/course_category.php

@ -73,7 +73,7 @@ switch ($action) {
if (isset($_POST['formSent']) && $_POST['formSent']) {
$categoryEntity = CourseCategory::add(
$_POST['code'],
$_POST['name'],
$_POST['title'],
$_POST['auth_course_child'],
$_POST['description'],
$parentId,
@ -92,7 +92,7 @@ switch ($action) {
if (isset($_POST['formSent']) && $_POST['formSent']) {
$categoryEntity = CourseCategory::edit(
$categoryId,
$_REQUEST['name'],
$_REQUEST['title'],
$_REQUEST['auth_course_child'],
$_REQUEST['code'],
$_REQUEST['description']
@ -144,15 +144,15 @@ if ('add' === $action || 'edit' === $action) {
if ('true' === api_get_setting('editor.save_titles_as_html')) {
$form->addHtmlEditor(
'name',
'title',
get_lang('Category name'),
true,
false,
['ToolbarSet' => 'TitleAsHtml']
);
} else {
$form->addElement('text', 'name', get_lang('Category name'));
$form->addRule('name', get_lang('Please enter a code and a name for the category'), 'required');
$form->addElement('text', 'title', get_lang('Category name'));
$form->addRule('title', get_lang('Please enter a code and a name for the category'), 'required');
}
$form->addRule('code', get_lang('Please enter a code and a name for the category'), 'required');
@ -191,8 +191,9 @@ if ('add' === $action || 'edit' === $action) {
$asset = $assetRepo->find($categoryInfo['asset_id']);
$image = $assetRepo->getAssetUrl($asset);
$escapedImageUrl = htmlspecialchars($image, ENT_QUOTES, 'UTF-8');
$form->addLabel(get_lang('Image'), "<img src=$image />");
$form->addLabel(get_lang('Image'), "<img src='$escapedImageUrl' alt='Image' />");
}
if ('edit' === $action && !empty($categoryInfo)) {

Loading…
Cancel
Save