Add option to redirect to course home in the catalog:

Setting: course_catalog_settings.redirect_after_subscription
pull/3159/head
Julio Montoya 6 years ago
parent ec7a67a518
commit ed7b80c7ba
  1. 33
      main/auth/courses.php
  2. 3
      main/install/configuration.dist.php

@ -64,6 +64,24 @@ $currentUrl = api_get_path(WEB_CODE_PATH).'auth/courses.php?category_code='.$cat
$content = ''; $content = '';
$toolTitle = get_lang('CourseCatalog'); $toolTitle = get_lang('CourseCatalog');
$courseCatalogSettings = [
'info_url' => 'course_description_popup',
'title_url' => 'course_home',
'image_url' => 'course_about',
];
$redirectAfterSubscription = 'course_home';
$settings = api_get_configuration_value('course_catalog_settings');
if (!empty($settings)) {
if (isset($settings['link_settings'])) {
$courseCatalogSettings = $settings['link_settings'];
}
if (isset($settings['redirect_after_subscription'])) {
$redirectAfterSubscription = $settings['redirect_after_subscription'];
}
}
switch ($action) { switch ($action) {
case 'unsubscribe': case 'unsubscribe':
// We are unsubscribing from a course (=Unsubscribe from course). // We are unsubscribing from a course (=Unsubscribe from course).
@ -86,7 +104,12 @@ switch ($action) {
} }
$courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : ''; $courseCodeToSubscribe = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : '';
if (Security::check_token('get')) { if (Security::check_token('get')) {
$courseInfo = api_get_course_info($courseCodeToSubscribe);
CourseManager::autoSubscribeToCourse($courseCodeToSubscribe); CourseManager::autoSubscribeToCourse($courseCodeToSubscribe);
if ('course_home' === $redirectAfterSubscription) {
header('Location: '.$courseInfo['course_public_url']);
exit;
}
header('Location: '.api_get_self()); header('Location: '.api_get_self());
exit; exit;
} }
@ -387,16 +410,6 @@ switch ($action) {
$courseUrl = api_get_path(WEB_COURSE_PATH); $courseUrl = api_get_path(WEB_COURSE_PATH);
$hideRating = api_get_configuration_value('hide_course_rating'); $hideRating = api_get_configuration_value('hide_course_rating');
$courseCatalogSettings = [
'info_url' => 'course_description_popup',
'title_url' => 'course_home',
'image_url' => 'course_about',
];
$settings = api_get_configuration_value('course_catalog_settings');
if (!empty($settings) && isset($settings['link_settings'])) {
$courseCatalogSettings = $settings['link_settings'];
}
if (!empty($courses)) { if (!empty($courses)) {
foreach ($courses as &$course) { foreach ($courses as &$course) {

@ -1434,7 +1434,8 @@ ALTER TABLE notification_event ADD COLUMN event_id INT NULL;
'info_url' => 'course_description_popup', // course description popup page 'info_url' => 'course_description_popup', // course description popup page
'title_url' => 'course_home', // Course home URL 'title_url' => 'course_home', // Course home URL
'image_url' => 'course_about', // Course about URL 'image_url' => 'course_about', // Course about URL
], ]
'redirect_after_subscription' => 'course_home', // or 'course_catalog' to stay in the page
];*/ ];*/
// KEEP THIS AT THE END // KEEP THIS AT THE END

Loading…
Cancel
Save