Merge pull request #62 from jmontoyaa/1.9.x

Auto subscription is only allow for "open to members" and "open to the w...
1.9.x
Julio Montoya 12 years ago
commit 96e1a83d0f
  1. 21
      main/auth/courses_controller.php
  2. 4
      main/inc/lib/course.lib.php
  3. 2
      main/inc/lib/main_api.lib.php

@ -167,17 +167,24 @@ class CoursesController { // extends Controller {
}
/**
*
* Auto user subcription to a course
*/
public function subscribe_user($course_code, $search_term, $category_code) {
$data = array();
$result = $this->model->subscribe_user($course_code);
if (!$result) {
$error = get_lang('CourseRegistrationCodeIncorrect');
$courseInfo = api_get_course_info($course_code);
// The course must be open in order to access the auto subscription
if (in_array($courseInfo['visibility'], array(COURSE_VISIBILITY_CLOSED, COURSE_VISIBILITY_REGISTERED))) {
$error = get_lang('SubscribingNotAllowed');
//$message = get_lang('SubscribingNotAllowed');
} else {
//Redirect directly to the course after subscription
$message = $result['message'];
$content = $result['content'];
$result = $this->model->subscribe_user($course_code);
if (!$result) {
$error = get_lang('CourseRegistrationCodeIncorrect');
} else {
//Redirect directly to the course after subscription
$message = $result['message'];
$content = $result['content'];
}
}
if (!empty($search_term)) {

@ -3967,8 +3967,8 @@ class CourseManager {
if (!api_is_anonymous($uid) &&
!$is_admin &&
(
($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) ||
$course['visibility'] == COURSE_VISIBILITY_REGISTERED && $course['subscribe'] == SUBSCRIBE_ALLOWED
($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
//$course['visibility'] == COURSE_VISIBILITY_REGISTERED && $course['subscribe'] == SUBSCRIBE_ALLOWED
) &&
$course['subscribe'] == SUBSCRIBE_ALLOWED &&
(!in_array($course['real_id'], $user_courses) || empty($user_courses))

@ -58,7 +58,7 @@ $_status_list[ANONYMOUS] = 'anonymous'; // 6
// COURSE VISIBILITY CONSTANTS
/** only visible for course admin */
define('COURSE_VISIBILITY_CLOSED', 0);
/** only visible for users registered in the course*/
/** only visible for users registered in the course */
define('COURSE_VISIBILITY_REGISTERED', 1);
/** Open for all registered users on the platform */
define('COURSE_VISIBILITY_OPEN_PLATFORM', 2);

Loading…
Cancel
Save