| 1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://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 |
* deprecatedlib.php - Old functions retained only for backward compatibility
|
|
|
19 |
*
|
|
|
20 |
* Old functions retained only for backward compatibility. New code should not
|
|
|
21 |
* use any of these functions.
|
|
|
22 |
*
|
|
|
23 |
* @package core
|
|
|
24 |
* @subpackage deprecated
|
|
|
25 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
|
|
26 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
27 |
* @deprecated
|
|
|
28 |
*/
|
|
|
29 |
|
|
|
30 |
defined('MOODLE_INTERNAL') || die();
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* List all core subsystems and their location
|
|
|
34 |
*
|
|
|
35 |
* This is a list of components that are part of the core and their
|
|
|
36 |
* language strings are defined in /lang/en/<<subsystem>>.php. If a given
|
|
|
37 |
* plugin is not listed here and it does not have proper plugintype prefix,
|
|
|
38 |
* then it is considered as course activity module.
|
|
|
39 |
*
|
|
|
40 |
* The location is optionally dirroot relative path. NULL means there is no special
|
|
|
41 |
* directory for this subsystem. If the location is set, the subsystem's
|
|
|
42 |
* renderer.php is expected to be there.
|
|
|
43 |
*
|
|
|
44 |
* @deprecated since 2.6, use core_component::get_core_subsystems()
|
|
|
45 |
* @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons
|
|
|
46 |
* @return array of (string)name => (string|null)location
|
|
|
47 |
*/
|
| 1441 |
ariadna |
48 |
#[\core\attribute\deprecated('core_component::get_core_subsystems', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
49 |
function get_core_subsystems($fullpaths = false) {
|
| 1441 |
ariadna |
50 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
51 |
global $CFG;
|
|
|
52 |
|
|
|
53 |
$subsystems = core_component::get_core_subsystems();
|
|
|
54 |
|
|
|
55 |
if ($fullpaths) {
|
|
|
56 |
return $subsystems;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
|
|
|
60 |
|
|
|
61 |
$dlength = strlen($CFG->dirroot);
|
|
|
62 |
|
|
|
63 |
foreach ($subsystems as $k => $v) {
|
|
|
64 |
if ($v === null) {
|
|
|
65 |
continue;
|
|
|
66 |
}
|
|
|
67 |
$subsystems[$k] = substr($v, $dlength+1);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
return $subsystems;
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
* Lists all plugin types.
|
|
|
75 |
*
|
|
|
76 |
* @deprecated since 2.6, use core_component::get_plugin_types()
|
|
|
77 |
* @param bool $fullpaths false means relative paths from dirroot
|
|
|
78 |
* @return array Array of strings - name=>location
|
|
|
79 |
*/
|
| 1441 |
ariadna |
80 |
#[\core\attribute\deprecated('core_component::get_plugin_types', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
81 |
function get_plugin_types($fullpaths = true) {
|
| 1441 |
ariadna |
82 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
83 |
global $CFG;
|
|
|
84 |
|
|
|
85 |
$types = core_component::get_plugin_types();
|
|
|
86 |
|
|
|
87 |
if ($fullpaths) {
|
|
|
88 |
return $types;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
|
|
|
92 |
|
|
|
93 |
$dlength = strlen($CFG->dirroot);
|
|
|
94 |
|
|
|
95 |
foreach ($types as $k => $v) {
|
|
|
96 |
if ($k === 'theme') {
|
|
|
97 |
$types[$k] = 'theme';
|
|
|
98 |
continue;
|
|
|
99 |
}
|
|
|
100 |
$types[$k] = substr($v, $dlength+1);
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
return $types;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* Use when listing real plugins of one type.
|
|
|
108 |
*
|
|
|
109 |
* @deprecated since 2.6, use core_component::get_plugin_list()
|
|
|
110 |
* @param string $plugintype type of plugin
|
|
|
111 |
* @return array name=>fulllocation pairs of plugins of given type
|
|
|
112 |
*/
|
| 1441 |
ariadna |
113 |
#[\core\attribute\deprecated('core_component::get_plugin_list', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
114 |
function get_plugin_list($plugintype) {
|
| 1441 |
ariadna |
115 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
116 |
|
|
|
117 |
if ($plugintype === '') {
|
|
|
118 |
$plugintype = 'mod';
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
return core_component::get_plugin_list($plugintype);
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
/**
|
|
|
125 |
* Get a list of all the plugins of a given type that define a certain class
|
|
|
126 |
* in a certain file. The plugin component names and class names are returned.
|
|
|
127 |
*
|
|
|
128 |
* @deprecated since 2.6, use core_component::get_plugin_list_with_class()
|
|
|
129 |
* @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
|
|
|
130 |
* @param string $class the part of the name of the class after the
|
|
|
131 |
* frankenstyle prefix. e.g 'thing' if you are looking for classes with
|
|
|
132 |
* names like report_courselist_thing. If you are looking for classes with
|
|
|
133 |
* the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
|
|
|
134 |
* @param string $file the name of file within the plugin that defines the class.
|
|
|
135 |
* @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
|
|
|
136 |
* and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
|
|
|
137 |
*/
|
| 1441 |
ariadna |
138 |
#[\core\attribute\deprecated('core_component::get_plugin_list_with_class', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
139 |
function get_plugin_list_with_class($plugintype, $class, $file) {
|
| 1441 |
ariadna |
140 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
141 |
return core_component::get_plugin_list_with_class($plugintype, $class, $file);
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
/**
|
|
|
145 |
* Returns the exact absolute path to plugin directory.
|
|
|
146 |
*
|
|
|
147 |
* @deprecated since 2.6, use core_component::get_plugin_directory()
|
|
|
148 |
* @param string $plugintype type of plugin
|
|
|
149 |
* @param string $name name of the plugin
|
|
|
150 |
* @return string full path to plugin directory; NULL if not found
|
|
|
151 |
*/
|
| 1441 |
ariadna |
152 |
#[\core\attribute\deprecated('core_component::get_plugin_directory', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
153 |
function get_plugin_directory($plugintype, $name) {
|
| 1441 |
ariadna |
154 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
155 |
if ($plugintype === '') {
|
|
|
156 |
$plugintype = 'mod';
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
return core_component::get_plugin_directory($plugintype, $name);
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
/**
|
|
|
163 |
* Normalize the component name using the "frankenstyle" names.
|
|
|
164 |
*
|
|
|
165 |
* @deprecated since 2.6, use core_component::normalize_component()
|
|
|
166 |
* @param string $component
|
|
|
167 |
* @return array two-items list of [(string)type, (string|null)name]
|
|
|
168 |
*/
|
| 1441 |
ariadna |
169 |
#[\core\attribute\deprecated('core_component::normalize_component', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
170 |
function normalize_component($component) {
|
| 1441 |
ariadna |
171 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
172 |
return core_component::normalize_component($component);
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
/**
|
|
|
176 |
* Return exact absolute path to a plugin directory.
|
|
|
177 |
*
|
|
|
178 |
* @deprecated since 2.6, use core_component::normalize_component()
|
|
|
179 |
*
|
|
|
180 |
* @param string $component name such as 'moodle', 'mod_forum'
|
|
|
181 |
* @return string full path to component directory; NULL if not found
|
|
|
182 |
*/
|
| 1441 |
ariadna |
183 |
#[\core\attribute\deprecated('core_component::get_component_directory', since: '4.5', mdl: 'MDL-82287')]
|
| 1 |
efrain |
184 |
function get_component_directory($component) {
|
| 1441 |
ariadna |
185 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
186 |
return core_component::get_component_directory($component);
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
/**
|
|
|
190 |
* @deprecated since 2.2, use context_course::instance() or other relevant class instead
|
|
|
191 |
*/
|
| 1441 |
ariadna |
192 |
#[\core\attribute\deprecated('\core\context::instance', since: '2.2', mdl: 'MDL-34472', final: true)]
|
|
|
193 |
function get_context_instance() {
|
|
|
194 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
195 |
}
|
|
|
196 |
|
|
|
197 |
/**
|
| 1441 |
ariadna |
198 |
* @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
|
| 1 |
efrain |
199 |
*/
|
| 1441 |
ariadna |
200 |
#[\core\attribute\deprecated('Not replaced', since: '2.0', mdl: 'MDL-19756', final: true)]
|
|
|
201 |
function can_use_rotated_text() {
|
|
|
202 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
203 |
}
|
|
|
204 |
|
|
|
205 |
/**
|
| 1441 |
ariadna |
206 |
* @deprecated since 2.2
|
| 1 |
efrain |
207 |
*/
|
| 1441 |
ariadna |
208 |
#[\core\attribute\deprecated('\core\context\system::instance', since: '2.2', mdl: 'MDL-34472', final: true)]
|
|
|
209 |
function get_system_context() {
|
|
|
210 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
211 |
}
|
|
|
212 |
|
|
|
213 |
/**
|
| 1441 |
ariadna |
214 |
* Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
|
|
|
215 |
* provide this function with the language strings for sortasc and sortdesc.
|
|
|
216 |
*
|
|
|
217 |
* @deprecated use $OUTPUT->arrow() instead.
|
| 1 |
efrain |
218 |
*/
|
| 1441 |
ariadna |
219 |
#[\core\attribute\deprecated('OUTPUT->[l|r]arrow', since: '2.0', mdl: 'MDL-19756', final: true)]
|
|
|
220 |
function print_arrow() {
|
|
|
221 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
222 |
}
|
|
|
223 |
|
|
|
224 |
/**
|
| 1441 |
ariadna |
225 |
* @deprecated since Moodle 4.0
|
| 1 |
efrain |
226 |
*/
|
| 1441 |
ariadna |
227 |
#[\core\attribute\deprecated('category_action_bar tertiary navigation', since: '4.0', mdl: 'MDL-73462', final: true)]
|
|
|
228 |
function print_course_request_buttons() {
|
|
|
229 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
230 |
}
|
|
|
231 |
|
|
|
232 |
/**
|
| 1441 |
ariadna |
233 |
* @deprecated since 4.2 Use \core\cron::run_main_process() instead.
|
| 1 |
efrain |
234 |
*/
|
| 1441 |
ariadna |
235 |
#[\core\attribute\deprecated('\core\cron::run_main_process()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
236 |
function cron_run() {
|
|
|
237 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
238 |
}
|
|
|
239 |
|
|
|
240 |
/**
|
| 1441 |
ariadna |
241 |
* @deprecated since 4.2 Use \core\cron::run_scheduled_tasks() instead.
|
| 1 |
efrain |
242 |
*/
|
| 1441 |
ariadna |
243 |
#[\core\attribute\deprecated('\core\cron::run_scheduled_tasks()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
244 |
function cron_run_scheduled_tasks() {
|
|
|
245 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
246 |
}
|
|
|
247 |
|
|
|
248 |
/**
|
| 1441 |
ariadna |
249 |
* @deprecated since 4.2 Use \core\cron::run_adhoc_tasks() instead.
|
| 1 |
efrain |
250 |
*/
|
| 1441 |
ariadna |
251 |
#[\core\attribute\deprecated('\core\cron::run_adhoc_tasks()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
252 |
function cron_run_adhoc_tasks() {
|
|
|
253 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
254 |
}
|
|
|
255 |
|
|
|
256 |
/**
|
| 1441 |
ariadna |
257 |
* @deprecated since 4.2 Use \core\cron::run_inner_scheduled_task() instead.
|
| 1 |
efrain |
258 |
*/
|
| 1441 |
ariadna |
259 |
#[\core\attribute\deprecated('\core\cron::run_inner_scheduled_task()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
260 |
function cron_run_inner_scheduled_task() {
|
|
|
261 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
262 |
}
|
|
|
263 |
|
|
|
264 |
/**
|
| 1441 |
ariadna |
265 |
* @deprecated since 4.2 Use \core\cron::run_inner_adhoc_task() instead.
|
| 1 |
efrain |
266 |
*/
|
| 1441 |
ariadna |
267 |
#[\core\attribute\deprecated('\core\cron::run_inner_adhoc_task()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
268 |
function cron_run_inner_adhoc_task() {
|
|
|
269 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
270 |
}
|
|
|
271 |
|
|
|
272 |
/**
|
|
|
273 |
|
| 1441 |
ariadna |
274 |
* @deprecated since 4.2 Use \core\cron::set_process_title() instead.
|
| 1 |
efrain |
275 |
*/
|
| 1441 |
ariadna |
276 |
#[\core\attribute\deprecated('\core\cron::set_process_title()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
277 |
function cron_set_process_title() {
|
|
|
278 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
279 |
}
|
|
|
280 |
|
|
|
281 |
/**
|
| 1441 |
ariadna |
282 |
* @deprecated since 4.2 Use \core\cron::trace_time_and_memory() instead.
|
| 1 |
efrain |
283 |
*/
|
| 1441 |
ariadna |
284 |
#[\core\attribute\deprecated('\core\cron::trace_time_and_memory()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
285 |
function cron_trace_time_and_memory() {
|
|
|
286 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
287 |
}
|
|
|
288 |
|
|
|
289 |
/**
|
| 1441 |
ariadna |
290 |
* @deprecated since 4.2 Use \core\cron::prepare_core_renderer() instead.
|
| 1 |
efrain |
291 |
*/
|
| 1441 |
ariadna |
292 |
#[\core\attribute\deprecated('\core\cron::prepare_core_renderer()', since: '4.2', mdl: 'MDL-77186', final: true)]
|
|
|
293 |
function cron_prepare_core_renderer() {
|
|
|
294 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
295 |
}
|
|
|
296 |
|
|
|
297 |
/**
|
| 1441 |
ariadna |
298 |
* @deprecated since 4.2. Use \core\cron::setup_user() instead.
|
| 1 |
efrain |
299 |
*/
|
| 1441 |
ariadna |
300 |
#[\core\attribute\deprecated('\core\cron::setup_user()', since: '4.2', mdl: 'MDL-77837', final: true)]
|
|
|
301 |
function cron_setup_user() {
|
|
|
302 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
303 |
}
|
|
|
304 |
|
|
|
305 |
/**
|
| 1441 |
ariadna |
306 |
* @deprecated since 4.3.
|
| 1 |
efrain |
307 |
*/
|
| 1441 |
ariadna |
308 |
#[\core\attribute\deprecated(since: '4.3', mdl: 'MDL-77837', final: true)]
|
|
|
309 |
function badges_get_oauth2_service_options() {
|
|
|
310 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
311 |
}
|
|
|
312 |
|
|
|
313 |
/**
|
| 1441 |
ariadna |
314 |
* @deprecated since 4.3.
|
| 1 |
efrain |
315 |
*/
|
| 1441 |
ariadna |
316 |
#[\core\attribute\deprecated(
|
|
|
317 |
since: '4.3',
|
|
|
318 |
reason: 'All functions associated with device specific themes are being removed',
|
|
|
319 |
mdl: 'MDL-77793',
|
|
|
320 |
final: true,
|
|
|
321 |
)]
|
|
|
322 |
function theme_is_device_locked() {
|
|
|
323 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
324 |
}
|
|
|
325 |
|
|
|
326 |
/**
|
| 1441 |
ariadna |
327 |
* @deprecated since 4.3.
|
| 1 |
efrain |
328 |
*/
|
| 1441 |
ariadna |
329 |
#[\core\attribute\deprecated(
|
|
|
330 |
since: '4.3',
|
|
|
331 |
reason: 'All functions associated with device specific themes are being removed',
|
|
|
332 |
mdl: 'MDL-77793',
|
|
|
333 |
final: true,
|
|
|
334 |
)]
|
|
|
335 |
function theme_get_locked_theme_for_device() {
|
|
|
336 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
337 |
}
|
|
|
338 |
|
|
|
339 |
/**
|
| 1441 |
ariadna |
340 |
* @deprecated since 4.3.
|
| 1 |
efrain |
341 |
*/
|
| 1441 |
ariadna |
342 |
#[\core\attribute\deprecated(
|
|
|
343 |
'random_bytes()',
|
|
|
344 |
since: '4.3',
|
|
|
345 |
reason: 'Since PHP 7.0 the random_bytes() is natively available and Moodle LMS requires greater than PHP 7.',
|
|
|
346 |
mdl: 'MDL-78698',
|
|
|
347 |
final: true,
|
|
|
348 |
)]
|
|
|
349 |
function random_bytes_emulate() {
|
|
|
350 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
351 |
}
|
|
|
352 |
|
|
|
353 |
/**
|
| 1441 |
ariadna |
354 |
* rc4encrypt
|
|
|
355 |
*
|
|
|
356 |
* @param string $data Data to encrypt.
|
|
|
357 |
* @return string The now encrypted data.
|
|
|
358 |
*
|
|
|
359 |
* @deprecated since Moodle 4.5 - please do not use this function any more, {@see \core\encryption::encrypt}
|
| 1 |
efrain |
360 |
*/
|
| 1441 |
ariadna |
361 |
#[\core\attribute\deprecated('\core\encryption::encrypt', since: '4.5', mdl: 'MDL-81940')]
|
|
|
362 |
function rc4encrypt($data) {
|
|
|
363 |
// No initial deprecation notice here, as the following method triggers its own.
|
|
|
364 |
return endecrypt(get_site_identifier(), $data, '');
|
| 1 |
efrain |
365 |
}
|
|
|
366 |
|
|
|
367 |
/**
|
| 1441 |
ariadna |
368 |
* rc4decrypt
|
|
|
369 |
*
|
|
|
370 |
* @param string $data Data to decrypt.
|
|
|
371 |
* @return string The now decrypted data.
|
|
|
372 |
*
|
|
|
373 |
* @deprecated since Moodle 4.5 - please do not use this function any more, {@see \core\encryption::decrypt}
|
| 1 |
efrain |
374 |
*/
|
| 1441 |
ariadna |
375 |
#[\core\attribute\deprecated('\core\encryption::decrypt', since: '4.5', mdl: 'MDL-81940')]
|
|
|
376 |
function rc4decrypt($data) {
|
|
|
377 |
// No initial deprecation notice here, as the following method triggers its own.
|
|
|
378 |
return endecrypt(get_site_identifier(), $data, 'de');
|
| 1 |
efrain |
379 |
}
|
|
|
380 |
|
|
|
381 |
/**
|
| 1441 |
ariadna |
382 |
* Based on a class by Mukul Sabharwal [mukulsabharwal @ yahoo.com]
|
|
|
383 |
*
|
|
|
384 |
* @param string $pwd The password to use when encrypting or decrypting
|
|
|
385 |
* @param string $data The data to be decrypted/encrypted
|
|
|
386 |
* @param string $case Either 'de' for decrypt or '' for encrypt
|
|
|
387 |
* @return string
|
|
|
388 |
*
|
|
|
389 |
* @deprecated since Moodle 4.5 - please do not use this function any more, {@see \core\encryption}
|
| 1 |
efrain |
390 |
*/
|
| 1441 |
ariadna |
391 |
#[\core\attribute\deprecated(\core\encryption::class, since: '4.5', mdl: 'MDL-81940')]
|
|
|
392 |
function endecrypt($pwd, $data, $case) {
|
|
|
393 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
394 |
|
| 1441 |
ariadna |
395 |
if ($case == 'de') {
|
|
|
396 |
$data = urldecode($data);
|
|
|
397 |
}
|
| 1 |
efrain |
398 |
|
| 1441 |
ariadna |
399 |
$key[] = '';
|
|
|
400 |
$box[] = '';
|
|
|
401 |
$pwdlength = strlen($pwd);
|
| 1 |
efrain |
402 |
|
| 1441 |
ariadna |
403 |
for ($i = 0; $i <= 255; $i++) {
|
|
|
404 |
$key[$i] = ord(substr($pwd, ($i % $pwdlength), 1));
|
|
|
405 |
$box[$i] = $i;
|
|
|
406 |
}
|
| 1 |
efrain |
407 |
|
| 1441 |
ariadna |
408 |
$x = 0;
|
| 1 |
efrain |
409 |
|
| 1441 |
ariadna |
410 |
for ($i = 0; $i <= 255; $i++) {
|
|
|
411 |
$x = ($x + $box[$i] + $key[$i]) % 256;
|
|
|
412 |
$tempswap = $box[$i];
|
|
|
413 |
$box[$i] = $box[$x];
|
|
|
414 |
$box[$x] = $tempswap;
|
|
|
415 |
}
|
| 1 |
efrain |
416 |
|
| 1441 |
ariadna |
417 |
$cipher = '';
|
| 1 |
efrain |
418 |
|
| 1441 |
ariadna |
419 |
$a = 0;
|
|
|
420 |
$j = 0;
|
| 1 |
efrain |
421 |
|
| 1441 |
ariadna |
422 |
for ($i = 0; $i < strlen($data); $i++) {
|
|
|
423 |
$a = ($a + 1) % 256;
|
|
|
424 |
$j = ($j + $box[$a]) % 256;
|
|
|
425 |
$temp = $box[$a];
|
|
|
426 |
$box[$a] = $box[$j];
|
|
|
427 |
$box[$j] = $temp;
|
|
|
428 |
$k = $box[(($box[$a] + $box[$j]) % 256)];
|
|
|
429 |
$cipherby = ord(substr($data, $i, 1)) ^ $k;
|
|
|
430 |
$cipher .= chr($cipherby);
|
|
|
431 |
}
|
| 1 |
efrain |
432 |
|
| 1441 |
ariadna |
433 |
if ($case == 'de') {
|
|
|
434 |
$cipher = urldecode(urlencode($cipher));
|
|
|
435 |
} else {
|
|
|
436 |
$cipher = urlencode($cipher);
|
|
|
437 |
}
|
| 1 |
efrain |
438 |
|
| 1441 |
ariadna |
439 |
return $cipher;
|
| 1 |
efrain |
440 |
}
|
|
|
441 |
|
|
|
442 |
/**
|
| 1441 |
ariadna |
443 |
* @deprecated Since Moodle 4.5
|
| 1 |
efrain |
444 |
*/
|
| 1441 |
ariadna |
445 |
#[\core\attribute\deprecated('This method should not be used', since: '4.5', mdl: 'MDL-80275', final: true)]
|
|
|
446 |
function disable_output_buffering(): void {
|
|
|
447 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
448 |
}
|
|
|
449 |
|
|
|
450 |
|
|
|
451 |
/**
|
| 1441 |
ariadna |
452 |
* Prints a grade menu (as part of an existing form) with help showing all possible numerical grades and scales.
|
| 1 |
efrain |
453 |
*
|
| 1441 |
ariadna |
454 |
* @todo Finish documenting this function
|
|
|
455 |
* @todo Deprecate: this is only used in a few contrib modules
|
| 1 |
efrain |
456 |
*
|
| 1441 |
ariadna |
457 |
* @param int $courseid The course ID
|
|
|
458 |
* @param string $name
|
|
|
459 |
* @param string $current
|
|
|
460 |
* @param boolean $includenograde Include those with no grades
|
|
|
461 |
* @param boolean $return If set to true returns rather than echo's
|
|
|
462 |
* @return string|bool|null Depending on value of $return
|
|
|
463 |
* @deprecated Since Moodle 4.5
|
| 1 |
efrain |
464 |
*/
|
| 1441 |
ariadna |
465 |
#[\core\attribute\deprecated('This method should not be used', since: '4.5', mdl: 'MDL-82157')]
|
|
|
466 |
function print_grade_menu($courseid, $name, $current, $includenograde=true, $return=false) {
|
|
|
467 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
468 |
global $OUTPUT;
|
|
|
469 |
|
| 1441 |
ariadna |
470 |
$output = '';
|
|
|
471 |
$strscale = get_string('scale');
|
|
|
472 |
$strscales = get_string('scales');
|
| 1 |
efrain |
473 |
|
| 1441 |
ariadna |
474 |
$scales = get_scales_menu($courseid);
|
|
|
475 |
foreach ($scales as $i => $scalename) {
|
|
|
476 |
$grades[-$i] = $strscale .': '. $scalename;
|
| 1 |
efrain |
477 |
}
|
| 1441 |
ariadna |
478 |
if ($includenograde) {
|
|
|
479 |
$grades[0] = get_string('nograde');
|
| 1 |
efrain |
480 |
}
|
| 1441 |
ariadna |
481 |
for ($i=100; $i>=1; $i--) {
|
|
|
482 |
$grades[$i] = $i;
|
| 1 |
efrain |
483 |
}
|
| 1441 |
ariadna |
484 |
$output .= html_writer::select($grades, $name, $current, false);
|
| 1 |
efrain |
485 |
|
| 1441 |
ariadna |
486 |
$linkobject = '<span class="helplink">' . $OUTPUT->pix_icon('help', $strscales) . '</span>';
|
|
|
487 |
$link = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => 1));
|
|
|
488 |
$action = new popup_action('click', $link, 'ratingscales', array('height' => 400, 'width' => 500));
|
|
|
489 |
$output .= $OUTPUT->action_link($link, $linkobject, $action, array('title' => $strscales));
|
| 1 |
efrain |
490 |
|
|
|
491 |
if ($return) {
|
| 1441 |
ariadna |
492 |
return $output;
|
| 1 |
efrain |
493 |
} else {
|
| 1441 |
ariadna |
494 |
echo $output;
|
| 1 |
efrain |
495 |
}
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
/**
|
| 1441 |
ariadna |
499 |
* Resets specified user's password and send the new password to the user via email.
|
|
|
500 |
*
|
|
|
501 |
* @param stdClass $user A {@link $USER} object
|
|
|
502 |
* @return bool Returns true if mail was sent OK and false if there was an error.
|
|
|
503 |
* @see setnew_password_and_mail()
|
|
|
504 |
* @deprecated Since Moodle 4.5
|
|
|
505 |
* @todo MDL-82646 Final deprecation in Moodle 6.0.
|
| 1 |
efrain |
506 |
*/
|
| 1441 |
ariadna |
507 |
#[\core\attribute\deprecated(
|
|
|
508 |
since: '4.5',
|
|
|
509 |
mdl: 'MDL-64148',
|
|
|
510 |
replacement: 'setnew_password_and_mail()',
|
|
|
511 |
reason: 'It is no longer used',
|
|
|
512 |
)]
|
|
|
513 |
function reset_password_and_mail($user) {
|
|
|
514 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
|
|
515 |
global $CFG;
|
| 1 |
efrain |
516 |
|
| 1441 |
ariadna |
517 |
$site = get_site();
|
|
|
518 |
$supportuser = core_user::get_support_user();
|
| 1 |
efrain |
519 |
|
| 1441 |
ariadna |
520 |
$userauth = get_auth_plugin($user->auth);
|
|
|
521 |
if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth)) {
|
|
|
522 |
trigger_error("Attempt to reset user password for user $user->username with Auth $user->auth.");
|
|
|
523 |
return false;
|
|
|
524 |
}
|
| 1 |
efrain |
525 |
|
| 1441 |
ariadna |
526 |
$newpassword = generate_password();
|
| 1 |
efrain |
527 |
|
| 1441 |
ariadna |
528 |
if (!$userauth->user_update_password($user, $newpassword)) {
|
|
|
529 |
throw new \moodle_exception("cannotsetpassword");
|
|
|
530 |
}
|
| 1 |
efrain |
531 |
|
| 1441 |
ariadna |
532 |
$a = new stdClass();
|
|
|
533 |
$a->firstname = $user->firstname;
|
|
|
534 |
$a->lastname = $user->lastname;
|
|
|
535 |
$a->sitename = format_string($site->fullname);
|
|
|
536 |
$a->username = $user->username;
|
|
|
537 |
$a->newpassword = $newpassword;
|
|
|
538 |
$a->link = $CFG->wwwroot .'/login/change_password.php';
|
|
|
539 |
$a->signoff = generate_email_signoff();
|
| 1 |
efrain |
540 |
|
| 1441 |
ariadna |
541 |
$message = get_string('newpasswordtext', '', $a);
|
| 1 |
efrain |
542 |
|
| 1441 |
ariadna |
543 |
$subject = format_string($site->fullname) .': '. get_string('changedpassword');
|
| 1 |
efrain |
544 |
|
| 1441 |
ariadna |
545 |
unset_user_preference('create_password', $user); // Prevent cron from generating the password.
|
| 1 |
efrain |
546 |
|
| 1441 |
ariadna |
547 |
// Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.
|
|
|
548 |
return email_to_user($user, $supportuser, $subject, $message);
|
| 1 |
efrain |
549 |
}
|
|
|
550 |
|
|
|
551 |
/**
|
| 1441 |
ariadna |
552 |
* @deprecated Since Moodle 4.0 MDL-71175. Please use plagiarism_get_links() or plugin specific functions..
|
| 1 |
efrain |
553 |
*/
|
| 1441 |
ariadna |
554 |
#[\core\attribute\deprecated(
|
|
|
555 |
replacement: 'plagiarism_get_links',
|
|
|
556 |
since: '4.0',
|
|
|
557 |
mdl: 'MDL-71175',
|
|
|
558 |
final: true,
|
|
|
559 |
)]
|
|
|
560 |
function plagiarism_get_file_results(): void {
|
|
|
561 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
562 |
}
|
|
|
563 |
|
|
|
564 |
/**
|
| 1441 |
ariadna |
565 |
* @deprecated Since Moodle 4.0 - Please use {plugin name}_before_standard_top_of_body_html instead.
|
| 1 |
efrain |
566 |
*/
|
| 1441 |
ariadna |
567 |
#[\core\attribute\deprecated(
|
|
|
568 |
replacement: '{plugin name}_before_standard_top_of_body_html',
|
|
|
569 |
since: '4.0',
|
|
|
570 |
mdl: 'MDL-71175',
|
|
|
571 |
final: true,
|
|
|
572 |
)]
|
|
|
573 |
function plagiarism_update_status(): void {
|
|
|
574 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
575 |
}
|
|
|
576 |
|
|
|
577 |
/**
|
| 1441 |
ariadna |
578 |
* ?
|
|
|
579 |
*
|
|
|
580 |
* @param string $modargs
|
|
|
581 |
* @param string $body Currently unused
|
|
|
582 |
*
|
|
|
583 |
* @deprecated Since Moodle 5.0
|
|
|
584 |
* @todo Final deprecation on Moodle 6.0. See MDL-83366.
|
| 1 |
efrain |
585 |
*/
|
| 1441 |
ariadna |
586 |
#[\core\attribute\deprecated(
|
|
|
587 |
replacement: null,
|
|
|
588 |
since: '5.0',
|
|
|
589 |
mdl: 'MDL-83366',
|
|
|
590 |
reason: 'The function is no longer used with the removal of the unused and non-functioning admin/process_email.php.',
|
|
|
591 |
)]
|
|
|
592 |
function moodle_process_email($modargs, $body) {
|
|
|
593 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
|
|
594 |
global $DB;
|
| 1 |
efrain |
595 |
|
| 1441 |
ariadna |
596 |
// The first char should be an unencoded letter. We'll take this as an action.
|
|
|
597 |
switch ($modargs[0]) {
|
|
|
598 |
case 'B': { // Bounce.
|
|
|
599 |
list(, $userid) = unpack('V', base64_decode(substr($modargs, 1, 8)));
|
|
|
600 |
if ($user = $DB->get_record("user", array('id' => $userid), "id,email")) {
|
|
|
601 |
// Check the half md5 of their email.
|
|
|
602 |
$md5check = substr(md5($user->email), 0, 16);
|
|
|
603 |
if ($md5check == substr($modargs, -16)) {
|
|
|
604 |
set_bounce_count($user);
|
|
|
605 |
}
|
|
|
606 |
// Else maybe they've already changed it?
|
|
|
607 |
}
|
|
|
608 |
}
|
|
|
609 |
break;
|
|
|
610 |
// Maybe more later?
|
|
|
611 |
}
|
| 1 |
efrain |
612 |
}
|
|
|
613 |
|
|
|
614 |
/**
|
| 1441 |
ariadna |
615 |
* Gets the default category for a module context.
|
|
|
616 |
* If no categories exist yet then default ones are created in all contexts.
|
|
|
617 |
*
|
|
|
618 |
* @param array $contexts The context objects.
|
|
|
619 |
* @return stdClass|null The default category - the category in the first module context supplied in $contexts
|
| 1 |
efrain |
620 |
*/
|
| 1441 |
ariadna |
621 |
#[\core\attribute\deprecated('This method should not be used', since: '5.0', mdl: 'MDL-71378')]
|
|
|
622 |
function question_make_default_categories($contexts): object {
|
|
|
623 |
global $DB;
|
|
|
624 |
static $preferredlevels = [
|
|
|
625 |
CONTEXT_COURSE => 4,
|
|
|
626 |
CONTEXT_MODULE => 3,
|
|
|
627 |
CONTEXT_COURSECAT => 2,
|
|
|
628 |
CONTEXT_SYSTEM => 1,
|
|
|
629 |
];
|
| 1 |
efrain |
630 |
|
| 1441 |
ariadna |
631 |
$toreturn = null;
|
|
|
632 |
$preferredness = 0;
|
|
|
633 |
// If it already exists, just return it.
|
|
|
634 |
foreach ($contexts as $key => $context) {
|
|
|
635 |
$topcategory = question_get_top_category($context->id, true);
|
|
|
636 |
if (!$exists = $DB->record_exists("question_categories",
|
|
|
637 |
['contextid' => $context->id, 'parent' => $topcategory->id])) {
|
|
|
638 |
// Otherwise, we need to make one.
|
|
|
639 |
$category = new stdClass();
|
|
|
640 |
$contextname = $context->get_context_name(false, true);
|
|
|
641 |
// Max length of name field is 255.
|
|
|
642 |
$category->name = shorten_text(get_string('defaultfor', 'question', $contextname), 255);
|
|
|
643 |
$category->info = get_string('defaultinfofor', 'question', $contextname);
|
|
|
644 |
$category->contextid = $context->id;
|
|
|
645 |
$category->parent = $topcategory->id;
|
|
|
646 |
// By default, all categories get this number, and are sorted alphabetically.
|
|
|
647 |
$category->sortorder = 999;
|
|
|
648 |
$category->stamp = make_unique_id_code();
|
|
|
649 |
$category->id = $DB->insert_record('question_categories', $category);
|
|
|
650 |
} else {
|
|
|
651 |
$category = question_get_default_category($context->id, true);
|
|
|
652 |
}
|
|
|
653 |
$thispreferredness = $preferredlevels[$context->contextlevel];
|
|
|
654 |
if (has_any_capability(['moodle/question:usemine', 'moodle/question:useall'], $context)) {
|
|
|
655 |
$thispreferredness += 10;
|
|
|
656 |
}
|
|
|
657 |
if ($thispreferredness > $preferredness) {
|
|
|
658 |
$toreturn = $category;
|
|
|
659 |
$preferredness = $thispreferredness;
|
|
|
660 |
}
|
|
|
661 |
}
|
| 1 |
efrain |
662 |
|
| 1441 |
ariadna |
663 |
if (!is_null($toreturn)) {
|
|
|
664 |
$toreturn = clone($toreturn);
|
|
|
665 |
}
|
|
|
666 |
return $toreturn;
|
| 1 |
efrain |
667 |
}
|
|
|
668 |
|
|
|
669 |
/**
|
| 1441 |
ariadna |
670 |
* All question categories and their questions are deleted for this course.
|
|
|
671 |
*
|
|
|
672 |
* @param stdClass $course an object representing the activity
|
|
|
673 |
* @param bool $notused this argument is not used any more. Kept for backwards compatibility.
|
|
|
674 |
* @return bool always true.
|
| 1 |
efrain |
675 |
*/
|
| 1441 |
ariadna |
676 |
#[\core\attribute\deprecated('This method should not be used', since: '5.0', mdl: 'MDL-71378')]
|
|
|
677 |
function question_delete_course($course, $notused = false): bool {
|
|
|
678 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
679 |
|
| 1441 |
ariadna |
680 |
$coursecontext = context_course::instance($course->id);
|
|
|
681 |
question_delete_context($coursecontext->id);
|
|
|
682 |
return true;
|
| 1 |
efrain |
683 |
}
|
|
|
684 |
|
|
|
685 |
/**
|
| 1441 |
ariadna |
686 |
* Category is about to be deleted,
|
|
|
687 |
* 1/ All question categories and their questions are deleted for this course category.
|
|
|
688 |
* 2/ All questions are moved to new category
|
| 1 |
efrain |
689 |
*
|
| 1441 |
ariadna |
690 |
* @param stdClass|core_course_category $category course category object
|
|
|
691 |
* @param stdClass|core_course_category $newcategory empty means everything deleted, otherwise id of
|
|
|
692 |
* category where content moved
|
|
|
693 |
* @param bool $notused this argument is no longer used. Kept for backwards compatibility.
|
|
|
694 |
* @return boolean
|
| 1 |
efrain |
695 |
*/
|
| 1441 |
ariadna |
696 |
#[\core\attribute\deprecated('This method should not be used', since: '5.0', mdl: 'MDL-71378')]
|
|
|
697 |
function question_delete_course_category($category, $newcategory, $notused = false): bool {
|
|
|
698 |
global $DB;
|
|
|
699 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
700 |
|
| 1441 |
ariadna |
701 |
$context = context_coursecat::instance($category->id);
|
|
|
702 |
if (empty($newcategory)) {
|
|
|
703 |
question_delete_context($context->id);
|
| 1 |
efrain |
704 |
|
| 1441 |
ariadna |
705 |
} else {
|
|
|
706 |
// Move question categories to the new context.
|
|
|
707 |
if (!$newcontext = context_coursecat::instance($newcategory->id)) {
|
|
|
708 |
return false;
|
|
|
709 |
}
|
| 1 |
efrain |
710 |
|
| 1441 |
ariadna |
711 |
// Only move question categories if there is any question category at all!
|
|
|
712 |
if ($topcategory = question_get_top_category($context->id)) {
|
|
|
713 |
$newtopcategory = question_get_top_category($newcontext->id, true);
|
| 1 |
efrain |
714 |
|
| 1441 |
ariadna |
715 |
question_move_category_to_context($topcategory->id, $context->id, $newcontext->id);
|
|
|
716 |
$DB->set_field('question_categories', 'parent', $newtopcategory->id, ['parent' => $topcategory->id]);
|
|
|
717 |
// Now delete the top category.
|
|
|
718 |
$DB->delete_records('question_categories', ['id' => $topcategory->id]);
|
|
|
719 |
}
|
|
|
720 |
}
|
| 1 |
efrain |
721 |
|
| 1441 |
ariadna |
722 |
return true;
|
| 1 |
efrain |
723 |
}
|
|
|
724 |
|
|
|
725 |
/**
|
| 1441 |
ariadna |
726 |
* Check if the igbinary extension installed is buggy one
|
| 1 |
efrain |
727 |
*
|
| 1441 |
ariadna |
728 |
* There are a few php-igbinary versions that are buggy and
|
|
|
729 |
* return any unserialised array with wrong index. This defeats
|
|
|
730 |
* key() and next() operations on them.
|
| 1 |
efrain |
731 |
*
|
| 1441 |
ariadna |
732 |
* This library is used by MUC and also by memcached and redis
|
|
|
733 |
* when available.
|
| 1 |
efrain |
734 |
*
|
| 1441 |
ariadna |
735 |
* Let's inform if there is some problem when:
|
|
|
736 |
* - php 7.2 is being used (php 7.3 and up are immune).
|
|
|
737 |
* - the igbinary extension is installed.
|
|
|
738 |
* - the version of the extension is between 3.2.2 and 3.2.4.
|
|
|
739 |
* - the buggy behaviour is reproduced.
|
| 1 |
efrain |
740 |
*
|
| 1441 |
ariadna |
741 |
* @param environment_results $result object to update, if relevant.
|
|
|
742 |
* @return environment_results|null updated results or null.
|
| 1 |
efrain |
743 |
*
|
| 1441 |
ariadna |
744 |
* @deprecated Since Moodle 5.0
|
|
|
745 |
* @todo Final deprecation on Moodle 6.0. See MDL-83675.
|
| 1 |
efrain |
746 |
*/
|
| 1441 |
ariadna |
747 |
#[\core\attribute\deprecated(
|
|
|
748 |
since: '5.0',
|
|
|
749 |
mdl: 'MDL-73700',
|
|
|
750 |
reason: 'Remove all the old php version checks from core',
|
|
|
751 |
)]
|
|
|
752 |
function check_igbinary322_version(environment_results $result) {
|
|
|
753 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
|
|
754 |
return null;
|
| 1 |
efrain |
755 |
}
|
|
|
756 |
|
|
|
757 |
/**
|
| 1441 |
ariadna |
758 |
* @deprecated since Moodle 4.3 MDL-79313
|
| 1 |
efrain |
759 |
*/
|
| 1441 |
ariadna |
760 |
#[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-79313', final: true)]
|
|
|
761 |
function calendar_top_controls() {
|
|
|
762 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
763 |
}
|
|
|
764 |
|
|
|
765 |
/**
|
| 1441 |
ariadna |
766 |
* @deprecated since Moodle 4.3 MDL-79432
|
| 1 |
efrain |
767 |
*/
|
| 1441 |
ariadna |
768 |
#[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-79432', final: true)]
|
|
|
769 |
function calendar_get_link_previous() {
|
|
|
770 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
771 |
}
|
|
|
772 |
|
|
|
773 |
/**
|
| 1441 |
ariadna |
774 |
* @deprecated since Moodle 4.3 MDL-79432
|
| 1 |
efrain |
775 |
*/
|
| 1441 |
ariadna |
776 |
#[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-79432', final: true)]
|
|
|
777 |
function calendar_get_link_next() {
|
|
|
778 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
| 1 |
efrain |
779 |
}
|
|
|
780 |
|
|
|
781 |
/**
|
| 1441 |
ariadna |
782 |
* Get the previous month.
|
| 1 |
efrain |
783 |
*
|
| 1441 |
ariadna |
784 |
* @param int $month the number of the month.
|
|
|
785 |
* @param int $year the number of the year.
|
|
|
786 |
* @return array previous month
|
| 1 |
efrain |
787 |
*
|
| 1441 |
ariadna |
788 |
* @deprecated since 5.0 MDL-79434 Use \core_calendar\type_factory::get_calendar_instance()->get_prev_month() instead,
|
|
|
789 |
* but pay regard to the order of arguments!
|
|
|
790 |
* @todo MDL-84655 Remove this function in Moodle 6.0
|
| 1 |
efrain |
791 |
*/
|
| 1441 |
ariadna |
792 |
#[\core\attribute\deprecated(
|
|
|
793 |
'\core_calendar\type_factory::get_calendar_instance()->get_prev_month()',
|
|
|
794 |
since: '5.0',
|
|
|
795 |
mdl: 'MDL-79434'
|
|
|
796 |
)]
|
|
|
797 |
function calendar_sub_month($month, $year) {
|
|
|
798 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
|
|
799 |
return \core_calendar\type_factory::get_calendar_instance()->get_prev_month($year, $month);
|
| 1 |
efrain |
800 |
}
|
|
|
801 |
|
|
|
802 |
/**
|
| 1441 |
ariadna |
803 |
* Get the next following month.
|
| 1 |
efrain |
804 |
*
|
| 1441 |
ariadna |
805 |
* @param int $month the number of the month.
|
|
|
806 |
* @param int $year the number of the year.
|
|
|
807 |
* @return array the following month
|
| 1 |
efrain |
808 |
*
|
| 1441 |
ariadna |
809 |
* @deprecated since 5.0 MDL-84657 Use \core_calendar\type_factory::get_calendar_instance()->get_prev_month() instead,
|
|
|
810 |
* but pay regard to the order of arguments!
|
|
|
811 |
* @todo MDL-84655 Remove this function in Moodle 6.0
|
| 1 |
efrain |
812 |
*/
|
| 1441 |
ariadna |
813 |
#[\core\attribute\deprecated(
|
|
|
814 |
'\core_calendar\type_factory::get_calendar_instance()->get_next_month()',
|
|
|
815 |
since: '5.0',
|
|
|
816 |
mdl: 'MDL-84657'
|
|
|
817 |
)]
|
|
|
818 |
function calendar_add_month($month, $year) {
|
|
|
819 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
|
|
820 |
return \core_calendar\type_factory::get_calendar_instance()->get_next_month($year, $month);
|
| 1 |
efrain |
821 |
}
|
|
|
822 |
|
|
|
823 |
/**
|
| 1441 |
ariadna |
824 |
* Copies a rectangular portion of the source image to another rectangle in the destination image
|
| 1 |
efrain |
825 |
*
|
| 1441 |
ariadna |
826 |
* This function calls imagecopyresampled() if it is available and GD version is 2 at least.
|
|
|
827 |
* Otherwise it reimplements the same behaviour. See the PHP manual page for more info.
|
| 1 |
efrain |
828 |
*
|
| 1441 |
ariadna |
829 |
* @link http://php.net/manual/en/function.imagecopyresampled.php
|
|
|
830 |
* @param resource|\GdImage $dst_img the destination GD image resource
|
|
|
831 |
* @param resource|\GdImage $src_img the source GD image resource
|
|
|
832 |
* @param int $dst_x vthe X coordinate of the upper left corner in the destination image
|
|
|
833 |
* @param int $dst_y the Y coordinate of the upper left corner in the destination image
|
|
|
834 |
* @param int $src_x the X coordinate of the upper left corner in the source image
|
|
|
835 |
* @param int $src_y the Y coordinate of the upper left corner in the source image
|
|
|
836 |
* @param int $dst_w the width of the destination rectangle
|
|
|
837 |
* @param int $dst_h the height of the destination rectangle
|
|
|
838 |
* @param int $src_w the width of the source rectangle
|
|
|
839 |
* @param int $src_h the height of the source rectangle
|
|
|
840 |
* @return ?bool tru on success, false otherwise
|
| 1 |
efrain |
841 |
*
|
| 1441 |
ariadna |
842 |
* @deprecated Since Moodle 5.0
|
|
|
843 |
* @todo Final deprecation on Moodle 6.0. See MDL-84734.
|
| 1 |
efrain |
844 |
*/
|
| 1441 |
ariadna |
845 |
#[\core\attribute\deprecated(
|
|
|
846 |
replacement: 'imagecopyresampled',
|
|
|
847 |
since: '5.0',
|
|
|
848 |
mdl: 'MDL-84449',
|
|
|
849 |
reason: 'GD is a strict requirement, so use imagecopyresampled() instead.'
|
|
|
850 |
)]
|
|
|
851 |
function imagecopybicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {
|
|
|
852 |
\core\deprecation::emit_deprecation(__FUNCTION__);
|
|
|
853 |
return imagecopyresampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
| 1 |
efrain |
854 |
}
|