MDL-72873 core_grades: Deprecate unused methods
[moodle.git] / lib / deprecatedlib.php
blobb6ce99915cce69ebb4adc9f4313cd37c997f2b0e
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 '
922 .'from class core_courseformat\\base');
926 * @deprecated since 2.4
928 function get_all_sections() {
929 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
933 * @deprecated since 2.4
935 function add_mod_to_section() {
936 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
940 * @deprecated since 2.4
942 function get_all_mods() {
943 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
947 * @deprecated since 2.4
949 function get_course_section() {
950 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
954 * @deprecated since 2.4
956 function format_weeks_get_section_dates() {
957 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
958 ' use it outside of format_weeks plugin');
962 * @deprecated since 2.5
964 function get_print_section_cm_text() {
965 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
966 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
970 * @deprecated since 2.5
972 function print_section_add_menus() {
973 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
974 'function course_section_add_cm_control()');
978 * @deprecated since 2.5. Please use:
979 * $courserenderer = $PAGE->get_renderer('core', 'course');
980 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
981 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
983 function make_editing_buttons() {
984 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
985 'lib/deprecatedlib.php on how to replace it');
989 * @deprecated since 2.5
991 function print_section() {
992 throw new coding_exception('Function print_section() is removed. Please use core_course\output\section_format '.
993 ' to render a course section instead.');
997 * @deprecated since 2.5
999 function print_overview() {
1000 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
1004 * @deprecated since 2.5
1006 function print_recent_activity() {
1007 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
1008 ' use it outside of block_recent_activity');
1012 * @deprecated since 2.5
1014 function delete_course_module() {
1015 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
1019 * @deprecated since 2.5
1021 function update_category_button() {
1022 throw new coding_exception('Function update_category_button() is removed. Pages to view '.
1023 'and edit courses are now separate and no longer depend on editing mode.');
1027 * @deprecated since 2.5
1029 function make_categories_list() {
1030 throw new coding_exception('Global function make_categories_list() is removed. Please use '.
1031 'core_course_category::make_categories_list() and core_course_category::get_parents()');
1035 * @deprecated since 2.5
1037 function category_delete_move() {
1038 throw new coding_exception('Function category_delete_move() is removed. Please use ' .
1039 'core_course_category::delete_move() instead.');
1043 * @deprecated since 2.5
1045 function category_delete_full() {
1046 throw new coding_exception('Function category_delete_full() is removed. Please use ' .
1047 'core_course_category::delete_full() instead.');
1051 * @deprecated since 2.5
1053 function move_category() {
1054 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.');
1058 * @deprecated since 2.5
1060 function course_category_hide() {
1061 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.');
1065 * @deprecated since 2.5
1067 function course_category_show() {
1068 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.');
1072 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or
1073 * core_course_category::get($catid, MUST_EXIST).
1075 function get_course_category() {
1076 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' .
1077 'see phpdocs for more details');
1081 * @deprecated since 2.5
1083 function create_course_category() {
1084 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' .
1085 'see phpdocs for more details');
1089 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children()
1091 function get_all_subcategories() {
1092 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '.
1093 'of core_course_category class. See phpdocs for more details');
1097 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children().
1099 function get_child_categories() {
1100 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' .
1101 'phpdocs for more details.');
1105 * @deprecated since 2.5
1107 function get_categories() {
1108 throw new coding_exception('Function get_categories() is removed. Please use ' .
1109 'appropriate functions from class core_course_category');
1113 * @deprecated since 2.5
1115 function print_course_search() {
1116 throw new coding_exception('Function print_course_search() is removed, please use course renderer');
1120 * @deprecated since 2.5
1122 function print_my_moodle() {
1123 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
1124 'function frontpage_my_courses()');
1128 * @deprecated since 2.5
1130 function print_remote_course() {
1131 throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
1135 * @deprecated since 2.5
1137 function print_remote_host() {
1138 throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
1142 * @deprecated since 2.5
1144 function print_whole_category_list() {
1145 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
1149 * @deprecated since 2.5
1151 function print_category_info() {
1152 throw new coding_exception('Function print_category_info() is removed, please use course renderer');
1156 * @deprecated since 2.5
1158 function get_course_category_tree() {
1159 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
1160 'renderer or core_course_category class, see function phpdocs for more info');
1164 * @deprecated since 2.5
1166 function print_courses() {
1167 throw new coding_exception('Function print_courses() is removed, please use course renderer');
1171 * @deprecated since 2.5
1173 function print_course() {
1174 throw new coding_exception('Function print_course() is removed, please use course renderer');
1178 * @deprecated since 2.5
1180 function get_category_courses_array() {
1181 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' .
1182 'core_course_category class');
1186 * @deprecated since 2.5
1188 function get_category_courses_array_recursively() {
1189 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' .
1190 'methods of core_course_category class', DEBUG_DEVELOPER);
1194 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
1196 function blog_get_context_url() {
1197 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
1201 * @deprecated since 2.5
1203 function get_courses_wmanagers() {
1204 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' .
1205 'core_course_category::get_courses()');
1209 * @deprecated since 2.5
1211 function convert_tree_to_html() {
1212 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
1216 * @deprecated since 2.5
1218 function convert_tabrows_to_tree() {
1219 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
1223 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
1225 function can_use_rotated_text() {
1226 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.');
1230 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
1232 function get_context_instance_by_id() {
1233 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
1237 * Returns system context or null if can not be created yet.
1239 * @see context_system::instance()
1240 * @deprecated since 2.2
1241 * @param bool $cache use caching
1242 * @return context system context (null if context table not created yet)
1244 function get_system_context($cache = true) {
1245 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
1246 return context_system::instance(0, IGNORE_MISSING, $cache);
1250 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
1252 function get_parent_contexts() {
1253 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
1257 * @deprecated since Moodle 2.2
1259 function get_parent_contextid() {
1260 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
1264 * @deprecated since 2.2
1266 function get_child_contexts() {
1267 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
1271 * @deprecated since 2.2
1273 function create_contexts() {
1274 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
1278 * @deprecated since 2.2
1280 function cleanup_contexts() {
1281 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.');
1285 * @deprecated since 2.2
1287 function build_context_path() {
1288 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
1292 * @deprecated since 2.2
1294 function rebuild_contexts() {
1295 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
1299 * @deprecated since Moodle 2.2
1301 function preload_course_contexts() {
1302 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
1306 * @deprecated since Moodle 2.2
1308 function context_moved() {
1309 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
1313 * @deprecated since 2.2
1315 function fetch_context_capabilities() {
1316 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
1320 * @deprecated since 2.2
1322 function context_instance_preload() {
1323 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
1327 * @deprecated since 2.2
1329 function get_contextlevel_name() {
1330 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
1334 * @deprecated since 2.2
1336 function print_context_name() {
1337 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
1341 * @deprecated since 2.2, use $context->mark_dirty() instead
1343 function mark_context_dirty() {
1344 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
1348 * @deprecated since Moodle 2.2
1350 function delete_context() {
1351 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
1352 'or $context->delete_content() instead.');
1356 * @deprecated since 2.2
1358 function get_context_url() {
1359 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
1363 * @deprecated since 2.2
1365 function get_course_context() {
1366 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
1370 * @deprecated since 2.2
1372 function get_user_courses_bycap() {
1373 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
1377 * @deprecated since Moodle 2.2
1379 function get_role_context_caps() {
1380 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
1384 * @deprecated since 2.2
1386 function get_courseid_from_context() {
1387 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
1391 * @deprecated since 2.2
1393 function context_instance_preload_sql() {
1394 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
1398 * @deprecated since 2.2
1400 function get_related_contexts_string() {
1401 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
1405 * @deprecated since 2.6
1407 function get_plugin_list_with_file() {
1408 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
1412 * @deprecated since 2.6
1414 function check_browser_operating_system() {
1415 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
1419 * @deprecated since 2.6
1421 function check_browser_version() {
1422 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
1426 * @deprecated since 2.6
1428 function get_device_type() {
1429 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.');
1433 * @deprecated since 2.6
1435 function get_device_type_list() {
1436 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
1440 * @deprecated since 2.6
1442 function get_selected_theme_for_device_type() {
1443 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
1447 * @deprecated since 2.6
1449 function get_device_cfg_var_name() {
1450 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
1454 * @deprecated since 2.6
1456 function set_user_device_type() {
1457 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
1461 * @deprecated since 2.6
1463 function get_user_device_type() {
1464 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.');
1468 * @deprecated since 2.6
1470 function get_browser_version_classes() {
1471 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.');
1475 * @deprecated since Moodle 2.6
1477 function generate_email_supportuser() {
1478 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
1482 * @deprecated since Moodle 2.6
1484 function badges_get_issued_badge_info() {
1485 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
1489 * @deprecated since 2.6
1491 function can_use_html_editor() {
1492 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.');
1497 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
1499 function count_login_failures() {
1500 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
1504 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
1506 function ajaxenabled() {
1507 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
1511 * @deprecated Since Moodle 2.7 MDL-44070
1513 function coursemodule_visible_for_user() {
1514 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
1515 please use \core_availability\info_module::is_user_visible()');
1519 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
1521 function enrol_cohort_get_cohorts() {
1522 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
1523 'cohort_get_available_cohorts() instead');
1527 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
1529 function enrol_cohort_can_view_cohort() {
1530 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
1534 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
1536 function cohort_get_visible_list() {
1537 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
1538 "that correctly checks capabilities.');
1542 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1544 function enrol_cohort_enrol_all_users() {
1545 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
1549 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1551 function enrol_cohort_search_cohorts() {
1552 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
1555 /* === Apis deprecated in since Moodle 2.9 === */
1558 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
1560 function message_current_user_is_involved() {
1561 throw new coding_exception('message_current_user_is_involved() can not be used any more.');
1565 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
1567 function profile_display_badges() {
1568 throw new coding_exception('profile_display_badges() can not be used any more.');
1572 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
1574 function useredit_shared_definition_preferences() {
1575 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
1580 * @deprecated since Moodle 2.9
1582 function calendar_normalize_tz() {
1583 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
1587 * @deprecated since Moodle 2.9
1589 function get_user_timezone_offset() {
1590 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1595 * @deprecated since Moodle 2.9
1597 function get_timezone_offset() {
1598 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1602 * @deprecated since Moodle 2.9
1604 function get_list_of_timezones() {
1605 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead');
1609 * @deprecated since Moodle 2.9
1611 function update_timezone_records() {
1612 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
1616 * @deprecated since Moodle 2.9
1618 function calculate_user_dst_table() {
1619 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
1623 * @deprecated since Moodle 2.9
1625 function dst_changes_for_year() {
1626 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
1630 * @deprecated since Moodle 2.9
1632 function get_timezone_record() {
1633 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
1636 /* === Apis deprecated since Moodle 3.0 === */
1638 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
1640 function get_referer() {
1641 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
1645 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
1647 function is_web_crawler() {
1648 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.');
1652 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
1654 function completion_cron() {
1655 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.');
1659 * @deprecated since 3.0
1661 function coursetag_get_tags() {
1662 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
1663 'Userid is no longer used for tagging courses.');
1667 * @deprecated since 3.0
1669 function coursetag_get_all_tags() {
1670 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
1671 'longer used for tagging courses.');
1675 * @deprecated since 3.0
1677 function coursetag_get_jscript() {
1678 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.');
1682 * @deprecated since 3.0
1684 function coursetag_get_jscript_links() {
1685 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
1689 * @deprecated since 3.0
1691 function coursetag_get_records() {
1692 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
1693 'Userid is no longer used for tagging courses.');
1697 * @deprecated since 3.0
1699 function coursetag_store_keywords() {
1700 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
1701 'Userid is no longer used for tagging courses.');
1705 * @deprecated since 3.0
1707 function coursetag_delete_keyword() {
1708 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
1709 'Userid is no longer used for tagging courses.');
1713 * @deprecated since 3.0
1715 function coursetag_get_tagged_courses() {
1716 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
1717 'Userid is no longer used for tagging courses.');
1721 * @deprecated since 3.0
1723 function coursetag_delete_course_tags() {
1724 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
1725 'Use core_tag_tag::remove_all_item_tags().');
1729 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1731 function tag_type_set() {
1732 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
1733 'core_tag_tag::get($tagid)->update().');
1737 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1739 function tag_description_set() {
1740 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
1741 'core_tag_tag::get($tagid)->update().');
1745 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1747 function tag_get_tags() {
1748 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
1749 'core_tag_tag::get_item_tags().');
1753 * @deprecated since 3.1
1755 function tag_get_tags_array() {
1756 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
1757 'core_tag_tag::get_item_tags_array().');
1761 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
1763 function tag_get_tags_csv() {
1764 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
1765 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1769 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1771 function tag_get_tags_ids() {
1772 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
1773 'core_tag_tag::get_item_tags() or similar methods.');
1777 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
1779 function tag_get_id() {
1780 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
1781 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
1785 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1787 function tag_rename() {
1788 throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
1789 'core_tag_tag::get($tagid)->update()');
1793 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
1795 function tag_delete_instance() {
1796 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
1797 'core_tag_tag::remove_item_tag()');
1801 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
1803 function tag_find_records() {
1804 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
1805 'core_tag_tag::get_by_name()->get_tagged_items()');
1809 * @deprecated since 3.1
1811 function tag_add() {
1812 throw new coding_exception('tag_add() can not be used anymore. You can use ' .
1813 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
1814 'created automatically when assigned to items');
1818 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
1820 function tag_assign() {
1821 throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
1822 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
1823 'ordering should not be set manually');
1827 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
1829 function tag_record_count() {
1830 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
1831 'core_tag_tag::get($tagid)->count_tagged_items().');
1835 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
1837 function tag_record_tagged_with() {
1838 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
1839 'core_tag_tag::get($tagid)->is_item_tagged_with().');
1843 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
1845 function tag_set_flag() {
1846 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
1847 'core_tag_tag::get($tagid)->flag()');
1851 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
1853 function tag_unset_flag() {
1854 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
1855 'core_tag_tag::get($tagid)->reset_flag()');
1859 * @deprecated since 3.1
1861 function tag_print_cloud() {
1862 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
1863 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
1864 'template core_tag/tagcloud.');
1868 * @deprecated since 3.0
1870 function tag_autocomplete() {
1871 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
1872 'element "tags" does proper autocomplete.');
1876 * @deprecated since 3.1
1878 function tag_print_description_box() {
1879 throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
1880 'See core_tag_renderer for similar code');
1884 * @deprecated since 3.1
1886 function tag_print_management_box() {
1887 throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
1888 'See core_tag_renderer for similar code');
1892 * @deprecated since 3.1
1894 function tag_print_search_box() {
1895 throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
1896 'See core_tag_renderer for similar code');
1900 * @deprecated since 3.1
1902 function tag_print_search_results() {
1903 throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
1904 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
1908 * @deprecated since 3.1
1910 function tag_print_tagged_users_table() {
1911 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
1912 'See core_user_renderer for similar code');
1916 * @deprecated since 3.1
1918 function tag_print_user_box() {
1919 throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
1920 'See core_user_renderer for similar code');
1924 * @deprecated since 3.1
1926 function tag_print_user_list() {
1927 throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
1928 'See core_user_renderer for similar code');
1932 * @deprecated since 3.1
1934 function tag_display_name() {
1935 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
1936 'core_tag_tag::make_display_name().');
1941 * @deprecated since 3.1
1943 function tag_normalize() {
1944 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
1945 'core_tag_tag::normalize().');
1949 * @deprecated since 3.1
1951 function tag_get_related_tags_csv() {
1952 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
1953 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1957 * @deprecated since 3.1
1959 function tag_set() {
1960 throw new coding_exception('tag_set() can not be used anymore. Please use ' .
1961 'core_tag_tag::set_item_tags().');
1965 * @deprecated since 3.1
1967 function tag_set_add() {
1968 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
1969 'core_tag_tag::add_item_tag().');
1973 * @deprecated since 3.1
1975 function tag_set_delete() {
1976 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
1977 'core_tag_tag::remove_item_tag().');
1981 * @deprecated since 3.1
1983 function tag_get() {
1984 throw new coding_exception('tag_get() can not be used anymore. Please use ' .
1985 'core_tag_tag::get() or core_tag_tag::get_by_name().');
1989 * @deprecated since 3.1
1991 function tag_get_related_tags() {
1992 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
1993 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
1994 'core_tag_tag::get_manual_related_tags().');
1998 * @deprecated since 3.1
2000 function tag_delete() {
2001 throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
2002 'core_tag_tag::delete_tags().');
2006 * @deprecated since 3.1
2008 function tag_delete_instances() {
2009 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
2010 'core_tag_tag::delete_instances().');
2014 * @deprecated since 3.1
2016 function tag_cleanup() {
2017 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
2018 '\core\task\tag_cron_task::cleanup().');
2022 * @deprecated since 3.1
2024 function tag_bulk_delete_instances() {
2025 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
2026 '\core\task\tag_cron_task::bulk_delete_instances().');
2031 * @deprecated since 3.1
2033 function tag_compute_correlations() {
2034 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
2035 'use \core\task\tag_cron_task::compute_correlations().');
2039 * @deprecated since 3.1
2041 function tag_process_computed_correlation() {
2042 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
2043 'use \core\task\tag_cron_task::process_computed_correlation().');
2047 * @deprecated since 3.1
2049 function tag_cron() {
2050 throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
2051 'use \core\task\tag_cron_task::execute().');
2055 * @deprecated since 3.1
2057 function tag_find_tags() {
2058 throw new coding_exception('tag_find_tags() can not be used anymore.');
2062 * @deprecated since 3.1
2064 function tag_get_name() {
2065 throw new coding_exception('tag_get_name() can not be used anymore.');
2069 * @deprecated since 3.1
2071 function tag_get_correlated() {
2072 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
2073 'use core_tag_tag::get_correlated_tags().');
2078 * @deprecated since 3.1
2080 function tag_cloud_sort() {
2081 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
2082 'be found in core_tag_collection::cloud_sort().');
2086 * @deprecated since Moodle 3.1
2088 function events_load_def() {
2089 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2094 * @deprecated since Moodle 3.1
2096 function events_queue_handler() {
2097 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2101 * @deprecated since Moodle 3.1
2103 function events_dispatch() {
2104 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2108 * @deprecated since Moodle 3.1
2110 function events_process_queued_handler() {
2111 throw new coding_exception(
2112 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
2117 * @deprecated since Moodle 3.1
2119 function events_update_definition() {
2120 throw new coding_exception(
2121 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
2126 * @deprecated since Moodle 3.1
2128 function events_cron() {
2129 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2133 * @deprecated since Moodle 3.1
2135 function events_trigger_legacy() {
2136 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2140 * @deprecated since Moodle 3.1
2142 function events_is_registered() {
2143 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2147 * @deprecated since Moodle 3.1
2149 function events_pending_count() {
2150 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2154 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2156 function clam_message_admins() {
2157 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
2158 'message_admins() method of \antivirus_clamav\scanner class.');
2162 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2164 function get_clam_error_code() {
2165 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
2166 'get_clam_error_code() method of \antivirus_clamav\scanner class.');
2170 * @deprecated since 3.1
2172 function course_get_cm_rename_action() {
2173 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
2174 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
2179 * @deprecated since Moodle 3.1
2181 function course_scale_used() {
2182 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
2183 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2187 * @deprecated since Moodle 3.1
2189 function site_scale_used() {
2190 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
2191 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2195 * @deprecated since Moodle 3.1. Use external_api::external_function_info().
2197 function external_function_info() {
2198 throw new coding_exception('external_function_info() can not be used any'.
2199 'more. Please use external_api::external_function_info() instead.');
2203 * @deprecated since Moodle 3.2
2204 * @see csv_import_reader::load_csv_content()
2206 function get_records_csv() {
2207 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' .
2208 'lib/csvlib.class.php csv_import_reader() instead.');
2212 * @deprecated since Moodle 3.2
2213 * @see download_as_dataformat (lib/dataformatlib.php)
2215 function put_records_csv() {
2216 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' .
2217 'lib/dataformatlib.php download_as_dataformat() instead.');
2221 * @deprecated since Moodle 3.2
2223 function css_is_colour() {
2224 throw new coding_exception('css_is_colour() can not be used anymore.');
2228 * @deprecated since Moodle 3.2
2230 function css_is_width() {
2231 throw new coding_exception('css_is_width() can not be used anymore.');
2235 * @deprecated since Moodle 3.2
2237 function css_sort_by_count() {
2238 throw new coding_exception('css_sort_by_count() can not be used anymore.');
2242 * @deprecated since Moodle 3.2
2244 function message_get_course_contexts() {
2245 throw new coding_exception('message_get_course_contexts() can not be used anymore.');
2249 * @deprecated since Moodle 3.2
2251 function message_remove_url_params() {
2252 throw new coding_exception('message_remove_url_params() can not be used anymore.');
2256 * @deprecated since Moodle 3.2
2258 function message_count_messages() {
2259 throw new coding_exception('message_count_messages() can not be used anymore.');
2263 * @deprecated since Moodle 3.2
2265 function message_count_blocked_users() {
2266 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' .
2267 '\core_message\api::count_blocked_users() instead.');
2271 * @deprecated since Moodle 3.2
2273 function message_contact_link() {
2274 throw new coding_exception('message_contact_link() can not be used anymore.');
2278 * @deprecated since Moodle 3.2
2280 function message_get_recent_notifications() {
2281 throw new coding_exception('message_get_recent_notifications() can not be used anymore.');
2285 * @deprecated since Moodle 3.2
2287 function message_history_link() {
2288 throw new coding_exception('message_history_link() can not be used anymore.');
2292 * @deprecated since Moodle 3.2
2294 function message_search() {
2295 throw new coding_exception('message_search() can not be used anymore.');
2299 * @deprecated since Moodle 3.2
2301 function message_shorten_message() {
2302 throw new coding_exception('message_shorten_message() can not be used anymore.');
2306 * @deprecated since Moodle 3.2
2308 function message_get_fragment() {
2309 throw new coding_exception('message_get_fragment() can not be used anymore.');
2313 * @deprecated since Moodle 3.2
2315 function message_get_history() {
2316 throw new coding_exception('message_get_history() can not be used anymore.');
2320 * @deprecated since Moodle 3.2
2322 function message_get_contact_add_remove_link() {
2323 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.');
2327 * @deprecated since Moodle 3.2
2329 function message_get_contact_block_link() {
2330 throw new coding_exception('message_get_contact_block_link() can not be used anymore.');
2334 * @deprecated since Moodle 3.2
2336 function message_mark_messages_read() {
2337 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' .
2338 '\core_message\api::mark_all_messages_as_read() instead.');
2342 * @deprecated since Moodle 3.2
2344 function message_can_post_message() {
2345 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' .
2346 '\core_message\api::can_send_message() instead.');
2350 * @deprecated since Moodle 3.2
2352 function message_is_user_non_contact_blocked() {
2353 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' .
2354 '\core_message\api::is_user_non_contact_blocked() instead.');
2358 * @deprecated since Moodle 3.2
2360 function message_is_user_blocked() {
2361 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' .
2362 '\core_message\api::is_user_blocked() instead.');
2366 * @deprecated since Moodle 3.2
2368 function print_log() {
2369 throw new coding_exception('print_log() can not be used anymore. Please use the ' .
2370 'report_log framework instead.');
2374 * @deprecated since Moodle 3.2
2376 function print_mnet_log() {
2377 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' .
2378 'report_log framework instead.');
2382 * @deprecated since Moodle 3.2
2384 function print_log_csv() {
2385 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' .
2386 'report_log framework instead.');
2390 * @deprecated since Moodle 3.2
2392 function print_log_xls() {
2393 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' .
2394 'report_log framework instead.');
2398 * @deprecated since Moodle 3.2
2400 function print_log_ods() {
2401 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' .
2402 'report_log framework instead.');
2406 * @deprecated since Moodle 3.2
2408 function build_logs_array() {
2409 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' .
2410 'report_log framework instead.');
2414 * @deprecated since Moodle 3.2
2416 function get_logs_usercourse() {
2417 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' .
2418 'report_log framework instead.');
2422 * @deprecated since Moodle 3.2
2424 function get_logs_userday() {
2425 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' .
2426 'report_log framework instead.');
2430 * @deprecated since Moodle 3.2
2432 function get_logs() {
2433 throw new coding_exception('get_logs() can not be used anymore. Please use the ' .
2434 'report_log framework instead.');
2438 * @deprecated since Moodle 3.2
2440 function prevent_form_autofill_password() {
2441 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.');
2445 * @deprecated since Moodle 3.3 MDL-57370
2447 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) {
2448 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' .
2449 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER);
2453 * @deprecated since Moodle 3.2
2455 function calendar_preferences_button() {
2456 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' .
2457 'preferences are now linked to the user preferences page.');
2461 * @deprecated since 3.3
2463 function calendar_wday_name() {
2464 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.');
2468 * @deprecated since 3.3
2470 function calendar_get_block_upcoming() {
2471 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' .
2472 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2476 * @deprecated since 3.3
2478 function calendar_print_month_selector() {
2479 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.');
2483 * @deprecated since 3.3
2485 function calendar_cron() {
2486 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.');
2490 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2492 function load_course_context() {
2493 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
2497 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2499 function load_role_access_by_context() {
2500 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
2504 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2506 function dedupe_user_access() {
2507 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
2511 * @deprecated since Moodle 3.4. MDL-49398.
2513 function get_user_access_sitewide() {
2514 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.');
2518 * @deprecated since Moodle 3.4. MDL-59333
2520 function calendar_get_mini() {
2521 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.');
2525 * @deprecated since Moodle 3.4. MDL-59333
2527 function calendar_get_upcoming() {
2528 throw new coding_exception('calendar_get_upcoming() has been removed. ' .
2529 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2533 * @deprecated since Moodle 3.4. MDL-50666
2535 function allow_override() {
2536 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.');
2540 * @deprecated since Moodle 3.4. MDL-50666
2542 function allow_assign() {
2543 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.');
2547 * @deprecated since Moodle 3.4. MDL-50666
2549 function allow_switch() {
2550 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.');
2554 * @deprecated since Moodle 3.5. MDL-61132
2556 function question_add_tops() {
2557 throw new coding_exception(
2558 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().'
2563 * @deprecated since Moodle 3.5. MDL-61132
2565 function question_is_only_toplevel_category_in_context() {
2566 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. '
2567 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.');
2571 * @deprecated since Moodle 3.5
2573 function message_move_userfrom_unread2read() {
2574 throw new coding_exception('message_move_userfrom_unread2read() has been removed.');
2578 * @deprecated since Moodle 3.5
2580 function message_get_blocked_users() {
2581 throw new coding_exception(
2582 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.'
2587 * @deprecated since Moodle 3.5
2589 function message_get_contacts() {
2590 throw new coding_exception('message_get_contacts() has been removed.');
2594 * @deprecated since Moodle 3.5
2596 function message_mark_message_read() {
2597 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read()
2598 or \core_message\api::mark_notification_as_read().');
2602 * @deprecated since Moodle 3.5
2604 function message_can_delete_message() {
2605 throw new coding_exception(
2606 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.'
2611 * @deprecated since Moodle 3.5
2613 function message_delete_message() {
2614 throw new coding_exception(
2615 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.'
2620 * @deprecated since 3.6
2622 function calendar_get_all_allowed_types() {
2623 throw new coding_exception(
2624 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.'
2630 * @deprecated since Moodle 3.6.
2632 function groups_get_all_groups_for_courses() {
2633 throw new coding_exception(
2634 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.'
2639 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2641 function events_get_cached() {
2642 throw new coding_exception(
2643 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2648 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2650 function events_uninstall() {
2651 throw new coding_exception(
2652 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2657 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2659 function events_cleanup() {
2660 throw new coding_exception(
2661 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2666 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2668 function events_dequeue() {
2669 throw new coding_exception(
2670 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2675 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2677 function events_get_handlers() {
2678 throw new coding_exception(
2679 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2684 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2686 function get_roles_on_exact_context() {
2687 throw new coding_exception(
2688 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.'
2693 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2695 function get_roles_with_assignment_on_context() {
2696 throw new coding_exception(
2697 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.'
2702 * @deprecated since Moodle 3.6
2704 function message_add_contact() {
2705 throw new coding_exception(
2706 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' .
2707 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' .
2708 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.'
2713 * @deprecated since Moodle 3.6
2715 function message_remove_contact() {
2716 throw new coding_exception(
2717 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.'
2722 * @deprecated since Moodle 3.6
2724 function message_unblock_contact() {
2725 throw new coding_exception(
2726 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.'
2731 * @deprecated since Moodle 3.6
2733 function message_block_contact() {
2734 throw new coding_exception(
2735 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' .
2736 '\core_message\api::block_user() instead.'
2741 * @deprecated since Moodle 3.6
2743 function message_get_contact() {
2744 throw new coding_exception(
2745 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.'
2750 * @deprecated since Moodle 3.7
2752 function get_courses_page() {
2753 throw new coding_exception(
2754 'Function get_courses_page() has been removed. Please use core_course_category::get_courses() ' .
2755 'or core_course_category::search_courses()'
2760 * @deprecated since Moodle 3.8
2762 function report_insights_context_insights(\context $context) {
2763 throw new coding_exception(
2764 'Function report_insights_context_insights() ' .
2765 'has been removed. Please use \core_analytics\manager::cached_models_with_insights instead'
2770 * Retrieve all metadata for the requested modules
2772 * @deprecated since 3.9.
2773 * @param object $course The Course
2774 * @param array $modnames An array containing the list of modules and their
2775 * names
2776 * @param int $sectionreturn The section to return to
2777 * @return array A list of stdClass objects containing metadata about each
2778 * module
2780 function get_module_metadata($course, $modnames, $sectionreturn = null) {
2781 global $OUTPUT;
2783 debugging('get_module_metadata is deprecated. Please use \core_course\local\service\content_item_service instead.');
2785 // get_module_metadata will be called once per section on the page and courses may show
2786 // different modules to one another
2787 static $modlist = array();
2788 if (!isset($modlist[$course->id])) {
2789 $modlist[$course->id] = array();
2792 $return = array();
2793 $urlbase = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey()));
2794 if ($sectionreturn !== null) {
2795 $urlbase->param('sr', $sectionreturn);
2797 foreach($modnames as $modname => $modnamestr) {
2798 if (!course_allowed_module($course, $modname)) {
2799 continue;
2801 if (isset($modlist[$course->id][$modname])) {
2802 // This module is already cached
2803 $return += $modlist[$course->id][$modname];
2804 continue;
2806 $modlist[$course->id][$modname] = array();
2808 // Create an object for a default representation of this module type in the activity chooser. It will be used
2809 // if module does not implement callback get_shortcuts() and it will also be passed to the callback if it exists.
2810 $defaultmodule = new stdClass();
2811 $defaultmodule->title = $modnamestr;
2812 $defaultmodule->name = $modname;
2813 $defaultmodule->link = new moodle_url($urlbase, array('add' => $modname));
2814 $defaultmodule->icon = $OUTPUT->pix_icon('icon', '', $defaultmodule->name, array('class' => 'icon'));
2815 $sm = get_string_manager();
2816 if ($sm->string_exists('modulename_help', $modname)) {
2817 $defaultmodule->help = get_string('modulename_help', $modname);
2818 if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs.
2819 $link = get_string('modulename_link', $modname);
2820 $linktext = get_string('morehelp');
2821 $defaultmodule->help .= html_writer::tag('div',
2822 $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));
2825 $defaultmodule->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
2827 // Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list
2828 // of elements to be added to activity chooser.
2829 $items = component_callback($modname, 'get_shortcuts', array($defaultmodule), null);
2830 if ($items !== null) {
2831 foreach ($items as $item) {
2832 // Add all items to the return array. All items must have different links, use them as a key in the return array.
2833 if (!isset($item->archetype)) {
2834 $item->archetype = $defaultmodule->archetype;
2836 if (!isset($item->icon)) {
2837 $item->icon = $defaultmodule->icon;
2839 // If plugin returned the only one item with the same link as default item - cache it as $modname,
2840 // otherwise append the link url to the module name.
2841 $item->name = (count($items) == 1 &&
2842 $item->link->out() === $defaultmodule->link->out()) ? $modname : $modname . ':' . $item->link;
2844 // If the module provides the helptext property, append it to the help text to match the look and feel
2845 // of the default course modules.
2846 if (isset($item->help) && isset($item->helplink)) {
2847 $linktext = get_string('morehelp');
2848 $item->help .= html_writer::tag('div',
2849 $OUTPUT->doc_link($item->helplink, $linktext, true), array('class' => 'helpdoclink'));
2851 $modlist[$course->id][$modname][$item->name] = $item;
2853 $return += $modlist[$course->id][$modname];
2854 // If get_shortcuts() callback is defined, the default module action is not added.
2855 // It is a responsibility of the callback to add it to the return value unless it is not needed.
2856 continue;
2859 // The callback get_shortcuts() was not found, use the default item for the activity chooser.
2860 $modlist[$course->id][$modname][$modname] = $defaultmodule;
2861 $return[$modname] = $defaultmodule;
2864 core_collator::asort_objects_by_property($return, 'title');
2865 return $return;
2869 * Runs a single cron task. This function assumes it is displaying output in pseudo-CLI mode.
2871 * The function will fail if the task is disabled.
2873 * Warning: Because this function closes the browser session, it may not be safe to continue
2874 * with other processing (other than displaying the rest of the page) after using this function!
2876 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task).
2877 * @todo final deprecation. To be removed in Moodle 4.1 MDL-63594.
2878 * @param \core\task\scheduled_task $task Task to run
2879 * @return bool True if cron run successful
2881 function cron_run_single_task(\core\task\scheduled_task $task) {
2882 debugging('cron_run_single_task() is deprecated. Please use \\core\task\manager::run_from_cli() instead.',
2883 DEBUG_DEVELOPER);
2884 return \core\task\manager::run_from_cli($task);
2888 * Executes cron functions for a specific type of plugin.
2890 * @param string $plugintype Plugin type (e.g. 'report')
2891 * @param string $description If specified, will display 'Starting (whatever)'
2892 * and 'Finished (whatever)' lines, otherwise does not display
2894 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2895 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2897 function cron_execute_plugin_type($plugintype, $description = null) {
2898 global $DB;
2900 // Get list from plugin => function for all plugins.
2901 $plugins = get_plugin_list_with_function($plugintype, 'cron');
2903 // Modify list for backward compatibility (different files/names).
2904 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins);
2906 // Return if no plugins with cron function to process.
2907 if (!$plugins) {
2908 return;
2911 if ($description) {
2912 mtrace('Starting '.$description);
2915 foreach ($plugins as $component => $cronfunction) {
2916 $dir = core_component::get_component_directory($component);
2918 // Get cron period if specified in version.php, otherwise assume every cron.
2919 $cronperiod = 0;
2920 if (file_exists("$dir/version.php")) {
2921 $plugin = new stdClass();
2922 include("$dir/version.php");
2923 if (isset($plugin->cron)) {
2924 $cronperiod = $plugin->cron;
2928 // Using last cron and cron period, don't run if it already ran recently.
2929 $lastcron = get_config($component, 'lastcron');
2930 if ($cronperiod && $lastcron) {
2931 if ($lastcron + $cronperiod > time()) {
2932 // Do not execute cron yet.
2933 continue;
2937 mtrace('Processing cron function for ' . $component . '...');
2938 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER);
2939 cron_trace_time_and_memory();
2940 $pre_dbqueries = $DB->perf_get_queries();
2941 $pre_time = microtime(true);
2943 $cronfunction();
2945 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " .
2946 round(microtime(true) - $pre_time, 2) . " seconds)");
2948 set_config('lastcron', time(), $component);
2949 core_php_time_limit::raise();
2952 if ($description) {
2953 mtrace('Finished ' . $description);
2958 * Used to add in old-style cron functions within plugins that have not been converted to the
2959 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used
2960 * cron.php and some used a different name.)
2962 * @param string $plugintype Plugin type e.g. 'report'
2963 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g.
2964 * 'report_frog_cron') for plugin cron functions that were already found using the new API
2965 * @return array Revised version of $plugins that adds in any extra plugin functions found by
2966 * looking in the older location
2968 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2969 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2971 function cron_bc_hack_plugin_functions($plugintype, $plugins) {
2972 global $CFG; // Mandatory in case it is referenced by include()d PHP script.
2974 if ($plugintype === 'report') {
2975 // Admin reports only - not course report because course report was
2976 // never implemented before, so doesn't need BC.
2977 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
2978 $component = $plugintype . '_' . $pluginname;
2979 if (isset($plugins[$component])) {
2980 // We already have detected the function using the new API.
2981 continue;
2983 if (!file_exists("$dir/cron.php")) {
2984 // No old style cron file present.
2985 continue;
2987 include_once("$dir/cron.php");
2988 $cronfunction = $component . '_cron';
2989 if (function_exists($cronfunction)) {
2990 $plugins[$component] = $cronfunction;
2991 } else {
2992 debugging("Invalid legacy cron.php detected in $component, " .
2993 "please use lib.php instead");
2996 } else if (strpos($plugintype, 'grade') === 0) {
2997 // Detect old style cron function names.
2998 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of
2999 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport.
3000 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
3001 $component = $plugintype.'_'.$pluginname;
3002 if (isset($plugins[$component])) {
3003 // We already have detected the function using the new API.
3004 continue;
3006 if (!file_exists("$dir/lib.php")) {
3007 continue;
3009 include_once("$dir/lib.php");
3010 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' .
3011 $pluginname . '_cron';
3012 if (function_exists($cronfunction)) {
3013 $plugins[$component] = $cronfunction;
3018 return $plugins;
3022 * Returns the SQL used by the participants table.
3024 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3025 * @param int $courseid The course id
3026 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3027 * @param int $accesssince The time since last access, 0 means any time
3028 * @param int $roleid The role id, 0 means all roles and -1 no roles
3029 * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned.
3030 * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed.
3031 * @param string|array $search The search that was performed, empty means perform no search
3032 * @param string $additionalwhere Any additional SQL to add to where
3033 * @param array $additionalparams The additional params
3034 * @return array
3036 function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3037 $search = '', $additionalwhere = '', $additionalparams = array()) {
3038 global $DB, $USER, $CFG;
3040 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3041 'Please use \core\table\participants_search::class with table filtersets instead.';
3042 debugging($deprecatedtext, DEBUG_DEVELOPER);
3044 // Get the context.
3045 $context = \context_course::instance($courseid, MUST_EXIST);
3047 $isfrontpage = ($courseid == SITEID);
3049 // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments.
3050 $onlyactive = true;
3051 $onlysuspended = false;
3052 if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) {
3053 switch ($statusid) {
3054 case ENROL_USER_ACTIVE:
3055 // Nothing to do here.
3056 break;
3057 case ENROL_USER_SUSPENDED:
3058 $onlyactive = false;
3059 $onlysuspended = true;
3060 break;
3061 default:
3062 // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false.
3063 $onlyactive = false;
3064 break;
3068 list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid);
3070 $joins = array('FROM {user} u');
3071 $wheres = array();
3073 // TODO Does not support custom user profile fields (MDL-70456).
3074 $userfields = \core_user\fields::get_identity_fields($context, false);
3075 $userfieldsapi = \core_user\fields::for_userpic()->including(...$userfields);
3076 $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
3078 if ($isfrontpage) {
3079 $select = "SELECT $userfieldssql, u.lastaccess";
3080 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually.
3081 if ($accesssince) {
3082 $wheres[] = user_get_user_lastaccess_sql($accesssince);
3084 } else {
3085 $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess";
3086 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only.
3087 // Not everybody has accessed the course yet.
3088 $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)';
3089 $params['courseid'] = $courseid;
3090 if ($accesssince) {
3091 $wheres[] = user_get_course_lastaccess_sql($accesssince);
3095 // Performance hacks - we preload user contexts together with accounts.
3096 $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
3097 $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)';
3098 $params['contextlevel'] = CONTEXT_USER;
3099 $select .= $ccselect;
3100 $joins[] = $ccjoin;
3102 // Limit list to users with some role only.
3103 if ($roleid) {
3104 // We want to query both the current context and parent contexts.
3105 list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true),
3106 SQL_PARAMS_NAMED, 'relatedctx');
3108 // Get users without any role.
3109 if ($roleid == -1) {
3110 $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)";
3111 $params = array_merge($params, $relatedctxparams);
3112 } else {
3113 $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
3114 $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
3118 if (!empty($search)) {
3119 if (!is_array($search)) {
3120 $search = [$search];
3122 foreach ($search as $index => $keyword) {
3123 $searchkey1 = 'search' . $index . '1';
3124 $searchkey2 = 'search' . $index . '2';
3125 $searchkey3 = 'search' . $index . '3';
3126 $searchkey4 = 'search' . $index . '4';
3127 $searchkey5 = 'search' . $index . '5';
3128 $searchkey6 = 'search' . $index . '6';
3129 $searchkey7 = 'search' . $index . '7';
3131 $conditions = array();
3132 // Search by fullname.
3133 $fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
3134 $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false);
3136 // Search by email.
3137 $email = $DB->sql_like('email', ':' . $searchkey2, false, false);
3138 if (!in_array('email', $userfields)) {
3139 $maildisplay = 'maildisplay' . $index;
3140 $userid1 = 'userid' . $index . '1';
3141 // Prevent users who hide their email address from being found by others
3142 // who aren't allowed to see hidden email addresses.
3143 $email = "(". $email ." AND (" .
3144 "u.maildisplay <> :$maildisplay " .
3145 "OR u.id = :$userid1". // User can always find himself.
3146 "))";
3147 $params[$maildisplay] = core_user::MAILDISPLAY_HIDE;
3148 $params[$userid1] = $USER->id;
3150 $conditions[] = $email;
3152 // Search by idnumber.
3153 $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false);
3154 if (!in_array('idnumber', $userfields)) {
3155 $userid2 = 'userid' . $index . '2';
3156 // Users who aren't allowed to see idnumbers should at most find themselves
3157 // when searching for an idnumber.
3158 $idnumber = "(". $idnumber . " AND u.id = :$userid2)";
3159 $params[$userid2] = $USER->id;
3161 $conditions[] = $idnumber;
3163 // TODO Does not support custom user profile fields (MDL-70456).
3164 $extrasearchfields = \core_user\fields::get_identity_fields($context, false);
3165 if (!empty($extrasearchfields)) {
3166 // Search all user identify fields.
3167 foreach ($extrasearchfields as $extrasearchfield) {
3168 if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) {
3169 // Already covered above. Search by country not supported.
3170 continue;
3172 $param = $searchkey3 . $extrasearchfield;
3173 $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false);
3174 $params[$param] = "%$keyword%";
3175 if (!in_array($extrasearchfield, $userfields)) {
3176 // User cannot see this field, but allow match if their own account.
3177 $userid3 = 'userid' . $index . '3' . $extrasearchfield;
3178 $condition = "(". $condition . " AND u.id = :$userid3)";
3179 $params[$userid3] = $USER->id;
3181 $conditions[] = $condition;
3185 // Search by middlename.
3186 $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false);
3187 $conditions[] = $middlename;
3189 // Search by alternatename.
3190 $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false);
3191 $conditions[] = $alternatename;
3193 // Search by firstnamephonetic.
3194 $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false);
3195 $conditions[] = $firstnamephonetic;
3197 // Search by lastnamephonetic.
3198 $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false);
3199 $conditions[] = $lastnamephonetic;
3201 $wheres[] = "(". implode(" OR ", $conditions) .") ";
3202 $params[$searchkey1] = "%$keyword%";
3203 $params[$searchkey2] = "%$keyword%";
3204 $params[$searchkey3] = "%$keyword%";
3205 $params[$searchkey4] = "%$keyword%";
3206 $params[$searchkey5] = "%$keyword%";
3207 $params[$searchkey6] = "%$keyword%";
3208 $params[$searchkey7] = "%$keyword%";
3212 if (!empty($additionalwhere)) {
3213 $wheres[] = $additionalwhere;
3214 $params = array_merge($params, $additionalparams);
3217 $from = implode("\n", $joins);
3218 if ($wheres) {
3219 $where = 'WHERE ' . implode(' AND ', $wheres);
3220 } else {
3221 $where = '';
3224 return array($select, $from, $where, $params);
3228 * Returns the total number of participants for a given course.
3230 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3231 * @param int $courseid The course id
3232 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3233 * @param int $accesssince The time since last access, 0 means any time
3234 * @param int $roleid The role id, 0 means all roles
3235 * @param int $enrolid The applied filter for the user enrolment ID.
3236 * @param int $status The applied filter for the user's enrolment status.
3237 * @param string|array $search The search that was performed, empty means perform no search
3238 * @param string $additionalwhere Any additional SQL to add to where
3239 * @param array $additionalparams The additional params
3240 * @return int
3242 function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3243 $search = '', $additionalwhere = '', $additionalparams = array()) {
3244 global $DB;
3246 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3247 'Please use \core\table\participants_search::class with table filtersets instead.';
3248 debugging($deprecatedtext, DEBUG_DEVELOPER);
3250 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3251 $statusid, $search, $additionalwhere, $additionalparams);
3253 return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
3257 * Returns the participants for a given course.
3259 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3260 * @param int $courseid The course id
3261 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3262 * @param int $accesssince The time since last access
3263 * @param int $roleid The role id
3264 * @param int $enrolid The applied filter for the user enrolment ID.
3265 * @param int $status The applied filter for the user's enrolment status.
3266 * @param string $search The search that was performed
3267 * @param string $additionalwhere Any additional SQL to add to where
3268 * @param array $additionalparams The additional params
3269 * @param string $sort The SQL sort
3270 * @param int $limitfrom return a subset of records, starting at this point (optional).
3271 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
3272 * @return moodle_recordset
3274 function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enrolid, $statusid, $search,
3275 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) {
3276 global $DB;
3278 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3279 'Please use \core\table\participants_search::class with table filtersets instead.';
3280 debugging($deprecatedtext, DEBUG_DEVELOPER);
3282 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3283 $statusid, $search, $additionalwhere, $additionalparams);
3285 return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
3289 * Returns the list of full course categories to be used in html_writer::select()
3291 * Calls {@see core_course_category::make_categories_list()} to build the list.
3293 * @deprecated since Moodle 3.10
3294 * @todo This will be finally removed for Moodle 4.2 as part of MDL-69124.
3295 * @return array array mapping course category id to the display name
3297 function make_categories_options() {
3298 $deprecatedtext = __FUNCTION__ . '() is deprecated. Please use \core_course_category::make_categories_list() instead.';
3299 debugging($deprecatedtext, DEBUG_DEVELOPER);
3301 return core_course_category::make_categories_list('', 0, ' / ');
3305 * Checks if current user is shown any extra fields when listing users.
3307 * Does not include any custom profile fields.
3309 * @param object $context Context
3310 * @param array $already Array of fields that we're going to show anyway
3311 * so don't bother listing them
3312 * @return array Array of field names from user table, not including anything
3313 * listed in $already
3314 * @deprecated since Moodle 3.11 MDL-45242
3315 * @see \core_user\fields
3317 function get_extra_user_fields($context, $already = array()) {
3318 debugging('get_extra_user_fields() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3320 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3321 return $fields->get_required_fields();
3325 * If the current user is to be shown extra user fields when listing or
3326 * selecting users, returns a string suitable for including in an SQL select
3327 * clause to retrieve those fields.
3329 * Does not include any custom profile fields.
3331 * @param context $context Context
3332 * @param string $alias Alias of user table, e.g. 'u' (default none)
3333 * @param string $prefix Prefix for field names using AS, e.g. 'u_' (default none)
3334 * @param array $already Array of fields that we're going to include anyway so don't list them (default none)
3335 * @return string Partial SQL select clause, beginning with comma, for example ',u.idnumber,u.department' unless it is blank
3336 * @deprecated since Moodle 3.11 MDL-45242
3337 * @see \core_user\fields
3339 function get_extra_user_fields_sql($context, $alias='', $prefix='', $already = array()) {
3340 debugging('get_extra_user_fields_sql() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3342 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3343 // Note: There will never be any joins or join params because we turned off profile fields.
3344 $selects = $fields->get_sql($alias, false, $prefix)->selects;
3346 return $selects;
3350 * Returns the display name of a field in the user table. Works for most fields that are commonly displayed to users.
3352 * Also works for custom fields.
3354 * @param string $field Field name, e.g. 'phone1'
3355 * @return string Text description taken from language file, e.g. 'Phone number'
3356 * @deprecated since Moodle 3.11 MDL-45242
3357 * @see \core_user\fields
3359 function get_user_field_name($field) {
3360 debugging('get_user_field_name() is deprecated. Please use \core_user\fields::get_display_name() instead', DEBUG_DEVELOPER);
3362 return \core_user\fields::get_display_name($field);
3366 * A centralised location for the all name fields. Returns an array / sql string snippet.
3368 * @param bool $returnsql True for an sql select field snippet.
3369 * @param string $tableprefix table query prefix to use in front of each field.
3370 * @param string $prefix prefix added to the name fields e.g. authorfirstname.
3371 * @param string $fieldprefix sql field prefix e.g. id AS userid.
3372 * @param bool $order moves firstname and lastname to the top of the array / start of the string.
3373 * @return array|string All name fields.
3374 * @deprecated since Moodle 3.11 MDL-45242
3375 * @see \core_user\fields
3377 function get_all_user_name_fields($returnsql = false, $tableprefix = null, $prefix = null, $fieldprefix = null, $order = false) {
3378 debugging('get_all_user_name_fields() is deprecated. Please use the \core_user\fields API instead', DEBUG_DEVELOPER);
3380 // This array is provided in this order because when called by fullname() (above) if firstname is before
3381 // firstnamephonetic str_replace() will change the wrong placeholder.
3382 $alternatenames = [];
3383 foreach (\core_user\fields::get_name_fields() as $field) {
3384 $alternatenames[$field] = $field;
3387 // Let's add a prefix to the array of user name fields if provided.
3388 if ($prefix) {
3389 foreach ($alternatenames as $key => $altname) {
3390 $alternatenames[$key] = $prefix . $altname;
3394 // If we want the end result to have firstname and lastname at the front / top of the result.
3395 if ($order) {
3396 // Move the last two elements (firstname, lastname) off the array and put them at the top.
3397 for ($i = 0; $i < 2; $i++) {
3398 // Get the last element.
3399 $lastelement = end($alternatenames);
3400 // Remove it from the array.
3401 unset($alternatenames[$lastelement]);
3402 // Put the element back on the top of the array.
3403 $alternatenames = array_merge(array($lastelement => $lastelement), $alternatenames);
3407 // Create an sql field snippet if requested.
3408 if ($returnsql) {
3409 if ($tableprefix) {
3410 if ($fieldprefix) {
3411 foreach ($alternatenames as $key => $altname) {
3412 $alternatenames[$key] = $tableprefix . '.' . $altname . ' AS ' . $fieldprefix . $altname;
3414 } else {
3415 foreach ($alternatenames as $key => $altname) {
3416 $alternatenames[$key] = $tableprefix . '.' . $altname;
3420 $alternatenames = implode(',', $alternatenames);
3422 return $alternatenames;
3426 * Update a subscription from the form data in one of the rows in the existing subscriptions table.
3428 * @param int $subscriptionid The ID of the subscription we are acting upon.
3429 * @param int $pollinterval The poll interval to use.
3430 * @param int $action The action to be performed. One of update or remove.
3431 * @throws dml_exception if invalid subscriptionid is provided
3432 * @return string A log of the import progress, including errors
3433 * @deprecated since Moodle 4.0 MDL-71953
3435 function calendar_process_subscription_row($subscriptionid, $pollinterval, $action) {
3436 debugging('calendar_process_subscription_row() is deprecated.', DEBUG_DEVELOPER);
3437 // Fetch the subscription from the database making sure it exists.
3438 $sub = calendar_get_subscription($subscriptionid);
3440 // Update or remove the subscription, based on action.
3441 switch ($action) {
3442 case CALENDAR_SUBSCRIPTION_UPDATE:
3443 // Skip updating file subscriptions.
3444 if (empty($sub->url)) {
3445 break;
3447 $sub->pollinterval = $pollinterval;
3448 calendar_update_subscription($sub);
3450 // Update the events.
3451 return "<p>" . get_string('subscriptionupdated', 'calendar', $sub->name) . "</p>" .
3452 calendar_update_subscription_events($subscriptionid);
3453 case CALENDAR_SUBSCRIPTION_REMOVE:
3454 calendar_delete_subscription($subscriptionid);
3455 return get_string('subscriptionremoved', 'calendar', $sub->name);
3456 break;
3457 default:
3458 break;
3460 return '';
3464 * Import events from an iCalendar object into a course calendar.
3466 * @param iCalendar $ical The iCalendar object.
3467 * @param int $unused Deprecated
3468 * @param int $subscriptionid The subscription ID.
3469 * @return string A log of the import progress, including errors.
3471 function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid = null) {
3472 debugging('calendar_import_icalendar_events() is deprecated. Please use calendar_import_events_from_ical() instead.',
3473 DEBUG_DEVELOPER);
3474 global $DB;
3476 $return = '';
3477 $eventcount = 0;
3478 $updatecount = 0;
3479 $skippedcount = 0;
3481 // Large calendars take a while...
3482 if (!CLI_SCRIPT) {
3483 \core_php_time_limit::raise(300);
3486 // Grab the timezone from the iCalendar file to be used later.
3487 if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) {
3488 $timezone = $ical->properties['X-WR-TIMEZONE'][0]->value;
3489 } else {
3490 $timezone = 'UTC';
3493 $icaluuids = [];
3494 foreach ($ical->components['VEVENT'] as $event) {
3495 $icaluuids[] = $event->properties['UID'][0]->value;
3496 $res = calendar_add_icalendar_event($event, null, $subscriptionid, $timezone);
3497 switch ($res) {
3498 case CALENDAR_IMPORT_EVENT_UPDATED:
3499 $updatecount++;
3500 break;
3501 case CALENDAR_IMPORT_EVENT_INSERTED:
3502 $eventcount++;
3503 break;
3504 case CALENDAR_IMPORT_EVENT_SKIPPED:
3505 $skippedcount++;
3506 break;
3507 case 0:
3508 $return .= '<p>' . get_string('erroraddingevent', 'calendar') . ': ';
3509 if (empty($event->properties['SUMMARY'])) {
3510 $return .= '(' . get_string('notitle', 'calendar') . ')';
3511 } else {
3512 $return .= $event->properties['SUMMARY'][0]->value;
3514 $return .= "</p>\n";
3515 break;
3519 $return .= html_writer::start_tag('ul');
3520 $existing = $DB->get_field('event_subscriptions', 'lastupdated', ['id' => $subscriptionid]);
3521 if (!empty($existing)) {
3522 $eventsuuids = $DB->get_records_menu('event', ['subscriptionid' => $subscriptionid], '', 'id, uuid');
3524 $icaleventscount = count($icaluuids);
3525 $tobedeleted = [];
3526 if (count($eventsuuids) > $icaleventscount) {
3527 foreach ($eventsuuids as $eventid => $eventuuid) {
3528 if (!in_array($eventuuid, $icaluuids)) {
3529 $tobedeleted[] = $eventid;
3532 if (!empty($tobedeleted)) {
3533 $DB->delete_records_list('event', 'id', $tobedeleted);
3534 $return .= html_writer::tag('li', get_string('eventsdeleted', 'calendar', count($tobedeleted)));
3539 $return .= html_writer::tag('li', get_string('eventsimported', 'calendar', $eventcount));
3540 $return .= html_writer::tag('li', get_string('eventsskipped', 'calendar', $skippedcount));
3541 $return .= html_writer::tag('li', get_string('eventsupdated', 'calendar', $updatecount));
3542 $return .= html_writer::end_tag('ul');
3543 return $return;
3547 * Print grading plugin selection tab-based navigation.
3549 * @deprecated since Moodle 4.0. Tabs navigation has been replaced with tertiary navigation.
3550 * @param string $active_type type of plugin on current page - import, export, report or edit
3551 * @param string $active_plugin active plugin type - grader, user, cvs, ...
3552 * @param array $plugin_info Array of plugins
3553 * @param boolean $return return as string
3555 * @return nothing or string if $return true
3557 function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false) {
3558 global $CFG, $COURSE;
3560 debugging('grade_print_tabs() has been deprecated. Tabs navigation has been replaced with tertiary navigation.',
3561 DEBUG_DEVELOPER);
3563 if (!isset($currenttab)) { //TODO: this is weird
3564 $currenttab = '';
3567 $tabs = array();
3568 $top_row = array();
3569 $bottom_row = array();
3570 $inactive = array($active_plugin);
3571 $activated = array($active_type);
3573 $count = 0;
3574 $active = '';
3576 foreach ($plugin_info as $plugin_type => $plugins) {
3577 if ($plugin_type == 'strings') {
3578 continue;
3581 // If $plugins is actually the definition of a child-less parent link:
3582 if (!empty($plugins->id)) {
3583 $string = $plugins->string;
3584 if (!empty($plugin_info[$active_type]->parent)) {
3585 $string = $plugin_info[$active_type]->parent->string;
3588 $top_row[] = new tabobject($plugin_type, $plugins->link, $string);
3589 continue;
3592 $first_plugin = reset($plugins);
3593 $url = $first_plugin->link;
3595 if ($plugin_type == 'report') {
3596 $url = $CFG->wwwroot.'/grade/report/index.php?id='.$COURSE->id;
3599 $top_row[] = new tabobject($plugin_type, $url, $plugin_info['strings'][$plugin_type]);
3601 if ($active_type == $plugin_type) {
3602 foreach ($plugins as $plugin) {
3603 $bottom_row[] = new tabobject($plugin->id, $plugin->link, $plugin->string);
3604 if ($plugin->id == $active_plugin) {
3605 $inactive = array($plugin->id);
3611 // Do not display rows that contain only one item, they are not helpful.
3612 if (count($top_row) > 1) {
3613 $tabs[] = $top_row;
3615 if (count($bottom_row) > 1) {
3616 $tabs[] = $bottom_row;
3618 if (empty($tabs)) {
3619 return;
3622 $rv = html_writer::div(print_tabs($tabs, $active_plugin, $inactive, $activated, true), 'grade-navigation');
3624 if ($return) {
3625 return $rv;
3626 } else {
3627 echo $rv;
3632 * Print grading plugin selection popup form.
3634 * @deprecated since Moodle 4.0. Dropdown box navigation has been replaced with tertiary navigation.
3635 * @param array $plugin_info An array of plugins containing information for the selector
3636 * @param boolean $return return as string
3638 * @return nothing or string if $return true
3640 function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return=false) {
3641 global $CFG, $OUTPUT, $PAGE;
3643 debugging('print_grade_plugin_selector() has been deprecated. Dropdown box navigation has been replaced ' .
3644 'with tertiary navigation.', DEBUG_DEVELOPER);
3646 $menu = array();
3647 $count = 0;
3648 $active = '';
3650 foreach ($plugin_info as $plugin_type => $plugins) {
3651 if ($plugin_type == 'strings') {
3652 continue;
3655 $first_plugin = reset($plugins);
3657 $sectionname = $plugin_info['strings'][$plugin_type];
3658 $section = array();
3660 foreach ($plugins as $plugin) {
3661 $link = $plugin->link->out(false);
3662 $section[$link] = $plugin->string;
3663 $count++;
3664 if ($plugin_type === $active_type and $plugin->id === $active_plugin) {
3665 $active = $link;
3669 if ($section) {
3670 $menu[] = array($sectionname=>$section);
3674 // finally print/return the popup form
3675 if ($count > 1) {
3676 $select = new url_select($menu, $active, null, 'choosepluginreport');
3677 $select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide'));
3678 if ($return) {
3679 return $OUTPUT->render($select);
3680 } else {
3681 echo $OUTPUT->render($select);
3683 } else {
3684 // only one option - no plugin selector needed
3685 return '';