diff --git a/certificates/index.php b/certificates/index.php index a8f1944d42..f7bcc1892b 100755 --- a/certificates/index.php +++ b/certificates/index.php @@ -10,6 +10,24 @@ require_once '../main/inc/global.inc.php'; $action = isset($_GET['action']) ? $_GET['action'] : null; $userId = isset($_GET['user_id']) ? $_GET['user_id'] : 0; +$category = Category::findByCertificate($_GET['id']); + +// Check if the certificate should use the course language +if (!empty($category) && !empty($category->get_course_code())) { + $courseInfo = api_get_course_info($category->get_course_code()); + $language = $courseInfo['language']; + + $languageFilesToLoad = api_get_language_files_to_load($language); + + foreach ($languageFilesToLoad as $languageFile) { + include $languageFile; + } + + // Overwrite the interface language with the course language + $language_interface = $language; + $language_interface_initial_value = $language_interface; +} + $certificate = new Certificate($_GET['id'], $userId); CustomCertificatePlugin::redirectCheck($certificate, $_GET['id'], $userId); diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 735b51a831..33df764d12 100755 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -2774,4 +2774,32 @@ class Category implements GradebookItem return api_float_val($categoryScore); } + + /** + * Find a gradebook category by the certificate ID. + * + * @param int $id + * + * @return Category|null + * @throws \Doctrine\ORM\NonUniqueResultException + */ + public static function findByCertificate($id) + { + $categoryId = Database::getManager() + ->createQuery("SELECT c.catId FROM ChamiloCoreBundle:GradebookCertificate c WHERE c.id = :id") + ->setParameters(['id' => $id]) + ->getOneOrNullResult(); + + if (empty($categoryId)) { + return null; + } + + $category = self::load($categoryId['catId']); + + if (empty($category)) { + return $category; + } + + return $category[0]; + } }