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