Merge branch 'MDL-73142-311' of https://github.com/susyzan/moodle into MOODLE_311_STABLE
[moodle.git] / lib / deprecatedlib.php
blob5601156e93bc3db9929629763db82e6f2bda3c86
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 (http://docs.moodle.org/dev/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 print_error() 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 from class format_base');
925 * @deprecated since 2.4
927 function get_all_sections() {
928 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
932 * @deprecated since 2.4
934 function add_mod_to_section() {
935 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
939 * @deprecated since 2.4
941 function get_all_mods() {
942 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
946 * @deprecated since 2.4
948 function get_course_section() {
949 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
953 * @deprecated since 2.4
955 function format_weeks_get_section_dates() {
956 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
957 ' use it outside of format_weeks plugin');
961 * @deprecated since 2.5
963 function get_print_section_cm_text() {
964 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
965 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
969 * @deprecated since 2.5
971 function print_section_add_menus() {
972 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
973 'function course_section_add_cm_control()');
977 * @deprecated since 2.5. Please use:
978 * $courserenderer = $PAGE->get_renderer('core', 'course');
979 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
980 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
982 function make_editing_buttons() {
983 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
984 'lib/deprecatedlib.php on how to replace it');
988 * @deprecated since 2.5
990 function print_section() {
991 throw new coding_exception('Function print_section() is removed. Please use course renderer function '.
992 'course_section_cm_list() instead.');
996 * @deprecated since 2.5
998 function print_overview() {
999 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
1003 * @deprecated since 2.5
1005 function print_recent_activity() {
1006 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
1007 ' use it outside of block_recent_activity');
1011 * @deprecated since 2.5
1013 function delete_course_module() {
1014 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
1018 * @deprecated since 2.5
1020 function update_category_button() {
1021 throw new coding_exception('Function update_category_button() is removed. Pages to view '.
1022 'and edit courses are now separate and no longer depend on editing mode.');
1026 * @deprecated since 2.5
1028 function make_categories_list() {
1029 throw new coding_exception('Global function make_categories_list() is removed. Please use '.
1030 'core_course_category::make_categories_list() and core_course_category::get_parents()');
1034 * @deprecated since 2.5
1036 function category_delete_move() {
1037 throw new coding_exception('Function category_delete_move() is removed. Please use ' .
1038 'core_course_category::delete_move() instead.');
1042 * @deprecated since 2.5
1044 function category_delete_full() {
1045 throw new coding_exception('Function category_delete_full() is removed. Please use ' .
1046 'core_course_category::delete_full() instead.');
1050 * @deprecated since 2.5
1052 function move_category() {
1053 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.');
1057 * @deprecated since 2.5
1059 function course_category_hide() {
1060 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.');
1064 * @deprecated since 2.5
1066 function course_category_show() {
1067 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.');
1071 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or
1072 * core_course_category::get($catid, MUST_EXIST).
1074 function get_course_category() {
1075 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' .
1076 'see phpdocs for more details');
1080 * @deprecated since 2.5
1082 function create_course_category() {
1083 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' .
1084 'see phpdocs for more details');
1088 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children()
1090 function get_all_subcategories() {
1091 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '.
1092 'of core_course_category class. See phpdocs for more details');
1096 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children().
1098 function get_child_categories() {
1099 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' .
1100 'phpdocs for more details.');
1104 * @deprecated since 2.5
1106 function get_categories() {
1107 throw new coding_exception('Function get_categories() is removed. Please use ' .
1108 'appropriate functions from class core_course_category');
1112 * @deprecated since 2.5
1114 function print_course_search() {
1115 throw new coding_exception('Function print_course_search() is removed, please use course renderer');
1119 * @deprecated since 2.5
1121 function print_my_moodle() {
1122 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
1123 'function frontpage_my_courses()');
1127 * @deprecated since 2.5
1129 function print_remote_course() {
1130 throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
1134 * @deprecated since 2.5
1136 function print_remote_host() {
1137 throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
1141 * @deprecated since 2.5
1143 function print_whole_category_list() {
1144 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
1148 * @deprecated since 2.5
1150 function print_category_info() {
1151 throw new coding_exception('Function print_category_info() is removed, please use course renderer');
1155 * @deprecated since 2.5
1157 function get_course_category_tree() {
1158 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
1159 'renderer or core_course_category class, see function phpdocs for more info');
1163 * @deprecated since 2.5
1165 function print_courses() {
1166 throw new coding_exception('Function print_courses() is removed, please use course renderer');
1170 * @deprecated since 2.5
1172 function print_course() {
1173 throw new coding_exception('Function print_course() is removed, please use course renderer');
1177 * @deprecated since 2.5
1179 function get_category_courses_array() {
1180 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' .
1181 'core_course_category class');
1185 * @deprecated since 2.5
1187 function get_category_courses_array_recursively() {
1188 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' .
1189 'methods of core_course_category class', DEBUG_DEVELOPER);
1193 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
1195 function blog_get_context_url() {
1196 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
1200 * @deprecated since 2.5
1202 function get_courses_wmanagers() {
1203 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' .
1204 'core_course_category::get_courses()');
1208 * @deprecated since 2.5
1210 function convert_tree_to_html() {
1211 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
1215 * @deprecated since 2.5
1217 function convert_tabrows_to_tree() {
1218 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
1222 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
1224 function can_use_rotated_text() {
1225 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.');
1229 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
1231 function get_context_instance_by_id() {
1232 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
1236 * Returns system context or null if can not be created yet.
1238 * @see context_system::instance()
1239 * @deprecated since 2.2
1240 * @param bool $cache use caching
1241 * @return context system context (null if context table not created yet)
1243 function get_system_context($cache = true) {
1244 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
1245 return context_system::instance(0, IGNORE_MISSING, $cache);
1249 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
1251 function get_parent_contexts() {
1252 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
1256 * @deprecated since Moodle 2.2
1258 function get_parent_contextid() {
1259 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
1263 * @deprecated since 2.2
1265 function get_child_contexts() {
1266 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
1270 * @deprecated since 2.2
1272 function create_contexts() {
1273 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
1277 * @deprecated since 2.2
1279 function cleanup_contexts() {
1280 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.');
1284 * @deprecated since 2.2
1286 function build_context_path() {
1287 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
1291 * @deprecated since 2.2
1293 function rebuild_contexts() {
1294 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
1298 * @deprecated since Moodle 2.2
1300 function preload_course_contexts() {
1301 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
1305 * @deprecated since Moodle 2.2
1307 function context_moved() {
1308 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
1312 * @deprecated since 2.2
1314 function fetch_context_capabilities() {
1315 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
1319 * @deprecated since 2.2
1321 function context_instance_preload() {
1322 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
1326 * @deprecated since 2.2
1328 function get_contextlevel_name() {
1329 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
1333 * @deprecated since 2.2
1335 function print_context_name() {
1336 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
1340 * @deprecated since 2.2, use $context->mark_dirty() instead
1342 function mark_context_dirty() {
1343 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
1347 * @deprecated since Moodle 2.2
1349 function delete_context() {
1350 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
1351 'or $context->delete_content() instead.');
1355 * @deprecated since 2.2
1357 function get_context_url() {
1358 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
1362 * @deprecated since 2.2
1364 function get_course_context() {
1365 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
1369 * @deprecated since 2.2
1371 function get_user_courses_bycap() {
1372 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
1376 * @deprecated since Moodle 2.2
1378 function get_role_context_caps() {
1379 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
1383 * @deprecated since 2.2
1385 function get_courseid_from_context() {
1386 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
1390 * @deprecated since 2.2
1392 function context_instance_preload_sql() {
1393 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
1397 * @deprecated since 2.2
1399 function get_related_contexts_string() {
1400 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
1404 * @deprecated since 2.6
1406 function get_plugin_list_with_file() {
1407 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
1411 * @deprecated since 2.6
1413 function check_browser_operating_system() {
1414 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
1418 * @deprecated since 2.6
1420 function check_browser_version() {
1421 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
1425 * @deprecated since 2.6
1427 function get_device_type() {
1428 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.');
1432 * @deprecated since 2.6
1434 function get_device_type_list() {
1435 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
1439 * @deprecated since 2.6
1441 function get_selected_theme_for_device_type() {
1442 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
1446 * @deprecated since 2.6
1448 function get_device_cfg_var_name() {
1449 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
1453 * @deprecated since 2.6
1455 function set_user_device_type() {
1456 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
1460 * @deprecated since 2.6
1462 function get_user_device_type() {
1463 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.');
1467 * @deprecated since 2.6
1469 function get_browser_version_classes() {
1470 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.');
1474 * @deprecated since Moodle 2.6
1476 function generate_email_supportuser() {
1477 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
1481 * @deprecated since Moodle 2.6
1483 function badges_get_issued_badge_info() {
1484 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
1488 * @deprecated since 2.6
1490 function can_use_html_editor() {
1491 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.');
1496 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
1498 function count_login_failures() {
1499 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
1503 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
1505 function ajaxenabled() {
1506 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
1510 * @deprecated Since Moodle 2.7 MDL-44070
1512 function coursemodule_visible_for_user() {
1513 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
1514 please use \core_availability\info_module::is_user_visible()');
1518 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
1520 function enrol_cohort_get_cohorts() {
1521 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
1522 'cohort_get_available_cohorts() instead');
1526 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
1528 function enrol_cohort_can_view_cohort() {
1529 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
1533 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
1535 function cohort_get_visible_list() {
1536 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
1537 "that correctly checks capabilities.');
1541 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1543 function enrol_cohort_enrol_all_users() {
1544 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
1548 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1550 function enrol_cohort_search_cohorts() {
1551 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
1554 /* === Apis deprecated in since Moodle 2.9 === */
1557 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
1559 function message_current_user_is_involved() {
1560 throw new coding_exception('message_current_user_is_involved() can not be used any more.');
1564 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
1566 function profile_display_badges() {
1567 throw new coding_exception('profile_display_badges() can not be used any more.');
1571 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
1573 function useredit_shared_definition_preferences() {
1574 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
1579 * @deprecated since Moodle 2.9
1581 function calendar_normalize_tz() {
1582 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
1586 * @deprecated since Moodle 2.9
1588 function get_user_timezone_offset() {
1589 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1594 * @deprecated since Moodle 2.9
1596 function get_timezone_offset() {
1597 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1601 * @deprecated since Moodle 2.9
1603 function get_list_of_timezones() {
1604 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead');
1608 * @deprecated since Moodle 2.9
1610 function update_timezone_records() {
1611 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
1615 * @deprecated since Moodle 2.9
1617 function calculate_user_dst_table() {
1618 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
1622 * @deprecated since Moodle 2.9
1624 function dst_changes_for_year() {
1625 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
1629 * @deprecated since Moodle 2.9
1631 function get_timezone_record() {
1632 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
1635 /* === Apis deprecated since Moodle 3.0 === */
1637 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
1639 function get_referer() {
1640 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
1644 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
1646 function is_web_crawler() {
1647 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.');
1651 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
1653 function completion_cron() {
1654 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.');
1658 * @deprecated since 3.0
1660 function coursetag_get_tags() {
1661 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
1662 'Userid is no longer used for tagging courses.');
1666 * @deprecated since 3.0
1668 function coursetag_get_all_tags() {
1669 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
1670 'longer used for tagging courses.');
1674 * @deprecated since 3.0
1676 function coursetag_get_jscript() {
1677 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.');
1681 * @deprecated since 3.0
1683 function coursetag_get_jscript_links() {
1684 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
1688 * @deprecated since 3.0
1690 function coursetag_get_records() {
1691 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
1692 'Userid is no longer used for tagging courses.');
1696 * @deprecated since 3.0
1698 function coursetag_store_keywords() {
1699 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
1700 'Userid is no longer used for tagging courses.');
1704 * @deprecated since 3.0
1706 function coursetag_delete_keyword() {
1707 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
1708 'Userid is no longer used for tagging courses.');
1712 * @deprecated since 3.0
1714 function coursetag_get_tagged_courses() {
1715 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
1716 'Userid is no longer used for tagging courses.');
1720 * @deprecated since 3.0
1722 function coursetag_delete_course_tags() {
1723 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
1724 'Use core_tag_tag::remove_all_item_tags().');
1728 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1730 function tag_type_set() {
1731 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
1732 'core_tag_tag::get($tagid)->update().');
1736 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1738 function tag_description_set() {
1739 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
1740 'core_tag_tag::get($tagid)->update().');
1744 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1746 function tag_get_tags() {
1747 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
1748 'core_tag_tag::get_item_tags().');
1752 * @deprecated since 3.1
1754 function tag_get_tags_array() {
1755 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
1756 'core_tag_tag::get_item_tags_array().');
1760 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
1762 function tag_get_tags_csv() {
1763 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
1764 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1768 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1770 function tag_get_tags_ids() {
1771 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
1772 'core_tag_tag::get_item_tags() or similar methods.');
1776 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
1778 function tag_get_id() {
1779 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
1780 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
1784 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1786 function tag_rename() {
1787 throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
1788 'core_tag_tag::get($tagid)->update()');
1792 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
1794 function tag_delete_instance() {
1795 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
1796 'core_tag_tag::remove_item_tag()');
1800 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
1802 function tag_find_records() {
1803 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
1804 'core_tag_tag::get_by_name()->get_tagged_items()');
1808 * @deprecated since 3.1
1810 function tag_add() {
1811 throw new coding_exception('tag_add() can not be used anymore. You can use ' .
1812 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
1813 'created automatically when assigned to items');
1817 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
1819 function tag_assign() {
1820 throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
1821 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
1822 'ordering should not be set manually');
1826 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
1828 function tag_record_count() {
1829 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
1830 'core_tag_tag::get($tagid)->count_tagged_items().');
1834 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
1836 function tag_record_tagged_with() {
1837 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
1838 'core_tag_tag::get($tagid)->is_item_tagged_with().');
1842 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
1844 function tag_set_flag() {
1845 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
1846 'core_tag_tag::get($tagid)->flag()');
1850 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
1852 function tag_unset_flag() {
1853 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
1854 'core_tag_tag::get($tagid)->reset_flag()');
1858 * @deprecated since 3.1
1860 function tag_print_cloud() {
1861 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
1862 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
1863 'template core_tag/tagcloud.');
1867 * @deprecated since 3.0
1869 function tag_autocomplete() {
1870 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
1871 'element "tags" does proper autocomplete.');
1875 * @deprecated since 3.1
1877 function tag_print_description_box() {
1878 throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
1879 'See core_tag_renderer for similar code');
1883 * @deprecated since 3.1
1885 function tag_print_management_box() {
1886 throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
1887 'See core_tag_renderer for similar code');
1891 * @deprecated since 3.1
1893 function tag_print_search_box() {
1894 throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
1895 'See core_tag_renderer for similar code');
1899 * @deprecated since 3.1
1901 function tag_print_search_results() {
1902 throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
1903 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
1907 * @deprecated since 3.1
1909 function tag_print_tagged_users_table() {
1910 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
1911 'See core_user_renderer for similar code');
1915 * @deprecated since 3.1
1917 function tag_print_user_box() {
1918 throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
1919 'See core_user_renderer for similar code');
1923 * @deprecated since 3.1
1925 function tag_print_user_list() {
1926 throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
1927 'See core_user_renderer for similar code');
1931 * @deprecated since 3.1
1933 function tag_display_name() {
1934 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
1935 'core_tag_tag::make_display_name().');
1940 * @deprecated since 3.1
1942 function tag_normalize() {
1943 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
1944 'core_tag_tag::normalize().');
1948 * @deprecated since 3.1
1950 function tag_get_related_tags_csv() {
1951 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
1952 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1956 * @deprecated since 3.1
1958 function tag_set() {
1959 throw new coding_exception('tag_set() can not be used anymore. Please use ' .
1960 'core_tag_tag::set_item_tags().');
1964 * @deprecated since 3.1
1966 function tag_set_add() {
1967 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
1968 'core_tag_tag::add_item_tag().');
1972 * @deprecated since 3.1
1974 function tag_set_delete() {
1975 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
1976 'core_tag_tag::remove_item_tag().');
1980 * @deprecated since 3.1
1982 function tag_get() {
1983 throw new coding_exception('tag_get() can not be used anymore. Please use ' .
1984 'core_tag_tag::get() or core_tag_tag::get_by_name().');
1988 * @deprecated since 3.1
1990 function tag_get_related_tags() {
1991 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
1992 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
1993 'core_tag_tag::get_manual_related_tags().');
1997 * @deprecated since 3.1
1999 function tag_delete() {
2000 throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
2001 'core_tag_tag::delete_tags().');
2005 * @deprecated since 3.1
2007 function tag_delete_instances() {
2008 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
2009 'core_tag_tag::delete_instances().');
2013 * @deprecated since 3.1
2015 function tag_cleanup() {
2016 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
2017 '\core\task\tag_cron_task::cleanup().');
2021 * @deprecated since 3.1
2023 function tag_bulk_delete_instances() {
2024 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
2025 '\core\task\tag_cron_task::bulk_delete_instances().');
2030 * @deprecated since 3.1
2032 function tag_compute_correlations() {
2033 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
2034 'use \core\task\tag_cron_task::compute_correlations().');
2038 * @deprecated since 3.1
2040 function tag_process_computed_correlation() {
2041 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
2042 'use \core\task\tag_cron_task::process_computed_correlation().');
2046 * @deprecated since 3.1
2048 function tag_cron() {
2049 throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
2050 'use \core\task\tag_cron_task::execute().');
2054 * @deprecated since 3.1
2056 function tag_find_tags() {
2057 throw new coding_exception('tag_find_tags() can not be used anymore.');
2061 * @deprecated since 3.1
2063 function tag_get_name() {
2064 throw new coding_exception('tag_get_name() can not be used anymore.');
2068 * @deprecated since 3.1
2070 function tag_get_correlated() {
2071 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
2072 'use core_tag_tag::get_correlated_tags().');
2077 * @deprecated since 3.1
2079 function tag_cloud_sort() {
2080 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
2081 'be found in core_tag_collection::cloud_sort().');
2085 * @deprecated since Moodle 3.1
2087 function events_load_def() {
2088 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2093 * @deprecated since Moodle 3.1
2095 function events_queue_handler() {
2096 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2100 * @deprecated since Moodle 3.1
2102 function events_dispatch() {
2103 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2107 * @deprecated since Moodle 3.1
2109 function events_process_queued_handler() {
2110 throw new coding_exception(
2111 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
2116 * @deprecated since Moodle 3.1
2118 function events_update_definition() {
2119 throw new coding_exception(
2120 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
2125 * @deprecated since Moodle 3.1
2127 function events_cron() {
2128 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2132 * @deprecated since Moodle 3.1
2134 function events_trigger_legacy() {
2135 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2139 * @deprecated since Moodle 3.1
2141 function events_is_registered() {
2142 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2146 * @deprecated since Moodle 3.1
2148 function events_pending_count() {
2149 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2153 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2155 function clam_message_admins() {
2156 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
2157 'message_admins() method of \antivirus_clamav\scanner class.');
2161 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2163 function get_clam_error_code() {
2164 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
2165 'get_clam_error_code() method of \antivirus_clamav\scanner class.');
2169 * @deprecated since 3.1
2171 function course_get_cm_rename_action() {
2172 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
2173 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
2178 * @deprecated since Moodle 3.1
2180 function course_scale_used() {
2181 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
2182 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2186 * @deprecated since Moodle 3.1
2188 function site_scale_used() {
2189 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
2190 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2194 * @deprecated since Moodle 3.1. Use external_api::external_function_info().
2196 function external_function_info() {
2197 throw new coding_exception('external_function_info() can not be used any'.
2198 'more. Please use external_api::external_function_info() instead.');
2202 * @deprecated since Moodle 3.2
2203 * @see csv_import_reader::load_csv_content()
2205 function get_records_csv() {
2206 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' .
2207 'lib/csvlib.class.php csv_import_reader() instead.');
2211 * @deprecated since Moodle 3.2
2212 * @see download_as_dataformat (lib/dataformatlib.php)
2214 function put_records_csv() {
2215 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' .
2216 'lib/dataformatlib.php download_as_dataformat() instead.');
2220 * @deprecated since Moodle 3.2
2222 function css_is_colour() {
2223 throw new coding_exception('css_is_colour() can not be used anymore.');
2227 * @deprecated since Moodle 3.2
2229 function css_is_width() {
2230 throw new coding_exception('css_is_width() can not be used anymore.');
2234 * @deprecated since Moodle 3.2
2236 function css_sort_by_count() {
2237 throw new coding_exception('css_sort_by_count() can not be used anymore.');
2241 * @deprecated since Moodle 3.2
2243 function message_get_course_contexts() {
2244 throw new coding_exception('message_get_course_contexts() can not be used anymore.');
2248 * @deprecated since Moodle 3.2
2250 function message_remove_url_params() {
2251 throw new coding_exception('message_remove_url_params() can not be used anymore.');
2255 * @deprecated since Moodle 3.2
2257 function message_count_messages() {
2258 throw new coding_exception('message_count_messages() can not be used anymore.');
2262 * @deprecated since Moodle 3.2
2264 function message_count_blocked_users() {
2265 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' .
2266 '\core_message\api::count_blocked_users() instead.');
2270 * @deprecated since Moodle 3.2
2272 function message_contact_link() {
2273 throw new coding_exception('message_contact_link() can not be used anymore.');
2277 * @deprecated since Moodle 3.2
2279 function message_get_recent_notifications() {
2280 throw new coding_exception('message_get_recent_notifications() can not be used anymore.');
2284 * @deprecated since Moodle 3.2
2286 function message_history_link() {
2287 throw new coding_exception('message_history_link() can not be used anymore.');
2291 * @deprecated since Moodle 3.2
2293 function message_search() {
2294 throw new coding_exception('message_search() can not be used anymore.');
2298 * @deprecated since Moodle 3.2
2300 function message_shorten_message() {
2301 throw new coding_exception('message_shorten_message() can not be used anymore.');
2305 * @deprecated since Moodle 3.2
2307 function message_get_fragment() {
2308 throw new coding_exception('message_get_fragment() can not be used anymore.');
2312 * @deprecated since Moodle 3.2
2314 function message_get_history() {
2315 throw new coding_exception('message_get_history() can not be used anymore.');
2319 * @deprecated since Moodle 3.2
2321 function message_get_contact_add_remove_link() {
2322 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.');
2326 * @deprecated since Moodle 3.2
2328 function message_get_contact_block_link() {
2329 throw new coding_exception('message_get_contact_block_link() can not be used anymore.');
2333 * @deprecated since Moodle 3.2
2335 function message_mark_messages_read() {
2336 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' .
2337 '\core_message\api::mark_all_messages_as_read() instead.');
2341 * @deprecated since Moodle 3.2
2343 function message_can_post_message() {
2344 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' .
2345 '\core_message\api::can_send_message() instead.');
2349 * @deprecated since Moodle 3.2
2351 function message_is_user_non_contact_blocked() {
2352 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' .
2353 '\core_message\api::is_user_non_contact_blocked() instead.');
2357 * @deprecated since Moodle 3.2
2359 function message_is_user_blocked() {
2360 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' .
2361 '\core_message\api::is_user_blocked() instead.');
2365 * @deprecated since Moodle 3.2
2367 function print_log() {
2368 throw new coding_exception('print_log() can not be used anymore. Please use the ' .
2369 'report_log framework instead.');
2373 * @deprecated since Moodle 3.2
2375 function print_mnet_log() {
2376 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' .
2377 'report_log framework instead.');
2381 * @deprecated since Moodle 3.2
2383 function print_log_csv() {
2384 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' .
2385 'report_log framework instead.');
2389 * @deprecated since Moodle 3.2
2391 function print_log_xls() {
2392 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' .
2393 'report_log framework instead.');
2397 * @deprecated since Moodle 3.2
2399 function print_log_ods() {
2400 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' .
2401 'report_log framework instead.');
2405 * @deprecated since Moodle 3.2
2407 function build_logs_array() {
2408 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' .
2409 'report_log framework instead.');
2413 * @deprecated since Moodle 3.2
2415 function get_logs_usercourse() {
2416 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' .
2417 'report_log framework instead.');
2421 * @deprecated since Moodle 3.2
2423 function get_logs_userday() {
2424 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' .
2425 'report_log framework instead.');
2429 * @deprecated since Moodle 3.2
2431 function get_logs() {
2432 throw new coding_exception('get_logs() can not be used anymore. Please use the ' .
2433 'report_log framework instead.');
2437 * @deprecated since Moodle 3.2
2439 function prevent_form_autofill_password() {
2440 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.');
2444 * @deprecated since Moodle 3.3 MDL-57370
2446 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) {
2447 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' .
2448 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER);
2452 * @deprecated since Moodle 3.2
2454 function calendar_preferences_button() {
2455 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' .
2456 'preferences are now linked to the user preferences page.');
2460 * @deprecated since 3.3
2462 function calendar_wday_name() {
2463 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.');
2467 * @deprecated since 3.3
2469 function calendar_get_block_upcoming() {
2470 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' .
2471 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2475 * @deprecated since 3.3
2477 function calendar_print_month_selector() {
2478 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.');
2482 * @deprecated since 3.3
2484 function calendar_cron() {
2485 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.');
2489 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2491 function load_course_context() {
2492 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
2496 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2498 function load_role_access_by_context() {
2499 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
2503 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2505 function dedupe_user_access() {
2506 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
2510 * @deprecated since Moodle 3.4. MDL-49398.
2512 function get_user_access_sitewide() {
2513 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.');
2517 * @deprecated since Moodle 3.4. MDL-59333
2519 function calendar_get_mini() {
2520 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.');
2524 * @deprecated since Moodle 3.4. MDL-59333
2526 function calendar_get_upcoming() {
2527 throw new coding_exception('calendar_get_upcoming() has been removed. ' .
2528 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2532 * @deprecated since Moodle 3.4. MDL-50666
2534 function allow_override() {
2535 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.');
2539 * @deprecated since Moodle 3.4. MDL-50666
2541 function allow_assign() {
2542 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.');
2546 * @deprecated since Moodle 3.4. MDL-50666
2548 function allow_switch() {
2549 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.');
2553 * @deprecated since Moodle 3.5. MDL-61132
2555 function question_add_tops() {
2556 throw new coding_exception(
2557 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().'
2562 * @deprecated since Moodle 3.5. MDL-61132
2564 function question_is_only_toplevel_category_in_context() {
2565 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. '
2566 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.');
2570 * @deprecated since Moodle 3.5
2572 function message_move_userfrom_unread2read() {
2573 throw new coding_exception('message_move_userfrom_unread2read() has been removed.');
2577 * @deprecated since Moodle 3.5
2579 function message_get_blocked_users() {
2580 throw new coding_exception(
2581 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.'
2586 * @deprecated since Moodle 3.5
2588 function message_get_contacts() {
2589 throw new coding_exception('message_get_contacts() has been removed.');
2593 * @deprecated since Moodle 3.5
2595 function message_mark_message_read() {
2596 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read()
2597 or \core_message\api::mark_notification_as_read().');
2601 * @deprecated since Moodle 3.5
2603 function message_can_delete_message() {
2604 throw new coding_exception(
2605 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.'
2610 * @deprecated since Moodle 3.5
2612 function message_delete_message() {
2613 throw new coding_exception(
2614 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.'
2619 * @deprecated since 3.6
2621 function calendar_get_all_allowed_types() {
2622 throw new coding_exception(
2623 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.'
2629 * @deprecated since Moodle 3.6.
2631 function groups_get_all_groups_for_courses() {
2632 throw new coding_exception(
2633 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.'
2638 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2640 function events_get_cached() {
2641 throw new coding_exception(
2642 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2647 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2649 function events_uninstall() {
2650 throw new coding_exception(
2651 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2656 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2658 function events_cleanup() {
2659 throw new coding_exception(
2660 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2665 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2667 function events_dequeue() {
2668 throw new coding_exception(
2669 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2674 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2676 function events_get_handlers() {
2677 throw new coding_exception(
2678 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2683 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2685 function get_roles_on_exact_context() {
2686 throw new coding_exception(
2687 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.'
2692 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2694 function get_roles_with_assignment_on_context() {
2695 throw new coding_exception(
2696 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.'
2701 * @deprecated since Moodle 3.6
2703 function message_add_contact() {
2704 throw new coding_exception(
2705 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' .
2706 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' .
2707 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.'
2712 * @deprecated since Moodle 3.6
2714 function message_remove_contact() {
2715 throw new coding_exception(
2716 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.'
2721 * @deprecated since Moodle 3.6
2723 function message_unblock_contact() {
2724 throw new coding_exception(
2725 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.'
2730 * @deprecated since Moodle 3.6
2732 function message_block_contact() {
2733 throw new coding_exception(
2734 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' .
2735 '\core_message\api::block_user() instead.'
2740 * @deprecated since Moodle 3.6
2742 function message_get_contact() {
2743 throw new coding_exception(
2744 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.'
2749 * @deprecated since Moodle 3.7
2751 function get_courses_page() {
2752 throw new coding_exception(
2753 'Function get_courses_page() has been removed. Please use core_course_category::get_courses() ' .
2754 'or core_course_category::search_courses()'
2759 * Returns the models that generated insights in the provided context.
2761 * @deprecated since Moodle 3.8 MDL-66091 - please do not use this function any more.
2762 * @todo MDL-65799 This will be deleted in Moodle 4.0
2763 * @see \core_analytics\manager::cached_models_with_insights
2764 * @param \context $context
2765 * @return int[]
2767 function report_insights_context_insights(\context $context) {
2769 debugging('report_insights_context_insights is deprecated. Please use ' .
2770 '\core_analytics\manager::cached_models_with_insights instead', DEBUG_DEVELOPER);
2772 return \core_analytics\manager::cached_models_with_insights($context);
2776 * Retrieve all metadata for the requested modules
2778 * @deprecated since 3.9.
2779 * @param object $course The Course
2780 * @param array $modnames An array containing the list of modules and their
2781 * names
2782 * @param int $sectionreturn The section to return to
2783 * @return array A list of stdClass objects containing metadata about each
2784 * module
2786 function get_module_metadata($course, $modnames, $sectionreturn = null) {
2787 global $OUTPUT;
2789 debugging('get_module_metadata is deprecated. Please use \core_course\local\service\content_item_service instead.');
2791 // get_module_metadata will be called once per section on the page and courses may show
2792 // different modules to one another
2793 static $modlist = array();
2794 if (!isset($modlist[$course->id])) {
2795 $modlist[$course->id] = array();
2798 $return = array();
2799 $urlbase = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey()));
2800 if ($sectionreturn !== null) {
2801 $urlbase->param('sr', $sectionreturn);
2803 foreach($modnames as $modname => $modnamestr) {
2804 if (!course_allowed_module($course, $modname)) {
2805 continue;
2807 if (isset($modlist[$course->id][$modname])) {
2808 // This module is already cached
2809 $return += $modlist[$course->id][$modname];
2810 continue;
2812 $modlist[$course->id][$modname] = array();
2814 // Create an object for a default representation of this module type in the activity chooser. It will be used
2815 // if module does not implement callback get_shortcuts() and it will also be passed to the callback if it exists.
2816 $defaultmodule = new stdClass();
2817 $defaultmodule->title = $modnamestr;
2818 $defaultmodule->name = $modname;
2819 $defaultmodule->link = new moodle_url($urlbase, array('add' => $modname));
2820 $defaultmodule->icon = $OUTPUT->pix_icon('icon', '', $defaultmodule->name, array('class' => 'icon'));
2821 $sm = get_string_manager();
2822 if ($sm->string_exists('modulename_help', $modname)) {
2823 $defaultmodule->help = get_string('modulename_help', $modname);
2824 if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs.
2825 $link = get_string('modulename_link', $modname);
2826 $linktext = get_string('morehelp');
2827 $defaultmodule->help .= html_writer::tag('div',
2828 $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));
2831 $defaultmodule->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
2833 // Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list
2834 // of elements to be added to activity chooser.
2835 $items = component_callback($modname, 'get_shortcuts', array($defaultmodule), null);
2836 if ($items !== null) {
2837 foreach ($items as $item) {
2838 // Add all items to the return array. All items must have different links, use them as a key in the return array.
2839 if (!isset($item->archetype)) {
2840 $item->archetype = $defaultmodule->archetype;
2842 if (!isset($item->icon)) {
2843 $item->icon = $defaultmodule->icon;
2845 // If plugin returned the only one item with the same link as default item - cache it as $modname,
2846 // otherwise append the link url to the module name.
2847 $item->name = (count($items) == 1 &&
2848 $item->link->out() === $defaultmodule->link->out()) ? $modname : $modname . ':' . $item->link;
2850 // If the module provides the helptext property, append it to the help text to match the look and feel
2851 // of the default course modules.
2852 if (isset($item->help) && isset($item->helplink)) {
2853 $linktext = get_string('morehelp');
2854 $item->help .= html_writer::tag('div',
2855 $OUTPUT->doc_link($item->helplink, $linktext, true), array('class' => 'helpdoclink'));
2857 $modlist[$course->id][$modname][$item->name] = $item;
2859 $return += $modlist[$course->id][$modname];
2860 // If get_shortcuts() callback is defined, the default module action is not added.
2861 // It is a responsibility of the callback to add it to the return value unless it is not needed.
2862 continue;
2865 // The callback get_shortcuts() was not found, use the default item for the activity chooser.
2866 $modlist[$course->id][$modname][$modname] = $defaultmodule;
2867 $return[$modname] = $defaultmodule;
2870 core_collator::asort_objects_by_property($return, 'title');
2871 return $return;
2875 * Runs a single cron task. This function assumes it is displaying output in pseudo-CLI mode.
2877 * The function will fail if the task is disabled.
2879 * Warning: Because this function closes the browser session, it may not be safe to continue
2880 * with other processing (other than displaying the rest of the page) after using this function!
2882 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task).
2883 * @todo final deprecation. To be removed in Moodle 4.1 MDL-63594.
2884 * @param \core\task\scheduled_task $task Task to run
2885 * @return bool True if cron run successful
2887 function cron_run_single_task(\core\task\scheduled_task $task) {
2888 debugging('cron_run_single_task() is deprecated. Please use \\core\task\manager::run_from_cli() instead.',
2889 DEBUG_DEVELOPER);
2890 return \core\task\manager::run_from_cli($task);
2894 * Executes cron functions for a specific type of plugin.
2896 * @param string $plugintype Plugin type (e.g. 'report')
2897 * @param string $description If specified, will display 'Starting (whatever)'
2898 * and 'Finished (whatever)' lines, otherwise does not display
2900 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2901 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2903 function cron_execute_plugin_type($plugintype, $description = null) {
2904 global $DB;
2906 // Get list from plugin => function for all plugins.
2907 $plugins = get_plugin_list_with_function($plugintype, 'cron');
2909 // Modify list for backward compatibility (different files/names).
2910 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins);
2912 // Return if no plugins with cron function to process.
2913 if (!$plugins) {
2914 return;
2917 if ($description) {
2918 mtrace('Starting '.$description);
2921 foreach ($plugins as $component => $cronfunction) {
2922 $dir = core_component::get_component_directory($component);
2924 // Get cron period if specified in version.php, otherwise assume every cron.
2925 $cronperiod = 0;
2926 if (file_exists("$dir/version.php")) {
2927 $plugin = new stdClass();
2928 include("$dir/version.php");
2929 if (isset($plugin->cron)) {
2930 $cronperiod = $plugin->cron;
2934 // Using last cron and cron period, don't run if it already ran recently.
2935 $lastcron = get_config($component, 'lastcron');
2936 if ($cronperiod && $lastcron) {
2937 if ($lastcron + $cronperiod > time()) {
2938 // Do not execute cron yet.
2939 continue;
2943 mtrace('Processing cron function for ' . $component . '...');
2944 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER);
2945 cron_trace_time_and_memory();
2946 $pre_dbqueries = $DB->perf_get_queries();
2947 $pre_time = microtime(true);
2949 $cronfunction();
2951 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " .
2952 round(microtime(true) - $pre_time, 2) . " seconds)");
2954 set_config('lastcron', time(), $component);
2955 core_php_time_limit::raise();
2958 if ($description) {
2959 mtrace('Finished ' . $description);
2964 * Used to add in old-style cron functions within plugins that have not been converted to the
2965 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used
2966 * cron.php and some used a different name.)
2968 * @param string $plugintype Plugin type e.g. 'report'
2969 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g.
2970 * 'report_frog_cron') for plugin cron functions that were already found using the new API
2971 * @return array Revised version of $plugins that adds in any extra plugin functions found by
2972 * looking in the older location
2974 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2975 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2977 function cron_bc_hack_plugin_functions($plugintype, $plugins) {
2978 global $CFG; // Mandatory in case it is referenced by include()d PHP script.
2980 if ($plugintype === 'report') {
2981 // Admin reports only - not course report because course report was
2982 // never implemented before, so doesn't need BC.
2983 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
2984 $component = $plugintype . '_' . $pluginname;
2985 if (isset($plugins[$component])) {
2986 // We already have detected the function using the new API.
2987 continue;
2989 if (!file_exists("$dir/cron.php")) {
2990 // No old style cron file present.
2991 continue;
2993 include_once("$dir/cron.php");
2994 $cronfunction = $component . '_cron';
2995 if (function_exists($cronfunction)) {
2996 $plugins[$component] = $cronfunction;
2997 } else {
2998 debugging("Invalid legacy cron.php detected in $component, " .
2999 "please use lib.php instead");
3002 } else if (strpos($plugintype, 'grade') === 0) {
3003 // Detect old style cron function names.
3004 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of
3005 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport.
3006 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
3007 $component = $plugintype.'_'.$pluginname;
3008 if (isset($plugins[$component])) {
3009 // We already have detected the function using the new API.
3010 continue;
3012 if (!file_exists("$dir/lib.php")) {
3013 continue;
3015 include_once("$dir/lib.php");
3016 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' .
3017 $pluginname . '_cron';
3018 if (function_exists($cronfunction)) {
3019 $plugins[$component] = $cronfunction;
3024 return $plugins;
3028 * Returns the SQL used by the participants table.
3030 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3031 * @param int $courseid The course id
3032 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3033 * @param int $accesssince The time since last access, 0 means any time
3034 * @param int $roleid The role id, 0 means all roles and -1 no roles
3035 * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned.
3036 * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed.
3037 * @param string|array $search The search that was performed, empty means perform no search
3038 * @param string $additionalwhere Any additional SQL to add to where
3039 * @param array $additionalparams The additional params
3040 * @return array
3042 function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3043 $search = '', $additionalwhere = '', $additionalparams = array()) {
3044 global $DB, $USER, $CFG;
3046 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3047 'Please use \core\table\participants_search::class with table filtersets instead.';
3048 debugging($deprecatedtext, DEBUG_DEVELOPER);
3050 // Get the context.
3051 $context = \context_course::instance($courseid, MUST_EXIST);
3053 $isfrontpage = ($courseid == SITEID);
3055 // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments.
3056 $onlyactive = true;
3057 $onlysuspended = false;
3058 if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) {
3059 switch ($statusid) {
3060 case ENROL_USER_ACTIVE:
3061 // Nothing to do here.
3062 break;
3063 case ENROL_USER_SUSPENDED:
3064 $onlyactive = false;
3065 $onlysuspended = true;
3066 break;
3067 default:
3068 // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false.
3069 $onlyactive = false;
3070 break;
3074 list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid);
3076 $joins = array('FROM {user} u');
3077 $wheres = array();
3079 // TODO Does not support custom user profile fields (MDL-70456).
3080 $userfields = \core_user\fields::get_identity_fields($context, false);
3081 $userfieldsapi = \core_user\fields::for_userpic()->including(...$userfields);
3082 $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
3084 if ($isfrontpage) {
3085 $select = "SELECT $userfieldssql, u.lastaccess";
3086 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually.
3087 if ($accesssince) {
3088 $wheres[] = user_get_user_lastaccess_sql($accesssince);
3090 } else {
3091 $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess";
3092 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only.
3093 // Not everybody has accessed the course yet.
3094 $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)';
3095 $params['courseid'] = $courseid;
3096 if ($accesssince) {
3097 $wheres[] = user_get_course_lastaccess_sql($accesssince);
3101 // Performance hacks - we preload user contexts together with accounts.
3102 $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
3103 $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)';
3104 $params['contextlevel'] = CONTEXT_USER;
3105 $select .= $ccselect;
3106 $joins[] = $ccjoin;
3108 // Limit list to users with some role only.
3109 if ($roleid) {
3110 // We want to query both the current context and parent contexts.
3111 list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true),
3112 SQL_PARAMS_NAMED, 'relatedctx');
3114 // Get users without any role.
3115 if ($roleid == -1) {
3116 $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)";
3117 $params = array_merge($params, $relatedctxparams);
3118 } else {
3119 $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
3120 $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
3124 if (!empty($search)) {
3125 if (!is_array($search)) {
3126 $search = [$search];
3128 foreach ($search as $index => $keyword) {
3129 $searchkey1 = 'search' . $index . '1';
3130 $searchkey2 = 'search' . $index . '2';
3131 $searchkey3 = 'search' . $index . '3';
3132 $searchkey4 = 'search' . $index . '4';
3133 $searchkey5 = 'search' . $index . '5';
3134 $searchkey6 = 'search' . $index . '6';
3135 $searchkey7 = 'search' . $index . '7';
3137 $conditions = array();
3138 // Search by fullname.
3139 $fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
3140 $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false);
3142 // Search by email.
3143 $email = $DB->sql_like('email', ':' . $searchkey2, false, false);
3144 if (!in_array('email', $userfields)) {
3145 $maildisplay = 'maildisplay' . $index;
3146 $userid1 = 'userid' . $index . '1';
3147 // Prevent users who hide their email address from being found by others
3148 // who aren't allowed to see hidden email addresses.
3149 $email = "(". $email ." AND (" .
3150 "u.maildisplay <> :$maildisplay " .
3151 "OR u.id = :$userid1". // User can always find himself.
3152 "))";
3153 $params[$maildisplay] = core_user::MAILDISPLAY_HIDE;
3154 $params[$userid1] = $USER->id;
3156 $conditions[] = $email;
3158 // Search by idnumber.
3159 $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false);
3160 if (!in_array('idnumber', $userfields)) {
3161 $userid2 = 'userid' . $index . '2';
3162 // Users who aren't allowed to see idnumbers should at most find themselves
3163 // when searching for an idnumber.
3164 $idnumber = "(". $idnumber . " AND u.id = :$userid2)";
3165 $params[$userid2] = $USER->id;
3167 $conditions[] = $idnumber;
3169 // TODO Does not support custom user profile fields (MDL-70456).
3170 $extrasearchfields = \core_user\fields::get_identity_fields($context, false);
3171 if (!empty($extrasearchfields)) {
3172 // Search all user identify fields.
3173 foreach ($extrasearchfields as $extrasearchfield) {
3174 if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) {
3175 // Already covered above. Search by country not supported.
3176 continue;
3178 $param = $searchkey3 . $extrasearchfield;
3179 $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false);
3180 $params[$param] = "%$keyword%";
3181 if (!in_array($extrasearchfield, $userfields)) {
3182 // User cannot see this field, but allow match if their own account.
3183 $userid3 = 'userid' . $index . '3' . $extrasearchfield;
3184 $condition = "(". $condition . " AND u.id = :$userid3)";
3185 $params[$userid3] = $USER->id;
3187 $conditions[] = $condition;
3191 // Search by middlename.
3192 $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false);
3193 $conditions[] = $middlename;
3195 // Search by alternatename.
3196 $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false);
3197 $conditions[] = $alternatename;
3199 // Search by firstnamephonetic.
3200 $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false);
3201 $conditions[] = $firstnamephonetic;
3203 // Search by lastnamephonetic.
3204 $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false);
3205 $conditions[] = $lastnamephonetic;
3207 $wheres[] = "(". implode(" OR ", $conditions) .") ";
3208 $params[$searchkey1] = "%$keyword%";
3209 $params[$searchkey2] = "%$keyword%";
3210 $params[$searchkey3] = "%$keyword%";
3211 $params[$searchkey4] = "%$keyword%";
3212 $params[$searchkey5] = "%$keyword%";
3213 $params[$searchkey6] = "%$keyword%";
3214 $params[$searchkey7] = "%$keyword%";
3218 if (!empty($additionalwhere)) {
3219 $wheres[] = $additionalwhere;
3220 $params = array_merge($params, $additionalparams);
3223 $from = implode("\n", $joins);
3224 if ($wheres) {
3225 $where = 'WHERE ' . implode(' AND ', $wheres);
3226 } else {
3227 $where = '';
3230 return array($select, $from, $where, $params);
3234 * Returns the total number of participants for a given course.
3236 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3237 * @param int $courseid The course id
3238 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3239 * @param int $accesssince The time since last access, 0 means any time
3240 * @param int $roleid The role id, 0 means all roles
3241 * @param int $enrolid The applied filter for the user enrolment ID.
3242 * @param int $status The applied filter for the user's enrolment status.
3243 * @param string|array $search The search that was performed, empty means perform no search
3244 * @param string $additionalwhere Any additional SQL to add to where
3245 * @param array $additionalparams The additional params
3246 * @return int
3248 function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3249 $search = '', $additionalwhere = '', $additionalparams = array()) {
3250 global $DB;
3252 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3253 'Please use \core\table\participants_search::class with table filtersets instead.';
3254 debugging($deprecatedtext, DEBUG_DEVELOPER);
3256 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3257 $statusid, $search, $additionalwhere, $additionalparams);
3259 return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
3263 * Returns the participants for a given course.
3265 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3266 * @param int $courseid The course id
3267 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3268 * @param int $accesssince The time since last access
3269 * @param int $roleid The role id
3270 * @param int $enrolid The applied filter for the user enrolment ID.
3271 * @param int $status The applied filter for the user's enrolment status.
3272 * @param string $search The search that was performed
3273 * @param string $additionalwhere Any additional SQL to add to where
3274 * @param array $additionalparams The additional params
3275 * @param string $sort The SQL sort
3276 * @param int $limitfrom return a subset of records, starting at this point (optional).
3277 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
3278 * @return moodle_recordset
3280 function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enrolid, $statusid, $search,
3281 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) {
3282 global $DB;
3284 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3285 'Please use \core\table\participants_search::class with table filtersets instead.';
3286 debugging($deprecatedtext, DEBUG_DEVELOPER);
3288 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3289 $statusid, $search, $additionalwhere, $additionalparams);
3291 return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
3295 * Returns the list of full course categories to be used in html_writer::select()
3297 * Calls {@see core_course_category::make_categories_list()} to build the list.
3299 * @deprecated since Moodle 3.10
3300 * @todo This will be finally removed for Moodle 4.2 as part of MDL-69124.
3301 * @return array array mapping course category id to the display name
3303 function make_categories_options() {
3304 $deprecatedtext = __FUNCTION__ . '() is deprecated. Please use \core_course_category::make_categories_list() instead.';
3305 debugging($deprecatedtext, DEBUG_DEVELOPER);
3307 return core_course_category::make_categories_list('', 0, ' / ');
3311 * Checks if current user is shown any extra fields when listing users.
3313 * Does not include any custom profile fields.
3315 * @param object $context Context
3316 * @param array $already Array of fields that we're going to show anyway
3317 * so don't bother listing them
3318 * @return array Array of field names from user table, not including anything
3319 * listed in $already
3320 * @deprecated since Moodle 3.11 MDL-45242
3321 * @see \core_user\fields
3323 function get_extra_user_fields($context, $already = array()) {
3324 debugging('get_extra_user_fields() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3326 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3327 return $fields->get_required_fields();
3331 * If the current user is to be shown extra user fields when listing or
3332 * selecting users, returns a string suitable for including in an SQL select
3333 * clause to retrieve those fields.
3335 * Does not include any custom profile fields.
3337 * @param context $context Context
3338 * @param string $alias Alias of user table, e.g. 'u' (default none)
3339 * @param string $prefix Prefix for field names using AS, e.g. 'u_' (default none)
3340 * @param array $already Array of fields that we're going to include anyway so don't list them (default none)
3341 * @return string Partial SQL select clause, beginning with comma, for example ',u.idnumber,u.department' unless it is blank
3342 * @deprecated since Moodle 3.11 MDL-45242
3343 * @see \core_user\fields
3345 function get_extra_user_fields_sql($context, $alias='', $prefix='', $already = array()) {
3346 debugging('get_extra_user_fields_sql() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3348 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3349 // Note: There will never be any joins or join params because we turned off profile fields.
3350 $selects = $fields->get_sql($alias, false, $prefix)->selects;
3352 return $selects;
3356 * Returns the display name of a field in the user table. Works for most fields that are commonly displayed to users.
3358 * Also works for custom fields.
3360 * @param string $field Field name, e.g. 'phone1'
3361 * @return string Text description taken from language file, e.g. 'Phone number'
3362 * @deprecated since Moodle 3.11 MDL-45242
3363 * @see \core_user\fields
3365 function get_user_field_name($field) {
3366 debugging('get_user_field_name() is deprecated. Please use \core_user\fields::get_display_name() instead', DEBUG_DEVELOPER);
3368 return \core_user\fields::get_display_name($field);
3372 * A centralised location for the all name fields. Returns an array / sql string snippet.
3374 * @param bool $returnsql True for an sql select field snippet.
3375 * @param string $tableprefix table query prefix to use in front of each field.
3376 * @param string $prefix prefix added to the name fields e.g. authorfirstname.
3377 * @param string $fieldprefix sql field prefix e.g. id AS userid.
3378 * @param bool $order moves firstname and lastname to the top of the array / start of the string.
3379 * @return array|string All name fields.
3380 * @deprecated since Moodle 3.11 MDL-45242
3381 * @see \core_user\fields
3383 function get_all_user_name_fields($returnsql = false, $tableprefix = null, $prefix = null, $fieldprefix = null, $order = false) {
3384 debugging('get_all_user_name_fields() is deprecated. Please use the \core_user\fields API instead', DEBUG_DEVELOPER);
3386 // This array is provided in this order because when called by fullname() (above) if firstname is before
3387 // firstnamephonetic str_replace() will change the wrong placeholder.
3388 $alternatenames = [];
3389 foreach (\core_user\fields::get_name_fields() as $field) {
3390 $alternatenames[$field] = $field;
3393 // Let's add a prefix to the array of user name fields if provided.
3394 if ($prefix) {
3395 foreach ($alternatenames as $key => $altname) {
3396 $alternatenames[$key] = $prefix . $altname;
3400 // If we want the end result to have firstname and lastname at the front / top of the result.
3401 if ($order) {
3402 // Move the last two elements (firstname, lastname) off the array and put them at the top.
3403 for ($i = 0; $i < 2; $i++) {
3404 // Get the last element.
3405 $lastelement = end($alternatenames);
3406 // Remove it from the array.
3407 unset($alternatenames[$lastelement]);
3408 // Put the element back on the top of the array.
3409 $alternatenames = array_merge(array($lastelement => $lastelement), $alternatenames);
3413 // Create an sql field snippet if requested.
3414 if ($returnsql) {
3415 if ($tableprefix) {
3416 if ($fieldprefix) {
3417 foreach ($alternatenames as $key => $altname) {
3418 $alternatenames[$key] = $tableprefix . '.' . $altname . ' AS ' . $fieldprefix . $altname;
3420 } else {
3421 foreach ($alternatenames as $key => $altname) {
3422 $alternatenames[$key] = $tableprefix . '.' . $altname;
3426 $alternatenames = implode(',', $alternatenames);
3428 return $alternatenames;