Skip to content

Commit

Permalink
Bugfix: Test modcontext, not systemcontext for invisible options
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser committed Dec 19, 2024
1 parent 85fa34d commit 872824f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions optionview.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@
$returnto = optional_param('returnto', '', PARAM_ALPHA);
$returnurl = optional_param('returnurl', '', PARAM_URL);

$syscontext = context_system::instance();
$modcontext = context_module::instance($cmid);

// If we have this setting.
if (!get_config('booking', 'bookonlyondetailspage')) {
require_capability('mod/booking:view', $modcontext);
}

$PAGE->set_context($syscontext);
$PAGE->set_context($modcontext);

$url = new moodle_url('/mod/booking/optionview.php', ['cmid' => $cmid, 'optionid' => $optionid]);
$PAGE->set_url($url);
Expand All @@ -69,7 +68,8 @@
die();
}

if ($settings = singleton_service::get_instance_of_booking_option_settings($optionid)) {
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);
if ($settings && !empty($settings->optionid)) {
if ($userid == $USER->id || $userid == 0) {
$user = $USER;
} else {
Expand Down Expand Up @@ -97,7 +97,7 @@

if ($data->is_invisible()) {
// If the user does have the capability to see invisible options...
if (has_capability('mod/booking:canseeinvisibleoptions', $syscontext)) {
if (has_capability('mod/booking:canseeinvisibleoptions', $modcontext)) {
// ... then show it.
echo $output->render_bookingoption_description_view($data);
} else {
Expand Down

0 comments on commit 872824f

Please sign in to comment.