From 99575eb5527ed0ca9628b835bbac01daf1a3706d Mon Sep 17 00:00:00 2001 From: Andrii Semenets Date: Sat, 28 Sep 2024 21:32:55 +0300 Subject: [PATCH] bugfix to: Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result (#86) --- cashier.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cashier.php b/cashier.php index 703a0b8..c343f57 100644 --- a/cashier.php +++ b/cashier.php @@ -46,12 +46,8 @@ shopping_cart::buy_for_user($userid); } -// We use our output class, but only need the generated array. -$cashier = new cashier($userid, true); -$data = $cashier->returnaslist(); - // Setup the page. -$PAGE->set_context(\context_system::instance()); +$PAGE->set_context($context); $PAGE->set_url("{$CFG->wwwroot}/local/shopping_cart/cashier.php"); $PAGE->set_title(get_string('cashier', 'local_shopping_cart')); $PAGE->set_heading(get_string('cashier', 'local_shopping_cart')); @@ -62,7 +58,10 @@ // Output the header. echo $OUTPUT->header(); -$context = context_system::instance(); +// We use our output class, but only need the generated array. +$cashier = new cashier($userid, true); +$data = $cashier->returnaslist(); + if (has_capability('local/shopping_cart:cashier', $context)) { $data['additonalcashiersection'] = format_text(get_config('local_shopping_cart', 'additonalcashiersection')); }