Merge branch 'MDL-79498-402' of https://github.com/junpataleta/moodle into MOODLE_402...
[moodle.git] / lib / deprecatedlib.php
blob887875ccef571bff9c62bce1ea923b9262933c68
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
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.
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/>.
18 /**
19 * deprecatedlib.php - Old functions retained only for backward compatibility
21 * Old functions retained only for backward compatibility. New code should not
22 * use any of these functions.
24 * @package core
25 * @subpackage deprecated
26 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 * @deprecated
31 defined('MOODLE_INTERNAL') || die();
33 /* === Functions that needs to be kept longer in deprecated lib than normal time period === */
35 /**
36 * @deprecated since 2.7 use new events instead
38 function add_to_log() {
39 throw new coding_exception('add_to_log() has been removed, please rewrite your code to the new events API');
42 /**
43 * @deprecated since 2.6
45 function events_trigger() {
46 throw new coding_exception('events_trigger() has been deprecated along with all Events 1 API in favour of Events 2 API.');
49 /**
50 * List all core subsystems and their location
52 * This is a list of components that are part of the core and their
53 * language strings are defined in /lang/en/<<subsystem>>.php. If a given
54 * plugin is not listed here and it does not have proper plugintype prefix,
55 * then it is considered as course activity module.
57 * The location is optionally dirroot relative path. NULL means there is no special
58 * directory for this subsystem. If the location is set, the subsystem's
59 * renderer.php is expected to be there.
61 * @deprecated since 2.6, use core_component::get_core_subsystems()
63 * @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons
64 * @return array of (string)name => (string|null)location
66 function get_core_subsystems($fullpaths = false) {
67 global $CFG;
69 // NOTE: do not add any other debugging here, keep forever.
71 $subsystems = core_component::get_core_subsystems();
73 if ($fullpaths) {
74 return $subsystems;
77 debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
79 $dlength = strlen($CFG->dirroot);
81 foreach ($subsystems as $k => $v) {
82 if ($v === null) {
83 continue;
85 $subsystems[$k] = substr($v, $dlength+1);
88 return $subsystems;
91 /**
92 * Lists all plugin types.
94 * @deprecated since 2.6, use core_component::get_plugin_types()
96 * @param bool $fullpaths false means relative paths from dirroot
97 * @return array Array of strings - name=>location
99 function get_plugin_types($fullpaths = true) {
100 global $CFG;
102 // NOTE: do not add any other debugging here, keep forever.
104 $types = core_component::get_plugin_types();
106 if ($fullpaths) {
107 return $types;
110 debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
112 $dlength = strlen($CFG->dirroot);
114 foreach ($types as $k => $v) {
115 if ($k === 'theme') {
116 $types[$k] = 'theme';
117 continue;
119 $types[$k] = substr($v, $dlength+1);
122 return $types;
126 * Use when listing real plugins of one type.
128 * @deprecated since 2.6, use core_component::get_plugin_list()
130 * @param string $plugintype type of plugin
131 * @return array name=>fulllocation pairs of plugins of given type
133 function get_plugin_list($plugintype) {
135 // NOTE: do not add any other debugging here, keep forever.
137 if ($plugintype === '') {
138 $plugintype = 'mod';
141 return core_component::get_plugin_list($plugintype);
145 * Get a list of all the plugins of a given type that define a certain class
146 * in a certain file. The plugin component names and class names are returned.
148 * @deprecated since 2.6, use core_component::get_plugin_list_with_class()
150 * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
151 * @param string $class the part of the name of the class after the
152 * frankenstyle prefix. e.g 'thing' if you are looking for classes with
153 * names like report_courselist_thing. If you are looking for classes with
154 * the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
155 * @param string $file the name of file within the plugin that defines the class.
156 * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
157 * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
159 function get_plugin_list_with_class($plugintype, $class, $file) {
161 // NOTE: do not add any other debugging here, keep forever.
163 return core_component::get_plugin_list_with_class($plugintype, $class, $file);
167 * Returns the exact absolute path to plugin directory.
169 * @deprecated since 2.6, use core_component::get_plugin_directory()
171 * @param string $plugintype type of plugin
172 * @param string $name name of the plugin
173 * @return string full path to plugin directory; NULL if not found
175 function get_plugin_directory($plugintype, $name) {
177 // NOTE: do not add any other debugging here, keep forever.
179 if ($plugintype === '') {
180 $plugintype = 'mod';
183 return core_component::get_plugin_directory($plugintype, $name);
187 * Normalize the component name using the "frankenstyle" names.
189 * @deprecated since 2.6, use core_component::normalize_component()
191 * @param string $component
192 * @return array two-items list of [(string)type, (string|null)name]
194 function normalize_component($component) {
196 // NOTE: do not add any other debugging here, keep forever.
198 return core_component::normalize_component($component);
202 * Return exact absolute path to a plugin directory.
204 * @deprecated since 2.6, use core_component::normalize_component()
206 * @param string $component name such as 'moodle', 'mod_forum'
207 * @return string full path to component directory; NULL if not found
209 function get_component_directory($component) {
211 // NOTE: do not add any other debugging here, keep forever.
213 return core_component::get_component_directory($component);
217 * Get the context instance as an object. This function will create the
218 * context instance if it does not exist yet.
220 * @deprecated since 2.2, use context_course::instance() or other relevant class instead
221 * @todo This will be deleted in Moodle 2.8, refer MDL-34472
222 * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
223 * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
224 * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
225 * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
226 * MUST_EXIST means throw exception if no record or multiple records found
227 * @return context The context object.
229 function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) {
231 debugging('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER);
233 $instances = (array)$instance;
234 $contexts = array();
236 $classname = context_helper::get_class_for_level($contextlevel);
238 // we do not load multiple contexts any more, PAGE should be responsible for any preloading
239 foreach ($instances as $inst) {
240 $contexts[$inst] = $classname::instance($inst, $strictness);
243 if (is_array($instance)) {
244 return $contexts;
245 } else {
246 return $contexts[$instance];
249 /* === End of long term deprecated api list === */
252 * @deprecated since 2.7 - use new file picker instead
254 function clam_log_upload() {
255 throw new coding_exception('clam_log_upload() can not be used any more, please use file picker instead');
259 * @deprecated since 2.7 - use new file picker instead
261 function clam_log_infected() {
262 throw new coding_exception('clam_log_infected() can not be used any more, please use file picker instead');
266 * @deprecated since 2.7 - use new file picker instead
268 function clam_change_log() {
269 throw new coding_exception('clam_change_log() can not be used any more, please use file picker instead');
273 * @deprecated since 2.7 - infected files are now deleted in file picker
275 function clam_replace_infected_file() {
276 throw new coding_exception('clam_replace_infected_file() can not be used any more, please use file picker instead');
280 * @deprecated since 2.7
282 function clam_handle_infected_file() {
283 throw new coding_exception('clam_handle_infected_file() can not be used any more, please use file picker instead');
287 * @deprecated since 2.7
289 function clam_scan_moodle_file() {
290 throw new coding_exception('clam_scan_moodle_file() can not be used any more, please use file picker instead');
295 * @deprecated since 2.7 PHP 5.4.x should be always compatible.
297 function password_compat_not_supported() {
298 throw new coding_exception('Do not use password_compat_not_supported() - bcrypt is now always available');
302 * @deprecated since 2.6
304 function session_get_instance() {
305 throw new coding_exception('session_get_instance() is removed, use \core\session\manager instead');
309 * @deprecated since 2.6
311 function session_is_legacy() {
312 throw new coding_exception('session_is_legacy() is removed, do not use any more');
316 * @deprecated since 2.6
318 function session_kill_all() {
319 throw new coding_exception('session_kill_all() is removed, use \core\session\manager::kill_all_sessions() instead');
323 * @deprecated since 2.6
325 function session_touch() {
326 throw new coding_exception('session_touch() is removed, use \core\session\manager::touch_session() instead');
330 * @deprecated since 2.6
332 function session_kill() {
333 throw new coding_exception('session_kill() is removed, use \core\session\manager::kill_session() instead');
337 * @deprecated since 2.6
339 function session_kill_user() {
340 throw new coding_exception('session_kill_user() is removed, use \core\session\manager::kill_user_sessions() instead');
344 * @deprecated since 2.6
346 function session_set_user() {
347 throw new coding_exception('session_set_user() is removed, use \core\session\manager::set_user() instead');
351 * @deprecated since 2.6
353 function session_is_loggedinas() {
354 throw new coding_exception('session_is_loggedinas() is removed, use \core\session\manager::is_loggedinas() instead');
358 * @deprecated since 2.6
360 function session_get_realuser() {
361 throw new coding_exception('session_get_realuser() is removed, use \core\session\manager::get_realuser() instead');
365 * @deprecated since 2.6
367 function session_loginas() {
368 throw new coding_exception('session_loginas() is removed, use \core\session\manager::loginas() instead');
372 * @deprecated since 2.6
374 function js_minify() {
375 throw new coding_exception('js_minify() is removed, use core_minify::js_files() or core_minify::js() instead.');
379 * @deprecated since 2.6
381 function css_minify_css() {
382 throw new coding_exception('css_minify_css() is removed, use core_minify::css_files() or core_minify::css() instead.');
385 // === Deprecated before 2.6.0 ===
388 * @deprecated
390 function check_gd_version() {
391 throw new coding_exception('check_gd_version() is removed, GD extension is always available now');
395 * @deprecated
397 function update_login_count() {
398 throw new coding_exception('update_login_count() is removed, all calls need to be removed');
402 * @deprecated
404 function reset_login_count() {
405 throw new coding_exception('reset_login_count() is removed, all calls need to be removed');
409 * @deprecated
411 function update_log_display_entry() {
413 throw new coding_exception('The update_log_display_entry() is removed, please use db/log.php description file instead.');
417 * @deprecated use the text formatting in a standard way instead (https://moodledev.io/docs/apis/subsystems/output#output-functions)
418 * this was abused mostly for embedding of attachments
420 function filter_text() {
421 throw new coding_exception('filter_text() can not be used anymore, use format_text(), format_string() etc instead.');
425 * @deprecated Loginhttps is no longer supported
427 function httpsrequired() {
428 throw new coding_exception('httpsrequired() can not be used any more. Loginhttps is no longer supported.');
432 * @deprecated since 3.1 - replacement legacy file API methods can be found on the moodle_url class, for example:
433 * The moodle_url::make_legacyfile_url() method can be used to generate a legacy course file url. To generate
434 * course module file.php url the moodle_url::make_file_url() should be used.
436 function get_file_url() {
437 throw new coding_exception('get_file_url() can not be used anymore. Please use ' .
438 'moodle_url factory methods instead.');
442 * @deprecated use get_enrolled_users($context) instead.
444 function get_course_participants() {
445 throw new coding_exception('get_course_participants() can not be used any more, use get_enrolled_users() instead.');
449 * @deprecated use is_enrolled($context, $userid) instead.
451 function is_course_participant() {
452 throw new coding_exception('is_course_participant() can not be used any more, use is_enrolled() instead.');
456 * @deprecated
458 function get_recent_enrolments() {
459 throw new coding_exception('get_recent_enrolments() is removed as it returned inaccurate results.');
463 * @deprecated use clean_param($string, PARAM_FILE) instead.
465 function detect_munged_arguments() {
466 throw new coding_exception('detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.');
471 * Unzip one zip file to a destination dir
472 * Both parameters must be FULL paths
473 * If destination isn't specified, it will be the
474 * SAME directory where the zip file resides.
476 * @global object
477 * @param string $zipfile The zip file to unzip
478 * @param string $destination The location to unzip to
479 * @param bool $showstatus_ignored Unused
480 * @deprecated since 2.0 MDL-15919
482 function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
483 debugging(__FUNCTION__ . '() is deprecated. '
484 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER);
486 // Extract everything from zipfile.
487 $path_parts = pathinfo(cleardoubleslashes($zipfile));
488 $zippath = $path_parts["dirname"]; //The path of the zip file
489 $zipfilename = $path_parts["basename"]; //The name of the zip file
490 $extension = $path_parts["extension"]; //The extension of the file
492 //If no file, error
493 if (empty($zipfilename)) {
494 return false;
497 //If no extension, error
498 if (empty($extension)) {
499 return false;
502 //Clear $zipfile
503 $zipfile = cleardoubleslashes($zipfile);
505 //Check zipfile exists
506 if (!file_exists($zipfile)) {
507 return false;
510 //If no destination, passed let's go with the same directory
511 if (empty($destination)) {
512 $destination = $zippath;
515 //Clear $destination
516 $destpath = rtrim(cleardoubleslashes($destination), "/");
518 //Check destination path exists
519 if (!is_dir($destpath)) {
520 return false;
523 $packer = get_file_packer('application/zip');
525 $result = $packer->extract_to_pathname($zipfile, $destpath);
527 if ($result === false) {
528 return false;
531 foreach ($result as $status) {
532 if ($status !== true) {
533 return false;
537 return true;
541 * Zip an array of files/dirs to a destination zip file
542 * Both parameters must be FULL paths to the files/dirs
544 * @global object
545 * @param array $originalfiles Files to zip
546 * @param string $destination The destination path
547 * @return bool Outcome
549 * @deprecated since 2.0 MDL-15919
551 function zip_files($originalfiles, $destination) {
552 debugging(__FUNCTION__ . '() is deprecated. '
553 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER);
555 // Extract everything from destination.
556 $path_parts = pathinfo(cleardoubleslashes($destination));
557 $destpath = $path_parts["dirname"]; //The path of the zip file
558 $destfilename = $path_parts["basename"]; //The name of the zip file
559 $extension = $path_parts["extension"]; //The extension of the file
561 //If no file, error
562 if (empty($destfilename)) {
563 return false;
566 //If no extension, add it
567 if (empty($extension)) {
568 $extension = 'zip';
569 $destfilename = $destfilename.'.'.$extension;
572 //Check destination path exists
573 if (!is_dir($destpath)) {
574 return false;
577 //Check destination path is writable. TODO!!
579 //Clean destination filename
580 $destfilename = clean_filename($destfilename);
582 //Now check and prepare every file
583 $files = array();
584 $origpath = NULL;
586 foreach ($originalfiles as $file) { //Iterate over each file
587 //Check for every file
588 $tempfile = cleardoubleslashes($file); // no doubleslashes!
589 //Calculate the base path for all files if it isn't set
590 if ($origpath === NULL) {
591 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
593 //See if the file is readable
594 if (!is_readable($tempfile)) { //Is readable
595 continue;
597 //See if the file/dir is in the same directory than the rest
598 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
599 continue;
601 //Add the file to the array
602 $files[] = $tempfile;
605 $zipfiles = array();
606 $start = strlen($origpath)+1;
607 foreach($files as $file) {
608 $zipfiles[substr($file, $start)] = $file;
611 $packer = get_file_packer('application/zip');
613 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
617 * @deprecated use groups_get_all_groups() instead.
619 function mygroupid() {
620 throw new coding_exception('mygroupid() can not be used any more, please use groups_get_all_groups() instead.');
624 * @deprecated since Moodle 2.0 MDL-14617 - please do not use this function any more.
626 function groupmode() {
627 throw new coding_exception('groupmode() can not be used any more, please use groups_get_* instead.');
631 * @deprecated Since year 2006 - please do not use this function any more.
633 function set_current_group() {
634 throw new coding_exception('set_current_group() can not be used anymore, please use $SESSION->currentgroup[$courseid] instead');
638 * @deprecated Since year 2006 - please do not use this function any more.
640 function get_current_group() {
641 throw new coding_exception('get_current_group() can not be used any more, please use groups_get_* instead');
645 * @deprecated Since Moodle 2.8
647 function groups_filter_users_by_course_module_visible() {
648 throw new coding_exception('groups_filter_users_by_course_module_visible() is removed. ' .
649 'Replace with a call to \core_availability\info_module::filter_user_list(), ' .
650 'which does basically the same thing but includes other restrictions such ' .
651 'as profile restrictions.');
655 * @deprecated Since Moodle 2.8
657 function groups_course_module_visible() {
658 throw new coding_exception('groups_course_module_visible() is removed, use $cm->uservisible to decide whether the current
659 user can ' . 'access an activity.', DEBUG_DEVELOPER);
663 * @deprecated since 2.0
665 function error() {
666 throw new coding_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a removed, please call
667 throw new \moodle_exception() instead of error()');
672 * @deprecated use $PAGE->theme->name instead.
674 function current_theme() {
675 throw new coding_exception('current_theme() can not be used any more, please use $PAGE->theme->name instead');
679 * @deprecated
681 function formerr() {
682 throw new coding_exception('formerr() is removed. Please change your code to use $OUTPUT->error_text($string).');
686 * @deprecated use $OUTPUT->skip_link_target() in instead.
688 function skip_main_destination() {
689 throw new coding_exception('skip_main_destination() can not be used any more, please use $OUTPUT->skip_link_target() instead.');
693 * @deprecated use $OUTPUT->container() instead.
695 function print_container() {
696 throw new coding_exception('print_container() can not be used any more. Please use $OUTPUT->container() instead.');
700 * @deprecated use $OUTPUT->container_start() instead.
702 function print_container_start() {
703 throw new coding_exception('print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.');
707 * @deprecated use $OUTPUT->container_end() instead.
709 function print_container_end() {
710 throw new coding_exception('print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.');
714 * @deprecated since Moodle 2.0 MDL-19077 - use $OUTPUT->notification instead.
716 function notify() {
717 throw new coding_exception('notify() is removed, please use $OUTPUT->notification() instead');
721 * @deprecated use $OUTPUT->continue_button() instead.
723 function print_continue() {
724 throw new coding_exception('print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.');
728 * @deprecated use $PAGE methods instead.
730 function print_header() {
732 throw new coding_exception('print_header() can not be used any more. Please use $PAGE methods instead.');
736 * @deprecated use $PAGE methods instead.
738 function print_header_simple() {
740 throw new coding_exception('print_header_simple() can not be used any more. Please use $PAGE methods instead.');
744 * @deprecated use $OUTPUT->block() instead.
746 function print_side_block() {
747 throw new coding_exception('print_side_block() can not be used any more, please use $OUTPUT->block() instead.');
751 * @deprecated since Moodle 3.6
753 function print_textarea() {
754 throw new coding_exception(
755 'print_textarea() has been removed. Please use $OUTPUT->print_textarea() instead.'
760 * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
761 * provide this function with the language strings for sortasc and sortdesc.
763 * @deprecated use $OUTPUT->arrow() instead.
764 * @todo final deprecation of this function once MDL-45448 is resolved
766 * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
768 * @global object
769 * @param string $direction 'up' or 'down'
770 * @param string $strsort The language string used for the alt attribute of this image
771 * @param bool $return Whether to print directly or return the html string
772 * @return string|void depending on $return
775 function print_arrow($direction='up', $strsort=null, $return=false) {
776 global $OUTPUT;
778 debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER);
780 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
781 return null;
784 $return = null;
786 switch ($direction) {
787 case 'up':
788 $sortdir = 'asc';
789 break;
790 case 'down':
791 $sortdir = 'desc';
792 break;
793 case 'move':
794 $sortdir = 'asc';
795 break;
796 default:
797 $sortdir = null;
798 break;
801 // Prepare language string
802 $strsort = '';
803 if (empty($strsort) && !empty($sortdir)) {
804 $strsort = get_string('sort' . $sortdir, 'grades');
807 $return = ' ' . $OUTPUT->pix_icon('t/' . $direction, $strsort) . ' ';
809 if ($return) {
810 return $return;
811 } else {
812 echo $return;
817 * @deprecated since Moodle 2.0
819 function choose_from_menu() {
820 throw new coding_exception('choose_from_menu() is removed. Please change your code to use html_writer::select().');
824 * @deprecated use $OUTPUT->help_icon_scale($courseid, $scale) instead.
826 function print_scale_menu_helpbutton() {
827 throw new coding_exception('print_scale_menu_helpbutton() can not be used any more. '.
828 'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.');
832 * @deprecated use html_writer::checkbox() instead.
834 function print_checkbox() {
835 throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.');
839 * @deprecated since Moodle 3.2
841 function update_module_button() {
842 throw new coding_exception('update_module_button() can not be used anymore. Activity modules should ' .
843 'not add the edit module button, the link is already available in the Administration block. Themes ' .
844 'can choose to display the link in the buttons row consistently for all module types.');
848 * @deprecated use $OUTPUT->navbar() instead
850 function print_navigation () {
851 throw new coding_exception('print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.');
855 * @deprecated Please use $PAGE->navabar methods instead.
857 function build_navigation() {
858 throw new coding_exception('build_navigation() can not be used any more, please use $PAGE->navbar methods instead.');
862 * @deprecated not relevant with global navigation in Moodle 2.x+
864 function navmenu() {
865 throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.');
868 /// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
872 * @deprecated please use calendar_event::create() instead.
874 function add_event() {
875 throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.');
879 * @deprecated please calendar_event->update() instead.
881 function update_event() {
882 throw new coding_exception('update_event() is removed, please use calendar_event->update() instead.');
886 * @deprecated please use calendar_event->delete() instead.
888 function delete_event() {
889 throw new coding_exception('delete_event() can not be used any more, please use '.
890 'calendar_event->delete() instead.');
894 * @deprecated please use calendar_event->toggle_visibility(false) instead.
896 function hide_event() {
897 throw new coding_exception('hide_event() can not be used any more, please use '.
898 'calendar_event->toggle_visibility(false) instead.');
902 * @deprecated please use calendar_event->toggle_visibility(true) instead.
904 function show_event() {
905 throw new coding_exception('show_event() can not be used any more, please use '.
906 'calendar_event->toggle_visibility(true) instead.');
910 * @deprecated since Moodle 2.2 use core_text::xxxx() instead.
912 function textlib_get_instance() {
913 throw new coding_exception('textlib_get_instance() can not be used any more, please use '.
914 'core_text::functioname() instead.');
918 * @deprecated since 2.4
920 function get_generic_section_name() {
921 throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality '
922 .'from class core_courseformat\\base');
926 * @deprecated since 2.4
928 function get_all_sections() {
929 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
933 * @deprecated since 2.4
935 function add_mod_to_section() {
936 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
940 * @deprecated since 2.4
942 function get_all_mods() {
943 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
947 * @deprecated since 2.4
949 function get_course_section() {
950 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
954 * @deprecated since 2.4
956 function format_weeks_get_section_dates() {
957 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
958 ' use it outside of format_weeks plugin');
962 * @deprecated since 2.5
964 function get_print_section_cm_text() {
965 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
966 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
970 * @deprecated since 2.5
972 function print_section_add_menus() {
973 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
974 'function course_section_add_cm_control()');
978 * @deprecated since 2.5. Please use:
979 * $courserenderer = $PAGE->get_renderer('core', 'course');
980 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
981 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
983 function make_editing_buttons() {
984 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
985 'lib/deprecatedlib.php on how to replace it');
989 * @deprecated since 2.5
991 function print_section() {
992 throw new coding_exception(
993 'Function print_section() is removed.' .
994 ' Please use core_courseformat\\output\\local\\content\\section' .
995 ' to render a course section instead.'
1000 * @deprecated since 2.5
1002 function print_overview() {
1003 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
1007 * @deprecated since 2.5
1009 function print_recent_activity() {
1010 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
1011 ' use it outside of block_recent_activity');
1015 * @deprecated since 2.5
1017 function delete_course_module() {
1018 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
1022 * @deprecated since 2.5
1024 function update_category_button() {
1025 throw new coding_exception('Function update_category_button() is removed. Pages to view '.
1026 'and edit courses are now separate and no longer depend on editing mode.');
1030 * @deprecated since 2.5
1032 function make_categories_list() {
1033 throw new coding_exception('Global function make_categories_list() is removed. Please use '.
1034 'core_course_category::make_categories_list() and core_course_category::get_parents()');
1038 * @deprecated since 2.5
1040 function category_delete_move() {
1041 throw new coding_exception('Function category_delete_move() is removed. Please use ' .
1042 'core_course_category::delete_move() instead.');
1046 * @deprecated since 2.5
1048 function category_delete_full() {
1049 throw new coding_exception('Function category_delete_full() is removed. Please use ' .
1050 'core_course_category::delete_full() instead.');
1054 * @deprecated since 2.5
1056 function move_category() {
1057 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.');
1061 * @deprecated since 2.5
1063 function course_category_hide() {
1064 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.');
1068 * @deprecated since 2.5
1070 function course_category_show() {
1071 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.');
1075 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or
1076 * core_course_category::get($catid, MUST_EXIST).
1078 function get_course_category() {
1079 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' .
1080 'see phpdocs for more details');
1084 * @deprecated since 2.5
1086 function create_course_category() {
1087 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' .
1088 'see phpdocs for more details');
1092 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children()
1094 function get_all_subcategories() {
1095 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '.
1096 'of core_course_category class. See phpdocs for more details');
1100 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children().
1102 function get_child_categories() {
1103 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' .
1104 'phpdocs for more details.');
1108 * @deprecated since 2.5
1110 function get_categories() {
1111 throw new coding_exception('Function get_categories() is removed. Please use ' .
1112 'appropriate functions from class core_course_category');
1116 * @deprecated since 2.5
1118 function print_course_search() {
1119 throw new coding_exception('Function print_course_search() is removed, please use course renderer');
1123 * @deprecated since 2.5
1125 function print_my_moodle() {
1126 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
1127 'function frontpage_my_courses()');
1131 * @deprecated since 2.5
1133 function print_remote_course() {
1134 throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
1138 * @deprecated since 2.5
1140 function print_remote_host() {
1141 throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
1145 * @deprecated since 2.5
1147 function print_whole_category_list() {
1148 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
1152 * @deprecated since 2.5
1154 function print_category_info() {
1155 throw new coding_exception('Function print_category_info() is removed, please use course renderer');
1159 * @deprecated since 2.5
1161 function get_course_category_tree() {
1162 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
1163 'renderer or core_course_category class, see function phpdocs for more info');
1167 * @deprecated since 2.5
1169 function print_courses() {
1170 throw new coding_exception('Function print_courses() is removed, please use course renderer');
1174 * @deprecated since 2.5
1176 function print_course() {
1177 throw new coding_exception('Function print_course() is removed, please use course renderer');
1181 * @deprecated since 2.5
1183 function get_category_courses_array() {
1184 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' .
1185 'core_course_category class');
1189 * @deprecated since 2.5
1191 function get_category_courses_array_recursively() {
1192 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' .
1193 'methods of core_course_category class', DEBUG_DEVELOPER);
1197 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
1199 function blog_get_context_url() {
1200 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
1204 * @deprecated since 2.5
1206 function get_courses_wmanagers() {
1207 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' .
1208 'core_course_category::get_courses()');
1212 * @deprecated since 2.5
1214 function convert_tree_to_html() {
1215 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
1219 * @deprecated since 2.5
1221 function convert_tabrows_to_tree() {
1222 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
1226 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
1228 function can_use_rotated_text() {
1229 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.');
1233 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
1235 function get_context_instance_by_id() {
1236 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
1240 * Returns system context or null if can not be created yet.
1242 * @see context_system::instance()
1243 * @deprecated since 2.2
1244 * @param bool $cache use caching
1245 * @return context system context (null if context table not created yet)
1247 function get_system_context($cache = true) {
1248 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
1249 return context_system::instance(0, IGNORE_MISSING, $cache);
1253 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
1255 function get_parent_contexts() {
1256 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
1260 * @deprecated since Moodle 2.2
1262 function get_parent_contextid() {
1263 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
1267 * @deprecated since 2.2
1269 function get_child_contexts() {
1270 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
1274 * @deprecated since 2.2
1276 function create_contexts() {
1277 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
1281 * @deprecated since 2.2
1283 function cleanup_contexts() {
1284 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.');
1288 * @deprecated since 2.2
1290 function build_context_path() {
1291 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
1295 * @deprecated since 2.2
1297 function rebuild_contexts() {
1298 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
1302 * @deprecated since Moodle 2.2
1304 function preload_course_contexts() {
1305 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
1309 * @deprecated since Moodle 2.2
1311 function context_moved() {
1312 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
1316 * @deprecated since 2.2
1318 function fetch_context_capabilities() {
1319 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
1323 * @deprecated since 2.2
1325 function context_instance_preload() {
1326 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
1330 * @deprecated since 2.2
1332 function get_contextlevel_name() {
1333 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
1337 * @deprecated since 2.2
1339 function print_context_name() {
1340 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
1344 * @deprecated since 2.2, use $context->mark_dirty() instead
1346 function mark_context_dirty() {
1347 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
1351 * @deprecated since Moodle 2.2
1353 function delete_context() {
1354 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
1355 'or $context->delete_content() instead.');
1359 * @deprecated since 2.2
1361 function get_context_url() {
1362 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
1366 * @deprecated since 2.2
1368 function get_course_context() {
1369 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
1373 * @deprecated since 2.2
1375 function get_user_courses_bycap() {
1376 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
1380 * @deprecated since Moodle 2.2
1382 function get_role_context_caps() {
1383 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
1387 * @deprecated since 2.2
1389 function get_courseid_from_context() {
1390 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
1394 * @deprecated since 2.2
1396 function context_instance_preload_sql() {
1397 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
1401 * @deprecated since 2.2
1403 function get_related_contexts_string() {
1404 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
1408 * @deprecated since 2.6
1410 function get_plugin_list_with_file() {
1411 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
1415 * @deprecated since 2.6
1417 function check_browser_operating_system() {
1418 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
1422 * @deprecated since 2.6
1424 function check_browser_version() {
1425 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
1429 * @deprecated since 2.6
1431 function get_device_type() {
1432 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.');
1436 * @deprecated since 2.6
1438 function get_device_type_list() {
1439 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
1443 * @deprecated since 2.6
1445 function get_selected_theme_for_device_type() {
1446 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
1450 * @deprecated since 2.6
1452 function get_device_cfg_var_name() {
1453 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
1457 * @deprecated since 2.6
1459 function set_user_device_type() {
1460 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
1464 * @deprecated since 2.6
1466 function get_user_device_type() {
1467 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.');
1471 * @deprecated since 2.6
1473 function get_browser_version_classes() {
1474 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.');
1478 * @deprecated since Moodle 2.6
1480 function generate_email_supportuser() {
1481 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
1485 * @deprecated since Moodle 2.6
1487 function badges_get_issued_badge_info() {
1488 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
1492 * @deprecated since 2.6
1494 function can_use_html_editor() {
1495 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.');
1500 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
1502 function count_login_failures() {
1503 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
1507 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
1509 function ajaxenabled() {
1510 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
1514 * @deprecated Since Moodle 2.7 MDL-44070
1516 function coursemodule_visible_for_user() {
1517 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
1518 please use \core_availability\info_module::is_user_visible()');
1522 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
1524 function enrol_cohort_get_cohorts() {
1525 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
1526 'cohort_get_available_cohorts() instead');
1530 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
1532 function enrol_cohort_can_view_cohort() {
1533 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
1537 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
1539 function cohort_get_visible_list() {
1540 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
1541 "that correctly checks capabilities.');
1545 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1547 function enrol_cohort_enrol_all_users() {
1548 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
1552 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1554 function enrol_cohort_search_cohorts() {
1555 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
1558 /* === Apis deprecated in since Moodle 2.9 === */
1561 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
1563 function message_current_user_is_involved() {
1564 throw new coding_exception('message_current_user_is_involved() can not be used any more.');
1568 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
1570 function profile_display_badges() {
1571 throw new coding_exception('profile_display_badges() can not be used any more.');
1575 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
1577 function useredit_shared_definition_preferences() {
1578 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
1583 * @deprecated since Moodle 2.9
1585 function calendar_normalize_tz() {
1586 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
1590 * @deprecated since Moodle 2.9
1592 function get_user_timezone_offset() {
1593 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1598 * @deprecated since Moodle 2.9
1600 function get_timezone_offset() {
1601 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1605 * @deprecated since Moodle 2.9
1607 function get_list_of_timezones() {
1608 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead');
1612 * @deprecated since Moodle 2.9
1614 function update_timezone_records() {
1615 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
1619 * @deprecated since Moodle 2.9
1621 function calculate_user_dst_table() {
1622 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
1626 * @deprecated since Moodle 2.9
1628 function dst_changes_for_year() {
1629 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
1633 * @deprecated since Moodle 2.9
1635 function get_timezone_record() {
1636 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
1639 /* === Apis deprecated since Moodle 3.0 === */
1641 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
1643 function get_referer() {
1644 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
1648 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
1650 function is_web_crawler() {
1651 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.');
1655 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
1657 function completion_cron() {
1658 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.');
1662 * @deprecated since 3.0
1664 function coursetag_get_tags() {
1665 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
1666 'Userid is no longer used for tagging courses.');
1670 * @deprecated since 3.0
1672 function coursetag_get_all_tags() {
1673 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
1674 'longer used for tagging courses.');
1678 * @deprecated since 3.0
1680 function coursetag_get_jscript() {
1681 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.');
1685 * @deprecated since 3.0
1687 function coursetag_get_jscript_links() {
1688 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
1692 * @deprecated since 3.0
1694 function coursetag_get_records() {
1695 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
1696 'Userid is no longer used for tagging courses.');
1700 * @deprecated since 3.0
1702 function coursetag_store_keywords() {
1703 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
1704 'Userid is no longer used for tagging courses.');
1708 * @deprecated since 3.0
1710 function coursetag_delete_keyword() {
1711 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
1712 'Userid is no longer used for tagging courses.');
1716 * @deprecated since 3.0
1718 function coursetag_get_tagged_courses() {
1719 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
1720 'Userid is no longer used for tagging courses.');
1724 * @deprecated since 3.0
1726 function coursetag_delete_course_tags() {
1727 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
1728 'Use core_tag_tag::remove_all_item_tags().');
1732 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1734 function tag_type_set() {
1735 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
1736 'core_tag_tag::get($tagid)->update().');
1740 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1742 function tag_description_set() {
1743 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
1744 'core_tag_tag::get($tagid)->update().');
1748 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1750 function tag_get_tags() {
1751 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
1752 'core_tag_tag::get_item_tags().');
1756 * @deprecated since 3.1
1758 function tag_get_tags_array() {
1759 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
1760 'core_tag_tag::get_item_tags_array().');
1764 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
1766 function tag_get_tags_csv() {
1767 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
1768 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1772 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1774 function tag_get_tags_ids() {
1775 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
1776 'core_tag_tag::get_item_tags() or similar methods.');
1780 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
1782 function tag_get_id() {
1783 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
1784 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
1788 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1790 function tag_rename() {
1791 throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
1792 'core_tag_tag::get($tagid)->update()');
1796 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
1798 function tag_delete_instance() {
1799 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
1800 'core_tag_tag::remove_item_tag()');
1804 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
1806 function tag_find_records() {
1807 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
1808 'core_tag_tag::get_by_name()->get_tagged_items()');
1812 * @deprecated since 3.1
1814 function tag_add() {
1815 throw new coding_exception('tag_add() can not be used anymore. You can use ' .
1816 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
1817 'created automatically when assigned to items');
1821 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
1823 function tag_assign() {
1824 throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
1825 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
1826 'ordering should not be set manually');
1830 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
1832 function tag_record_count() {
1833 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
1834 'core_tag_tag::get($tagid)->count_tagged_items().');
1838 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
1840 function tag_record_tagged_with() {
1841 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
1842 'core_tag_tag::get($tagid)->is_item_tagged_with().');
1846 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
1848 function tag_set_flag() {
1849 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
1850 'core_tag_tag::get($tagid)->flag()');
1854 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
1856 function tag_unset_flag() {
1857 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
1858 'core_tag_tag::get($tagid)->reset_flag()');
1862 * @deprecated since 3.1
1864 function tag_print_cloud() {
1865 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
1866 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
1867 'template core_tag/tagcloud.');
1871 * @deprecated since 3.0
1873 function tag_autocomplete() {
1874 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
1875 'element "tags" does proper autocomplete.');
1879 * @deprecated since 3.1
1881 function tag_print_description_box() {
1882 throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
1883 'See core_tag_renderer for similar code');
1887 * @deprecated since 3.1
1889 function tag_print_management_box() {
1890 throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
1891 'See core_tag_renderer for similar code');
1895 * @deprecated since 3.1
1897 function tag_print_search_box() {
1898 throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
1899 'See core_tag_renderer for similar code');
1903 * @deprecated since 3.1
1905 function tag_print_search_results() {
1906 throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
1907 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
1911 * @deprecated since 3.1
1913 function tag_print_tagged_users_table() {
1914 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
1915 'See core_user_renderer for similar code');
1919 * @deprecated since 3.1
1921 function tag_print_user_box() {
1922 throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
1923 'See core_user_renderer for similar code');
1927 * @deprecated since 3.1
1929 function tag_print_user_list() {
1930 throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
1931 'See core_user_renderer for similar code');
1935 * @deprecated since 3.1
1937 function tag_display_name() {
1938 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
1939 'core_tag_tag::make_display_name().');
1944 * @deprecated since 3.1
1946 function tag_normalize() {
1947 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
1948 'core_tag_tag::normalize().');
1952 * @deprecated since 3.1
1954 function tag_get_related_tags_csv() {
1955 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
1956 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1960 * @deprecated since 3.1
1962 function tag_set() {
1963 throw new coding_exception('tag_set() can not be used anymore. Please use ' .
1964 'core_tag_tag::set_item_tags().');
1968 * @deprecated since 3.1
1970 function tag_set_add() {
1971 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
1972 'core_tag_tag::add_item_tag().');
1976 * @deprecated since 3.1
1978 function tag_set_delete() {
1979 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
1980 'core_tag_tag::remove_item_tag().');
1984 * @deprecated since 3.1
1986 function tag_get() {
1987 throw new coding_exception('tag_get() can not be used anymore. Please use ' .
1988 'core_tag_tag::get() or core_tag_tag::get_by_name().');
1992 * @deprecated since 3.1
1994 function tag_get_related_tags() {
1995 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
1996 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
1997 'core_tag_tag::get_manual_related_tags().');
2001 * @deprecated since 3.1
2003 function tag_delete() {
2004 throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
2005 'core_tag_tag::delete_tags().');
2009 * @deprecated since 3.1
2011 function tag_delete_instances() {
2012 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
2013 'core_tag_tag::delete_instances().');
2017 * @deprecated since 3.1
2019 function tag_cleanup() {
2020 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
2021 '\core\task\tag_cron_task::cleanup().');
2025 * @deprecated since 3.1
2027 function tag_bulk_delete_instances() {
2028 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
2029 '\core\task\tag_cron_task::bulk_delete_instances().');
2034 * @deprecated since 3.1
2036 function tag_compute_correlations() {
2037 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
2038 'use \core\task\tag_cron_task::compute_correlations().');
2042 * @deprecated since 3.1
2044 function tag_process_computed_correlation() {
2045 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
2046 'use \core\task\tag_cron_task::process_computed_correlation().');
2050 * @deprecated since 3.1
2052 function tag_cron() {
2053 throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
2054 'use \core\task\tag_cron_task::execute().');
2058 * @deprecated since 3.1
2060 function tag_find_tags() {
2061 throw new coding_exception('tag_find_tags() can not be used anymore.');
2065 * @deprecated since 3.1
2067 function tag_get_name() {
2068 throw new coding_exception('tag_get_name() can not be used anymore.');
2072 * @deprecated since 3.1
2074 function tag_get_correlated() {
2075 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
2076 'use core_tag_tag::get_correlated_tags().');
2081 * @deprecated since 3.1
2083 function tag_cloud_sort() {
2084 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
2085 'be found in core_tag_collection::cloud_sort().');
2089 * @deprecated since Moodle 3.1
2091 function events_load_def() {
2092 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2097 * @deprecated since Moodle 3.1
2099 function events_queue_handler() {
2100 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2104 * @deprecated since Moodle 3.1
2106 function events_dispatch() {
2107 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2111 * @deprecated since Moodle 3.1
2113 function events_process_queued_handler() {
2114 throw new coding_exception(
2115 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
2120 * @deprecated since Moodle 3.1
2122 function events_update_definition() {
2123 throw new coding_exception(
2124 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
2129 * @deprecated since Moodle 3.1
2131 function events_cron() {
2132 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2136 * @deprecated since Moodle 3.1
2138 function events_trigger_legacy() {
2139 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2143 * @deprecated since Moodle 3.1
2145 function events_is_registered() {
2146 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2150 * @deprecated since Moodle 3.1
2152 function events_pending_count() {
2153 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2157 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2159 function clam_message_admins() {
2160 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
2161 'message_admins() method of \antivirus_clamav\scanner class.');
2165 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2167 function get_clam_error_code() {
2168 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
2169 'get_clam_error_code() method of \antivirus_clamav\scanner class.');
2173 * @deprecated since 3.1
2175 function course_get_cm_rename_action() {
2176 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
2177 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
2182 * @deprecated since Moodle 3.1
2184 function course_scale_used() {
2185 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
2186 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2190 * @deprecated since Moodle 3.1
2192 function site_scale_used() {
2193 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
2194 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2198 * @deprecated since Moodle 3.1. Use external_api::external_function_info().
2200 function external_function_info() {
2201 throw new coding_exception('external_function_info() can not be used any'.
2202 'more. Please use external_api::external_function_info() instead.');
2206 * @deprecated since Moodle 3.2
2207 * @see csv_import_reader::load_csv_content()
2209 function get_records_csv() {
2210 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' .
2211 'lib/csvlib.class.php csv_import_reader() instead.');
2215 * @deprecated since Moodle 3.2
2216 * @see download_as_dataformat (lib/dataformatlib.php)
2218 function put_records_csv() {
2219 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' .
2220 'lib/dataformatlib.php download_as_dataformat() instead.');
2224 * @deprecated since Moodle 3.2
2226 function css_is_colour() {
2227 throw new coding_exception('css_is_colour() can not be used anymore.');
2231 * @deprecated since Moodle 3.2
2233 function css_is_width() {
2234 throw new coding_exception('css_is_width() can not be used anymore.');
2238 * @deprecated since Moodle 3.2
2240 function css_sort_by_count() {
2241 throw new coding_exception('css_sort_by_count() can not be used anymore.');
2245 * @deprecated since Moodle 3.2
2247 function message_get_course_contexts() {
2248 throw new coding_exception('message_get_course_contexts() can not be used anymore.');
2252 * @deprecated since Moodle 3.2
2254 function message_remove_url_params() {
2255 throw new coding_exception('message_remove_url_params() can not be used anymore.');
2259 * @deprecated since Moodle 3.2
2261 function message_count_messages() {
2262 throw new coding_exception('message_count_messages() can not be used anymore.');
2266 * @deprecated since Moodle 3.2
2268 function message_count_blocked_users() {
2269 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' .
2270 '\core_message\api::count_blocked_users() instead.');
2274 * @deprecated since Moodle 3.2
2276 function message_contact_link() {
2277 throw new coding_exception('message_contact_link() can not be used anymore.');
2281 * @deprecated since Moodle 3.2
2283 function message_get_recent_notifications() {
2284 throw new coding_exception('message_get_recent_notifications() can not be used anymore.');
2288 * @deprecated since Moodle 3.2
2290 function message_history_link() {
2291 throw new coding_exception('message_history_link() can not be used anymore.');
2295 * @deprecated since Moodle 3.2
2297 function message_search() {
2298 throw new coding_exception('message_search() can not be used anymore.');
2302 * @deprecated since Moodle 3.2
2304 function message_shorten_message() {
2305 throw new coding_exception('message_shorten_message() can not be used anymore.');
2309 * @deprecated since Moodle 3.2
2311 function message_get_fragment() {
2312 throw new coding_exception('message_get_fragment() can not be used anymore.');
2316 * @deprecated since Moodle 3.2
2318 function message_get_history() {
2319 throw new coding_exception('message_get_history() can not be used anymore.');
2323 * @deprecated since Moodle 3.2
2325 function message_get_contact_add_remove_link() {
2326 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.');
2330 * @deprecated since Moodle 3.2
2332 function message_get_contact_block_link() {
2333 throw new coding_exception('message_get_contact_block_link() can not be used anymore.');
2337 * @deprecated since Moodle 3.2
2339 function message_mark_messages_read() {
2340 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' .
2341 '\core_message\api::mark_all_messages_as_read() instead.');
2345 * @deprecated since Moodle 3.2
2347 function message_can_post_message() {
2348 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' .
2349 '\core_message\api::can_send_message() instead.');
2353 * @deprecated since Moodle 3.2
2355 function message_is_user_non_contact_blocked() {
2356 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' .
2357 '\core_message\api::is_user_non_contact_blocked() instead.');
2361 * @deprecated since Moodle 3.2
2363 function message_is_user_blocked() {
2364 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' .
2365 '\core_message\api::is_user_blocked() instead.');
2369 * @deprecated since Moodle 3.2
2371 function print_log() {
2372 throw new coding_exception('print_log() can not be used anymore. Please use the ' .
2373 'report_log framework instead.');
2377 * @deprecated since Moodle 3.2
2379 function print_mnet_log() {
2380 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' .
2381 'report_log framework instead.');
2385 * @deprecated since Moodle 3.2
2387 function print_log_csv() {
2388 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' .
2389 'report_log framework instead.');
2393 * @deprecated since Moodle 3.2
2395 function print_log_xls() {
2396 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' .
2397 'report_log framework instead.');
2401 * @deprecated since Moodle 3.2
2403 function print_log_ods() {
2404 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' .
2405 'report_log framework instead.');
2409 * @deprecated since Moodle 3.2
2411 function build_logs_array() {
2412 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' .
2413 'report_log framework instead.');
2417 * @deprecated since Moodle 3.2
2419 function get_logs_usercourse() {
2420 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' .
2421 'report_log framework instead.');
2425 * @deprecated since Moodle 3.2
2427 function get_logs_userday() {
2428 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' .
2429 'report_log framework instead.');
2433 * @deprecated since Moodle 3.2
2435 function get_logs() {
2436 throw new coding_exception('get_logs() can not be used anymore. Please use the ' .
2437 'report_log framework instead.');
2441 * @deprecated since Moodle 3.2
2443 function prevent_form_autofill_password() {
2444 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.');
2448 * @deprecated since Moodle 3.3 MDL-57370
2450 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) {
2451 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' .
2452 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER);
2456 * @deprecated since Moodle 3.2
2458 function calendar_preferences_button() {
2459 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' .
2460 'preferences are now linked to the user preferences page.');
2464 * @deprecated since 3.3
2466 function calendar_wday_name() {
2467 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.');
2471 * @deprecated since 3.3
2473 function calendar_get_block_upcoming() {
2474 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' .
2475 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2479 * @deprecated since 3.3
2481 function calendar_print_month_selector() {
2482 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.');
2486 * @deprecated since 3.3
2488 function calendar_cron() {
2489 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.');
2493 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2495 function load_course_context() {
2496 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
2500 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2502 function load_role_access_by_context() {
2503 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
2507 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2509 function dedupe_user_access() {
2510 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
2514 * @deprecated since Moodle 3.4. MDL-49398.
2516 function get_user_access_sitewide() {
2517 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.');
2521 * @deprecated since Moodle 3.4. MDL-59333
2523 function calendar_get_mini() {
2524 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.');
2528 * @deprecated since Moodle 3.4. MDL-59333
2530 function calendar_get_upcoming() {
2531 throw new coding_exception('calendar_get_upcoming() has been removed. ' .
2532 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2536 * @deprecated since Moodle 3.4. MDL-50666
2538 function allow_override() {
2539 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.');
2543 * @deprecated since Moodle 3.4. MDL-50666
2545 function allow_assign() {
2546 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.');
2550 * @deprecated since Moodle 3.4. MDL-50666
2552 function allow_switch() {
2553 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.');
2557 * @deprecated since Moodle 3.5. MDL-61132
2559 function question_add_tops() {
2560 throw new coding_exception(
2561 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().'
2566 * @deprecated since Moodle 3.5. MDL-61132
2568 function question_is_only_toplevel_category_in_context() {
2569 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. '
2570 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.');
2574 * @deprecated since Moodle 3.5
2576 function message_move_userfrom_unread2read() {
2577 throw new coding_exception('message_move_userfrom_unread2read() has been removed.');
2581 * @deprecated since Moodle 3.5
2583 function message_get_blocked_users() {
2584 throw new coding_exception(
2585 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.'
2590 * @deprecated since Moodle 3.5
2592 function message_get_contacts() {
2593 throw new coding_exception('message_get_contacts() has been removed.');
2597 * @deprecated since Moodle 3.5
2599 function message_mark_message_read() {
2600 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read()
2601 or \core_message\api::mark_notification_as_read().');
2605 * @deprecated since Moodle 3.5
2607 function message_can_delete_message() {
2608 throw new coding_exception(
2609 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.'
2614 * @deprecated since Moodle 3.5
2616 function message_delete_message() {
2617 throw new coding_exception(
2618 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.'
2623 * @deprecated since 3.6
2625 function calendar_get_all_allowed_types() {
2626 throw new coding_exception(
2627 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.'
2633 * @deprecated since Moodle 3.6.
2635 function groups_get_all_groups_for_courses() {
2636 throw new coding_exception(
2637 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.'
2642 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2644 function events_get_cached() {
2645 throw new coding_exception(
2646 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2651 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2653 function events_uninstall() {
2654 throw new coding_exception(
2655 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2660 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2662 function events_cleanup() {
2663 throw new coding_exception(
2664 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2669 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2671 function events_dequeue() {
2672 throw new coding_exception(
2673 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2678 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2680 function events_get_handlers() {
2681 throw new coding_exception(
2682 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2687 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2689 function get_roles_on_exact_context() {
2690 throw new coding_exception(
2691 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.'
2696 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2698 function get_roles_with_assignment_on_context() {
2699 throw new coding_exception(
2700 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.'
2705 * @deprecated since Moodle 3.6
2707 function message_add_contact() {
2708 throw new coding_exception(
2709 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' .
2710 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' .
2711 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.'
2716 * @deprecated since Moodle 3.6
2718 function message_remove_contact() {
2719 throw new coding_exception(
2720 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.'
2725 * @deprecated since Moodle 3.6
2727 function message_unblock_contact() {
2728 throw new coding_exception(
2729 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.'
2734 * @deprecated since Moodle 3.6
2736 function message_block_contact() {
2737 throw new coding_exception(
2738 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' .
2739 '\core_message\api::block_user() instead.'
2744 * @deprecated since Moodle 3.6
2746 function message_get_contact() {
2747 throw new coding_exception(
2748 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.'
2753 * @deprecated since Moodle 3.7
2755 function get_courses_page() {
2756 throw new coding_exception(
2757 'Function get_courses_page() has been removed. Please use core_course_category::get_courses() ' .
2758 'or core_course_category::search_courses()'
2763 * @deprecated since Moodle 3.8
2765 function report_insights_context_insights(\context $context) {
2766 throw new coding_exception(
2767 'Function report_insights_context_insights() ' .
2768 'has been removed. Please use \core_analytics\manager::cached_models_with_insights instead'
2773 * @deprecated since 3.9
2775 function get_module_metadata() {
2776 throw new coding_exception(
2777 'get_module_metadata() has been removed. Please use \core_course\local\service\content_item_service instead.');
2781 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task).
2783 function cron_run_single_task() {
2784 throw new coding_exception(
2785 'cron_run_single_task() has been removed. Please use \\core\task\manager::run_from_cli() instead.'
2790 * Executes cron functions for a specific type of plugin.
2792 * @param string $plugintype Plugin type (e.g. 'report')
2793 * @param string $description If specified, will display 'Starting (whatever)'
2794 * and 'Finished (whatever)' lines, otherwise does not display
2796 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2797 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2799 function cron_execute_plugin_type($plugintype, $description = null) {
2800 global $DB;
2802 // Get list from plugin => function for all plugins.
2803 $plugins = get_plugin_list_with_function($plugintype, 'cron');
2805 // Modify list for backward compatibility (different files/names).
2806 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins);
2808 // Return if no plugins with cron function to process.
2809 if (!$plugins) {
2810 return;
2813 if ($description) {
2814 mtrace('Starting '.$description);
2817 foreach ($plugins as $component => $cronfunction) {
2818 $dir = core_component::get_component_directory($component);
2820 // Get cron period if specified in version.php, otherwise assume every cron.
2821 $cronperiod = 0;
2822 if (file_exists("$dir/version.php")) {
2823 $plugin = new stdClass();
2824 include("$dir/version.php");
2825 if (isset($plugin->cron)) {
2826 $cronperiod = $plugin->cron;
2830 // Using last cron and cron period, don't run if it already ran recently.
2831 $lastcron = get_config($component, 'lastcron');
2832 if ($cronperiod && $lastcron) {
2833 if ($lastcron + $cronperiod > time()) {
2834 // Do not execute cron yet.
2835 continue;
2839 mtrace('Processing cron function for ' . $component . '...');
2840 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER);
2841 \core\cron::trace_time_and_memory();
2842 $pre_dbqueries = $DB->perf_get_queries();
2843 $pre_time = microtime(true);
2845 $cronfunction();
2847 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " .
2848 round(microtime(true) - $pre_time, 2) . " seconds)");
2850 set_config('lastcron', time(), $component);
2851 core_php_time_limit::raise();
2854 if ($description) {
2855 mtrace('Finished ' . $description);
2860 * Used to add in old-style cron functions within plugins that have not been converted to the
2861 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used
2862 * cron.php and some used a different name.)
2864 * @param string $plugintype Plugin type e.g. 'report'
2865 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g.
2866 * 'report_frog_cron') for plugin cron functions that were already found using the new API
2867 * @return array Revised version of $plugins that adds in any extra plugin functions found by
2868 * looking in the older location
2870 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2871 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2873 function cron_bc_hack_plugin_functions($plugintype, $plugins) {
2874 global $CFG; // Mandatory in case it is referenced by include()d PHP script.
2876 if ($plugintype === 'report') {
2877 // Admin reports only - not course report because course report was
2878 // never implemented before, so doesn't need BC.
2879 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
2880 $component = $plugintype . '_' . $pluginname;
2881 if (isset($plugins[$component])) {
2882 // We already have detected the function using the new API.
2883 continue;
2885 if (!file_exists("$dir/cron.php")) {
2886 // No old style cron file present.
2887 continue;
2889 include_once("$dir/cron.php");
2890 $cronfunction = $component . '_cron';
2891 if (function_exists($cronfunction)) {
2892 $plugins[$component] = $cronfunction;
2893 } else {
2894 debugging("Invalid legacy cron.php detected in $component, " .
2895 "please use lib.php instead");
2898 } else if (strpos($plugintype, 'grade') === 0) {
2899 // Detect old style cron function names.
2900 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of
2901 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport.
2902 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
2903 $component = $plugintype.'_'.$pluginname;
2904 if (isset($plugins[$component])) {
2905 // We already have detected the function using the new API.
2906 continue;
2908 if (!file_exists("$dir/lib.php")) {
2909 continue;
2911 include_once("$dir/lib.php");
2912 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' .
2913 $pluginname . '_cron';
2914 if (function_exists($cronfunction)) {
2915 $plugins[$component] = $cronfunction;
2920 return $plugins;
2924 * Returns the SQL used by the participants table.
2926 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
2927 * @param int $courseid The course id
2928 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
2929 * @param int $accesssince The time since last access, 0 means any time
2930 * @param int $roleid The role id, 0 means all roles and -1 no roles
2931 * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned.
2932 * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed.
2933 * @param string|array $search The search that was performed, empty means perform no search
2934 * @param string $additionalwhere Any additional SQL to add to where
2935 * @param array $additionalparams The additional params
2936 * @return array
2938 function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
2939 $search = '', $additionalwhere = '', $additionalparams = array()) {
2940 global $DB, $USER, $CFG;
2942 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
2943 'Please use \core\table\participants_search::class with table filtersets instead.';
2944 debugging($deprecatedtext, DEBUG_DEVELOPER);
2946 // Get the context.
2947 $context = \context_course::instance($courseid, MUST_EXIST);
2949 $isfrontpage = ($courseid == SITEID);
2951 // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments.
2952 $onlyactive = true;
2953 $onlysuspended = false;
2954 if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) {
2955 switch ($statusid) {
2956 case ENROL_USER_ACTIVE:
2957 // Nothing to do here.
2958 break;
2959 case ENROL_USER_SUSPENDED:
2960 $onlyactive = false;
2961 $onlysuspended = true;
2962 break;
2963 default:
2964 // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false.
2965 $onlyactive = false;
2966 break;
2970 list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid);
2972 $joins = array('FROM {user} u');
2973 $wheres = array();
2975 // TODO Does not support custom user profile fields (MDL-70456).
2976 $userfields = \core_user\fields::get_identity_fields($context, false);
2977 $userfieldsapi = \core_user\fields::for_userpic()->including(...$userfields);
2978 $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
2980 if ($isfrontpage) {
2981 $select = "SELECT $userfieldssql, u.lastaccess";
2982 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually.
2983 if ($accesssince) {
2984 $wheres[] = user_get_user_lastaccess_sql($accesssince);
2986 } else {
2987 $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess";
2988 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only.
2989 // Not everybody has accessed the course yet.
2990 $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)';
2991 $params['courseid'] = $courseid;
2992 if ($accesssince) {
2993 $wheres[] = user_get_course_lastaccess_sql($accesssince);
2997 // Performance hacks - we preload user contexts together with accounts.
2998 $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
2999 $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)';
3000 $params['contextlevel'] = CONTEXT_USER;
3001 $select .= $ccselect;
3002 $joins[] = $ccjoin;
3004 // Limit list to users with some role only.
3005 if ($roleid) {
3006 // We want to query both the current context and parent contexts.
3007 list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true),
3008 SQL_PARAMS_NAMED, 'relatedctx');
3010 // Get users without any role.
3011 if ($roleid == -1) {
3012 $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)";
3013 $params = array_merge($params, $relatedctxparams);
3014 } else {
3015 $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
3016 $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
3020 if (!empty($search)) {
3021 if (!is_array($search)) {
3022 $search = [$search];
3024 foreach ($search as $index => $keyword) {
3025 $searchkey1 = 'search' . $index . '1';
3026 $searchkey2 = 'search' . $index . '2';
3027 $searchkey3 = 'search' . $index . '3';
3028 $searchkey4 = 'search' . $index . '4';
3029 $searchkey5 = 'search' . $index . '5';
3030 $searchkey6 = 'search' . $index . '6';
3031 $searchkey7 = 'search' . $index . '7';
3033 $conditions = array();
3034 // Search by fullname.
3035 $fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
3036 $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false);
3038 // Search by email.
3039 $email = $DB->sql_like('email', ':' . $searchkey2, false, false);
3040 if (!in_array('email', $userfields)) {
3041 $maildisplay = 'maildisplay' . $index;
3042 $userid1 = 'userid' . $index . '1';
3043 // Prevent users who hide their email address from being found by others
3044 // who aren't allowed to see hidden email addresses.
3045 $email = "(". $email ." AND (" .
3046 "u.maildisplay <> :$maildisplay " .
3047 "OR u.id = :$userid1". // User can always find himself.
3048 "))";
3049 $params[$maildisplay] = core_user::MAILDISPLAY_HIDE;
3050 $params[$userid1] = $USER->id;
3052 $conditions[] = $email;
3054 // Search by idnumber.
3055 $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false);
3056 if (!in_array('idnumber', $userfields)) {
3057 $userid2 = 'userid' . $index . '2';
3058 // Users who aren't allowed to see idnumbers should at most find themselves
3059 // when searching for an idnumber.
3060 $idnumber = "(". $idnumber . " AND u.id = :$userid2)";
3061 $params[$userid2] = $USER->id;
3063 $conditions[] = $idnumber;
3065 // TODO Does not support custom user profile fields (MDL-70456).
3066 $extrasearchfields = \core_user\fields::get_identity_fields($context, false);
3067 if (!empty($extrasearchfields)) {
3068 // Search all user identify fields.
3069 foreach ($extrasearchfields as $extrasearchfield) {
3070 if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) {
3071 // Already covered above. Search by country not supported.
3072 continue;
3074 $param = $searchkey3 . $extrasearchfield;
3075 $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false);
3076 $params[$param] = "%$keyword%";
3077 if (!in_array($extrasearchfield, $userfields)) {
3078 // User cannot see this field, but allow match if their own account.
3079 $userid3 = 'userid' . $index . '3' . $extrasearchfield;
3080 $condition = "(". $condition . " AND u.id = :$userid3)";
3081 $params[$userid3] = $USER->id;
3083 $conditions[] = $condition;
3087 // Search by middlename.
3088 $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false);
3089 $conditions[] = $middlename;
3091 // Search by alternatename.
3092 $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false);
3093 $conditions[] = $alternatename;
3095 // Search by firstnamephonetic.
3096 $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false);
3097 $conditions[] = $firstnamephonetic;
3099 // Search by lastnamephonetic.
3100 $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false);
3101 $conditions[] = $lastnamephonetic;
3103 $wheres[] = "(". implode(" OR ", $conditions) .") ";
3104 $params[$searchkey1] = "%$keyword%";
3105 $params[$searchkey2] = "%$keyword%";
3106 $params[$searchkey3] = "%$keyword%";
3107 $params[$searchkey4] = "%$keyword%";
3108 $params[$searchkey5] = "%$keyword%";
3109 $params[$searchkey6] = "%$keyword%";
3110 $params[$searchkey7] = "%$keyword%";
3114 if (!empty($additionalwhere)) {
3115 $wheres[] = $additionalwhere;
3116 $params = array_merge($params, $additionalparams);
3119 $from = implode("\n", $joins);
3120 if ($wheres) {
3121 $where = 'WHERE ' . implode(' AND ', $wheres);
3122 } else {
3123 $where = '';
3126 return array($select, $from, $where, $params);
3130 * Returns the total number of participants for a given course.
3132 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3133 * @param int $courseid The course id
3134 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3135 * @param int $accesssince The time since last access, 0 means any time
3136 * @param int $roleid The role id, 0 means all roles
3137 * @param int $enrolid The applied filter for the user enrolment ID.
3138 * @param int $status The applied filter for the user's enrolment status.
3139 * @param string|array $search The search that was performed, empty means perform no search
3140 * @param string $additionalwhere Any additional SQL to add to where
3141 * @param array $additionalparams The additional params
3142 * @return int
3144 function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3145 $search = '', $additionalwhere = '', $additionalparams = array()) {
3146 global $DB;
3148 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3149 'Please use \core\table\participants_search::class with table filtersets instead.';
3150 debugging($deprecatedtext, DEBUG_DEVELOPER);
3152 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3153 $statusid, $search, $additionalwhere, $additionalparams);
3155 return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
3159 * Returns the participants for a given course.
3161 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3162 * @param int $courseid The course id
3163 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3164 * @param int $accesssince The time since last access
3165 * @param int $roleid The role id
3166 * @param int $enrolid The applied filter for the user enrolment ID.
3167 * @param int $status The applied filter for the user's enrolment status.
3168 * @param string $search The search that was performed
3169 * @param string $additionalwhere Any additional SQL to add to where
3170 * @param array $additionalparams The additional params
3171 * @param string $sort The SQL sort
3172 * @param int $limitfrom return a subset of records, starting at this point (optional).
3173 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
3174 * @return moodle_recordset
3176 function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enrolid, $statusid, $search,
3177 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) {
3178 global $DB;
3180 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3181 'Please use \core\table\participants_search::class with table filtersets instead.';
3182 debugging($deprecatedtext, DEBUG_DEVELOPER);
3184 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3185 $statusid, $search, $additionalwhere, $additionalparams);
3187 return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
3191 * @deprecated Since Moodle 3.9. MDL-65835
3193 function plagiarism_save_form_elements() {
3194 throw new coding_exception(
3195 'Function plagiarism_save_form_elements() has been removed. ' .
3196 'Please use {plugin name}_coursemodule_edit_post_actions() instead.'
3201 * @deprecated Since Moodle 3.9. MDL-65835
3203 function plagiarism_get_form_elements_module() {
3204 throw new coding_exception(
3205 'Function plagiarism_get_form_elements_module() has been removed. ' .
3206 'Please use {plugin name}_coursemodule_standard_elements() instead.'
3212 * @deprecated since Moodle 3.10
3214 function make_categories_options() {
3215 throw new coding_exception(__FUNCTION__ . '() has been removed. ' .
3216 'Please use \core_course_category::make_categories_list() instead.');
3220 * @deprecated since 3.10
3222 function message_count_unread_messages() {
3223 throw new coding_exception('message_count_unread_messages has been removed.');
3227 * @deprecated since 3.10
3229 function serialise_tool_proxy() {
3230 throw new coding_exception('serialise_tool_proxy has been removed.');
3234 * Checks if current user is shown any extra fields when listing users.
3236 * Does not include any custom profile fields.
3238 * @param object $context Context
3239 * @param array $already Array of fields that we're going to show anyway
3240 * so don't bother listing them
3241 * @return array Array of field names from user table, not including anything
3242 * listed in $already
3243 * @deprecated since Moodle 3.11 MDL-45242
3244 * @see \core_user\fields
3246 function get_extra_user_fields($context, $already = array()) {
3247 debugging('get_extra_user_fields() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3249 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3250 return $fields->get_required_fields();
3254 * If the current user is to be shown extra user fields when listing or
3255 * selecting users, returns a string suitable for including in an SQL select
3256 * clause to retrieve those fields.
3258 * Does not include any custom profile fields.
3260 * @param context $context Context
3261 * @param string $alias Alias of user table, e.g. 'u' (default none)
3262 * @param string $prefix Prefix for field names using AS, e.g. 'u_' (default none)
3263 * @param array $already Array of fields that we're going to include anyway so don't list them (default none)
3264 * @return string Partial SQL select clause, beginning with comma, for example ',u.idnumber,u.department' unless it is blank
3265 * @deprecated since Moodle 3.11 MDL-45242
3266 * @see \core_user\fields
3268 function get_extra_user_fields_sql($context, $alias='', $prefix='', $already = array()) {
3269 debugging('get_extra_user_fields_sql() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3271 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3272 // Note: There will never be any joins or join params because we turned off profile fields.
3273 $selects = $fields->get_sql($alias, false, $prefix)->selects;
3275 return $selects;
3279 * Returns the display name of a field in the user table. Works for most fields that are commonly displayed to users.
3281 * Also works for custom fields.
3283 * @param string $field Field name, e.g. 'phone1'
3284 * @return string Text description taken from language file, e.g. 'Phone number'
3285 * @deprecated since Moodle 3.11 MDL-45242
3286 * @see \core_user\fields
3288 function get_user_field_name($field) {
3289 debugging('get_user_field_name() is deprecated. Please use \core_user\fields::get_display_name() instead', DEBUG_DEVELOPER);
3291 return \core_user\fields::get_display_name($field);
3295 * A centralised location for the all name fields. Returns an array / sql string snippet.
3297 * @param bool $returnsql True for an sql select field snippet.
3298 * @param string $tableprefix table query prefix to use in front of each field.
3299 * @param string $prefix prefix added to the name fields e.g. authorfirstname.
3300 * @param string $fieldprefix sql field prefix e.g. id AS userid.
3301 * @param bool $order moves firstname and lastname to the top of the array / start of the string.
3302 * @return array|string All name fields.
3303 * @deprecated since Moodle 3.11 MDL-45242
3304 * @see \core_user\fields
3306 function get_all_user_name_fields($returnsql = false, $tableprefix = null, $prefix = null, $fieldprefix = null, $order = false) {
3307 debugging('get_all_user_name_fields() is deprecated. Please use the \core_user\fields API instead', DEBUG_DEVELOPER);
3309 // This array is provided in this order because when called by fullname() (above) if firstname is before
3310 // firstnamephonetic str_replace() will change the wrong placeholder.
3311 $alternatenames = [];
3312 foreach (\core_user\fields::get_name_fields() as $field) {
3313 $alternatenames[$field] = $field;
3316 // Let's add a prefix to the array of user name fields if provided.
3317 if ($prefix) {
3318 foreach ($alternatenames as $key => $altname) {
3319 $alternatenames[$key] = $prefix . $altname;
3323 // If we want the end result to have firstname and lastname at the front / top of the result.
3324 if ($order) {
3325 // Move the last two elements (firstname, lastname) off the array and put them at the top.
3326 for ($i = 0; $i < 2; $i++) {
3327 // Get the last element.
3328 $lastelement = end($alternatenames);
3329 // Remove it from the array.
3330 unset($alternatenames[$lastelement]);
3331 // Put the element back on the top of the array.
3332 $alternatenames = array_merge(array($lastelement => $lastelement), $alternatenames);
3336 // Create an sql field snippet if requested.
3337 if ($returnsql) {
3338 if ($tableprefix) {
3339 if ($fieldprefix) {
3340 foreach ($alternatenames as $key => $altname) {
3341 $alternatenames[$key] = $tableprefix . '.' . $altname . ' AS ' . $fieldprefix . $altname;
3343 } else {
3344 foreach ($alternatenames as $key => $altname) {
3345 $alternatenames[$key] = $tableprefix . '.' . $altname;
3349 $alternatenames = implode(',', $alternatenames);
3351 return $alternatenames;
3355 * Update a subscription from the form data in one of the rows in the existing subscriptions table.
3357 * @param int $subscriptionid The ID of the subscription we are acting upon.
3358 * @param int $pollinterval The poll interval to use.
3359 * @param int $action The action to be performed. One of update or remove.
3360 * @throws dml_exception if invalid subscriptionid is provided
3361 * @return string A log of the import progress, including errors
3362 * @deprecated since Moodle 4.0 MDL-71953
3364 function calendar_process_subscription_row($subscriptionid, $pollinterval, $action) {
3365 debugging('calendar_process_subscription_row() is deprecated.', DEBUG_DEVELOPER);
3366 // Fetch the subscription from the database making sure it exists.
3367 $sub = calendar_get_subscription($subscriptionid);
3369 // Update or remove the subscription, based on action.
3370 switch ($action) {
3371 case CALENDAR_SUBSCRIPTION_UPDATE:
3372 // Skip updating file subscriptions.
3373 if (empty($sub->url)) {
3374 break;
3376 $sub->pollinterval = $pollinterval;
3377 calendar_update_subscription($sub);
3379 // Update the events.
3380 return "<p>" . get_string('subscriptionupdated', 'calendar', $sub->name) . "</p>" .
3381 calendar_update_subscription_events($subscriptionid);
3382 case CALENDAR_SUBSCRIPTION_REMOVE:
3383 calendar_delete_subscription($subscriptionid);
3384 return get_string('subscriptionremoved', 'calendar', $sub->name);
3385 break;
3386 default:
3387 break;
3389 return '';
3393 * Import events from an iCalendar object into a course calendar.
3395 * @param iCalendar $ical The iCalendar object.
3396 * @param int $unused Deprecated
3397 * @param int $subscriptionid The subscription ID.
3398 * @return string A log of the import progress, including errors.
3400 function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid = null) {
3401 debugging('calendar_import_icalendar_events() is deprecated. Please use calendar_import_events_from_ical() instead.',
3402 DEBUG_DEVELOPER);
3403 global $DB;
3405 $return = '';
3406 $eventcount = 0;
3407 $updatecount = 0;
3408 $skippedcount = 0;
3410 // Large calendars take a while...
3411 if (!CLI_SCRIPT) {
3412 \core_php_time_limit::raise(300);
3415 // Grab the timezone from the iCalendar file to be used later.
3416 if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) {
3417 $timezone = $ical->properties['X-WR-TIMEZONE'][0]->value;
3418 } else {
3419 $timezone = 'UTC';
3422 $icaluuids = [];
3423 foreach ($ical->components['VEVENT'] as $event) {
3424 $icaluuids[] = $event->properties['UID'][0]->value;
3425 $res = calendar_add_icalendar_event($event, null, $subscriptionid, $timezone);
3426 switch ($res) {
3427 case CALENDAR_IMPORT_EVENT_UPDATED:
3428 $updatecount++;
3429 break;
3430 case CALENDAR_IMPORT_EVENT_INSERTED:
3431 $eventcount++;
3432 break;
3433 case CALENDAR_IMPORT_EVENT_SKIPPED:
3434 $skippedcount++;
3435 break;
3436 case 0:
3437 $return .= '<p>' . get_string('erroraddingevent', 'calendar') . ': ';
3438 if (empty($event->properties['SUMMARY'])) {
3439 $return .= '(' . get_string('notitle', 'calendar') . ')';
3440 } else {
3441 $return .= $event->properties['SUMMARY'][0]->value;
3443 $return .= "</p>\n";
3444 break;
3448 $return .= html_writer::start_tag('ul');
3449 $existing = $DB->get_field('event_subscriptions', 'lastupdated', ['id' => $subscriptionid]);
3450 if (!empty($existing)) {
3451 $eventsuuids = $DB->get_records_menu('event', ['subscriptionid' => $subscriptionid], '', 'id, uuid');
3453 $icaleventscount = count($icaluuids);
3454 $tobedeleted = [];
3455 if (count($eventsuuids) > $icaleventscount) {
3456 foreach ($eventsuuids as $eventid => $eventuuid) {
3457 if (!in_array($eventuuid, $icaluuids)) {
3458 $tobedeleted[] = $eventid;
3461 if (!empty($tobedeleted)) {
3462 $DB->delete_records_list('event', 'id', $tobedeleted);
3463 $return .= html_writer::tag('li', get_string('eventsdeleted', 'calendar', count($tobedeleted)));
3468 $return .= html_writer::tag('li', get_string('eventsimported', 'calendar', $eventcount));
3469 $return .= html_writer::tag('li', get_string('eventsskipped', 'calendar', $skippedcount));
3470 $return .= html_writer::tag('li', get_string('eventsupdated', 'calendar', $updatecount));
3471 $return .= html_writer::end_tag('ul');
3472 return $return;
3476 * Print grading plugin selection tab-based navigation.
3478 * @deprecated since Moodle 4.0. Tabs navigation has been replaced with tertiary navigation.
3479 * @param string $active_type type of plugin on current page - import, export, report or edit
3480 * @param string $active_plugin active plugin type - grader, user, cvs, ...
3481 * @param array $plugin_info Array of plugins
3482 * @param boolean $return return as string
3484 * @return nothing or string if $return true
3486 function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false) {
3487 global $CFG, $COURSE;
3489 debugging('grade_print_tabs() has been deprecated. Tabs navigation has been replaced with tertiary navigation.',
3490 DEBUG_DEVELOPER);
3492 if (!isset($currenttab)) { //TODO: this is weird
3493 $currenttab = '';
3496 $tabs = array();
3497 $top_row = array();
3498 $bottom_row = array();
3499 $inactive = array($active_plugin);
3500 $activated = array($active_type);
3502 $count = 0;
3503 $active = '';
3505 foreach ($plugin_info as $plugin_type => $plugins) {
3506 if ($plugin_type == 'strings') {
3507 continue;
3510 // If $plugins is actually the definition of a child-less parent link:
3511 if (!empty($plugins->id)) {
3512 $string = $plugins->string;
3513 if (!empty($plugin_info[$active_type]->parent)) {
3514 $string = $plugin_info[$active_type]->parent->string;
3517 $top_row[] = new tabobject($plugin_type, $plugins->link, $string);
3518 continue;
3521 $first_plugin = reset($plugins);
3522 $url = $first_plugin->link;
3524 if ($plugin_type == 'report') {
3525 $url = $CFG->wwwroot.'/grade/report/index.php?id='.$COURSE->id;
3528 $top_row[] = new tabobject($plugin_type, $url, $plugin_info['strings'][$plugin_type]);
3530 if ($active_type == $plugin_type) {
3531 foreach ($plugins as $plugin) {
3532 $bottom_row[] = new tabobject($plugin->id, $plugin->link, $plugin->string);
3533 if ($plugin->id == $active_plugin) {
3534 $inactive = array($plugin->id);
3540 // Do not display rows that contain only one item, they are not helpful.
3541 if (count($top_row) > 1) {
3542 $tabs[] = $top_row;
3544 if (count($bottom_row) > 1) {
3545 $tabs[] = $bottom_row;
3547 if (empty($tabs)) {
3548 return;
3551 $rv = html_writer::div(print_tabs($tabs, $active_plugin, $inactive, $activated, true), 'grade-navigation');
3553 if ($return) {
3554 return $rv;
3555 } else {
3556 echo $rv;
3561 * Print grading plugin selection popup form.
3563 * @deprecated since Moodle 4.0. Dropdown box navigation has been replaced with tertiary navigation.
3564 * @param array $plugin_info An array of plugins containing information for the selector
3565 * @param boolean $return return as string
3567 * @return nothing or string if $return true
3569 function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return=false) {
3570 global $CFG, $OUTPUT, $PAGE;
3572 debugging('print_grade_plugin_selector() has been deprecated. Dropdown box navigation has been replaced ' .
3573 'with tertiary navigation.', DEBUG_DEVELOPER);
3575 $menu = array();
3576 $count = 0;
3577 $active = '';
3579 foreach ($plugin_info as $plugin_type => $plugins) {
3580 if ($plugin_type == 'strings') {
3581 continue;
3584 $first_plugin = reset($plugins);
3586 $sectionname = $plugin_info['strings'][$plugin_type];
3587 $section = array();
3589 foreach ($plugins as $plugin) {
3590 $link = $plugin->link->out(false);
3591 $section[$link] = $plugin->string;
3592 $count++;
3593 if ($plugin_type === $active_type and $plugin->id === $active_plugin) {
3594 $active = $link;
3598 if ($section) {
3599 $menu[] = array($sectionname=>$section);
3603 // finally print/return the popup form
3604 if ($count > 1) {
3605 $select = new url_select($menu, $active, null, 'choosepluginreport');
3606 $select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide'));
3607 if ($return) {
3608 return $OUTPUT->render($select);
3609 } else {
3610 echo $OUTPUT->render($select);
3612 } else {
3613 // only one option - no plugin selector needed
3614 return '';
3618 * Purge the cache of a course section.
3620 * $sectioninfo must have following attributes:
3621 * - course: course id
3622 * - section: section number
3624 * @param object $sectioninfo section info
3625 * @return void
3626 * @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_section_cache_by_id()}
3627 * or {@link course_modinfo::purge_course_section_cache_by_number()} instead.
3629 function course_purge_section_cache(object $sectioninfo): void {
3630 debugging(__FUNCTION__ . '() is deprecated. ' .
3631 'Please use course_modinfo::purge_course_section_cache_by_id() ' .
3632 'or course_modinfo::purge_course_section_cache_by_number() instead.',
3633 DEBUG_DEVELOPER);
3634 $sectionid = $sectioninfo->section;
3635 $courseid = $sectioninfo->course;
3636 course_modinfo::purge_course_section_cache_by_id($courseid, $sectionid);
3640 * Purge the cache of a course module.
3642 * $cm must have following attributes:
3643 * - id: cmid
3644 * - course: course id
3646 * @param cm_info|stdClass $cm course module
3647 * @return void
3648 * @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_module_cache()} instead.
3650 function course_purge_module_cache($cm): void {
3651 debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::purge_course_module_cache() instead.',
3652 DEBUG_DEVELOPER);
3653 $cmid = $cm->id;
3654 $courseid = $cm->course;
3655 course_modinfo::purge_course_module_cache($courseid, $cmid);
3660 * For a given course, returns an array of course activity objects
3661 * Each item in the array contains he following properties:
3663 * @param int $courseid course id
3664 * @param bool $usecache get activities from cache if modinfo exists when $usecache is true
3665 * @return array list of activities
3666 * @deprecated since Moodle 4.0. Please use {@link course_modinfo::get_array_of_activities()} instead.
3668 function get_array_of_activities(int $courseid, bool $usecache = false): array {
3669 debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::get_array_of_activities() instead.',
3670 DEBUG_DEVELOPER);
3671 return course_modinfo::get_array_of_activities(get_course($courseid), $usecache);
3675 * Abort execution by throwing of a general exception,
3676 * default exception handler displays the error message in most cases.
3678 * @deprecated since Moodle 4.1
3679 * @todo MDL-74484 Final deprecation in Moodle 4.5.
3680 * @param string $errorcode The name of the language string containing the error message.
3681 * Normally this should be in the error.php lang file.
3682 * @param string $module The language file to get the error message from.
3683 * @param string $link The url where the user will be prompted to continue.
3684 * If no url is provided the user will be directed to the site index page.
3685 * @param object $a Extra words and phrases that might be required in the error string
3686 * @param string $debuginfo optional debugging information
3687 * @return void, always throws exception!
3689 function print_error($errorcode, $module = 'error', $link = '', $a = null, $debuginfo = null) {
3690 debugging("The function print_error() is deprecated. " .
3691 "Please throw a new moodle_exception instance instead.", DEBUG_DEVELOPER);
3692 throw new \moodle_exception($errorcode, $module, $link, $a, $debuginfo);
3696 * Execute cron tasks
3698 * @param int|null $keepalive The keepalive time for this cron run.
3699 * @deprecated since 4.2 Use \core\cron::run_main_process() instead.
3701 function cron_run(?int $keepalive = null): void {
3702 debugging(
3703 'The cron_run() function is deprecated. Please use \core\cron::run_main_process() instead.',
3704 DEBUG_DEVELOPER
3706 \core\cron::run_main_process($keepalive);
3710 * Execute all queued scheduled tasks, applying necessary concurrency limits and time limits.
3712 * @param int $timenow The time this process started.
3713 * @deprecated since 4.2 Use \core\cron::run_scheduled_tasks() instead.
3715 function cron_run_scheduled_tasks(int $timenow) {
3716 debugging(
3717 'The cron_run_scheduled_tasks() function is deprecated. Please use \core\cron::run_scheduled_tasks() instead.',
3718 DEBUG_DEVELOPER
3720 \core\cron::run_scheduled_tasks($timenow);
3724 * Execute all queued adhoc tasks, applying necessary concurrency limits and time limits.
3726 * @param int $timenow The time this process started.
3727 * @param int $keepalive Keep this function alive for N seconds and poll for new adhoc tasks.
3728 * @param bool $checklimits Should we check limits?
3729 * @deprecated since 4.2 Use \core\cron::run_adhoc_tasks() instead.
3731 function cron_run_adhoc_tasks(int $timenow, $keepalive = 0, $checklimits = true) {
3732 debugging(
3733 'The cron_run_adhoc_tasks() function is deprecated. Please use \core\cron::run_adhoc_tasks() instead.',
3734 DEBUG_DEVELOPER
3736 \core\cron::run_adhoc_tasks($timenow, $keepalive, $checklimits);
3740 * Shared code that handles running of a single scheduled task within the cron.
3742 * Not intended for calling directly outside of this library!
3744 * @param \core\task\task_base $task
3745 * @deprecated since 4.2 Use \core\cron::run_inner_scheduled_task() instead.
3747 function cron_run_inner_scheduled_task(\core\task\task_base $task) {
3748 debugging(
3749 'The cron_run_inner_scheduled_task() function is deprecated. Please use \core\cron::run_inner_scheduled_task() instead.',
3750 DEBUG_DEVELOPER
3752 \core\cron::run_inner_scheduled_task($task);
3756 * Shared code that handles running of a single adhoc task within the cron.
3758 * @param \core\task\adhoc_task $task
3759 * @deprecated since 4.2 Use \core\cron::run_inner_adhoc_task() instead.
3761 function cron_run_inner_adhoc_task(\core\task\adhoc_task $task) {
3762 debugging(
3763 'The cron_run_inner_adhoc_task() function is deprecated. Please use \core\cron::run_inner_adhoc_task() instead.',
3764 DEBUG_DEVELOPER
3766 \core\cron::run_inner_adhoc_task($task);
3770 * Sets the process title
3772 * This makes it very easy for a sysadmin to immediately see what task
3773 * a cron process is running at any given moment.
3775 * @param string $title process status title
3776 * @deprecated since 4.2 Use \core\cron::set_process_title() instead.
3778 function cron_set_process_title(string $title) {
3779 debugging(
3780 'The cron_set_process_title() function is deprecated. Please use \core\cron::set_process_title() instead.',
3781 DEBUG_DEVELOPER
3783 \core\cron::set_process_title($title);
3787 * Output some standard information during cron runs. Specifically current time
3788 * and memory usage. This method also does gc_collect_cycles() (before displaying
3789 * memory usage) to try to help PHP manage memory better.
3791 * @deprecated since 4.2 Use \core\cron::trace_time_and_memory() instead.
3793 function cron_trace_time_and_memory() {
3794 debugging(
3795 'The cron_trace_time_and_memory() function is deprecated. Please use \core\cron::trace_time_and_memory() instead.',
3796 DEBUG_DEVELOPER
3798 \core\cron::trace_time_and_memory();
3802 * Prepare the output renderer for the cron run.
3804 * This involves creating a new $PAGE, and $OUTPUT fresh for each task and prevents any one task from influencing
3805 * any other.
3807 * @param bool $restore Whether to restore the original PAGE and OUTPUT
3808 * @deprecated since 4.2 Use \core\cron::prepare_core_renderer() instead.
3810 function cron_prepare_core_renderer($restore = false) {
3811 debugging(
3812 'The cron_prepare_core_renderer() function is deprecated. Please use \core\cron::prepare_core_renderer() instead.',
3813 DEBUG_DEVELOPER
3815 \core\cron::prepare_core_renderer($restore);
3819 * Sets up current user and course environment (lang, etc.) in cron.
3820 * Do not use outside of cron script!
3822 * @param stdClass $user full user object, null means default cron user (admin),
3823 * value 'reset' means reset internal static caches.
3824 * @param stdClass $course full course record, null means $SITE
3825 * @param bool $leavepagealone If specified, stops it messing with global page object
3826 * @deprecated since 4.2. Use \core\core::setup_user() instead.
3827 * @return void
3829 function cron_setup_user($user = null, $course = null, $leavepagealone = false) {
3830 debugging(
3831 'The cron_setup_user() function is deprecated. ' .
3832 'Please use \core\cron::setup_user() and reset_user_cache() as appropriate instead.',
3833 DEBUG_DEVELOPER
3836 if ($user === 'reset') {
3837 \core\cron::reset_user_cache();
3838 return;
3841 \core\cron::setup_user($user, $course, $leavepagealone);