Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

1.9.x
Yannick Warnier 11 years ago
commit 5c934b3d9a
  1. 26
      main/inc/lib/main_api.lib.php
  2. 2
      tests/scripts/fix_exercise_score_in_lp.php

@ -912,36 +912,48 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
$is_allowed_in_course = api_is_allowed_in_course(); $is_allowed_in_course = api_is_allowed_in_course();
$is_visible = false; $is_visible = false;
$course_info = api_get_course_info();
if (empty($course_info)) {
api_not_allowed($print_headers);
return false;
}
if (api_is_drh()) { if (api_is_drh()) {
return true; return true;
} }
if (api_is_platform_admin($allow_session_admins)) { if (api_is_platform_admin($allow_session_admins)) {
return true; return true;
} }
$course_info = api_get_course_info();
if (isset($course_info) && isset($course_info['visibility'])) { if (isset($course_info) && isset($course_info['visibility'])) {
switch ($course_info['visibility']) { switch ($course_info['visibility']) {
default: default:
case COURSE_VISIBILITY_CLOSED: //Completely closed: the course is only accessible to the teachers. - 0 case COURSE_VISIBILITY_CLOSED:
// Completely closed: the course is only accessible to the teachers. - 0
if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) { if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
$is_visible = true; $is_visible = true;
} }
break; break;
case COURSE_VISIBILITY_REGISTERED: //Private - access authorized to course members only - 1 case COURSE_VISIBILITY_REGISTERED:
// Private - access authorized to course members only - 1
if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) { if (api_get_user_id() && !api_is_anonymous() && $is_allowed_in_course) {
$is_visible = true; $is_visible = true;
} }
break; break;
case COURSE_VISIBILITY_OPEN_PLATFORM: // Open - access allowed for users registered on the platform - 2 case COURSE_VISIBILITY_OPEN_PLATFORM:
// Open - access allowed for users registered on the platform - 2
if (api_get_user_id() && !api_is_anonymous()) { if (api_get_user_id() && !api_is_anonymous()) {
$is_visible = true; $is_visible = true;
} }
break; break;
case COURSE_VISIBILITY_OPEN_WORLD: //Open - access allowed for the whole world - 3 case COURSE_VISIBILITY_OPEN_WORLD:
//Open - access allowed for the whole world - 3
$is_visible = true; $is_visible = true;
break; break;
case COURSE_VISIBILITY_HIDDEN: //Completely closed: the course is only accessible to the teachers. - 0 case COURSE_VISIBILITY_HIDDEN:
//Completely closed: the course is only accessible to the teachers. - 0
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$is_visible = true; $is_visible = true;
} }
@ -7583,4 +7595,4 @@ function api_register_campus($listCampus = true) {
Database::query($sql); Database::query($sql);
} }
// Reload the settings. // Reload the settings.
} }

@ -5,6 +5,8 @@
* This script works only if 1 there's one attempt * This script works only if 1 there's one attempt
*/ */
exit;
require_once '../../main/inc/global.inc.php'; require_once '../../main/inc/global.inc.php';
api_protect_admin_script(); api_protect_admin_script();

Loading…
Cancel
Save