Fix loop when subscribing user to course when its anonymous.

Redirect to inscription if user is anonymous.
remotes/angel/1.11.x
jmontoyaa 8 years ago
parent 268f651ede
commit 536587f301
  1. 6
      main/auth/courses.php
  2. 38
      main/auth/courses_controller.php
  3. 1
      main/auth/inscription.php
  4. 7
      main/template/default/auth/courses_categories.php

@ -151,7 +151,11 @@ if (isset($_REQUEST['search_course'])) {
// Subscribe user to course
if (isset($_REQUEST['subscribe_course'])) {
if ($ctok == $_GET['sec_token']) {
$courses_controller->subscribe_user($_GET['subscribe_course'], $_GET['search_term'], $categoryCode);
$courses_controller->subscribe_user(
$_GET['subscribe_course'],
$_GET['search_term'],
$categoryCode
);
}
}

@ -217,35 +217,37 @@ class CoursesController
return false;
}
$message = '';
$error = '';
$content = '';
$result = [];
// The course must be open in order to access the auto subscription
if (in_array(
$courseInfo['visibility'],
array(COURSE_VISIBILITY_CLOSED, COURSE_VISIBILITY_REGISTERED, COURSE_VISIBILITY_HIDDEN))
) {
$error = get_lang('SubscribingNotAllowed');
Display::addFlash(
Display::return_message(
get_lang('SubscribingNotAllowed'),
'warning'
)
);
} else {
// Redirect to subscription
if (api_is_anonymous()) {
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php&c='.$course_code);
exit;
}
$result = $this->model->subscribe_user($course_code);
if (!$result) {
$error = get_lang('CourseRegistrationCodeIncorrect');
Display::addFlash(
Display::return_message(
get_lang('CourseRegistrationCodeIncorrect'),
'warning'
)
);
} else {
// Redirect directly to the course after subscription
$message = isset($result['message']) ? $result['message'] : '';
$content = isset($result['content']) ? $result['content'] : '';
Display::addFlash(
Display::return_message($result['message'])
);
}
}
if (!empty($search_term)) {
$this->search_courses($search_term, $message, $error, $content);
} else {
$this->courses_categories('subscribe', $category_code, $message, $error, $content);
}
return $result;
}
/**

@ -429,7 +429,6 @@ if (!CustomPages::enabled()) {
// Terms and conditions
if (api_get_setting('allow_terms_conditions') == 'true') {
if (!api_is_platform_admin()) {
if (api_get_setting('show_terms_if_profile_completed') === 'true') {
$userInfo = api_get_user_info();

@ -61,7 +61,6 @@ $code = isset($code) ? $code : null;
<?php } ?>
});
</script>
<div class="row">
<div class="col-md-4">
<h5><?php echo get_lang('Search'); ?></h5>
@ -131,7 +130,6 @@ $code = isset($code) ? $code : null;
<div class="row">
<?php
if ($showCourses && $action != 'display_sessions') {
if (!empty($message)) {
Display::display_confirmation_message($message, false);
}
@ -177,7 +175,10 @@ if ($showCourses && $action != 'display_sessions') {
// display the course bloc
$html .= '<div class="col-xs-6 col-sm-6 col-md-3"><div class="items items-courses">';
$course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : '';
$course['category_title'] = '';
if (isset($course['category'])) {
$course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : '';
}
// display thumbnail
$html .= returnThumbnail($course);

Loading…
Cancel
Save