Skip to content

Commit

Permalink
bugfix to: Coding problem: $PAGE->context was not set. You may have f…
Browse files Browse the repository at this point in the history
…orgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result (#86)
  • Loading branch information
semteacher committed Sep 28, 2024
1 parent 5d4f9bd commit 99575eb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cashier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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'));
}
Expand Down

0 comments on commit 99575eb

Please sign in to comment.