|
| 1 | +<?php |
| 2 | +// This file is part of Moodle - https://moodle.org/ |
| 3 | +// |
| 4 | +// Moodle is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU General Public License as published by |
| 6 | +// the Free Software Foundation, either version 3 of the License, or |
| 7 | +// (at your option) any later version. |
| 8 | +// |
| 9 | +// Moodle is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU General Public License |
| 15 | +// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +/** |
| 18 | + * Viewing a custom content instance |
| 19 | + * |
| 20 | + * @package mod_cms |
| 21 | + * @author Jason den Dulk <[email protected]> |
| 22 | + * @copyright 2023, Catalyst IT |
| 23 | + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 24 | + */ |
| 25 | +use mod_cms\local\model\cms; |
| 26 | +require_once('../../config.php'); |
| 27 | + |
| 28 | +// TODO This is a stub. |
| 29 | + |
| 30 | +$id = optional_param('id', 0, PARAM_INT); // Course Module ID. |
| 31 | +$action = optional_param('action', '', PARAM_TEXT); |
| 32 | +$foruserid = optional_param('user', 0, PARAM_INT); |
| 33 | +$forceview = optional_param('forceview', 0, PARAM_BOOL); |
| 34 | + |
| 35 | +$cm = get_coursemodule_from_id('cms', $id, 0, false, MUST_EXIST); |
| 36 | + |
| 37 | +$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); |
| 38 | +$cms = new cms($cm->instance); |
| 39 | + |
| 40 | +$PAGE->set_cm($cm, $course); // Set's up global $COURSE. |
| 41 | +$context = context_module::instance($cm->id); |
| 42 | +$PAGE->set_context($context); |
| 43 | + |
| 44 | +require_login($course, true, $cm); |
| 45 | +require_capability('mod/cms:view', $context); |
| 46 | + |
| 47 | +$url = new moodle_url('/mod/cms/view.php', array('id' => $cm->id)); |
| 48 | +$PAGE->set_url($url); |
| 49 | + |
| 50 | +// Print the page header. |
| 51 | +echo $OUTPUT->header(); |
| 52 | + |
| 53 | +// TODO: Replace the following line with the full content. |
| 54 | +echo html_writer::tag('h2', $cms->get('name')); |
| 55 | + |
| 56 | +// Finish the page. |
| 57 | +echo $OUTPUT->footer(); |
0 commit comments