mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-33937 Paged course view: Allows view of sections that are not visible
This commit is contained in:
parent
f4a9bf65da
commit
c069dacfc1
2 changed files with 22 additions and 4 deletions
|
@ -99,8 +99,18 @@
|
||||||
$infoid = $course->id;
|
$infoid = $course->id;
|
||||||
if(!empty($section)) {
|
if(!empty($section)) {
|
||||||
$loglabel = 'view section';
|
$loglabel = 'view section';
|
||||||
$sectionparams = array('course' => $course->id, 'section' => $section);
|
|
||||||
$coursesections = $DB->get_record('course_sections', $sectionparams, 'id', MUST_EXIST);
|
// Get section details and check it exists.
|
||||||
|
$modinfo = get_fast_modinfo($course);
|
||||||
|
$coursesections = $modinfo->get_section_info($section, MUST_EXIST);
|
||||||
|
|
||||||
|
// Check user is allowed to see it.
|
||||||
|
if (!$coursesections->uservisible) {
|
||||||
|
// Note: We actually already know they don't have this capability
|
||||||
|
// or uservisible would have been true; this is just to get the
|
||||||
|
// correct error message shown.
|
||||||
|
require_capability('moodle/course:viewhiddensections', $context);
|
||||||
|
}
|
||||||
$infoid = $coursesections->id;
|
$infoid = $coursesections->id;
|
||||||
$logparam .= '§ionid='. $infoid;
|
$logparam .= '§ionid='. $infoid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,9 +202,17 @@ class course_modinfo extends stdClass {
|
||||||
/**
|
/**
|
||||||
* Gets data about specific numbered section.
|
* Gets data about specific numbered section.
|
||||||
* @param int $sectionnumber Number (not id) of section
|
* @param int $sectionnumber Number (not id) of section
|
||||||
* @return section_info Information for numbered section
|
* @param int $strictness Use MUST_EXIST to throw exception if it doesn't
|
||||||
|
* @return section_info Information for numbered section or null if not found
|
||||||
*/
|
*/
|
||||||
public function get_section_info($sectionnumber) {
|
public function get_section_info($sectionnumber, $strictness = IGNORE_MISSING) {
|
||||||
|
if (!array_key_exists($sectionnumber, $this->sectioninfo)) {
|
||||||
|
if ($strictness === MUST_EXIST) {
|
||||||
|
throw new moodle_exception('sectionnotexist');
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return $this->sectioninfo[$sectionnumber];
|
return $this->sectioninfo[$sectionnumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue