diff --git a/main/admin/course_category.php b/main/admin/course_category.php index 40ab5cb99a9..377f973eea4 100755 --- a/main/admin/course_category.php +++ b/main/admin/course_category.php @@ -54,8 +54,11 @@ if (!$ret) { $errorMsg = Display::return_message(get_lang('CatCodeAlreadyUsed'), 'error'); } else { - if ($myCourseListAsCategory && isset($_FILES['image'])) { - CourseCategory::saveImage($ret, $_FILES['image']); + if ($myCourseListAsCategory) { + if (isset($_FILES['image'])) { + CourseCategory::saveImage($ret, $_FILES['image']); + } + CourseCategory::saveDescription($ret, $_POST['description']); } } @@ -129,12 +132,19 @@ $form->addGroup($group, null, get_lang("AllowCoursesInCategory")); if ($myCourseListAsCategory) { + $form->addHtmlEditor( + 'description', + get_lang('Description'), + false, + false, + ['ToolbarSet' => 'Minimal'] + ); $form->addFile('image', get_lang('Image'), ['accept' => 'image/*']); - if ($action == 'edit' && !empty($categoryInfo['image'])) { $form->addHtml('
-
'.Display::img( +
'. + Display::img( api_get_path(WEB_UPLOAD_PATH).$categoryInfo['image'], get_lang('Image'), ['width' => 256] diff --git a/main/inc/lib/course_category.lib.php b/main/inc/lib/course_category.lib.php index a184e9b5355..4fd10c1f7d1 100755 --- a/main/inc/lib/course_category.lib.php +++ b/main/inc/lib/course_category.lib.php @@ -1158,6 +1158,11 @@ public static function getCourseCatalogNameTools($action) */ public static function saveImage($categoryId, $fileData) { + $categoryInfo = self::getCategoryById($categoryId); + if (empty($categoryInfo)) { + return; + } + if (!empty($fileData['error'])) { return; } @@ -1176,7 +1181,31 @@ public static function saveImage($categoryId, $fileData) $image->send_image($fileDir.$fileName); $table = Database::get_main_table(TABLE_MAIN_CATEGORY); + Database::update( + $table, + ['image' => $dirName.$fileName], + ['id = ?' => $categoryId] + ); + } - Database::update($table, ['image' => $dirName.$fileName], ['id = ?' => $categoryId]); + /** + * @param $categoryId + * @param string $description + * + * @return string + */ + public static function saveDescription($categoryId, $description) + { + $categoryInfo = self::getCategoryById($categoryId); + if (empty($categoryInfo)) { + return false; + } + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); + Database::update( + $table, + ['description' => $description], + ['id = ?' => $categoryId] + ); + return true; } } diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index cd959fa15e8..fb46a6a59f8 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -572,6 +572,7 @@ //$_configuration['show_simple_session_info'] = true; // Show course category list on My Courses page before the courses. Requires a DB change //ALTER TABLE course_category ADD image varchar(255) NULL; +//ALTER TABLE course_category ADD description LONGTEXT NULL; //$_configuration['my_courses_list_as_category'] = false; // ------ diff --git a/main/template/default/user_portal/course_categories.tpl b/main/template/default/user_portal/course_categories.tpl index 7921a67db5e..f547cb4eb75 100644 --- a/main/template/default/user_portal/course_categories.tpl +++ b/main/template/default/user_portal/course_categories.tpl @@ -12,6 +12,9 @@

{{ category.name }}

{{ category.code }}

+ {% if category.description %} +

{{ category.description }}

+ {% endif %} {{ 'View'|get_lang }}