diff --git a/main/admin/course_add.php b/main/admin/course_add.php
index 6b7369a575..8046956948 100644
--- a/main/admin/course_add.php
+++ b/main/admin/course_add.php
@@ -92,6 +92,7 @@ $group[]= $form->createElement('radio', 'visibility', get_lang('CourseAccess'),
$group[]= $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[]= $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
+$group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addGroup($group,'', get_lang('CourseAccess'), '
');
diff --git a/main/admin/course_edit.php b/main/admin/course_edit.php
index 02557b321b..f0ca8518d9 100644
--- a/main/admin/course_edit.php
+++ b/main/admin/course_edit.php
@@ -157,6 +157,7 @@ $group[]= $form->createElement('radio', 'visibility', get_lang("CourseAccess"),
$group[]= $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[]= $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
+$group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addGroup($group,'', get_lang('CourseAccess'), '
');
$group = array();
diff --git a/main/admin/course_list.php b/main/admin/course_list.php
index f3ce4c1ec6..c77212890d 100644
--- a/main/admin/course_list.php
+++ b/main/admin/course_list.php
@@ -148,6 +148,9 @@ function get_course_visibility_icon($v) {
case 3:
return Display::return_icon('bullet_blue.gif', get_lang('OpenToTheWorld'), array('style' => $style));
break;
+ case 4:
+ return Display::return_icon('bullet_grey.gif', get_lang('CourseVisibilityHidden'), array('style' => $style));
+ break;
default:
return '';
}
@@ -192,6 +195,7 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$form->addElement('radio', 'keyword_visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$form->addElement('radio', 'keyword_visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
+ $form->addElement('radio', 'keyword_visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
$form->addElement('radio', 'keyword_visibility', null, get_lang('All'), '%');
$form->addElement('radio', 'keyword_subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$form->addElement('radio', 'keyword_subscribe', null, get_lang('Denied'), 0);
diff --git a/main/auth/courses_controller.php b/main/auth/courses_controller.php
index 4ea8f6b29c..33d2bde955 100644
--- a/main/auth/courses_controller.php
+++ b/main/auth/courses_controller.php
@@ -173,7 +173,7 @@ class CoursesController { // extends Controller {
$data = array();
$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))) {
+ if (in_array($courseInfo['visibility'], array(COURSE_VISIBILITY_CLOSED, COURSE_VISIBILITY_REGISTERED, COURSE_VISIBILITY_HIDDEN))) {
$error = get_lang('SubscribingNotAllowed');
//$message = get_lang('SubscribingNotAllowed');
} else {
diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php
index 786c5ff379..419009e70d 100644
--- a/main/course_info/infocours.php
+++ b/main/course_info/infocours.php
@@ -196,6 +196,10 @@ $group[]= $form->createElement('radio', 'visibility', get_lang("CourseAccess"),
$group[]= $form->createElement('radio', 'visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);
$group[]= $form->createElement('radio', 'visibility', null, get_lang('Private'), COURSE_VISIBILITY_REGISTERED);
$group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED);
+// The "hidden" visibility is only available to portal admins
+if (api_is_platform_admin()) {
+ $group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisibilityHidden'), COURSE_VISIBILITY_HIDDEN);
+}
$form->addGroup($group, '', array(get_lang("CourseAccess"), get_lang("CourseAccessConfigTip")), '');
$url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=1";
diff --git a/main/img/bullet_grey.gif b/main/img/bullet_grey.gif
new file mode 100644
index 0000000000..f00836df66
Binary files /dev/null and b/main/img/bullet_grey.gif differ
diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php
index fb34850743..75bc219260 100644
--- a/main/inc/lib/course.lib.php
+++ b/main/inc/lib/course.lib.php
@@ -2961,6 +2961,9 @@ class CourseManager {
if ($number_of_courses > 0) {
while ($course = Database::fetch_array($rs_special_course)) {
$course_info = api_get_course_info($course['code']);
+ if ($course_info['visibility'] != COURSE_VISIBILITY_HIDDEN) {
+ continue;
+ }
$params = array();
// Get notifications.
//$course['id_session'] = null;
@@ -3108,6 +3111,9 @@ class CourseManager {
// Browse through all courses.
while ($course = Database::fetch_array($result)) {
$course_info = api_get_course_info($course['code']);
+ if ($course_info['visibility'] == COURSE_VISIBILITY_HIDDEN) {
+ continue;
+ }
//$course['id_session'] = null;
$course_info['id_session'] = null;
$course_info['status'] = $course['status'];
@@ -3281,7 +3287,7 @@ class CourseManager {
$session_title = '';
if ($session_accessible) {
- if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
+ if ($course_visibility != COURSE_VISIBILITY_HIDDEN && ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER)) {
if (!$nosession) {
if (empty($course_info['id_session'])) {
$course_info['id_session'] = 0;
@@ -3308,7 +3314,7 @@ class CourseManager {
$params['right_actions'] = '';
- if ($course_visibility != COURSE_VISIBILITY_CLOSED) {
+ if ($course_visibility != COURSE_VISIBILITY_CLOSED && $course_visibility != COURSE_VISIBILITY_HIDDEN) {
if ($load_dirs) {
$params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'';
$params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_'.$course_info['id_session'], 'class'=>'document_preview_container'));
@@ -3338,7 +3344,7 @@ class CourseManager {
$session_title .= isset($course['special_course']) ? ' '.Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : '';
// Display the "what's new" icons
- if ($course_visibility != COURSE_VISIBILITY_CLOSED) {
+ if ($course_visibility != COURSE_VISIBILITY_CLOSED && $course_visibility != COURSE_VISIBILITY_HIDDEN) {
$session_title .= Display :: show_notification($course_info);
}
@@ -3802,7 +3808,7 @@ class CourseManager {
" WHERE u.access_url_id = ".$_configuration['access_url']." AND".
" login_course_date <= now() AND ".
" login_course_date > DATE_SUB(now(), INTERVAL $days DAY) AND".
- " visibility <> '".COURSE_VISIBILITY_CLOSED."'".
+ " visibility <> '".COURSE_VISIBILITY_CLOSED."' AND visibility <> '".COURSE_VISIBILITY_HIDDEN."'".
" GROUP BY course_code".
" ORDER BY course_count DESC".
" LIMIT $limit";
@@ -3925,6 +3931,9 @@ class CourseManager {
if (!isset($course['real_id']) && empty($course['real_id'])) {
$course = api_get_course_info($course['code']);
}
+ if ($course['visibility'] != COURSE_VISIBILITY_HIDDEN) {
+ return array();
+ }
$is_admin = api_is_platform_admin_by_id($uid);
$options = array();
diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php
index 91ed47f713..b25e850449 100644
--- a/main/inc/lib/login.lib.php
+++ b/main/inc/lib/login.lib.php
@@ -673,6 +673,11 @@ class Login
$is_allowed_in_course = true;
}
break;
+ case COURSE_VISIBILITY_HIDDEN: //4
+ if ($is_platformAdmin) {
+ $is_allowed_in_course = true;
+ }
+ break;
}
}
diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php
index 225bb40395..381982598e 100644
--- a/main/inc/lib/main_api.lib.php
+++ b/main/inc/lib/main_api.lib.php
@@ -64,7 +64,8 @@ define('COURSE_VISIBILITY_REGISTERED', 1);
define('COURSE_VISIBILITY_OPEN_PLATFORM', 2);
/** Open for the whole world */
define('COURSE_VISIBILITY_OPEN_WORLD', 3);
-
+/** Invisible to all except admin */
+define('COURSE_VISIBILITY_HIDDEN', 4);
// SESSION VISIBILITY CONSTANTS
define('SESSION_VISIBLE_READ_ONLY', 1);
@@ -887,6 +888,11 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
case COURSE_VISIBILITY_OPEN_WORLD: //Open - access allowed for the whole world - 3
$is_visible = true;
break;
+ case COURSE_VISIBILITY_HIDDEN: //Completely closed: the course is only accessible to the teachers. - 0
+ if (api_is_platform_admin()) {
+ $is_visible = true;
+ }
+ break;
}
//If pasword is set and user is not registered to the course then the course is not visible
if ($is_allowed_in_course == false & isset($course_info['registration_code']) && !empty($course_info['registration_code'])) {
@@ -4824,6 +4830,8 @@ function api_is_course_visible_for_user($userid = null, $cid = null) {
case COURSE_VISIBILITY_REGISTERED:
case COURSE_VISIBILITY_CLOSED:
return $is_platformAdmin || $is_courseMember || $is_courseAdmin;
+ case COURSE_VISIBILITY_HIDDEN:
+ return $is_platformAdmin;
}
return false;
}
diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php
index 48007e434a..010c6ea506 100644
--- a/main/inc/lib/social.lib.php
+++ b/main/inc/lib/social.lib.php
@@ -460,7 +460,7 @@ class SocialManager extends UserManager
$result .= $s_htlm_status_icon;
//show a hyperlink to the course, unless the course is closed and user is not course admin
- if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
+ if ($course_visibility != COURSE_VISIBILITY_HIDDEN && ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER)) {
$result .= ' '.$course_title.'';
} else {
$result .= $course_title." "." ".get_lang('CourseClosed')."";
diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php
index 9a46cf5ad7..5186682673 100644
--- a/main/inc/lib/userportal.lib.php
+++ b/main/inc/lib/userportal.lib.php
@@ -497,7 +497,7 @@ class IndexManager {
foreach ($course_list as $course) {
// $setting_show_also_closed_courses
-
+ if ($course['visibility'] == COURSE_VISIBILITY_HIDDEN) { continue; }
if (!$setting_show_also_closed_courses) {
// If we do not show the closed courses
// we only show the courses that are open to the world (to everybody)
@@ -532,15 +532,17 @@ class IndexManager {
$courses_list_string .= "