MDL-69521 core: Move all comments in code from 4.1 to 3.11
[moodle.git] / lib / deprecatedlib.php
CommitLineData
c861fe2f 1<?php
2
a5cb8d69 3// This file is part of Moodle - http://moodle.org/
4//
c861fe2f 5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
a5cb8d69 14//
c861fe2f 15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
c4d0753b 17
18/**
19 * deprecatedlib.php - Old functions retained only for backward compatibility
20 *
21 * Old functions retained only for backward compatibility. New code should not
22 * use any of these functions.
23 *
78bfb562 24 * @package core
c861fe2f 25 * @subpackage deprecated
78bfb562
PS
26 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
c861fe2f 28 * @deprecated
c4d0753b 29 */
30
78bfb562
PS
31defined('MOODLE_INTERNAL') || die();
32
33c46db5
AA
33/* === Functions that needs to be kept longer in deprecated lib than normal time period === */
34
35/**
33c46db5 36 * @deprecated since 2.7 use new events instead
33c46db5 37 */
d464fb43
JO
38function add_to_log() {
39 throw new coding_exception('add_to_log() has been removed, please rewrite your code to the new events API');
33c46db5
AA
40}
41
42/**
33c46db5 43 * @deprecated since 2.6
33c46db5 44 */
b41e1d7c
AG
45function events_trigger() {
46 throw new coding_exception('events_trigger() has been deprecated along with all Events 1 API in favour of Events 2 API.');
33c46db5
AA
47}
48
49/**
50 * List all core subsystems and their location
51 *
52 * This is a whitelist of components that are part of the core and their
53 * language strings are defined in /lang/en/<<subsystem>>.php. If a given
54 * plugin is not listed here and it does not have proper plugintype prefix,
55 * then it is considered as course activity module.
56 *
57 * The location is optionally dirroot relative path. NULL means there is no special
58 * directory for this subsystem. If the location is set, the subsystem's
59 * renderer.php is expected to be there.
60 *
61 * @deprecated since 2.6, use core_component::get_core_subsystems()
62 *
63 * @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons
64 * @return array of (string)name => (string|null)location
65 */
66function get_core_subsystems($fullpaths = false) {
67 global $CFG;
68
69 // NOTE: do not add any other debugging here, keep forever.
70
71 $subsystems = core_component::get_core_subsystems();
72
73 if ($fullpaths) {
74 return $subsystems;
75 }
76
77 debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
78
79 $dlength = strlen($CFG->dirroot);
80
81 foreach ($subsystems as $k => $v) {
82 if ($v === null) {
83 continue;
84 }
85 $subsystems[$k] = substr($v, $dlength+1);
86 }
87
88 return $subsystems;
89}
90
91/**
92 * Lists all plugin types.
93 *
94 * @deprecated since 2.6, use core_component::get_plugin_types()
95 *
96 * @param bool $fullpaths false means relative paths from dirroot
97 * @return array Array of strings - name=>location
98 */
99function get_plugin_types($fullpaths = true) {
100 global $CFG;
101
102 // NOTE: do not add any other debugging here, keep forever.
103
104 $types = core_component::get_plugin_types();
105
106 if ($fullpaths) {
107 return $types;
108 }
109
110 debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
111
112 $dlength = strlen($CFG->dirroot);
113
114 foreach ($types as $k => $v) {
115 if ($k === 'theme') {
116 $types[$k] = 'theme';
117 continue;
118 }
119 $types[$k] = substr($v, $dlength+1);
120 }
121
122 return $types;
123}
124
125/**
126 * Use when listing real plugins of one type.
127 *
128 * @deprecated since 2.6, use core_component::get_plugin_list()
129 *
130 * @param string $plugintype type of plugin
131 * @return array name=>fulllocation pairs of plugins of given type
132 */
133function get_plugin_list($plugintype) {
134
135 // NOTE: do not add any other debugging here, keep forever.
136
137 if ($plugintype === '') {
138 $plugintype = 'mod';
139 }
140
141 return core_component::get_plugin_list($plugintype);
142}
143
144/**
145 * Get a list of all the plugins of a given type that define a certain class
146 * in a certain file. The plugin component names and class names are returned.
147 *
148 * @deprecated since 2.6, use core_component::get_plugin_list_with_class()
149 *
150 * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
151 * @param string $class the part of the name of the class after the
152 * frankenstyle prefix. e.g 'thing' if you are looking for classes with
153 * names like report_courselist_thing. If you are looking for classes with
154 * the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
155 * @param string $file the name of file within the plugin that defines the class.
156 * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
157 * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
158 */
159function get_plugin_list_with_class($plugintype, $class, $file) {
160
161 // NOTE: do not add any other debugging here, keep forever.
162
163 return core_component::get_plugin_list_with_class($plugintype, $class, $file);
164}
165
166/**
167 * Returns the exact absolute path to plugin directory.
168 *
169 * @deprecated since 2.6, use core_component::get_plugin_directory()
170 *
171 * @param string $plugintype type of plugin
172 * @param string $name name of the plugin
173 * @return string full path to plugin directory; NULL if not found
174 */
175function get_plugin_directory($plugintype, $name) {
176
177 // NOTE: do not add any other debugging here, keep forever.
178
179 if ($plugintype === '') {
180 $plugintype = 'mod';
181 }
182
183 return core_component::get_plugin_directory($plugintype, $name);
184}
185
186/**
187 * Normalize the component name using the "frankenstyle" names.
188 *
189 * @deprecated since 2.6, use core_component::normalize_component()
190 *
191 * @param string $component
6b6a2ec4 192 * @return array two-items list of [(string)type, (string|null)name]
33c46db5
AA
193 */
194function normalize_component($component) {
195
196 // NOTE: do not add any other debugging here, keep forever.
197
198 return core_component::normalize_component($component);
199}
200
201/**
202 * Return exact absolute path to a plugin directory.
203 *
204 * @deprecated since 2.6, use core_component::normalize_component()
205 *
206 * @param string $component name such as 'moodle', 'mod_forum'
207 * @return string full path to component directory; NULL if not found
208 */
209function get_component_directory($component) {
210
211 // NOTE: do not add any other debugging here, keep forever.
212
213 return core_component::get_component_directory($component);
214}
215
216/**
217 * Get the context instance as an object. This function will create the
218 * context instance if it does not exist yet.
219 *
220 * @deprecated since 2.2, use context_course::instance() or other relevant class instead
221 * @todo This will be deleted in Moodle 2.8, refer MDL-34472
222 * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
223 * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
224 * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
225 * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
226 * MUST_EXIST means throw exception if no record or multiple records found
227 * @return context The context object.
228 */
229function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) {
230
231 debugging('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER);
232
233 $instances = (array)$instance;
234 $contexts = array();
235
236 $classname = context_helper::get_class_for_level($contextlevel);
237
238 // we do not load multiple contexts any more, PAGE should be responsible for any preloading
239 foreach ($instances as $inst) {
240 $contexts[$inst] = $classname::instance($inst, $strictness);
241 }
242
243 if (is_array($instance)) {
244 return $contexts;
245 } else {
246 return $contexts[$instance];
247 }
248}
249/* === End of long term deprecated api list === */
250
114e3209 251/**
114e3209 252 * @deprecated since 2.7 - use new file picker instead
114e3209 253 */
5ab88243 254function clam_log_upload() {
6dd7175a 255 throw new coding_exception('clam_log_upload() can not be used any more, please use file picker instead');
114e3209
256}
257
258/**
114e3209 259 * @deprecated since 2.7 - use new file picker instead
114e3209 260 */
5ab88243 261function clam_log_infected() {
6dd7175a 262 throw new coding_exception('clam_log_infected() can not be used any more, please use file picker instead');
114e3209
263}
264
265/**
114e3209 266 * @deprecated since 2.7 - use new file picker instead
114e3209 267 */
5ab88243 268function clam_change_log() {
6dd7175a 269 throw new coding_exception('clam_change_log() can not be used any more, please use file picker instead');
114e3209
270}
271
272/**
114e3209 273 * @deprecated since 2.7 - infected files are now deleted in file picker
114e3209 274 */
5ab88243 275function clam_replace_infected_file() {
6dd7175a 276 throw new coding_exception('clam_replace_infected_file() can not be used any more, please use file picker instead');
114e3209
277}
278
7293a1aa 279/**
7293a1aa
DP
280 * @deprecated since 2.7
281 */
5ab88243 282function clam_handle_infected_file() {
7293a1aa
DP
283 throw new coding_exception('clam_handle_infected_file() can not be used any more, please use file picker instead');
284}
285
286/**
7293a1aa
DP
287 * @deprecated since 2.7
288 */
5ab88243 289function clam_scan_moodle_file() {
7293a1aa
DP
290 throw new coding_exception('clam_scan_moodle_file() can not be used any more, please use file picker instead');
291}
292
293
6780a1d3 294/**
6780a1d3 295 * @deprecated since 2.7 PHP 5.4.x should be always compatible.
6780a1d3
296 */
297function password_compat_not_supported() {
1ac1d29b 298 throw new coding_exception('Do not use password_compat_not_supported() - bcrypt is now always available');
6780a1d3
299}
300
d79d5ac2 301/**
d79d5ac2 302 * @deprecated since 2.6
d79d5ac2
PS
303 */
304function session_get_instance() {
2149326b 305 throw new coding_exception('session_get_instance() is removed, use \core\session\manager instead');
d79d5ac2
PS
306}
307
308/**
d79d5ac2 309 * @deprecated since 2.6
d79d5ac2
PS
310 */
311function session_is_legacy() {
2149326b 312 throw new coding_exception('session_is_legacy() is removed, do not use any more');
d79d5ac2
PS
313}
314
315/**
d79d5ac2
PS
316 * @deprecated since 2.6
317 */
318function session_kill_all() {
2149326b 319 throw new coding_exception('session_kill_all() is removed, use \core\session\manager::kill_all_sessions() instead');
d79d5ac2
PS
320}
321
322/**
d79d5ac2 323 * @deprecated since 2.6
d79d5ac2 324 */
5ab88243 325function session_touch() {
2149326b 326 throw new coding_exception('session_touch() is removed, use \core\session\manager::touch_session() instead');
d79d5ac2
PS
327}
328
329/**
d79d5ac2 330 * @deprecated since 2.6
d79d5ac2 331 */
5ab88243 332function session_kill() {
2149326b 333 throw new coding_exception('session_kill() is removed, use \core\session\manager::kill_session() instead');
d79d5ac2
PS
334}
335
336/**
d79d5ac2 337 * @deprecated since 2.6
d79d5ac2 338 */
5ab88243 339function session_kill_user() {
2149326b 340 throw new coding_exception('session_kill_user() is removed, use \core\session\manager::kill_user_sessions() instead');
d79d5ac2
PS
341}
342
d79d5ac2 343/**
d79d5ac2 344 * @deprecated since 2.6
d79d5ac2 345 */
5ab88243 346function session_set_user() {
2149326b 347 throw new coding_exception('session_set_user() is removed, use \core\session\manager::set_user() instead');
d79d5ac2
PS
348}
349
350/**
d79d5ac2 351 * @deprecated since 2.6
d79d5ac2
PS
352 */
353function session_is_loggedinas() {
2149326b 354 throw new coding_exception('session_is_loggedinas() is removed, use \core\session\manager::is_loggedinas() instead');
d79d5ac2
PS
355}
356
357/**
d79d5ac2 358 * @deprecated since 2.6
d79d5ac2
PS
359 */
360function session_get_realuser() {
2149326b 361 throw new coding_exception('session_get_realuser() is removed, use \core\session\manager::get_realuser() instead');
d79d5ac2
PS
362}
363
364/**
d79d5ac2 365 * @deprecated since 2.6
d79d5ac2 366 */
5ab88243 367function session_loginas() {
2149326b 368 throw new coding_exception('session_loginas() is removed, use \core\session\manager::loginas() instead');
d79d5ac2
PS
369}
370
6b32d6bc 371/**
6b32d6bc 372 * @deprecated since 2.6
6b32d6bc 373 */
5ab88243 374function js_minify() {
2149326b 375 throw new coding_exception('js_minify() is removed, use core_minify::js_files() or core_minify::js() instead.');
6b32d6bc
PS
376}
377
378/**
6b32d6bc 379 * @deprecated since 2.6
6b32d6bc 380 */
5ab88243 381function css_minify_css() {
2149326b 382 throw new coding_exception('css_minify_css() is removed, use core_minify::css_files() or core_minify::css() instead.');
6b32d6bc
PS
383}
384
9e19a0f0
PS
385// === Deprecated before 2.6.0 ===
386
689096bc 387/**
2a723541 388 * @deprecated
689096bc
PS
389 */
390function check_gd_version() {
2149326b 391 throw new coding_exception('check_gd_version() is removed, GD extension is always available now');
689096bc
PS
392}
393
b28247fe 394/**
b28247fe
PS
395 * @deprecated
396 */
397function update_login_count() {
2149326b 398 throw new coding_exception('update_login_count() is removed, all calls need to be removed');
b28247fe
PS
399}
400
401/**
b28247fe
PS
402 * @deprecated
403 */
404function reset_login_count() {
2149326b 405 throw new coding_exception('reset_login_count() is removed, all calls need to be removed');
b28247fe
PS
406}
407
c6d75bff 408/**
c6d75bff 409 * @deprecated
c6d75bff 410 */
5ab88243 411function update_log_display_entry() {
c6d75bff 412
2149326b 413 throw new coding_exception('The update_log_display_entry() is removed, please use db/log.php description file instead.');
c6d75bff
PS
414}
415
35716b86 416/**
05226d76 417 * @deprecated use the text formatting in a standard way instead (http://docs.moodle.org/dev/Output_functions)
35716b86 418 * this was abused mostly for embedding of attachments
35716b86 419 */
5ab88243 420function filter_text() {
e4d9185e 421 throw new coding_exception('filter_text() can not be used anymore, use format_text(), format_string() etc instead.');
35716b86
PS
422}
423
17c70aa0 424/**
4b501ec9 425 * @deprecated Loginhttps is no longer supported
17c70aa0
PS
426 */
427function httpsrequired() {
4b501ec9 428 throw new coding_exception('httpsrequired() can not be used any more. Loginhttps is no longer supported.');
17c70aa0
PS
429}
430
50a8bd6c 431/**
11d4bea2
SL
432 * @deprecated since 3.1 - replacement legacy file API methods can be found on the moodle_url class, for example:
433 * The moodle_url::make_legacyfile_url() method can be used to generate a legacy course file url. To generate
434 * course module file.php url the moodle_url::make_file_url() should be used.
50a8bd6c 435 */
5ab88243
MG
436function get_file_url() {
437 throw new coding_exception('get_file_url() can not be used anymore. Please use ' .
438 'moodle_url factory methods instead.');
50a8bd6c
PS
439}
440
613bbd7c 441/**
05226d76 442 * @deprecated use get_enrolled_users($context) instead.
613bbd7c 443 */
5ab88243 444function get_course_participants() {
e4d9185e 445 throw new coding_exception('get_course_participants() can not be used any more, use get_enrolled_users() instead.');
613bbd7c 446}
447
613bbd7c 448/**
05226d76 449 * @deprecated use is_enrolled($context, $userid) instead.
613bbd7c 450 */
5ab88243 451function is_course_participant() {
e4d9185e 452 throw new coding_exception('is_course_participant() can not be used any more, use is_enrolled() instead.');
613bbd7c 453}
454
455/**
1ac1d29b 456 * @deprecated
613bbd7c 457 */
5ab88243 458function get_recent_enrolments() {
2149326b 459 throw new coding_exception('get_recent_enrolments() is removed as it returned inaccurate results.');
613bbd7c 460}
461
ed5dd29f 462/**
05226d76 463 * @deprecated use clean_param($string, PARAM_FILE) instead.
ed5dd29f 464 */
5ab88243 465function detect_munged_arguments() {
e4d9185e 466 throw new coding_exception('detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.');
ed5dd29f 467}
468
9152fc99 469
0c6d2dd4 470/**
471 * Unzip one zip file to a destination dir
472 * Both parameters must be FULL paths
473 * If destination isn't specified, it will be the
474 * SAME directory where the zip file resides.
c861fe2f 475 *
476 * @global object
477 * @param string $zipfile The zip file to unzip
478 * @param string $destination The location to unzip to
479 * @param bool $showstatus_ignored Unused
2c2f4f17 480 * @deprecated since 2.0 MDL-15919
0c6d2dd4 481 */
482function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
2c2f4f17
AN
483 debugging(__FUNCTION__ . '() is deprecated. '
484 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER);
0c6d2dd4 485
2c2f4f17 486 // Extract everything from zipfile.
0c6d2dd4 487 $path_parts = pathinfo(cleardoubleslashes($zipfile));
488 $zippath = $path_parts["dirname"]; //The path of the zip file
489 $zipfilename = $path_parts["basename"]; //The name of the zip file
490 $extension = $path_parts["extension"]; //The extension of the file
491
492 //If no file, error
493 if (empty($zipfilename)) {
494 return false;
495 }
496
497 //If no extension, error
498 if (empty($extension)) {
499 return false;
500 }
501
502 //Clear $zipfile
503 $zipfile = cleardoubleslashes($zipfile);
504
505 //Check zipfile exists
506 if (!file_exists($zipfile)) {
507 return false;
508 }
509
510 //If no destination, passed let's go with the same directory
511 if (empty($destination)) {
512 $destination = $zippath;
513 }
514
515 //Clear $destination
516 $destpath = rtrim(cleardoubleslashes($destination), "/");
517
518 //Check destination path exists
519 if (!is_dir($destpath)) {
520 return false;
521 }
522
0b0bfa93 523 $packer = get_file_packer('application/zip');
524
525 $result = $packer->extract_to_pathname($zipfile, $destpath);
0c6d2dd4 526
527 if ($result === false) {
528 return false;
529 }
530
531 foreach ($result as $status) {
532 if ($status !== true) {
533 return false;
534 }
535 }
536
537 return true;
538}
539
ed94cb66 540/**
541 * Zip an array of files/dirs to a destination zip file
542 * Both parameters must be FULL paths to the files/dirs
c861fe2f 543 *
544 * @global object
545 * @param array $originalfiles Files to zip
546 * @param string $destination The destination path
547 * @return bool Outcome
56b9e796
AN
548 *
549 * @deprecated since 2.0 MDL-15919
ed94cb66 550 */
56b9e796
AN
551function zip_files($originalfiles, $destination) {
552 debugging(__FUNCTION__ . '() is deprecated. '
553 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER);
ed94cb66 554
56b9e796 555 // Extract everything from destination.
ed94cb66 556 $path_parts = pathinfo(cleardoubleslashes($destination));
557 $destpath = $path_parts["dirname"]; //The path of the zip file
558 $destfilename = $path_parts["basename"]; //The name of the zip file
559 $extension = $path_parts["extension"]; //The extension of the file
560
561 //If no file, error
562 if (empty($destfilename)) {
563 return false;
564 }
565
566 //If no extension, add it
567 if (empty($extension)) {
568 $extension = 'zip';
569 $destfilename = $destfilename.'.'.$extension;
570 }
571
572 //Check destination path exists
573 if (!is_dir($destpath)) {
574 return false;
575 }
576
577 //Check destination path is writable. TODO!!
578
579 //Clean destination filename
580 $destfilename = clean_filename($destfilename);
581
582 //Now check and prepare every file
583 $files = array();
584 $origpath = NULL;
585
586 foreach ($originalfiles as $file) { //Iterate over each file
587 //Check for every file
588 $tempfile = cleardoubleslashes($file); // no doubleslashes!
589 //Calculate the base path for all files if it isn't set
590 if ($origpath === NULL) {
591 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
592 }
593 //See if the file is readable
594 if (!is_readable($tempfile)) { //Is readable
595 continue;
596 }
597 //See if the file/dir is in the same directory than the rest
598 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
599 continue;
600 }
601 //Add the file to the array
602 $files[] = $tempfile;
603 }
604
605 $zipfiles = array();
606 $start = strlen($origpath)+1;
607 foreach($files as $file) {
608 $zipfiles[substr($file, $start)] = $file;
609 }
610
0b0bfa93 611 $packer = get_file_packer('application/zip');
ed94cb66 612
3ed22f1a 613 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
ed94cb66 614}
615
5bf243d1 616/**
05226d76 617 * @deprecated use groups_get_all_groups() instead.
5bf243d1 618 */
5ab88243 619function mygroupid() {
e4d9185e 620 throw new coding_exception('mygroupid() can not be used any more, please use groups_get_all_groups() instead.');
5bf243d1 621}
622
5bf243d1 623/**
d494100e 624 * @deprecated since Moodle 2.0 MDL-14617 - please do not use this function any more.
5bf243d1 625 */
5ab88243 626function groupmode() {
53ca9cc8 627 throw new coding_exception('groupmode() can not be used any more, please use groups_get_* instead.');
5bf243d1 628}
629
c584346c 630/**
d494100e 631 * @deprecated Since year 2006 - please do not use this function any more.
c584346c 632 */
5ab88243 633function set_current_group() {
53ca9cc8 634 throw new coding_exception('set_current_group() can not be used anymore, please use $SESSION->currentgroup[$courseid] instead');
c584346c 635}
636
5bf243d1 637/**
d494100e 638 * @deprecated Since year 2006 - please do not use this function any more.
5bf243d1 639 */
5ab88243 640function get_current_group() {
53ca9cc8 641 throw new coding_exception('get_current_group() can not be used any more, please use groups_get_* instead');
5bf243d1 642}
643
061e6b28 644/**
061e6b28 645 * @deprecated Since Moodle 2.8
646 */
5ab88243 647function groups_filter_users_by_course_module_visible() {
2149326b 648 throw new coding_exception('groups_filter_users_by_course_module_visible() is removed. ' .
061e6b28 649 'Replace with a call to \core_availability\info_module::filter_user_list(), ' .
650 'which does basically the same thing but includes other restrictions such ' .
1ac1d29b 651 'as profile restrictions.');
061e6b28 652}
653
654/**
061e6b28 655 * @deprecated Since Moodle 2.8
656 */
5ab88243 657function groups_course_module_visible() {
2149326b
AA
658 throw new coding_exception('groups_course_module_visible() is removed, use $cm->uservisible to decide whether the current
659 user can ' . 'access an activity.', DEBUG_DEVELOPER);
061e6b28 660}
5bf243d1 661
8ec50604 662/**
1ac1d29b 663 * @deprecated since 2.0
8ec50604 664 */
5ab88243 665function error() {
2149326b 666 throw new coding_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a removed, please call
1ac1d29b 667 print_error() instead of error()');
251387d0 668}
8ec50604 669
8ec50604 670
b7009474 671/**
672 * @deprecated use $PAGE->theme->name instead.
b7009474 673 */
674function current_theme() {
e4d9185e 675 throw new coding_exception('current_theme() can not be used any more, please use $PAGE->theme->name instead');
b7009474 676}
677
8954245a 678/**
8954245a 679 * @deprecated
8954245a 680 */
5ab88243 681function formerr() {
2149326b 682 throw new coding_exception('formerr() is removed. Please change your code to use $OUTPUT->error_text($string).');
8954245a 683}
684
34a2777c 685/**
34a2777c 686 * @deprecated use $OUTPUT->skip_link_target() in instead.
34a2777c 687 */
688function skip_main_destination() {
e4d9185e 689 throw new coding_exception('skip_main_destination() can not be used any more, please use $OUTPUT->skip_link_target() instead.');
34a2777c 690}
691
34a2777c 692/**
05226d76 693 * @deprecated use $OUTPUT->container() instead.
34a2777c 694 */
5ab88243 695function print_container() {
e4d9185e 696 throw new coding_exception('print_container() can not be used any more. Please use $OUTPUT->container() instead.');
34a2777c 697}
698
699/**
05226d76 700 * @deprecated use $OUTPUT->container_start() instead.
34a2777c 701 */
5ab88243 702function print_container_start() {
e4d9185e 703 throw new coding_exception('print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.');
34a2777c 704}
705
706/**
05226d76 707 * @deprecated use $OUTPUT->container_end() instead.
34a2777c 708 */
5ab88243 709function print_container_end() {
e4d9185e 710 throw new coding_exception('print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.');
34a2777c 711}
712
713/**
ef53650e 714 * @deprecated since Moodle 2.0 MDL-19077 - use $OUTPUT->notification instead.
34a2777c 715 */
943e2900
AA
716function notify() {
717 throw new coding_exception('notify() is removed, please use $OUTPUT->notification() instead');
34a2777c 718}
719
720/**
05226d76 721 * @deprecated use $OUTPUT->continue_button() instead.
34a2777c 722 */
5ab88243 723function print_continue() {
e4d9185e 724 throw new coding_exception('print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.');
34a2777c 725}
726
34a2777c 727/**
05226d76 728 * @deprecated use $PAGE methods instead.
34a2777c 729 */
5ab88243 730function print_header() {
34a2777c 731
e4d9185e 732 throw new coding_exception('print_header() can not be used any more. Please use $PAGE methods instead.');
34a2777c 733}
734
47a1aa45 735/**
05226d76 736 * @deprecated use $PAGE methods instead.
47a1aa45 737 */
5ab88243 738function print_header_simple() {
47a1aa45 739
e4d9185e 740 throw new coding_exception('print_header_simple() can not be used any more. Please use $PAGE methods instead.');
47a1aa45 741}
742
a5cb8d69 743/**
05226d76 744 * @deprecated use $OUTPUT->block() instead.
a5cb8d69 745 */
5ab88243 746function print_side_block() {
e4d9185e 747 throw new coding_exception('print_side_block() can not be used any more, please use $OUTPUT->block() instead.');
a5cb8d69 748}
749
f8065dd2 750/**
350d7b06 751 * @deprecated since Moodle 3.6
b27a27ad
MM
752 */
753function print_textarea() {
754 throw new coding_exception(
755 'print_textarea() has been removed. Please use $OUTPUT->print_textarea() instead.'
756 );
f8065dd2 757}
758
f8065dd2 759/**
760 * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
761 * provide this function with the language strings for sortasc and sortdesc.
762 *
05226d76 763 * @deprecated use $OUTPUT->arrow() instead.
e4d9185e 764 * @todo final deprecation of this function once MDL-45448 is resolved
f8065dd2 765 *
f8065dd2 766 * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
767 *
768 * @global object
769 * @param string $direction 'up' or 'down'
770 * @param string $strsort The language string used for the alt attribute of this image
771 * @param bool $return Whether to print directly or return the html string
772 * @return string|void depending on $return
773 *
774 */
775function print_arrow($direction='up', $strsort=null, $return=false) {
f8065dd2 776 global $OUTPUT;
777
05226d76
DP
778 debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER);
779
f8065dd2 780 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
781 return null;
782 }
783
784 $return = null;
785
786 switch ($direction) {
787 case 'up':
788 $sortdir = 'asc';
789 break;
790 case 'down':
791 $sortdir = 'desc';
792 break;
793 case 'move':
794 $sortdir = 'asc';
795 break;
796 default:
797 $sortdir = null;
798 break;
799 }
800
801 // Prepare language string
802 $strsort = '';
803 if (empty($strsort) && !empty($sortdir)) {
804 $strsort = get_string('sort' . $sortdir, 'grades');
805 }
806
663640f5 807 $return = ' ' . $OUTPUT->pix_icon('t/' . $direction, $strsort) . ' ';
f8065dd2 808
809 if ($return) {
810 return $return;
811 } else {
812 echo $return;
813 }
814}
815
8100c169 816/**
8100c169 817 * @deprecated since Moodle 2.0
8100c169 818 */
5ab88243 819function choose_from_menu() {
2149326b 820 throw new coding_exception('choose_from_menu() is removed. Please change your code to use html_writer::select().');
053203a8 821}
822
c68e4098 823/**
05226d76 824 * @deprecated use $OUTPUT->help_icon_scale($courseid, $scale) instead.
c68e4098 825 */
5ab88243 826function print_scale_menu_helpbutton() {
e4d9185e
DP
827 throw new coding_exception('print_scale_menu_helpbutton() can not be used any more. '.
828 'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.');
c68e4098 829}
830
49c8c8d2 831/**
05226d76 832 * @deprecated use html_writer::checkbox() instead.
49c8c8d2 833 */
5ab88243 834function print_checkbox() {
e4d9185e 835 throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.');
49c8c8d2 836}
6a5c71b9 837
d3932d2b 838/**
d3932d2b 839 * @deprecated since Moodle 3.2
d3932d2b 840 */
216b8947
MG
841function update_module_button() {
842 throw new coding_exception('update_module_button() can not be used anymore. Activity modules should ' .
843 'not add the edit module button, the link is already available in the Administration block. Themes ' .
844 'can choose to display the link in the buttons row consistently for all module types.');
d3932d2b
JP
845}
846
7d2a0492 847/**
05226d76 848 * @deprecated use $OUTPUT->navbar() instead
7d2a0492 849 */
5ab88243 850function print_navigation () {
e4d9185e 851 throw new coding_exception('print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.');
7d2a0492 852}
853
854/**
05226d76 855 * @deprecated Please use $PAGE->navabar methods instead.
7d2a0492 856 */
5ab88243 857function build_navigation() {
e4d9185e 858 throw new coding_exception('build_navigation() can not be used any more, please use $PAGE->navbar methods instead.');
7d2a0492 859}
860
861/**
05226d76 862 * @deprecated not relevant with global navigation in Moodle 2.x+
7d2a0492 863 */
5ab88243 864function navmenu() {
e4d9185e 865 throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.');
f43cdceb 866}
76d9df3f
SH
867
868/// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
869
870
871/**
e1cd93ce 872 * @deprecated please use calendar_event::create() instead.
76d9df3f 873 */
5ab88243 874function add_event() {
e1cd93ce 875 throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.');
76d9df3f
SH
876}
877
878/**
e1cd93ce 879 * @deprecated please calendar_event->update() instead.
76d9df3f 880 */
5ab88243 881function update_event() {
e1cd93ce 882 throw new coding_exception('update_event() is removed, please use calendar_event->update() instead.');
76d9df3f
SH
883}
884
885/**
e1cd93ce 886 * @deprecated please use calendar_event->delete() instead.
76d9df3f 887 */
5ab88243 888function delete_event() {
e4d9185e 889 throw new coding_exception('delete_event() can not be used any more, please use '.
e1cd93ce 890 'calendar_event->delete() instead.');
76d9df3f
SH
891}
892
893/**
e1cd93ce 894 * @deprecated please use calendar_event->toggle_visibility(false) instead.
76d9df3f 895 */
5ab88243 896function hide_event() {
e4d9185e 897 throw new coding_exception('hide_event() can not be used any more, please use '.
e1cd93ce 898 'calendar_event->toggle_visibility(false) instead.');
76d9df3f
SH
899}
900
901/**
e1cd93ce 902 * @deprecated please use calendar_event->toggle_visibility(true) instead.
76d9df3f 903 */
5ab88243 904function show_event() {
e4d9185e 905 throw new coding_exception('show_event() can not be used any more, please use '.
e1cd93ce 906 'calendar_event->toggle_visibility(true) instead.');
0189bf77 907}
6f3451e5 908
3fed29a7 909/**
6b61c2c4 910 * @deprecated since Moodle 2.2 use core_text::xxxx() instead.
3fed29a7
PS
911 */
912function textlib_get_instance() {
6b61c2c4
FM
913 throw new coding_exception('textlib_get_instance() can not be used any more, please use '.
914 'core_text::functioname() instead.');
3fed29a7
PS
915}
916
ee7084e9 917/**
ee7084e9 918 * @deprecated since 2.4
ee7084e9 919 */
5ab88243 920function get_generic_section_name() {
1ac1d29b 921 throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base');
ee7084e9 922}
99e9f9a6
MG
923
924/**
99e9f9a6 925 * @deprecated since 2.4
99e9f9a6 926 */
5ab88243 927function get_all_sections() {
2149326b 928 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
99e9f9a6 929}
722e6ba9
MG
930
931/**
722e6ba9 932 * @deprecated since 2.4
722e6ba9 933 */
5ab88243 934function add_mod_to_section() {
2149326b 935 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
722e6ba9 936}
d57aa283
MG
937
938/**
d57aa283 939 * @deprecated since 2.4
d57aa283 940 */
5ab88243 941function get_all_mods() {
2149326b 942 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
d57aa283 943}
4ede27b2
MG
944
945/**
4ede27b2 946 * @deprecated since 2.4
4ede27b2 947 */
5ab88243 948function get_course_section() {
2149326b 949 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
4ede27b2 950}
1b2581f4
MG
951
952/**
1b2581f4 953 * @deprecated since 2.4
1b2581f4 954 */
5ab88243 955function format_weeks_get_section_dates() {
2149326b 956 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
1ac1d29b 957 ' use it outside of format_weeks plugin');
1b2581f4 958}
9a36be73
MG
959
960/**
9a36be73 961 * @deprecated since 2.5
9a36be73 962 */
5ab88243 963function get_print_section_cm_text() {
2149326b 964 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
1ac1d29b 965 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
9a36be73
MG
966}
967
968/**
9a36be73 969 * @deprecated since 2.5
9a36be73 970 */
5ab88243 971function print_section_add_menus() {
2149326b 972 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
1ac1d29b 973 'function course_section_add_cm_control()');
9a36be73
MG
974}
975
976/**
5ab88243 977 * @deprecated since 2.5. Please use:
9a36be73
MG
978 * $courserenderer = $PAGE->get_renderer('core', 'course');
979 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
980 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
9a36be73 981 */
5ab88243 982function make_editing_buttons() {
2149326b 983 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
1ac1d29b 984 'lib/deprecatedlib.php on how to replace it');
9a36be73
MG
985}
986
987/**
9a36be73 988 * @deprecated since 2.5
9a36be73 989 */
5ab88243 990function print_section() {
2149326b 991 throw new coding_exception('Function print_section() is removed. Please use course renderer function '.
1ac1d29b 992 'course_section_cm_list() instead.');
9a36be73 993}
00ba185d 994
ff233851 995/**
ff233851 996 * @deprecated since 2.5
ff233851 997 */
5ab88243 998function print_overview() {
2149326b 999 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
ff233851 1000}
a3f66bde
MG
1001
1002/**
a3f66bde 1003 * @deprecated since 2.5
a3f66bde 1004 */
5ab88243 1005function print_recent_activity() {
2149326b 1006 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
1ac1d29b 1007 ' use it outside of block_recent_activity');
a3f66bde 1008}
a347aee3
MN
1009
1010/**
a347aee3 1011 * @deprecated since 2.5
a347aee3 1012 */
5ab88243 1013function delete_course_module() {
2149326b 1014 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
a347aee3 1015}
2c49fb4c
MG
1016
1017/**
2c49fb4c 1018 * @deprecated since 2.5
2c49fb4c 1019 */
5ab88243 1020function update_category_button() {
2149326b 1021 throw new coding_exception('Function update_category_button() is removed. Pages to view '.
1ac1d29b 1022 'and edit courses are now separate and no longer depend on editing mode.');
2c49fb4c 1023}
4e0b6025
MG
1024
1025/**
4e0b6025 1026 * @deprecated since 2.5
4e0b6025 1027 */
5ab88243 1028function make_categories_list() {
2149326b 1029 throw new coding_exception('Global function make_categories_list() is removed. Please use '.
442f12f8 1030 'core_course_category::make_categories_list() and core_course_category::get_parents()');
4e0b6025 1031}
deb65ced
MG
1032
1033/**
deb65ced 1034 * @deprecated since 2.5
deb65ced 1035 */
5ab88243 1036function category_delete_move() {
442f12f8
MG
1037 throw new coding_exception('Function category_delete_move() is removed. Please use ' .
1038 'core_course_category::delete_move() instead.');
deb65ced
MG
1039}
1040
1041/**
deb65ced 1042 * @deprecated since 2.5
deb65ced 1043 */
5ab88243 1044function category_delete_full() {
442f12f8
MG
1045 throw new coding_exception('Function category_delete_full() is removed. Please use ' .
1046 'core_course_category::delete_full() instead.');
deb65ced 1047}
6e1d1ee0
MG
1048
1049/**
6e1d1ee0 1050 * @deprecated since 2.5
6e1d1ee0 1051 */
5ab88243 1052function move_category() {
442f12f8 1053 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.');
6e1d1ee0
MG
1054}
1055
1056/**
6e1d1ee0 1057 * @deprecated since 2.5
6e1d1ee0 1058 */
5ab88243 1059function course_category_hide() {
442f12f8 1060 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.');
6e1d1ee0
MG
1061}
1062
1063/**
6e1d1ee0 1064 * @deprecated since 2.5
6e1d1ee0 1065 */
5ab88243 1066function course_category_show() {
442f12f8 1067 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.');
6e1d1ee0 1068}
2d8a275b
MG
1069
1070/**
442f12f8
MG
1071 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or
1072 * core_course_category::get($catid, MUST_EXIST).
2d8a275b 1073 */
5ab88243 1074function get_course_category() {
442f12f8
MG
1075 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' .
1076 'see phpdocs for more details');
2d8a275b 1077}
9bad61db
MG
1078
1079/**
9bad61db 1080 * @deprecated since 2.5
9bad61db 1081 */
5ab88243 1082function create_course_category() {
442f12f8
MG
1083 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' .
1084 'see phpdocs for more details');
9bad61db 1085}
bc81b006
MG
1086
1087/**
442f12f8 1088 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children()
bc81b006 1089 */
5ab88243 1090function get_all_subcategories() {
442f12f8
MG
1091 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '.
1092 'of core_course_category class. See phpdocs for more details');
bc81b006 1093}
8db5dcb7
MG
1094
1095/**
442f12f8 1096 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children().
8db5dcb7 1097 */
5ab88243 1098function get_child_categories() {
442f12f8
MG
1099 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' .
1100 'phpdocs for more details.');
8db5dcb7 1101}
e1d54562
MG
1102
1103/**
e1d54562 1104 * @deprecated since 2.5
e1d54562 1105 */
5ab88243
MG
1106function get_categories() {
1107 throw new coding_exception('Function get_categories() is removed. Please use ' .
442f12f8 1108 'appropriate functions from class core_course_category');
e1d54562 1109}
a8d683ca
MG
1110
1111/**
a8d683ca 1112* @deprecated since 2.5
a8d683ca 1113*/
5ab88243 1114function print_course_search() {
2149326b 1115 throw new coding_exception('Function print_course_search() is removed, please use course renderer');
a8d683ca 1116}
09ae7ee0
MG
1117
1118/**
09ae7ee0
MG
1119 * @deprecated since 2.5
1120 */
1121function print_my_moodle() {
5ab88243
MG
1122 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
1123 'function frontpage_my_courses()');
09ae7ee0
MG
1124}
1125
1126/**
09ae7ee0
MG
1127 * @deprecated since 2.5
1128 */
5ab88243 1129function print_remote_course() {
2149326b 1130 throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
09ae7ee0
MG
1131}
1132
1133/**
09ae7ee0
MG
1134 * @deprecated since 2.5
1135 */
5ab88243 1136function print_remote_host() {
2149326b 1137 throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
09ae7ee0
MG
1138}
1139
1140/**
09ae7ee0 1141 * @deprecated since 2.5
09ae7ee0 1142 */
5ab88243 1143function print_whole_category_list() {
2149326b 1144 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
09ae7ee0
MG
1145}
1146
1147/**
09ae7ee0 1148 * @deprecated since 2.5
09ae7ee0 1149 */
5ab88243 1150function print_category_info() {
2149326b 1151 throw new coding_exception('Function print_category_info() is removed, please use course renderer');
09ae7ee0
MG
1152}
1153
1154/**
09ae7ee0 1155 * @deprecated since 2.5
09ae7ee0 1156 */
5ab88243
MG
1157function get_course_category_tree() {
1158 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
442f12f8 1159 'renderer or core_course_category class, see function phpdocs for more info');
09ae7ee0
MG
1160}
1161
1162/**
09ae7ee0 1163 * @deprecated since 2.5
09ae7ee0 1164 */
5ab88243 1165function print_courses() {
2149326b 1166 throw new coding_exception('Function print_courses() is removed, please use course renderer');
09ae7ee0
MG
1167}
1168
1169/**
09ae7ee0 1170 * @deprecated since 2.5
09ae7ee0 1171 */
5ab88243 1172function print_course() {
2149326b 1173 throw new coding_exception('Function print_course() is removed, please use course renderer');
09ae7ee0
MG
1174}
1175
1176/**
09ae7ee0 1177 * @deprecated since 2.5
09ae7ee0 1178 */
5ab88243 1179function get_category_courses_array() {
442f12f8
MG
1180 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' .
1181 'core_course_category class');
09ae7ee0
MG
1182}
1183
1184/**
09ae7ee0 1185 * @deprecated since 2.5
09ae7ee0 1186 */
5ab88243 1187function get_category_courses_array_recursively() {
442f12f8
MG
1188 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' .
1189 'methods of core_course_category class', DEBUG_DEVELOPER);
09ae7ee0
MG
1190}
1191
7ac18cf9 1192/**
7ac18cf9 1193 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
7ac18cf9 1194 */
5ab88243 1195function blog_get_context_url() {
2149326b 1196 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
7ac18cf9
AA
1197}
1198
09ae7ee0 1199/**
09ae7ee0 1200 * @deprecated since 2.5
09ae7ee0 1201 */
5ab88243 1202function get_courses_wmanagers() {
442f12f8
MG
1203 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' .
1204 'core_course_category::get_courses()');
09ae7ee0 1205}
c269b9d1
MG
1206
1207/**
c269b9d1 1208 * @deprecated since 2.5
c269b9d1 1209 */
5ab88243 1210function convert_tree_to_html() {
2149326b 1211 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
c269b9d1
MG
1212}
1213
1214/**
c269b9d1 1215 * @deprecated since 2.5
c269b9d1 1216 */
5ab88243 1217function convert_tabrows_to_tree() {
2149326b 1218 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
c269b9d1 1219}
9052fc44 1220
8ef3a222 1221/**
8ef3a222 1222 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
8ef3a222
DP
1223 */
1224function can_use_rotated_text() {
2149326b 1225 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.');
8ef3a222 1226}
61a0299a 1227
ce2b2150 1228/**
ce2b2150 1229 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
ce2b2150 1230 */
5ab88243 1231function get_context_instance_by_id() {
f9b7be4f 1232 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
ce2b2150 1233}
85b2e46f 1234
492ba9de
AA
1235/**
1236 * Returns system context or null if can not be created yet.
1237 *
1238 * @see context_system::instance()
01546175 1239 * @deprecated since 2.2
492ba9de
AA
1240 * @param bool $cache use caching
1241 * @return context system context (null if context table not created yet)
1242 */
1243function get_system_context($cache = true) {
1244 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
1245 return context_system::instance(0, IGNORE_MISSING, $cache);
1246}
8e8891b7
FM
1247
1248/**
8e8891b7 1249 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
8e8891b7 1250 */
5ab88243 1251function get_parent_contexts() {
2149326b 1252 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
8e8891b7 1253}
766fd0d9
AD
1254
1255/**
7f5b51c4 1256 * @deprecated since Moodle 2.2
766fd0d9 1257 */
5ab88243 1258function get_parent_contextid() {
2149326b 1259 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
766fd0d9 1260}
f9aa8016
FM
1261
1262/**
f9aa8016 1263 * @deprecated since 2.2
f9aa8016 1264 */
5ab88243 1265function get_child_contexts() {
2149326b 1266 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
f9aa8016 1267}
9fdbf620
FM
1268
1269/**
9fdbf620 1270 * @deprecated since 2.2
9fdbf620 1271 */
5ab88243 1272function create_contexts() {
2149326b 1273 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
9fdbf620 1274}
84378a57
FM
1275
1276/**
84378a57 1277 * @deprecated since 2.2
84378a57
FM
1278 */
1279function cleanup_contexts() {
2149326b 1280 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.');
84378a57 1281}
79f6b384
FM
1282
1283/**
79f6b384 1284 * @deprecated since 2.2
79f6b384 1285 */
5ab88243 1286function build_context_path() {
2149326b 1287 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
79f6b384 1288}
cc4de415
FM
1289
1290/**
cc4de415 1291 * @deprecated since 2.2
cc4de415 1292 */
5ab88243 1293function rebuild_contexts() {
2149326b 1294 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
cc4de415 1295}
8f7d3d12
RT
1296
1297/**
8f7d3d12 1298 * @deprecated since Moodle 2.2
8f7d3d12 1299 */
5ab88243 1300function preload_course_contexts() {
2149326b 1301 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
8f7d3d12 1302}
2c5b0eb7
RT
1303
1304/**
2c5b0eb7 1305 * @deprecated since Moodle 2.2
2c5b0eb7 1306 */
5ab88243 1307function context_moved() {
2149326b 1308 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
c5dcd25d
AA
1309}
1310
a439b2f9 1311/**
a439b2f9 1312 * @deprecated since 2.2
a439b2f9 1313 */
5ab88243 1314function fetch_context_capabilities() {
2149326b 1315 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
a439b2f9
FM
1316}
1317
c5dcd25d 1318/**
c5dcd25d 1319 * @deprecated since 2.2
c5dcd25d 1320 */
5ab88243 1321function context_instance_preload() {
2149326b 1322 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
c5dcd25d 1323}
b4482dfe
AG
1324
1325/**
b4482dfe 1326 * @deprecated since 2.2
b4482dfe 1327 */
5ab88243 1328function get_contextlevel_name() {
2149326b 1329 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
b4482dfe 1330}
329846f1
AG
1331
1332/**
329846f1 1333 * @deprecated since 2.2
329846f1 1334 */
5ab88243 1335function print_context_name() {
2149326b 1336 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
329846f1 1337}
1de02d62
AG
1338
1339/**
1de02d62 1340 * @deprecated since 2.2, use $context->mark_dirty() instead
1de02d62 1341 */
5ab88243 1342function mark_context_dirty() {
2149326b 1343 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
1de02d62 1344}
c592eea2
RT
1345
1346/**
c592eea2 1347 * @deprecated since Moodle 2.2
c592eea2 1348 */
5ab88243
MG
1349function delete_context() {
1350 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
1351 'or $context->delete_content() instead.');
c592eea2 1352}
6c89d4e1
MN
1353
1354/**
6c89d4e1 1355 * @deprecated since 2.2
6c89d4e1 1356 */
5ab88243 1357function get_context_url() {
2149326b 1358 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
6c89d4e1
MN
1359}
1360
dd33f4af 1361/**
dd33f4af 1362 * @deprecated since 2.2
dd33f4af 1363 */
5ab88243 1364function get_course_context() {
2149326b 1365 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
dd33f4af 1366}
6acc54b3
AA
1367
1368/**
6acc54b3 1369 * @deprecated since 2.2
6acc54b3 1370 */
5ab88243 1371function get_user_courses_bycap() {
2149326b 1372 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
6acc54b3 1373}
ae38dcb1
RT
1374
1375/**
ae38dcb1 1376 * @deprecated since Moodle 2.2
ae38dcb1 1377 */
5ab88243 1378function get_role_context_caps() {
2149326b 1379 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
ae38dcb1 1380}
b123a543
FM
1381
1382/**
b123a543 1383 * @deprecated since 2.2
b123a543 1384 */
5ab88243 1385function get_courseid_from_context() {
2149326b 1386 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
6a30b48d 1387}
2e4c0c91
FM
1388
1389/**
2e4c0c91 1390 * @deprecated since 2.2
2e4c0c91 1391 */
5ab88243 1392function context_instance_preload_sql() {
2149326b 1393 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
b123a543 1394}
b6452844
MN
1395
1396/**
b6452844 1397 * @deprecated since 2.2
b6452844 1398 */
5ab88243 1399function get_related_contexts_string() {
2149326b 1400 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
b6452844 1401}
0142523d 1402
d0cac8b5 1403/**
d0cac8b5 1404 * @deprecated since 2.6
d0cac8b5 1405 */
5ab88243 1406function get_plugin_list_with_file() {
2149326b 1407 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
d0cac8b5 1408}
c3d2fbf9
SH
1409
1410/**
c3d2fbf9 1411 * @deprecated since 2.6
c3d2fbf9 1412 */
5ab88243 1413function check_browser_operating_system() {
2149326b 1414 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1415}
1416
1417/**
c3d2fbf9 1418 * @deprecated since 2.6
c3d2fbf9 1419 */
5ab88243 1420function check_browser_version() {
2149326b 1421 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1422}
1423
1424/**
c3d2fbf9 1425 * @deprecated since 2.6
c3d2fbf9
SH
1426 */
1427function get_device_type() {
2149326b 1428 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1429}
1430
1431/**
c3d2fbf9 1432 * @deprecated since 2.6
c3d2fbf9 1433 */
5ab88243 1434function get_device_type_list() {
2149326b 1435 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1436}
1437
1438/**
c3d2fbf9 1439 * @deprecated since 2.6
c3d2fbf9 1440 */
5ab88243 1441function get_selected_theme_for_device_type() {
2149326b 1442 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1443}
1444
1445/**
c3d2fbf9 1446 * @deprecated since 2.6
c3d2fbf9 1447 */
5ab88243 1448function get_device_cfg_var_name() {
2149326b 1449 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1450}
1451
1452/**
c3d2fbf9 1453 * @deprecated since 2.6
c3d2fbf9 1454 */
5ab88243 1455function set_user_device_type() {
2149326b 1456 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1457}
1458
1459/**
c3d2fbf9 1460 * @deprecated since 2.6
c3d2fbf9
SH
1461 */
1462function get_user_device_type() {
2149326b 1463 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1464}
1465
1466/**
c3d2fbf9 1467 * @deprecated since 2.6
c3d2fbf9
SH
1468 */
1469function get_browser_version_classes() {
2149326b 1470 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.');
2b503e40
RT
1471}
1472
1473/**
2b503e40 1474 * @deprecated since Moodle 2.6
2b503e40
RT
1475 */
1476function generate_email_supportuser() {
2149326b 1477 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
853e506a
Y
1478}
1479
1480/**
853e506a 1481 * @deprecated since Moodle 2.6
853e506a 1482 */
5ab88243 1483function badges_get_issued_badge_info() {
2149326b 1484 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
853e506a 1485}
3d27180e
DW
1486
1487/**
3d27180e 1488 * @deprecated since 2.6
3d27180e
DW
1489 */
1490function can_use_html_editor() {
2149326b 1491 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.');
3d27180e 1492}
52dc1de7
AA
1493
1494
1495/**
26e4b0ca 1496 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
52dc1de7 1497 */
5ab88243 1498function count_login_failures() {
26e4b0ca 1499 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
52dc1de7 1500}
de878a38 1501
6538153b 1502/**
44ab05b3 1503 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
6538153b 1504 */
5ab88243 1505function ajaxenabled() {
44ab05b3 1506 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
6538153b 1507}
8d1f33e1 1508
1509/**
e56e8e3a 1510 * @deprecated Since Moodle 2.7 MDL-44070
8d1f33e1 1511 */
5ab88243 1512function coursemodule_visible_for_user() {
e56e8e3a
AA
1513 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
1514 please use \core_availability\info_module::is_user_visible()');
8d1f33e1 1515}
80f98467
MG
1516
1517/**
58b5b04d 1518 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
80f98467 1519 */
5ab88243
MG
1520function enrol_cohort_get_cohorts() {
1521 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
1ac1d29b 1522 'cohort_get_available_cohorts() instead');
80f98467
MG
1523}
1524
1525/**
80f98467 1526 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
80f98467 1527 */
5ab88243 1528function enrol_cohort_can_view_cohort() {
2149326b 1529 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
80f98467
MG
1530}
1531
1532/**
80f98467 1533 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
80f98467 1534 */
5ab88243 1535function cohort_get_visible_list() {
2149326b 1536 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
1ac1d29b 1537 "that correctly checks capabilities.');
80f98467 1538}
58b5b04d
MG
1539
1540/**
58b5b04d 1541 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
58b5b04d 1542 */
5ab88243 1543function enrol_cohort_enrol_all_users() {
2149326b 1544 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
58b5b04d
MG
1545}
1546
1547/**
58b5b04d 1548 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
58b5b04d 1549 */
5ab88243 1550function enrol_cohort_search_cohorts() {
2149326b 1551 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
58b5b04d 1552}
bdc83277 1553
8322ed4a
AA
1554/* === Apis deprecated in since Moodle 2.9 === */
1555
bdc83277 1556/**
bdc83277 1557 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
bdc83277 1558 */
5ab88243 1559function message_current_user_is_involved() {
be43ad0d 1560 throw new coding_exception('message_current_user_is_involved() can not be used any more.');
bdc83277 1561}
b19cc4ef
AA
1562
1563/**
b19cc4ef 1564 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
b19cc4ef 1565 */
5ab88243 1566function profile_display_badges() {
a77e0611 1567 throw new coding_exception('profile_display_badges() can not be used any more.');
b19cc4ef 1568}
efd32edb
AG
1569
1570/**
efd32edb 1571 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
efd32edb 1572 */
5ab88243 1573function useredit_shared_definition_preferences() {
ab2d9b34 1574 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
efd32edb 1575}
8322ed4a
AA
1576
1577
1578/**
8322ed4a 1579 * @deprecated since Moodle 2.9
8322ed4a 1580 */
5ab88243 1581function calendar_normalize_tz() {
678b315f 1582 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
8322ed4a
AA
1583}
1584
1585/**
8322ed4a 1586 * @deprecated since Moodle 2.9
8322ed4a 1587 */
5ab88243 1588function get_user_timezone_offset() {
a77e0611
SL
1589 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1590
8322ed4a
AA
1591}
1592
1593/**
8322ed4a 1594 * @deprecated since Moodle 2.9
8322ed4a 1595 */
5ab88243 1596function get_timezone_offset() {
a77e0611 1597 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
8322ed4a
AA
1598}
1599
1600/**
8322ed4a 1601 * @deprecated since Moodle 2.9
8322ed4a
AA
1602 */
1603function get_list_of_timezones() {
a77e0611 1604 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead');
8322ed4a
AA
1605}
1606
1607/**
8322ed4a 1608 * @deprecated since Moodle 2.9
8322ed4a 1609 */
5ab88243 1610function update_timezone_records() {
a77e0611 1611 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
8322ed4a
AA
1612}
1613
1614/**
8322ed4a 1615 * @deprecated since Moodle 2.9
8322ed4a 1616 */
5ab88243 1617function calculate_user_dst_table() {
a77e0611 1618 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
8322ed4a
AA
1619}
1620
1621/**
8322ed4a 1622 * @deprecated since Moodle 2.9
8322ed4a 1623 */
5ab88243 1624function dst_changes_for_year() {
a77e0611 1625 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
8322ed4a
AA
1626}
1627
1628/**
8322ed4a 1629 * @deprecated since Moodle 2.9
8322ed4a 1630 */
5ab88243 1631function get_timezone_record() {
a77e0611 1632 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
8322ed4a
AA
1633}
1634
2149326b 1635/* === Apis deprecated since Moodle 3.0 === */
f4864c1c 1636/**
f4864c1c 1637 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
f4864c1c 1638 */
5ab88243 1639function get_referer() {
e4f4d341 1640 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
988592c5 1641}
25d9ae9a 1642
34c6ec18 1643/**
34c6ec18
AN
1644 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
1645 */
1646function is_web_crawler() {
e4f4d341 1647 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.');
34c6ec18 1648}
ebdfde76 1649
0628925b 1650/**
0628925b 1651 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
0628925b
DP
1652 */
1653function completion_cron() {
e4f4d341 1654 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.');
0628925b 1655}
9e66dff0 1656
0d1e5456 1657/**
0d1e5456 1658 * @deprecated since 3.0
0d1e5456 1659 */
5ab88243
MG
1660function coursetag_get_tags() {
1661 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
1662 'Userid is no longer used for tagging courses.');
0d1e5456
MG
1663}
1664
1665/**
0d1e5456 1666 * @deprecated since 3.0
0d1e5456 1667 */
5ab88243
MG
1668function coursetag_get_all_tags() {
1669 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
1670 'longer used for tagging courses.');
0d1e5456
MG
1671}
1672
1673/**
0d1e5456 1674 * @deprecated since 3.0
0d1e5456
MG
1675 */
1676function coursetag_get_jscript() {
e4f4d341 1677 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.');
0d1e5456
MG
1678}
1679
1680/**
0d1e5456 1681 * @deprecated since 3.0
0d1e5456 1682 */
5ab88243 1683function coursetag_get_jscript_links() {
e4f4d341 1684 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
0d1e5456
MG
1685}
1686
1687/**
5ab88243
MG
1688 * @deprecated since 3.0
1689 */
1690function coursetag_get_records() {
1691 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
1692 'Userid is no longer used for tagging courses.');
c026a28d
MG
1693}
1694
1695/**
5ab88243 1696 * @deprecated since 3.0
c026a28d 1697 */
5ab88243
MG
1698function coursetag_store_keywords() {
1699 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
1700 'Userid is no longer used for tagging courses.');
1701}
c026a28d 1702
5ab88243
MG
1703/**
1704 * @deprecated since 3.0
1705 */
1706function coursetag_delete_keyword() {
1707 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
1708 'Userid is no longer used for tagging courses.');
1709}
c026a28d 1710
5ab88243
MG
1711/**
1712 * @deprecated since 3.0
1713 */
1714function coursetag_get_tagged_courses() {
1715 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
1716 'Userid is no longer used for tagging courses.');
c026a28d
MG
1717}
1718
1719/**
5ab88243 1720 * @deprecated since 3.0
c026a28d 1721 */
5ab88243
MG
1722function coursetag_delete_course_tags() {
1723 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
1724 'Use core_tag_tag::remove_all_item_tags().');
1725}
c026a28d 1726
5ab88243
MG
1727/**
1728 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1729 */
1730function tag_type_set() {
1731 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
1732 'core_tag_tag::get($tagid)->update().');
1733}
c026a28d 1734
5ab88243
MG
1735/**
1736 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1737 */
1738function tag_description_set() {
1739 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
1740 'core_tag_tag::get($tagid)->update().');
1741}
c026a28d 1742
5ab88243
MG
1743/**
1744 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1745 */
1746function tag_get_tags() {
1747 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
1748 'core_tag_tag::get_item_tags().');
1749}
c026a28d 1750
5ab88243
MG
1751/**
1752 * @deprecated since 3.1
1753 */
1754function tag_get_tags_array() {
1755 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
1756 'core_tag_tag::get_item_tags_array().');
1757}
c026a28d 1758
5ab88243
MG
1759/**
1760 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
1761 */
1762function tag_get_tags_csv() {
1763 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
1764 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1765}
c026a28d 1766
5ab88243
MG
1767/**
1768 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1769 */
1770function tag_get_tags_ids() {
1771 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
1772 'core_tag_tag::get_item_tags() or similar methods.');
1773}
c026a28d 1774
5ab88243
MG
1775/**
1776 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
1777 */
1778function tag_get_id() {
1779 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
1780 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
1781}
c026a28d 1782
5ab88243
MG
1783/**
1784 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1785 */
1786function tag_rename() {
1787 throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
1788 'core_tag_tag::get($tagid)->update()');
1789}
c026a28d 1790
5ab88243
MG
1791/**
1792 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
1793 */
1794function tag_delete_instance() {
1795 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
1796 'core_tag_tag::remove_item_tag()');
1797}
c026a28d 1798
5ab88243
MG
1799/**
1800 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
1801 */
1802function tag_find_records() {
1803 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
1804 'core_tag_tag::get_by_name()->get_tagged_items()');
c026a28d
MG
1805}
1806
1807/**
c026a28d 1808 * @deprecated since 3.1
c026a28d 1809 */
5ab88243
MG
1810function tag_add() {
1811 throw new coding_exception('tag_add() can not be used anymore. You can use ' .
1812 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
1813 'created automatically when assigned to items');
1814}
c026a28d 1815
5ab88243
MG
1816/**
1817 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
1818 */
1819function tag_assign() {
1820 throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
1821 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
1822 'ordering should not be set manually');
1823}
c026a28d 1824
5ab88243
MG
1825/**
1826 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
1827 */
1828function tag_record_count() {
1829 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
1830 'core_tag_tag::get($tagid)->count_tagged_items().');
1831}
c026a28d 1832
5ab88243
MG
1833/**
1834 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
1835 */
1836function tag_record_tagged_with() {
1837 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
1838 'core_tag_tag::get($tagid)->is_item_tagged_with().');
1839}
c026a28d 1840
5ab88243
MG
1841/**
1842 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
1843 */
1844function tag_set_flag() {
1845 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
1846 'core_tag_tag::get($tagid)->flag()');
c026a28d
MG
1847}
1848
1849/**
5ab88243 1850 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
c026a28d 1851 */
5ab88243
MG
1852function tag_unset_flag() {
1853 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
1854 'core_tag_tag::get($tagid)->reset_flag()');
c026a28d
MG
1855}
1856
1857/**
c026a28d 1858 * @deprecated since 3.1
c026a28d 1859 */
5ab88243
MG
1860function tag_print_cloud() {
1861 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
1862 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
1863 'template core_tag/tagcloud.');
1864}
c026a28d 1865
5ab88243
MG
1866/**
1867 * @deprecated since 3.0
1868 */
1869function tag_autocomplete() {
1870 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
1871 'element "tags" does proper autocomplete.');
c026a28d
MG
1872}
1873
1874/**
c026a28d 1875 * @deprecated since 3.1
c026a28d 1876 */
5ab88243
MG
1877function tag_print_description_box() {
1878 throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
1879 'See core_tag_renderer for similar code');
c026a28d
MG
1880}
1881
1882/**
c026a28d
MG
1883 * @deprecated since 3.1
1884 */
5ab88243
MG
1885function tag_print_management_box() {
1886 throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
1887 'See core_tag_renderer for similar code');
1888}
1889
c026a28d 1890/**
c026a28d
MG
1891 * @deprecated since 3.1
1892 */
5ab88243
MG
1893function tag_print_search_box() {
1894 throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
1895 'See core_tag_renderer for similar code');
1896}
1897
c026a28d 1898/**
c026a28d
MG
1899 * @deprecated since 3.1
1900 */
5ab88243
MG
1901function tag_print_search_results() {
1902 throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
1903 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
1904}
1905
c026a28d 1906/**
c026a28d
MG
1907 * @deprecated since 3.1
1908 */
5ab88243
MG
1909function tag_print_tagged_users_table() {
1910 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
1911 'See core_user_renderer for similar code');
1912}
c026a28d
MG
1913
1914/**
c026a28d
MG
1915 * @deprecated since 3.1
1916 */
5ab88243
MG
1917function tag_print_user_box() {
1918 throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
1919 'See core_user_renderer for similar code');
1920}
1921
c026a28d 1922/**
c026a28d
MG
1923 * @deprecated since 3.1
1924 */
5ab88243
MG
1925function tag_print_user_list() {
1926 throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
1927 'See core_user_renderer for similar code');
1928}
c026a28d
MG
1929
1930/**
c026a28d
MG
1931 * @deprecated since 3.1
1932 */
5ab88243
MG
1933function tag_display_name() {
1934 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
1935 'core_tag_tag::make_display_name().');
1936
1937}
1938
c026a28d 1939/**
c026a28d
MG
1940 * @deprecated since 3.1
1941 */
5ab88243
MG
1942function tag_normalize() {
1943 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
1944 'core_tag_tag::normalize().');
1945}
1946
c026a28d 1947/**
c026a28d
MG
1948 * @deprecated since 3.1
1949 */
5ab88243
MG
1950function tag_get_related_tags_csv() {
1951 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
1952 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1953}
c026a28d
MG
1954
1955/**
c026a28d 1956 * @deprecated since 3.1
5ab88243
MG
1957 */
1958function tag_set() {
1959 throw new coding_exception('tag_set() can not be used anymore. Please use ' .
1960 'core_tag_tag::set_item_tags().');
c026a28d
MG
1961}
1962
1963/**
c026a28d 1964 * @deprecated since 3.1
5ab88243
MG
1965 */
1966function tag_set_add() {
1967 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
1968 'core_tag_tag::add_item_tag().');
c026a28d
MG
1969}
1970
1971/**
c026a28d 1972 * @deprecated since 3.1
c026a28d 1973 */
5ab88243
MG
1974function tag_set_delete() {
1975 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
1976 'core_tag_tag::remove_item_tag().');
c026a28d
MG
1977}
1978
1979/**
c026a28d 1980 * @deprecated since 3.1
c026a28d 1981 */
5ab88243
MG
1982function tag_get() {
1983 throw new coding_exception('tag_get() can not be used anymore. Please use ' .
1984 'core_tag_tag::get() or core_tag_tag::get_by_name().');
c026a28d
MG
1985}
1986
1987/**
c026a28d 1988 * @deprecated since 3.1
5ab88243
MG
1989 */
1990function tag_get_related_tags() {
1991 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
1992 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
1993 'core_tag_tag::get_manual_related_tags().');
c026a28d
MG
1994}
1995
1996/**
c026a28d 1997 * @deprecated since 3.1
c026a28d 1998 */
5ab88243
MG
1999function tag_delete() {
2000 throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
2001 'core_tag_tag::delete_tags().');
c026a28d
MG
2002}
2003
2004/**
c026a28d 2005 * @deprecated since 3.1
c026a28d 2006 */
5ab88243
MG
2007function tag_delete_instances() {
2008 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
2009 'core_tag_tag::delete_instances().');
c026a28d
MG
2010}
2011
2012/**
c026a28d
MG
2013 * @deprecated since 3.1
2014 */
2015function tag_cleanup() {
5ab88243
MG
2016 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
2017 '\core\task\tag_cron_task::cleanup().');
c026a28d
MG
2018}
2019
2020/**
c026a28d 2021 * @deprecated since 3.1
c026a28d 2022 */
5ab88243
MG
2023function tag_bulk_delete_instances() {
2024 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
2025 '\core\task\tag_cron_task::bulk_delete_instances().');
c026a28d 2026
c026a28d
MG
2027}
2028
2029/**
c026a28d 2030 * @deprecated since 3.1
c026a28d 2031 */
5ab88243
MG
2032function tag_compute_correlations() {
2033 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
2034 'use \core\task\tag_cron_task::compute_correlations().');
c026a28d
MG
2035}
2036
2037/**
c026a28d 2038 * @deprecated since 3.1
c026a28d 2039 */
5ab88243
MG
2040function tag_process_computed_correlation() {
2041 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
2042 'use \core\task\tag_cron_task::process_computed_correlation().');
c026a28d
MG
2043}
2044
2045/**
c026a28d
MG
2046 * @deprecated since 3.1
2047 */
2048function tag_cron() {
5ab88243
MG
2049 throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
2050 'use \core\task\tag_cron_task::execute().');
c026a28d
MG
2051}
2052
2053/**
c026a28d 2054 * @deprecated since 3.1
5ab88243
MG
2055 */
2056function tag_find_tags() {
2057 throw new coding_exception('tag_find_tags() can not be used anymore.');
c026a28d
MG
2058}
2059
2060/**
c026a28d 2061 * @deprecated since 3.1
c026a28d 2062 */
5ab88243
MG
2063function tag_get_name() {
2064 throw new coding_exception('tag_get_name() can not be used anymore.');
c026a28d
MG
2065}
2066
2067/**
c026a28d 2068 * @deprecated since 3.1
c026a28d 2069 */
5ab88243
MG
2070function tag_get_correlated() {
2071 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
2072 'use core_tag_tag::get_correlated_tags().');
2073
c026a28d
MG
2074}
2075
2076/**
c026a28d 2077 * @deprecated since 3.1
c026a28d 2078 */
5ab88243
MG
2079function tag_cloud_sort() {
2080 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
2081 'be found in core_tag_collection::cloud_sort().');
c026a28d 2082}
32f8bbd8
DM
2083
2084/**
32f8bbd8 2085 * @deprecated since Moodle 3.1
32f8bbd8 2086 */
b41e1d7c
AG
2087function events_load_def() {
2088 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8 2089
32f8bbd8
DM
2090}
2091
2092/**
32f8bbd8 2093 * @deprecated since Moodle 3.1
32f8bbd8 2094 */
b41e1d7c
AG
2095function events_queue_handler() {
2096 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8
DM
2097}
2098
2099/**
32f8bbd8 2100 * @deprecated since Moodle 3.1
32f8bbd8 2101 */
b41e1d7c
AG
2102function events_dispatch() {
2103 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8
DM
2104}
2105
2106/**
32f8bbd8 2107 * @deprecated since Moodle 3.1
32f8bbd8 2108 */
b41e1d7c
AG
2109function events_process_queued_handler() {
2110 throw new coding_exception(
2111 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
2112 );
32f8bbd8
DM
2113}
2114
2115/**
32f8bbd8 2116 * @deprecated since Moodle 3.1
32f8bbd8 2117 */
b41e1d7c
AG
2118function events_update_definition() {
2119 throw new coding_exception(
2120 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
2121 );
32f8bbd8
DM
2122}
2123
2124/**
32f8bbd8 2125 * @deprecated since Moodle 3.1
32f8bbd8 2126 */
b41e1d7c
AG
2127function events_cron() {
2128 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8
DM
2129}
2130
2131/**
32f8bbd8 2132 * @deprecated since Moodle 3.1
b41e1d7c
AG
2133 */
2134function events_trigger_legacy() {
2135 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8
DM
2136}
2137
2138/**
32f8bbd8 2139 * @deprecated since Moodle 3.1
32f8bbd8 2140 */
b41e1d7c
AG
2141function events_is_registered() {
2142 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8
DM
2143}
2144
2145/**
32f8bbd8 2146 * @deprecated since Moodle 3.1
32f8bbd8 2147 */
b41e1d7c
AG
2148function events_pending_count() {
2149 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
32f8bbd8 2150}
375223c6
RK
2151
2152/**
375223c6 2153 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
375223c6 2154 */
5ab88243
MG
2155function clam_message_admins() {
2156 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
2157 'message_admins() method of \antivirus_clamav\scanner class.');
375223c6
RK
2158}
2159
2160/**
375223c6 2161 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
375223c6 2162 */
5ab88243
MG
2163function get_clam_error_code() {
2164 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
2165 'get_clam_error_code() method of \antivirus_clamav\scanner class.');
375223c6 2166}
f59f89b4
MG
2167
2168/**
f59f89b4 2169 * @deprecated since 3.1
f59f89b4 2170 */
5ab88243
MG
2171function course_get_cm_rename_action() {
2172 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
2173 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
f59f89b4 2174
f59f89b4 2175}
4a166bfd 2176
5ab88243 2177/**
322f3141 2178 * @deprecated since Moodle 3.1
322f3141 2179 */
5ab88243
MG
2180function course_scale_used() {
2181 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
2182 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
322f3141
MG
2183}
2184
2185/**
322f3141 2186 * @deprecated since Moodle 3.1
322f3141 2187 */
5ab88243
MG
2188function site_scale_used() {
2189 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
2190 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
322f3141 2191}
11c16f5f
DW
2192
2193/**
437ffc9f 2194 * @deprecated since Moodle 3.1. Use external_api::external_function_info().
11c16f5f 2195 */
5ab88243 2196function external_function_info() {
437ffc9f 2197 throw new coding_exception('external_function_info() can not be used any'.
2198 'more. Please use external_api::external_function_info() instead.');
11c16f5f
DW
2199}
2200
f6f0ba2d 2201/**
216b8947 2202 * @deprecated since Moodle 3.2
f6f0ba2d 2203 * @see csv_import_reader::load_csv_content()
f6f0ba2d 2204 */
216b8947
MG
2205function get_records_csv() {
2206 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' .
2207 'lib/csvlib.class.php csv_import_reader() instead.');
f6f0ba2d
AG
2208}
2209
2210/**
216b8947 2211 * @deprecated since Moodle 3.2
f6f0ba2d 2212 * @see download_as_dataformat (lib/dataformatlib.php)
f6f0ba2d 2213 */
216b8947
MG
2214function put_records_csv() {
2215 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' .
2216 'lib/dataformatlib.php download_as_dataformat() instead.');
f6f0ba2d 2217}
d52ebf11
DP
2218
2219/**
d52ebf11 2220 * @deprecated since Moodle 3.2
216b8947
MG
2221 */
2222function css_is_colour() {
2223 throw new coding_exception('css_is_colour() can not be used anymore.');
d52ebf11
DP
2224}
2225
2226/**
d52ebf11 2227 * @deprecated since Moodle 3.2
d52ebf11 2228 */
216b8947
MG
2229function css_is_width() {
2230 throw new coding_exception('css_is_width() can not be used anymore.');
d52ebf11
DP
2231}
2232
2233/**
d52ebf11 2234 * @deprecated since Moodle 3.2
d52ebf11 2235 */
216b8947
MG
2236function css_sort_by_count() {
2237 throw new coding_exception('css_sort_by_count() can not be used anymore.');
d52ebf11
DP
2238}
2239
2240/**
d52ebf11 2241 * @deprecated since Moodle 3.2
216b8947
MG
2242 */
2243function message_get_course_contexts() {
2244 throw new coding_exception('message_get_course_contexts() can not be used anymore.');
d52ebf11 2245}
5b0769db
MN
2246
2247/**
5b0769db 2248 * @deprecated since Moodle 3.2
5b0769db 2249 */
216b8947
MG
2250function message_remove_url_params() {
2251 throw new coding_exception('message_remove_url_params() can not be used anymore.');
5b0769db
MN
2252}
2253
2254/**
5b0769db 2255 * @deprecated since Moodle 3.2
5b0769db 2256 */
216b8947
MG
2257function message_count_messages() {
2258 throw new coding_exception('message_count_messages() can not be used anymore.');
5b0769db
MN
2259}
2260
2261/**
5b0769db 2262 * @deprecated since Moodle 3.2
5b0769db 2263 */
216b8947
MG
2264function message_count_blocked_users() {
2265 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' .
2266 '\core_message\api::count_blocked_users() instead.');
5b0769db
MN
2267}
2268
2269/**
5b0769db 2270 * @deprecated since Moodle 3.2
5b0769db 2271 */
216b8947
MG
2272function message_contact_link() {
2273 throw new coding_exception('message_contact_link() can not be used anymore.');
5b0769db
MN
2274}
2275
2276/**
5b0769db 2277 * @deprecated since Moodle 3.2
5b0769db 2278 */
216b8947
MG
2279function message_get_recent_notifications() {
2280 throw new coding_exception('message_get_recent_notifications() can not be used anymore.');
5b0769db
MN
2281}
2282
2283/**
5b0769db 2284 * @deprecated since Moodle 3.2
5b0769db 2285 */
216b8947
MG
2286function message_history_link() {
2287 throw new coding_exception('message_history_link() can not be used anymore.');
5b0769db
MN
2288}
2289
2290/**
5b0769db 2291 * @deprecated since Moodle 3.2
216b8947
MG
2292 */
2293function message_search() {
2294 throw new coding_exception('message_search() can not be used anymore.');
5b0769db
MN
2295}
2296
2297/**
5b0769db 2298 * @deprecated since Moodle 3.2
5b0769db 2299 */
216b8947
MG
2300function message_shorten_message() {
2301 throw new coding_exception('message_shorten_message() can not be used anymore.');
5b0769db
MN
2302}
2303
2304/**
5b0769db 2305 * @deprecated since Moodle 3.2
216b8947
MG
2306 */
2307function message_get_fragment() {
2308 throw new coding_exception('message_get_fragment() can not be used anymore.');
5b0769db
MN
2309}
2310
2311/**
5b0769db 2312 * @deprecated since Moodle 3.2
5b0769db 2313 */
216b8947
MG
2314function message_get_history() {
2315 throw new coding_exception('message_get_history() can not be used anymore.');
5b0769db
MN
2316}
2317
2318/**
5b0769db 2319 * @deprecated since Moodle 3.2
5b0769db 2320 */
216b8947
MG
2321function message_get_contact_add_remove_link() {
2322 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.');
5b0769db
MN
2323}
2324
2325/**
5b0769db 2326 * @deprecated since Moodle 3.2
216b8947
MG
2327 */
2328function message_get_contact_block_link() {
2329 throw new coding_exception('message_get_contact_block_link() can not be used anymore.');
5b0769db
MN
2330}
2331
2332/**
5b0769db 2333 * @deprecated since Moodle 3.2
216b8947
MG
2334 */
2335function message_mark_messages_read() {
2336 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' .
2337 '\core_message\api::mark_all_messages_as_read() instead.');
5b0769db
MN
2338}
2339
2340/**
5b0769db 2341 * @deprecated since Moodle 3.2
5b0769db 2342 */
216b8947
MG
2343function message_page_type_list() {
2344 throw new coding_exception('message_page_type_list() can not be used anymore.');
5b0769db
MN
2345}
2346
2347/**
5b0769db 2348 * @deprecated since Moodle 3.2
5b0769db 2349 */
216b8947
MG
2350function message_can_post_message() {
2351 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' .
06d046c1 2352 '\core_message\api::can_send_message() instead.');
5b0769db
MN
2353}
2354
2355/**
5b0769db 2356 * @deprecated since Moodle 3.2
5b0769db 2357 */
216b8947
MG
2358function message_is_user_non_contact_blocked() {
2359 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' .
2360 '\core_message\api::is_user_non_contact_blocked() instead.');
5b0769db
MN
2361}
2362
2363/**
5b0769db 2364 * @deprecated since Moodle 3.2
5b0769db 2365 */
216b8947
MG
2366function message_is_user_blocked() {
2367 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' .
2368 '\core_message\api::is_user_blocked() instead.');
5b0769db
MN
2369}
2370
2371/**
5b0769db 2372 * @deprecated since Moodle 3.2
5b0769db 2373 */
216b8947
MG
2374function print_log() {
2375 throw new coding_exception('print_log() can not be used anymore. Please use the ' .
2376 'report_log framework instead.');
5b0769db 2377}
f0f4c193
AN
2378
2379/**
216b8947 2380 * @deprecated since Moodle 3.2
f0f4c193 2381 */
216b8947
MG
2382function print_mnet_log() {
2383 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' .
2384 'report_log framework instead.');
f0f4c193
AN
2385}
2386
2387/**
216b8947 2388 * @deprecated since Moodle 3.2
f0f4c193 2389 */
216b8947
MG
2390function print_log_csv() {
2391 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' .
2392 'report_log framework instead.');
f0f4c193
AN
2393}
2394
2395/**
216b8947 2396 * @deprecated since Moodle 3.2
f0f4c193 2397 */
216b8947
MG
2398function print_log_xls() {
2399 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' .
2400 'report_log framework instead.');
f0f4c193
AN
2401}
2402
2403/**
216b8947 2404 * @deprecated since Moodle 3.2
f0f4c193 2405 */
216b8947
MG
2406function print_log_ods() {
2407 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' .
2408 'report_log framework instead.');
f0f4c193
AN
2409}
2410
2411/**
216b8947 2412 * @deprecated since Moodle 3.2
f0f4c193 2413 */
216b8947
MG
2414function build_logs_array() {
2415 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' .
2416 'report_log framework instead.');
f0f4c193
AN
2417}
2418
2419/**
216b8947 2420 * @deprecated since Moodle 3.2
f0f4c193 2421 */
216b8947
MG
2422function get_logs_usercourse() {
2423 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' .
2424 'report_log framework instead.');
f0f4c193
AN
2425}
2426
2427/**
216b8947 2428 * @deprecated since Moodle 3.2
f0f4c193 2429 */
216b8947
MG
2430function get_logs_userday() {
2431 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' .
2432 'report_log framework instead.');
f0f4c193
AN
2433}
2434
2435/**
216b8947
MG
2436 * @deprecated since Moodle 3.2
2437 */
2438function get_logs() {
2439 throw new coding_exception('get_logs() can not be used anymore. Please use the ' .
2440 'report_log framework instead.');
ac157b0b
AN
2441}
2442
2443/**
216b8947 2444 * @deprecated since Moodle 3.2
ac157b0b
AN
2445 */
2446function prevent_form_autofill_password() {
216b8947 2447 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.');
f0f4c193 2448}
b1e6f1a8
RW
2449
2450/**
b1e6f1a8 2451 * @deprecated since Moodle 3.3 MDL-57370
b1e6f1a8
RW
2452 */
2453function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) {
0d51ae7e
MN
2454 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' .
2455 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER);
b1e6f1a8 2456}
12cbce0a
MN
2457
2458/**
12cbce0a 2459 * @deprecated since Moodle 3.2
12cbce0a 2460 */
216b8947
MG
2461function calendar_preferences_button() {
2462 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' .
2463 'preferences are now linked to the user preferences page.');
12cbce0a
MN
2464}
2465
12cbce0a 2466/**
12cbce0a 2467 * @deprecated since 3.3
12cbce0a 2468 */
27607e6a
MM
2469function calendar_wday_name() {
2470 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.');
12cbce0a
MN
2471}
2472
12cbce0a 2473/**
12cbce0a 2474 * @deprecated since 3.3
12cbce0a 2475 */
27607e6a
MM
2476function calendar_get_block_upcoming() {
2477 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' .
2478 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
12cbce0a
MN
2479}
2480
12cbce0a 2481/**
12cbce0a 2482 * @deprecated since 3.3
27607e6a
MM
2483 */
2484function calendar_print_month_selector() {
2485 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.');
12cbce0a
MN
2486}
2487
12cbce0a 2488/**
12cbce0a 2489 * @deprecated since 3.3
12cbce0a
MN
2490 */
2491function calendar_cron() {
27607e6a 2492 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.');
12cbce0a 2493}
e705e69e 2494
e705e69e 2495/**
e705e69e 2496 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
e705e69e 2497 */
5ab88243 2498function load_course_context() {
4bdd7693 2499 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
e705e69e
TL
2500}
2501
2502/**
e705e69e 2503 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
e705e69e 2504 */
5ab88243 2505function load_role_access_by_context() {
4bdd7693 2506 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
e705e69e
TL
2507}
2508
2509/**
e705e69e 2510 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
e705e69e
TL
2511 */
2512function dedupe_user_access() {
4bdd7693 2513 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
e705e69e
TL
2514}
2515
2516/**
e705e69e 2517 * @deprecated since Moodle 3.4. MDL-49398.
e705e69e 2518 */
db9f122f
MM
2519function get_user_access_sitewide() {
2520 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.');
e705e69e 2521}
5ff61146
AN
2522
2523/**
5ff61146
AN
2524 * @deprecated since Moodle 3.4. MDL-59333
2525 */
db9f122f
MM
2526function calendar_get_mini() {
2527 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.');
5ff61146 2528}
41b7375c
AN
2529
2530/**
41b7375c
AN
2531 * @deprecated since Moodle 3.4. MDL-59333
2532 */
db9f122f
MM
2533function calendar_get_upcoming() {
2534 throw new coding_exception('calendar_get_upcoming() has been removed. ' .
2535 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
41b7375c 2536}
64cd4596
AH
2537
2538/**
64cd4596
AH
2539 * @deprecated since Moodle 3.4. MDL-50666
2540 */
db9f122f
MM
2541function allow_override() {
2542 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.');
64cd4596
AH
2543}
2544
2545/**
64cd4596
AH
2546 * @deprecated since Moodle 3.4. MDL-50666
2547 */
db9f122f
MM
2548function allow_assign() {
2549 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.');
64cd4596
AH
2550}
2551
2552/**
64cd4596
AH
2553 * @deprecated since Moodle 3.4. MDL-50666
2554 */
db9f122f
MM
2555function allow_switch() {
2556 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.');
64cd4596 2557}
bb063971
SR
2558
2559/**
bb063971
SR
2560 * @deprecated since Moodle 3.5. MDL-61132
2561 */
2ead888f
AA
2562function question_add_tops() {
2563 throw new coding_exception(
2564 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().'
2565 );
9275220d
SR
2566}
2567
2568/**
9275220d
SR
2569 * @deprecated since Moodle 3.5. MDL-61132
2570 */
2ead888f
AA
2571function question_is_only_toplevel_category_in_context() {
2572 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. '
2573 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.');
9275220d 2574}
883ce421
MN
2575
2576/**
883ce421
MN
2577 * @deprecated since Moodle 3.5
2578 */
2ead888f
AA
2579function message_move_userfrom_unread2read() {
2580 throw new coding_exception('message_move_userfrom_unread2read() has been removed.');
883ce421
MN
2581}
2582
2583/**
883ce421
MN
2584 * @deprecated since Moodle 3.5
2585 */
2ead888f
AA
2586function message_get_blocked_users() {
2587 throw new coding_exception(
2588 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.'
2589 );
883ce421
MN
2590}
2591
2592/**
883ce421
MN
2593 * @deprecated since Moodle 3.5
2594 */
2ead888f
AA
2595function message_get_contacts() {
2596 throw new coding_exception('message_get_contacts() has been removed.');
883ce421
MN
2597}
2598
2599/**
883ce421
MN
2600 * @deprecated since Moodle 3.5
2601 */
2ead888f
AA
2602function message_mark_message_read() {
2603 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read()
2604 or \core_message\api::mark_notification_as_read().');
883ce421
MN
2605}
2606
883ce421 2607/**
883ce421
MN
2608 * @deprecated since Moodle 3.5
2609 */
2ead888f
AA
2610function message_can_delete_message() {
2611 throw new coding_exception(
2612 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.'
2613 );
883ce421
MN
2614}
2615
2616/**
883ce421
MN
2617 * @deprecated since Moodle 3.5
2618 */
2ead888f
AA
2619function message_delete_message() {
2620 throw new coding_exception(
2621 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.'
2622 );
883ce421 2623}
375b15a3
SL
2624
2625/**
375b15a3 2626 * @deprecated since 3.6
375b15a3
SL
2627 */
2628function calendar_get_all_allowed_types() {
b27a27ad
MM
2629 throw new coding_exception(
2630 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.'
2631 );
375b15a3 2632
375b15a3 2633}
e2b7dca0
SL
2634
2635/**
b27a27ad 2636 * @deprecated since Moodle 3.6.
e2b7dca0 2637 */
b27a27ad
MM
2638function groups_get_all_groups_for_courses() {
2639 throw new coding_exception(
2640 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.'
2641 );
e2b7dca0 2642}
5454e72c
AG
2643
2644/**
5454e72c 2645 * @deprecated since Moodle 3.6. Please use the Events 2 API.
5454e72c 2646 */
b27a27ad
MM
2647function events_get_cached() {
2648 throw new coding_exception(
2649 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2650 );
5454e72c
AG
2651}
2652
2653/**
5454e72c 2654 * @deprecated since Moodle 3.6. Please use the Events 2 API.
5454e72c 2655 */
b27a27ad
MM
2656function events_uninstall() {
2657 throw new coding_exception(
2658 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2659 );
5454e72c
AG
2660}
2661
2662/**
5454e72c 2663 * @deprecated since Moodle 3.6. Please use the Events 2 API.
b27a27ad
MM
2664 */
2665function events_cleanup() {
2666 throw new coding_exception(
2667 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2668 );
5454e72c
AG
2669}
2670
2671/**
5454e72c 2672 * @deprecated since Moodle 3.6. Please use the Events 2 API.
b27a27ad
MM
2673 */
2674function events_dequeue() {
2675 throw new coding_exception(
2676 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2677 );
5454e72c
AG
2678}
2679
2680/**
5454e72c 2681 * @deprecated since Moodle 3.6. Please use the Events 2 API.
b27a27ad
MM
2682 */
2683function events_get_handlers() {
2684 throw new coding_exception(
2685 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2686 );
5454e72c 2687}
925d1dc6 2688
df536ab1 2689/**
df536ab1 2690 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
df536ab1 2691 */
b27a27ad
MM
2692function get_roles_on_exact_context() {
2693 throw new coding_exception(
2694 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.'
2695 );
df536ab1 2696}
2697
2698/**
df536ab1 2699 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
df536ab1 2700 */
b27a27ad
MM
2701function get_roles_with_assignment_on_context() {
2702 throw new coding_exception(
2703 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.'
2704 );
df536ab1 2705}
0b3eadcd
MN
2706
2707/**
0b3eadcd 2708 * @deprecated since Moodle 3.6
b27a27ad
MM
2709 */
2710function message_add_contact() {
2711 throw new coding_exception(
2712 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' .
0b3eadcd 2713 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' .
b27a27ad
MM
2714 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.'
2715 );
0b3eadcd
MN
2716}
2717
2718/**
0b3eadcd 2719 * @deprecated since Moodle 3.6
0b3eadcd 2720 */
b27a27ad
MM
2721function message_remove_contact() {
2722 throw new coding_exception(
2723 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.'
2724 );
0b3eadcd
MN
2725}
2726
2727/**
0b3eadcd 2728 * @deprecated since Moodle 3.6
0b3eadcd 2729 */
b27a27ad
MM
2730function message_unblock_contact() {
2731 throw new coding_exception(
2732 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.'
2733 );
0b3eadcd
MN
2734}
2735
2736/**
0b3eadcd 2737 * @deprecated since Moodle 3.6
0b3eadcd 2738 */
b27a27ad
MM
2739function message_block_contact() {
2740 throw new coding_exception(
2741 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' .
2742 '\core_message\api::block_user() instead.'
2743 );
0b3eadcd
MN
2744}
2745
2746/**
0b3eadcd 2747 * @deprecated since Moodle 3.6
0b3eadcd 2748 */
b27a27ad
MM
2749function message_get_contact() {
2750 throw new coding_exception(
2751 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.'
2752 );
0b3eadcd 2753}
88d2677e
MG
2754
2755/**
2756 * Returns list of courses, for whole site, or category
2757 *
2758 * Similar to get_courses, but allows paging
2759 * Important: Using c.* for fields is extremely expensive because
2760 * we are using distinct. You almost _NEVER_ need all the fields
2761 * in such a large SELECT
2762 *
2763 * @deprecated since Moodle 3.7
74ee34fd 2764 * @todo The final deprecation of this function will take place in Moodle 3.11 - see MDL-65319.
88d2677e
MG
2765 *
2766 * @param string|int $categoryid Either a category id or 'all' for everything
2767 * @param string $sort A field and direction to sort by
2768 * @param string $fields The additional fields to return
2769 * @param int $totalcount Reference for the number of courses
2770 * @param string $limitfrom The course to start from
2771 * @param string $limitnum The number of courses to limit to
2772 * @return array Array of courses
2773 */
2774function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*",
2775 &$totalcount, $limitfrom="", $limitnum="") {
2776 debugging('Function get_courses_page() is deprecated. Please use core_course_category::get_courses() ' .
2777 'or core_course_category::search_courses()', DEBUG_DEVELOPER);
2778 global $USER, $CFG, $DB;
2779
2780 $params = array();
2781
2782 $categoryselect = "";
2783 if ($categoryid !== "all" && is_numeric($categoryid)) {
2784 $categoryselect = "WHERE c.category = :catid";
2785 $params['catid'] = $categoryid;
2786 } else {
2787 $categoryselect = "";
2788 }
2789
2790 $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
2791 $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
2792 $params['contextlevel'] = CONTEXT_COURSE;
2793
2794 $totalcount = 0;
2795 if (!$limitfrom) {
2796 $limitfrom = 0;
2797 }
2798 $visiblecourses = array();
2799
2800 $sql = "SELECT $fields $ccselect
2801 FROM {course} c
2802 $ccjoin
2803 $categoryselect
2804 ORDER BY $sort";
2805
2806 // Pull out all course matching the cat.
2807 $rs = $DB->get_recordset_sql($sql, $params);
2808 // Iteration will have to be done inside loop to keep track of the limitfrom and limitnum.
2809 foreach ($rs as $course) {
2810 context_helper::preload_from_record($course);
2811 if (core_course_category::can_view_course_info($course)) {
2812 $totalcount++;
2813 if ($totalcount > $limitfrom && (!$limitnum or count($visiblecourses) < $limitnum)) {
2814 $visiblecourses [$course->id] = $course;
2815 }
2816 }
2817 }
2818 $rs->close();
2819 return $visiblecourses;
2820}
93e71c71
DM
2821
2822/**
2823 * Returns the models that generated insights in the provided context.
2824 *
2825 * @deprecated since Moodle 3.8 MDL-66091 - please do not use this function any more.
2826 * @todo MDL-65799 This will be deleted in Moodle 4.2
2827 * @see \core_analytics\manager::cached_models_with_insights
2828 * @param \context $context
2829 * @return int[]
2830 */
2831function report_insights_context_insights(\context $context) {
2832
2833 debugging('report_insights_context_insights is deprecated. Please use ' .
2834 '\core_analytics\manager::cached_models_with_insights instead', DEBUG_DEVELOPER);
2835
2836 return \core_analytics\manager::cached_models_with_insights($context);
2837}
12f73788
JD
2838
2839/**
2840 * Retrieve all metadata for the requested modules
2841 *
2842 * @deprecated since 3.9.
2843 * @param object $course The Course
2844 * @param array $modnames An array containing the list of modules and their
2845 * names
2846 * @param int $sectionreturn The section to return to
2847 * @return array A list of stdClass objects containing metadata about each
2848 * module
2849 */
2850function get_module_metadata($course, $modnames, $sectionreturn = null) {
2851 global $OUTPUT;
2852
2853 debugging('get_module_metadata is deprecated. Please use \core_course\local\service\content_item_service instead.');
2854
2855 // get_module_metadata will be called once per section on the page and courses may show
2856 // different modules to one another
2857 static $modlist = array();
2858 if (!isset($modlist[$course->id])) {
2859 $modlist[$course->id] = array();
2860 }
2861
2862 $return = array();
2863 $urlbase = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey()));
2864 if ($sectionreturn !== null) {
2865 $urlbase->param('sr', $sectionreturn);
2866 }
2867 foreach($modnames as $modname => $modnamestr) {
2868 if (!course_allowed_module($course, $modname)) {
2869 continue;
2870 }
2871 if (isset($modlist[$course->id][$modname])) {
2872 // This module is already cached
2873 $return += $modlist[$course->id][$modname];
2874 continue;
2875 }
2876 $modlist[$course->id][$modname] = array();
2877
2878 // Create an object for a default representation of this module type in the activity chooser. It will be used
2879 // if module does not implement callback get_shortcuts() and it will also be passed to the callback if it exists.
2880 $defaultmodule = new stdClass();
2881 $defaultmodule->title = $modnamestr;
2882 $defaultmodule->name = $modname;
2883 $defaultmodule->link = new moodle_url($urlbase, array('add' => $modname));
2884 $defaultmodule->icon = $OUTPUT->pix_icon('icon', '', $defaultmodule->name, array('class' => 'icon'));
2885 $sm = get_string_manager();
2886 if ($sm->string_exists('modulename_help', $modname)) {
2887 $defaultmodule->help = get_string('modulename_help', $modname);
2888 if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs.
2889 $link = get_string('modulename_link', $modname);
2890 $linktext = get_string('morehelp');
2891 $defaultmodule->help .= html_writer::tag('div',
2892 $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));
2893 }
2894 }
2895 $defaultmodule->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
2896
2897 // Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list
2898 // of elements to be added to activity chooser.
2899 $items = component_callback($modname, 'get_shortcuts', array($defaultmodule), null);
2900 if ($items !== null) {
2901 foreach ($items as $item) {
2902 // Add all items to the return array. All items must have different links, use them as a key in the return array.
2903 if (!isset($item->archetype)) {
2904 $item->archetype = $defaultmodule->archetype;
2905 }
2906 if (!isset($item->icon)) {
2907 $item->icon = $defaultmodule->icon;
2908 }
2909 // If plugin returned the only one item with the same link as default item - cache it as $modname,
2910 // otherwise append the link url to the module name.
2911 $item->name = (count($items) == 1 &&
2912 $item->link->out() === $defaultmodule->link->out()) ? $modname : $modname . ':' . $item->link;
2913
2914 // If the module provides the helptext property, append it to the help text to match the look and feel
2915 // of the default course modules.
2916 if (isset($item->help) && isset($item->helplink)) {
2917 $linktext = get_string('morehelp');
2918 $item->help .= html_writer::tag('div',
2919 $OUTPUT->doc_link($item->helplink, $linktext, true), array('class' => 'helpdoclink'));
2920 }
2921 $modlist[$course->id][$modname][$item->name] = $item;
2922 }
2923 $return += $modlist[$course->id][$modname];
2924 // If get_shortcuts() callback is defined, the default module action is not added.
2925 // It is a responsibility of the callback to add it to the return value unless it is not needed.
2926 continue;
2927 }
2928
2929 // The callback get_shortcuts() was not found, use the default item for the activity chooser.
2930 $modlist[$course->id][$modname][$modname] = $defaultmodule;
2931 $return[$modname] = $defaultmodule;
2932 }
2933
2934 core_collator::asort_objects_by_property($return, 'title');
2935 return $return;
2936}
db15746c 2937
2938/**
2939 * Runs a single cron task. This function assumes it is displaying output in pseudo-CLI mode.
2940 *
2941 * The function will fail if the task is disabled.
2942 *
2943 * Warning: Because this function closes the browser session, it may not be safe to continue
2944 * with other processing (other than displaying the rest of the page) after using this function!
2945 *
2946 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task).
2947 * @todo final deprecation. To be removed in Moodle 4.3 MDL-63594.
2948 * @param \core\task\scheduled_task $task Task to run
2949 * @return bool True if cron run successful
2950 */
2951function cron_run_single_task(\core\task\scheduled_task $task) {
2952 debugging('cron_run_single_task() is deprecated. Please use \\core\task\manager::run_from_cli() instead.',
2953 DEBUG_DEVELOPER);
2954 return \core\task\manager::run_from_cli($task);
2955}
d2ecc75e
EL
2956
2957/**
2958 * Executes cron functions for a specific type of plugin.
2959 *
2960 * @param string $plugintype Plugin type (e.g. 'report')
2961 * @param string $description If specified, will display 'Starting (whatever)'
2962 * and 'Finished (whatever)' lines, otherwise does not display
2963 *
2964 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2965 * @todo MDL-61165 This will be deleted in Moodle 4.3.
2966 */
2967function cron_execute_plugin_type($plugintype, $description = null) {
2968 global $DB;
2969
2970 // Get list from plugin => function for all plugins.
2971 $plugins = get_plugin_list_with_function($plugintype, 'cron');
2972
2973 // Modify list for backward compatibility (different files/names).
2974 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins);
2975
2976 // Return if no plugins with cron function to process.
2977 if (!$plugins) {
2978 return;
2979 }
2980
2981 if ($description) {
2982 mtrace('Starting '.$description);
2983 }
2984
2985 foreach ($plugins as $component => $cronfunction) {
2986 $dir = core_component::get_component_directory($component);
2987
2988 // Get cron period if specified in version.php, otherwise assume every cron.
2989 $cronperiod = 0;
2990 if (file_exists("$dir/version.php")) {
2991 $plugin = new stdClass();
2992 include("$dir/version.php");
2993 if (isset($plugin->cron)) {
2994 $cronperiod = $plugin->cron;
2995 }
2996 }
2997
2998 // Using last cron and cron period, don't run if it already ran recently.
2999 $lastcron = get_config($component, 'lastcron');
3000 if ($cronperiod && $lastcron) {
3001 if ($lastcron + $cronperiod > time()) {
3002 // Do not execute cron yet.
3003 continue;
3004 }
3005 }
3006
3007 mtrace('Processing cron function for ' . $component . '...');
3008 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER);
3009 cron_trace_time_and_memory();
3010 $pre_dbqueries = $DB->perf_get_queries();
3011 $pre_time = microtime(true);
3012
3013 $cronfunction();
3014
3015 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " .
3016 round(microtime(true) - $pre_time, 2) . " seconds)");
3017
3018 set_config('lastcron', time(), $component);
3019 core_php_time_limit::raise();
3020 }
3021
3022 if ($description) {
3023 mtrace('Finished ' . $description);
3024 }
3025}
3026
3027/**
3028 * Used to add in old-style cron functions within plugins that have not been converted to the
3029 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used
3030 * cron.php and some used a different name.)
3031 *
3032 * @param string $plugintype Plugin type e.g. 'report'
3033 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g.
3034 * 'report_frog_cron') for plugin cron functions that were already found using the new API
3035 * @return array Revised version of $plugins that adds in any extra plugin functions found by
3036 * looking in the older location
3037 *
3038 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
3039 * @todo MDL-61165 This will be deleted in Moodle 4.3.
3040 */
3041function cron_bc_hack_plugin_functions($plugintype, $plugins) {
3042 global $CFG; // Mandatory in case it is referenced by include()d PHP script.
3043
3044 if ($plugintype === 'report') {
3045 // Admin reports only - not course report because course report was
3046 // never implemented before, so doesn't need BC.
3047 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
3048 $component = $plugintype . '_' . $pluginname;
3049 if (isset($plugins[$component])) {
3050 // We already have detected the function using the new API.
3051 continue;
3052 }
3053 if (!file_exists("$dir/cron.php")) {
3054 // No old style cron file present.
3055 continue;
3056 }
3057 include_once("$dir/cron.php");
3058 $cronfunction = $component . '_cron';
3059 if (function_exists($cronfunction)) {
3060 $plugins[$component] = $cronfunction;
3061 } else {
3062 debugging("Invalid legacy cron.php detected in $component, " .
3063 "please use lib.php instead");
3064 }
3065 }
3066 } else if (strpos($plugintype, 'grade') === 0) {
3067 // Detect old style cron function names.
3068 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of
3069 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport.
3070 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
3071 $component = $plugintype.'_'.$pluginname;
3072 if (isset($plugins[$component])) {
3073 // We already have detected the function using the new API.
3074 continue;
3075 }
3076 if (!file_exists("$dir/lib.php")) {
3077 continue;
3078 }
3079 include_once("$dir/lib.php");
3080 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' .
3081 $pluginname . '_cron';
3082 if (function_exists($cronfunction)) {
3083 $plugins[$component] = $cronfunction;
3084 }
3085 }
3086 }
3087
3088 return $plugins;
3089}
2396e315
MH
3090
3091/**
3092 * Returns the SQL used by the participants table.
3093 *