|
|
|
@ -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)) { |
|
|
|
|