-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathview.php
98 lines (78 loc) · 2 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
declare(strict_types=1);
/**
* @package mod_matrix
* @copyright 2022, New Vector Ltd (Trading as Element)
* @license SPDX-License-Identifier: Apache-2.0
*/
use mod_matrix\Container;
use mod_matrix\Moodle;
use mod_matrix\Plugin;
require '../../config.php';
require_once __DIR__ . '/vendor/autoload.php';
/** @var int $courseModuleId */
$courseModuleId = required_param(
'id',
PARAM_INT,
);
/** @var cm_info $cm */
[$course, $cm] = get_course_and_cm_from_cmid(
$courseModuleId,
Plugin\Application\Plugin::NAME,
);
$moduleId = Plugin\Domain\ModuleId::fromString((string) $cm->instance);
$container = Container::instance();
$module = $container->moduleRepository()->findOneBy([
'id' => $moduleId->toInt(),
]);
if (!$module instanceof Plugin\Domain\Module) {
throw new \RuntimeException(\sprintf(
'A Matrix module with id "%d" could not be found.',
$moduleId->toInt(),
));
}
require_login(
$course,
true,
$cm,
);
/** @var moodle_page $PAGE */
$PAGE->set_cacheable(false);
$PAGE->set_heading($course->fullname);
$PAGE->set_title($module->name()->toString());
$PAGE->set_url('/mod/matrix/view.php', [
'id' => $cm->id,
]);
/** @var core_renderer $OUTPUT */
echo $OUTPUT->header();
if (!has_capability('mod/matrix:view', $PAGE->context)) {
/** @var core_renderer $OUTPUT */
echo $OUTPUT->header();
echo $this->renderer->confirm(
\sprintf(
'<p>%s</p>%s',
get_string(
isguestuser() ? 'view_noguests' : 'view_nojoin',
Plugin\Application\Plugin::NAME,
),
get_string('liketologin'),
),
get_login_url(),
new moodle_url('/course/view.php', [
'id' => $module->courseId()->toInt(),
]),
);
echo $OUTPUT->footer();
exit;
}
$frontController = new Plugin\Infrastructure\FrontController(
$container,
$PAGE,
$OUTPUT,
);
/** @var stdClass $USER */
$frontController->handle(
$module,
$cm,
$USER,
);