-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.php
165 lines (151 loc) · 4.52 KB
/
lib.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Library functions for custom content type module
*
* @package mod_cms
* @author Marcus Boon<[email protected]>
* @copyright Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_course\local\entity\content_item;
use mod_cms\local\lib;
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/vendor/autoload.php');
/**
* Triggered as soon as practical on every moodle bootstrap after config has
* been loaded. The $USER object is available at this point too.
*
* NOTE: DO NOT REMOVE. This currently ensures all vendor libraries are loaded.
*/
function mod_cms_after_config() {
}
/**
* Returns whether a feature is supported or not.
*
* @uses FEATURE_IDNUMBER
* @uses FEATURE_GROUPS
* @uses FEATURE_GROUPINGS
* @uses FEATURE_MOD_INTRO
* @uses FEATURE_COMPLETION_TRACKS_VIEWS
* @uses FEATURE_GRADE_HAS_GRADE
* @uses FEATURE_GRADE_OUTCOMES
* @uses FEATURE_MOD_ARCHETYPE
* @uses MOD_ARCHETYPE_RESOURCE
* @param string $feature FEATURE_xx constant for requested feature
*
* @return bool|null
*/
function cms_supports($feature) {
global $version;
switch($feature) {
case FEATURE_IDNUMBER:
case FEATURE_BACKUP_MOODLE2:
case FEATURE_NO_VIEW_LINK:
return true;
case FEATURE_MOD_INTRO:
case FEATURE_GROUPS:
case FEATURE_GROUPINGS:
case FEATURE_COMPLETION_TRACKS_VIEWS:
case FEATURE_GRADE_HAS_GRADE:
case FEATURE_GRADE_OUTCOMES:
return false;
case FEATURE_MOD_ARCHETYPE:
return MOD_ARCHETYPE_RESOURCE;
default:
}
// Version 4.0.0 and later.
if ($version >= 2022041900) {
switch ($feature) {
case FEATURE_MOD_PURPOSE:
return MOD_PURPOSE_CONTENT;
default:
}
}
return null;
}
/**
* Obtains a list of defined content types to be included in the activity chooser panel.
*
* @param content_item $defaultmodulecontentitem
* @param stdClass $user
* @param stdClass $course
* @return array
*/
function cms_get_course_content_items(content_item $defaultmodulecontentitem, stdClass $user,
stdClass $course) {
return lib::get_course_content_items($defaultmodulecontentitem, $user, $course);
}
/**
* Adds an instance of a CMS activity.
*
* @param stdClass $instancedata Data to populate the instance.
* @param moodleform_mod|null $mform
* @return int The ID of the newly crated instance.
*/
function cms_add_instance(stdClass $instancedata, $mform = null): int {
return lib::add_instance($instancedata, $mform);
}
/**
* Updates an activity instance.
*
* @param stdClass $instancedata
* @param moodleform_mod $mform
* @return bool
*/
function cms_update_instance(stdClass $instancedata, $mform): bool {
return lib::update_instance($instancedata, $mform);
}
/**
* Removes an instance of an activity.
*
* @param int $id
* @return bool
*/
function cms_delete_instance(int $id): bool {
return lib::delete_instance($id);
}
/**
* Sets info into cminfo at the dynamic stage.
*
* @param \cm_info $cminfo
*/
function cms_cm_info_dynamic(cm_info $cminfo) {
lib::cm_info_dynamic($cminfo);
}
/**
* Sets info into cminfo at the view stage.
*
* @param \cm_info $cminfo
*/
function cms_cm_info_view(cm_info $cminfo) {
lib::cm_info_view($cminfo);
}
/**
* Serves file
*
* @param stdClass $course
* @param stdClass $cm
* @param context $context
* @param string $filearea
* @param array $args
* @param bool $forcedownload
* @param array $options additional options affecting the file serving
* @return bool|null false if file not found, does not return anything if found - just send the file
*/
function cms_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, $options = []) {
return lib::pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, $options);
}