Skip to content

Commit

Permalink
Merge pull request #180 from davidherney/rwthmoodle-fix-endless-redir…
Browse files Browse the repository at this point in the history
…ects-in-certain-cases

Rwthmoodle fix endless redirects in certain cases
  • Loading branch information
davidherney committed May 4, 2024
2 parents 46515ac + a84d5a8 commit dd7aac8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
14 changes: 3 additions & 11 deletions classes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
$displaysection = $this->format->get_section_number();
$enablecustomstyles = get_config('format_onetopic', 'enablecustomstyles');

// Can we view the section in question?
$context = \context_course::instance($course->id);
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);

// Init custom tabs.
$section = 0;

Expand All @@ -200,12 +196,8 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for

$thissection = $sections[$section];

$showsection = true;
if (!$thissection->visible || !$thissection->available) {
$showsection = $canviewhidden || !($course->hiddensections == 1);
}

if ($showsection) {
// Can we view the section in question?
if ($thissection->uservisible || $course->hiddensections != 1) {

$formatoptions = course_get_format($course)->get_format_options($thissection);

Expand Down Expand Up @@ -253,7 +245,7 @@ private function get_tabs(course_modinfo $modinfo, \renderer_base $output): \for
if (!$thissection->visible || !$thissection->available) {
$specialclass .= ' dimmed disabled ';

if (!$canviewhidden) {
if (!$thissection->uservisible) {
$inactivetab = true;
}
}
Expand Down
9 changes: 2 additions & 7 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,11 @@ protected function __construct($format, $courseid) {
$realsection = 1;
}

// Can view the hidden sections in current course?
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);

$modinfo = get_fast_modinfo($course);
$sections = $modinfo->get_section_info_all();

// Check if the display section is available.
if ((!$canviewhidden && (!$sections[$realsection]->uservisible || !$sections[$realsection]->available))) {
if (!$sections[$realsection]->uservisible) {

self::$formatmsgs[] = get_string('hidden_message', 'format_onetopic', $this->get_section_name($realsection));

Expand All @@ -205,9 +202,7 @@ protected function __construct($format, $courseid) {

do {
$formatoptions = $this->get_format_options($k);
if ($formatoptions['level'] == 0
&& ($sections[$k]->available && $sections[$k]->uservisible)
|| $canviewhidden) {
if ($formatoptions['level'] == 0 && $sections[$k]->uservisible) {
$valid = true;
break;
}
Expand Down

0 comments on commit dd7aac8

Please sign in to comment.