Skip to content

Commit 9ec3007

Browse files
committed
Admin: Add config hide_breadcrumb_if_not_allowed BT#18892
- If the user is blocked with not allowed (red message), then the breadcrumb is hidden. Adds more checks if course doesn't exists inside a session.
1 parent 266a488 commit 9ec3007

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

main/inc/lib/api.lib.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
11861186
}
11871187

11881188
$isAllowedInCourse = api_is_allowed_in_course();
1189+
11891190
$is_visible = false;
11901191
if (isset($course_info) && isset($course_info['visibility'])) {
11911192
switch ($course_info['visibility']) {
@@ -1247,6 +1248,11 @@ function api_protect_course_script($print_headers = false, $allow_session_admins
12471248
if (!$isAllowedInCourse) {
12481249
$is_visible = false;
12491250
}
1251+
1252+
// Check if course is inside session.
1253+
if (!SessionManager::relation_session_course_exist($session_id, $course_info['real_id'])) {
1254+
$is_visible = false;
1255+
}
12501256
}
12511257

12521258
if (!$is_visible) {
@@ -3935,7 +3941,12 @@ function api_not_allowed(
39353941
$show_headers = 1;
39363942
}
39373943

3938-
$tpl = new Template(null, $show_headers, $show_headers, false, true, false, true, $responseCode);
3944+
$hideBreadCrumb = false;
3945+
if (api_get_configuration_value('hide_breadcrumb_if_not_allowed')) {
3946+
$hideBreadCrumb = true;
3947+
}
3948+
3949+
$tpl = new Template(null, $show_headers, $show_headers, $hideBreadCrumb, true, false, true, $responseCode);
39393950
$tpl->assign('hide_login_link', 1);
39403951
$tpl->assign('content', $msg);
39413952

main/inc/local.inc.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,8 +1300,22 @@
13001300

13011301
// We are in a session course? Check session permissions
13021302
if (!empty($session_id)) {
1303-
if (!empty($session_id) && !empty($_course)) {
1303+
if (!empty($_course)) {
13041304
if (!SessionManager::relation_session_course_exist($session_id, $_course['real_id'])) {
1305+
// Deleting all access.
1306+
Session::erase('session_name');
1307+
Session::erase('id_session');
1308+
Session::erase('_real_cid');
1309+
Session::erase('_cid');
1310+
Session::erase('_course');
1311+
Session::erase('_gid');
1312+
Session::erase('is_courseAdmin');
1313+
Session::erase('is_courseMember');
1314+
Session::erase('is_courseTutor');
1315+
Session::erase('is_session_general_coach');
1316+
Session::erase('is_allowed_in_course');
1317+
Session::erase('is_sessionAdmin');
1318+
13051319
api_not_allowed(true);
13061320
}
13071321
}

main/install/configuration.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,9 @@
19551955
// Requires a user checkbox extra field called "ask_new_password".
19561956
//$_configuration['force_renew_password_at_first_login'] = true;
19571957

1958+
// If the user is blocked with not allowed (red message), then the breadcrumb is hidden.
1959+
//$_configuration['hide_breadcrumb_if_not_allowed'] = true;
1960+
19581961
// KEEP THIS AT THE END
19591962
// -------- Custom DB changes
19601963
// Add user activation by confirmation email

0 commit comments

Comments
 (0)