diff --git a/main/admin/course_add.php b/main/admin/course_add.php index 2994777e98..4d46c442a5 100755 --- a/main/admin/course_add.php +++ b/main/admin/course_add.php @@ -200,6 +200,14 @@ if ($form->validate()) { $course['gradebook_model_id'] = isset($course['gradebook_model_id']) ? $course['gradebook_model_id'] : null; // Fixing category code $course['course_category'] = isset($course['category_code']) ? $course['category_code'] : ''; + + include_once api_get_path(SYS_CODE_PATH) . 'lang/english/trad4all.inc.php'; + $file_to_include = api_get_path(SYS_CODE_PATH) . 'lang/' . $course['course_language'] . '/trad4all.inc.php'; + + if (file_exists($file_to_include)) { + include $file_to_include; + } + $course_info = CourseManager::create_course($course); header('Location: course_list.php'.($course_info===false?'?action=show_msg&warn='.api_get_last_failure():'')); diff --git a/main/create_course/add_course.php b/main/create_course/add_course.php index 65cd4830e4..3516518914 100755 --- a/main/create_course/add_course.php +++ b/main/create_course/add_course.php @@ -293,6 +293,13 @@ if ($form->validate()) { $params['course_language'] = $course_language; $params['gradebook_model_id'] = isset($course_values['gradebook_model_id']) ? $course_values['gradebook_model_id'] : null; + include_once api_get_path(SYS_CODE_PATH) . 'lang/english/trad4all.inc.php'; + $file_to_include = api_get_path(SYS_CODE_PATH) . 'lang/' . $course_language . '/trad4all.inc.php'; + + if (file_exists($file_to_include)) { + include $file_to_include; + } + $course_info = CourseManager::create_course($params); if (!empty($course_info)) { diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index ecbda3cc60..c3295371a8 100755 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -394,21 +394,6 @@ class AddCourse return $pictures; } - /** - * Function to convert a string from the language files to a string ready - * to insert into the database (escapes single quotes) - * @author Bart Mollet (bart.mollet@hogent.be) - * @param string $string The string to convert - * @return string The string converted to insert into the database - * @assert ('a\'b') === 'ab' - */ - public static function lang2db($string) - { - $string = str_replace("\\'", "'", $string); - $string = Database::escape_string($string); - return $string; - } - /** * Fills the course database with some required content and example content. * @param int Course (int) ID @@ -452,13 +437,6 @@ class AddCourse TABLE_MAIN_GRADEBOOK_LINK ); - include_once api_get_path(SYS_CODE_PATH) . 'lang/english/trad4all.inc.php'; - $file_to_include = api_get_path(SYS_CODE_PATH) . 'lang/' . $language . '/trad4all.inc.php'; - - if (file_exists($file_to_include)) { - include_once $file_to_include; - } - $visible_for_all = 1; $visible_for_course_admin = 0; $visible_for_platform_admin = 2; @@ -686,21 +664,28 @@ class AddCourse /* Course homepage tools for platform admin only */ /* Group tool */ - - Database::query( - "INSERT INTO $TABLEGROUPCATEGORIES (c_id, id, title , description, max_student, self_reg_allowed, self_unreg_allowed, groups_per_user, display_order, doc_state,calendar_state, work_state ,announcements_state, forum_state, wiki_state, chat_state) - VALUES ($course_id, '2', '" . self::lang2db(get_lang('DefaultGroupCategory')) . "', '', '8', '0', '0', '0', '0', 1, 1 ,1 ,1 ,1, 1, 1);" - ); - - /* Example Material */ - global $language_interface; - $language_interface = !empty($language_interface) ? $language_interface : api_get_setting( - 'platformLanguage' + Database::insert( + $TABLEGROUPCATEGORIES, + [ + 'c_id' => $course_id, + 'id' => 2, + 'title' => get_lang('DefaultGroupCategory'), + 'description' => '', + 'max_student' => 8, + 'self_reg_allowed' => 0, + 'self_unreg_allowed' => 0, + 'groups_per_user' => 0, + 'display_order' => 0, + 'doc_state' => 1, + 'calendar_state' => 1, + 'work_state' => 1, + 'announcements_state' => 1, + 'forum_state' => 1, + 'wiki_state' => 1, + 'chat_state' => 1 + ] ); - // Example material should be in the same language as the course is. - $language_interface_original = $language_interface; - $language_interface = $language; $now = api_get_utc_datetime(); $files = [ @@ -996,7 +981,7 @@ class AddCourse /* Introduction text */ $intro_text = '
-