From 3eede57da9eabda1d6b59a799e0e45dd88d69504 Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Sun, 4 Jun 2017 12:13:08 +0300 Subject: [PATCH] Fix: Moodle 3.3 compatibility --- export.php | 46 +++++++++++++++++++++++++++++++++++++++++++--- lib.php | 2 ++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/export.php b/export.php index 5a2d367..16979eb 100644 --- a/export.php +++ b/export.php @@ -21,15 +21,55 @@ * @package game **/ -defined('MOODLE_INTERNAL') || die(); +require_once(dirname(__FILE__) . '/../../config.php'); +$id = optional_param('id', 0, PARAM_INT); // Course Module ID. + if (!$cm = get_coursemodule_from_id('game', $id)) { + print_error('invalidcoursemodule'); + } + if (! $course = $DB->get_record('course', array('id' => $cm->course))) { + print_error('coursemisconf'); + } + if (! $game = $DB->get_record('game', array('id' => $cm->instance))) { + print_error('invalidcoursemodule'); + } + +require_login($course->id, false, $cm); +$context = game_get_context_module_instance( $cm->id); +require_capability('mod/game:view', $context); +// Initialize $PAGE, compute blocks. +$PAGE->set_url('/mod/game/view.php', array('id' => $cm->id)); + +$edit = optional_param('edit', -1, PARAM_BOOL); +if ($edit != -1 && $PAGE->user_allowed_editing()) { + $USER->editing = $edit; +} + +// Note: MDL-19010 there will be further changes to printing header and blocks. +// The code will be much nicer than this eventually. +$title = $course->shortname . ': ' . format_string($game->name); + +if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { + $buttons = '
'. + ''. + ''. + '
'; + $PAGE->set_button($buttons); +} + +$PAGE->set_title($title); +$PAGE->set_heading($course->fullname); + +echo $OUTPUT->header(); ob_start(); require_once( $CFG->dirroot.'/lib/formslib.php'); require( 'locallib.php'); -require( 'headergame.php'); -$context = game_get_context_module_instance( $cm->id); +require_login($course->id, false, $cm); + if (!has_capability('mod/game:viewreports', $context)) { return; } diff --git a/lib.php b/lib.php index e9a89fb..fc8da5b 100644 --- a/lib.php +++ b/lib.php @@ -851,6 +851,8 @@ function game_extend_settings_navigation($settings, $gamenode) { break; } } + + $gamenode->make_active(); } /* Returns an array of game type objects to construct