3 // This file is part of Moodle - http://moodle.org/
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.
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/>.
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.
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
31 defined('MOODLE_INTERNAL') ||
die();
33 /* === Functions that needs to be kept longer in deprecated lib than normal time period === */
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');
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.');
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) {
69 // NOTE: do not add any other debugging here, keep forever.
71 $subsystems = core_component
::get_core_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) {
85 $subsystems[$k] = substr($v, $dlength+
1);
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) {
102 // NOTE: do not add any other debugging here, keep forever.
104 $types = core_component
::get_plugin_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';
119 $types[$k] = substr($v, $dlength+
1);
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 === '') {
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 === '') {
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;
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)) {
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 ===
390 function check_gd_version() {
391 throw new coding_exception('check_gd_version() is removed, GD extension is always available now');
397 function update_login_count() {
398 throw new coding_exception('update_login_count() is removed, all calls need to be removed');
404 function reset_login_count() {
405 throw new coding_exception('reset_login_count() is removed, all calls need to be removed');
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.');
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.
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
493 if (empty($zipfilename)) {
497 //If no extension, error
498 if (empty($extension)) {
503 $zipfile = cleardoubleslashes($zipfile);
505 //Check zipfile exists
506 if (!file_exists($zipfile)) {
510 //If no destination, passed let's go with the same directory
511 if (empty($destination)) {
512 $destination = $zippath;
516 $destpath = rtrim(cleardoubleslashes($destination), "/");
518 //Check destination path exists
519 if (!is_dir($destpath)) {
523 $packer = get_file_packer('application/zip');
525 $result = $packer->extract_to_pathname($zipfile, $destpath);
527 if ($result === false) {
531 foreach ($result as $status) {
532 if ($status !== true) {
541 * Zip an array of files/dirs to a destination zip file
542 * Both parameters must be FULL paths to the files/dirs
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
562 if (empty($destfilename)) {
566 //If no extension, add it
567 if (empty($extension)) {
569 $destfilename = $destfilename.'.'.$extension;
572 //Check destination path exists
573 if (!is_dir($destpath)) {
577 //Check destination path is writable. TODO!!
579 //Clean destination filename
580 $destfilename = clean_filename($destfilename);
582 //Now check and prepare every file
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
597 //See if the file/dir is in the same directory than the rest
598 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
601 //Add the file to the array
602 $files[] = $tempfile;
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
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');
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.
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.
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) {
778 debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER
);
780 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
786 switch ($direction) {
801 // Prepare language string
803 if (empty($strsort) && !empty($sortdir)) {
804 $strsort = get_string('sort' . $sortdir, 'grades');
807 $return = ' ' . $OUTPUT->pix_icon('t/' . $direction, $strsort) . ' ';
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+
865 throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.');
868 /// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
872 * @deprecated please use calendar_event::create() instead.
874 function add_event() {
875 throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.');
879 * @deprecated please calendar_event->update() instead.
881 function update_event() {
882 throw new coding_exception('update_event() is removed, please use calendar_event->update() instead.');
886 * @deprecated please use calendar_event->delete() instead.
888 function delete_event() {
889 throw new coding_exception('delete_event() can not be used any more, please use '.
890 'calendar_event->delete() instead.');
894 * @deprecated please use calendar_event->toggle_visibility(false) instead.
896 function hide_event() {
897 throw new coding_exception('hide_event() can not be used any more, please use '.
898 'calendar_event->toggle_visibility(false) instead.');
902 * @deprecated please use calendar_event->toggle_visibility(true) instead.
904 function show_event() {
905 throw new coding_exception('show_event() can not be used any more, please use '.
906 'calendar_event->toggle_visibility(true) instead.');
910 * @deprecated since Moodle 2.2 use core_text::xxxx() instead.
912 function textlib_get_instance() {
913 throw new coding_exception('textlib_get_instance() can not be used any more, please use '.
914 'core_text::functioname() instead.');
918 * @deprecated since 2.4
920 function get_generic_section_name() {
921 throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base');
925 * @deprecated since 2.4
927 function get_all_sections() {
928 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
932 * @deprecated since 2.4
934 function add_mod_to_section() {
935 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
939 * @deprecated since 2.4
941 function get_all_mods() {
942 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
946 * @deprecated since 2.4
948 function get_course_section() {
949 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
953 * @deprecated since 2.4
955 function format_weeks_get_section_dates() {
956 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
957 ' use it outside of format_weeks plugin');
961 * @deprecated since 2.5
963 function get_print_section_cm_text() {
964 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
965 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
969 * @deprecated since 2.5
971 function print_section_add_menus() {
972 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
973 'function course_section_add_cm_control()');
977 * @deprecated since 2.5. Please use:
978 * $courserenderer = $PAGE->get_renderer('core', 'course');
979 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
980 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
982 function make_editing_buttons() {
983 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
984 'lib/deprecatedlib.php on how to replace it');
988 * @deprecated since 2.5
990 function print_section() {
991 throw new coding_exception('Function print_section() is removed. Please use course renderer function '.
992 'course_section_cm_list() instead.');
996 * @deprecated since 2.5
998 function print_overview() {
999 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
1003 * @deprecated since 2.5
1005 function print_recent_activity() {
1006 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
1007 ' use it outside of block_recent_activity');
1011 * @deprecated since 2.5
1013 function delete_course_module() {
1014 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
1018 * @deprecated since 2.5
1020 function update_category_button() {
1021 throw new coding_exception('Function update_category_button() is removed. Pages to view '.
1022 'and edit courses are now separate and no longer depend on editing mode.');
1026 * @deprecated since 2.5
1028 function make_categories_list() {
1029 throw new coding_exception('Global function make_categories_list() is removed. Please use '.
1030 'core_course_category::make_categories_list() and core_course_category::get_parents()');
1034 * @deprecated since 2.5
1036 function category_delete_move() {
1037 throw new coding_exception('Function category_delete_move() is removed. Please use ' .
1038 'core_course_category::delete_move() instead.');
1042 * @deprecated since 2.5
1044 function category_delete_full() {
1045 throw new coding_exception('Function category_delete_full() is removed. Please use ' .
1046 'core_course_category::delete_full() instead.');
1050 * @deprecated since 2.5
1052 function move_category() {
1053 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.');
1057 * @deprecated since 2.5
1059 function course_category_hide() {
1060 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.');
1064 * @deprecated since 2.5
1066 function course_category_show() {
1067 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.');
1071 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or
1072 * core_course_category::get($catid, MUST_EXIST).
1074 function get_course_category() {
1075 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' .
1076 'see phpdocs for more details');
1080 * @deprecated since 2.5
1082 function create_course_category() {
1083 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' .
1084 'see phpdocs for more details');
1088 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children()
1090 function get_all_subcategories() {
1091 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '.
1092 'of core_course_category class. See phpdocs for more details');
1096 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children().
1098 function get_child_categories() {
1099 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' .
1100 'phpdocs for more details.');
1104 * @deprecated since 2.5
1106 function get_categories() {
1107 throw new coding_exception('Function get_categories() is removed. Please use ' .
1108 'appropriate functions from class core_course_category');
1112 * @deprecated since 2.5
1114 function print_course_search() {
1115 throw new coding_exception('Function print_course_search() is removed, please use course renderer');
1119 * @deprecated since 2.5
1121 function print_my_moodle() {
1122 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
1123 'function frontpage_my_courses()');
1127 * @deprecated since 2.5
1129 function print_remote_course() {
1130 throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
1134 * @deprecated since 2.5
1136 function print_remote_host() {
1137 throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
1141 * @deprecated since 2.5
1143 function print_whole_category_list() {
1144 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
1148 * @deprecated since 2.5
1150 function print_category_info() {
1151 throw new coding_exception('Function print_category_info() is removed, please use course renderer');
1155 * @deprecated since 2.5
1157 function get_course_category_tree() {
1158 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
1159 'renderer or core_course_category class, see function phpdocs for more info');
1163 * @deprecated since 2.5
1165 function print_courses() {
1166 throw new coding_exception('Function print_courses() is removed, please use course renderer');
1170 * @deprecated since 2.5
1172 function print_course() {
1173 throw new coding_exception('Function print_course() is removed, please use course renderer');
1177 * @deprecated since 2.5
1179 function get_category_courses_array() {
1180 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' .
1181 'core_course_category class');
1185 * @deprecated since 2.5
1187 function get_category_courses_array_recursively() {
1188 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' .
1189 'methods of core_course_category class', DEBUG_DEVELOPER
);
1193 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
1195 function blog_get_context_url() {
1196 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
1200 * @deprecated since 2.5
1202 function get_courses_wmanagers() {
1203 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' .
1204 'core_course_category::get_courses()');
1208 * @deprecated since 2.5
1210 function convert_tree_to_html() {
1211 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
1215 * @deprecated since 2.5
1217 function convert_tabrows_to_tree() {
1218 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
1222 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
1224 function can_use_rotated_text() {
1225 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.');
1229 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
1231 function get_context_instance_by_id() {
1232 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
1236 * Returns system context or null if can not be created yet.
1238 * @see context_system::instance()
1239 * @deprecated since 2.2
1240 * @param bool $cache use caching
1241 * @return context system context (null if context table not created yet)
1243 function get_system_context($cache = true) {
1244 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER
);
1245 return context_system
::instance(0, IGNORE_MISSING
, $cache);
1249 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
1251 function get_parent_contexts() {
1252 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
1256 * @deprecated since Moodle 2.2
1258 function get_parent_contextid() {
1259 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
1263 * @deprecated since 2.2
1265 function get_child_contexts() {
1266 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
1270 * @deprecated since 2.2
1272 function create_contexts() {
1273 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
1277 * @deprecated since 2.2
1279 function cleanup_contexts() {
1280 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.');
1284 * @deprecated since 2.2
1286 function build_context_path() {
1287 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
1291 * @deprecated since 2.2
1293 function rebuild_contexts() {
1294 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
1298 * @deprecated since Moodle 2.2
1300 function preload_course_contexts() {
1301 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
1305 * @deprecated since Moodle 2.2
1307 function context_moved() {
1308 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
1312 * @deprecated since 2.2
1314 function fetch_context_capabilities() {
1315 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
1319 * @deprecated since 2.2
1321 function context_instance_preload() {
1322 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
1326 * @deprecated since 2.2
1328 function get_contextlevel_name() {
1329 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
1333 * @deprecated since 2.2
1335 function print_context_name() {
1336 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
1340 * @deprecated since 2.2, use $context->mark_dirty() instead
1342 function mark_context_dirty() {
1343 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
1347 * @deprecated since Moodle 2.2
1349 function delete_context() {
1350 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
1351 'or $context->delete_content() instead.');
1355 * @deprecated since 2.2
1357 function get_context_url() {
1358 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
1362 * @deprecated since 2.2
1364 function get_course_context() {
1365 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
1369 * @deprecated since 2.2
1371 function get_user_courses_bycap() {
1372 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
1376 * @deprecated since Moodle 2.2
1378 function get_role_context_caps() {
1379 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
1383 * @deprecated since 2.2
1385 function get_courseid_from_context() {
1386 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
1390 * @deprecated since 2.2
1392 function context_instance_preload_sql() {
1393 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
1397 * @deprecated since 2.2
1399 function get_related_contexts_string() {
1400 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
1404 * @deprecated since 2.6
1406 function get_plugin_list_with_file() {
1407 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
1411 * @deprecated since 2.6
1413 function check_browser_operating_system() {
1414 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
1418 * @deprecated since 2.6
1420 function check_browser_version() {
1421 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
1425 * @deprecated since 2.6
1427 function get_device_type() {
1428 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.');
1432 * @deprecated since 2.6
1434 function get_device_type_list() {
1435 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
1439 * @deprecated since 2.6
1441 function get_selected_theme_for_device_type() {
1442 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
1446 * @deprecated since 2.6
1448 function get_device_cfg_var_name() {
1449 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
1453 * @deprecated since 2.6
1455 function set_user_device_type() {
1456 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
1460 * @deprecated since 2.6
1462 function get_user_device_type() {
1463 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.');
1467 * @deprecated since 2.6
1469 function get_browser_version_classes() {
1470 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.');
1474 * @deprecated since Moodle 2.6
1476 function generate_email_supportuser() {
1477 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
1481 * @deprecated since Moodle 2.6
1483 function badges_get_issued_badge_info() {
1484 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
1488 * @deprecated since 2.6
1490 function can_use_html_editor() {
1491 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.');
1496 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
1498 function count_login_failures() {
1499 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
1503 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
1505 function ajaxenabled() {
1506 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
1510 * @deprecated Since Moodle 2.7 MDL-44070
1512 function coursemodule_visible_for_user() {
1513 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
1514 please use \core_availability\info_module::is_user_visible()');
1518 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
1520 function enrol_cohort_get_cohorts() {
1521 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
1522 'cohort_get_available_cohorts() instead');
1526 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
1528 function enrol_cohort_can_view_cohort() {
1529 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
1533 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
1535 function cohort_get_visible_list() {
1536 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
1537 "that correctly checks capabilities.');
1541 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1543 function enrol_cohort_enrol_all_users() {
1544 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
1548 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1550 function enrol_cohort_search_cohorts() {
1551 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
1554 /* === Apis deprecated in since Moodle 2.9 === */
1557 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
1559 function message_current_user_is_involved() {
1560 throw new coding_exception('message_current_user_is_involved() can not be used any more.');
1564 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
1566 function profile_display_badges() {
1567 throw new coding_exception('profile_display_badges() can not be used any more.');
1571 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
1573 function useredit_shared_definition_preferences() {
1574 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
1579 * @deprecated since Moodle 2.9
1581 function calendar_normalize_tz() {
1582 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
1586 * @deprecated since Moodle 2.9
1588 function get_user_timezone_offset() {
1589 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1594 * @deprecated since Moodle 2.9
1596 function get_timezone_offset() {
1597 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1601 * @deprecated since Moodle 2.9
1603 function get_list_of_timezones() {
1604 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead');
1608 * @deprecated since Moodle 2.9
1610 function update_timezone_records() {
1611 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
1615 * @deprecated since Moodle 2.9
1617 function calculate_user_dst_table() {
1618 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
1622 * @deprecated since Moodle 2.9
1624 function dst_changes_for_year() {
1625 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
1629 * @deprecated since Moodle 2.9
1631 function get_timezone_record() {
1632 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
1635 /* === Apis deprecated since Moodle 3.0 === */
1637 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
1639 function get_referer() {
1640 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
1644 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
1646 function is_web_crawler() {
1647 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.');
1651 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
1653 function completion_cron() {
1654 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.');
1658 * @deprecated since 3.0
1660 function coursetag_get_tags() {
1661 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
1662 'Userid is no longer used for tagging courses.');
1666 * @deprecated since 3.0
1668 function coursetag_get_all_tags() {
1669 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
1670 'longer used for tagging courses.');
1674 * @deprecated since 3.0
1676 function coursetag_get_jscript() {
1677 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.');
1681 * @deprecated since 3.0
1683 function coursetag_get_jscript_links() {
1684 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
1688 * @deprecated since 3.0
1690 function coursetag_get_records() {
1691 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
1692 'Userid is no longer used for tagging courses.');
1696 * @deprecated since 3.0
1698 function coursetag_store_keywords() {
1699 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
1700 'Userid is no longer used for tagging courses.');
1704 * @deprecated since 3.0
1706 function coursetag_delete_keyword() {
1707 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
1708 'Userid is no longer used for tagging courses.');
1712 * @deprecated since 3.0
1714 function coursetag_get_tagged_courses() {
1715 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
1716 'Userid is no longer used for tagging courses.');
1720 * @deprecated since 3.0
1722 function coursetag_delete_course_tags() {
1723 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
1724 'Use core_tag_tag::remove_all_item_tags().');
1728 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1730 function tag_type_set() {
1731 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
1732 'core_tag_tag::get($tagid)->update().');
1736 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1738 function tag_description_set() {
1739 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
1740 'core_tag_tag::get($tagid)->update().');
1744 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1746 function tag_get_tags() {
1747 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
1748 'core_tag_tag::get_item_tags().');
1752 * @deprecated since 3.1
1754 function tag_get_tags_array() {
1755 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
1756 'core_tag_tag::get_item_tags_array().');
1760 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
1762 function tag_get_tags_csv() {
1763 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
1764 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1768 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1770 function tag_get_tags_ids() {
1771 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
1772 'core_tag_tag::get_item_tags() or similar methods.');
1776 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
1778 function tag_get_id() {
1779 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
1780 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
1784 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1786 function tag_rename() {
1787 throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
1788 'core_tag_tag::get($tagid)->update()');
1792 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
1794 function tag_delete_instance() {
1795 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
1796 'core_tag_tag::remove_item_tag()');
1800 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
1802 function tag_find_records() {
1803 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
1804 'core_tag_tag::get_by_name()->get_tagged_items()');
1808 * @deprecated since 3.1
1810 function tag_add() {
1811 throw new coding_exception('tag_add() can not be used anymore. You can use ' .
1812 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
1813 'created automatically when assigned to items');
1817 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
1819 function tag_assign() {
1820 throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
1821 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
1822 'ordering should not be set manually');
1826 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
1828 function tag_record_count() {
1829 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
1830 'core_tag_tag::get($tagid)->count_tagged_items().');
1834 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
1836 function tag_record_tagged_with() {
1837 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
1838 'core_tag_tag::get($tagid)->is_item_tagged_with().');
1842 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
1844 function tag_set_flag() {
1845 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
1846 'core_tag_tag::get($tagid)->flag()');
1850 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
1852 function tag_unset_flag() {
1853 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
1854 'core_tag_tag::get($tagid)->reset_flag()');
1858 * @deprecated since 3.1
1860 function tag_print_cloud() {
1861 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
1862 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
1863 'template core_tag/tagcloud.');
1867 * @deprecated since 3.0
1869 function tag_autocomplete() {
1870 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
1871 'element "tags" does proper autocomplete.');
1875 * @deprecated since 3.1
1877 function tag_print_description_box() {
1878 throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
1879 'See core_tag_renderer for similar code');
1883 * @deprecated since 3.1
1885 function tag_print_management_box() {
1886 throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
1887 'See core_tag_renderer for similar code');
1891 * @deprecated since 3.1
1893 function tag_print_search_box() {
1894 throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
1895 'See core_tag_renderer for similar code');
1899 * @deprecated since 3.1
1901 function tag_print_search_results() {
1902 throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
1903 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
1907 * @deprecated since 3.1
1909 function tag_print_tagged_users_table() {
1910 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
1911 'See core_user_renderer for similar code');
1915 * @deprecated since 3.1
1917 function tag_print_user_box() {
1918 throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
1919 'See core_user_renderer for similar code');
1923 * @deprecated since 3.1
1925 function tag_print_user_list() {
1926 throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
1927 'See core_user_renderer for similar code');
1931 * @deprecated since 3.1
1933 function tag_display_name() {
1934 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
1935 'core_tag_tag::make_display_name().');
1940 * @deprecated since 3.1
1942 function tag_normalize() {
1943 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
1944 'core_tag_tag::normalize().');
1948 * @deprecated since 3.1
1950 function tag_get_related_tags_csv() {
1951 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
1952 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1956 * @deprecated since 3.1
1958 function tag_set() {
1959 throw new coding_exception('tag_set() can not be used anymore. Please use ' .
1960 'core_tag_tag::set_item_tags().');
1964 * @deprecated since 3.1
1966 function tag_set_add() {
1967 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
1968 'core_tag_tag::add_item_tag().');
1972 * @deprecated since 3.1
1974 function tag_set_delete() {
1975 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
1976 'core_tag_tag::remove_item_tag().');
1980 * @deprecated since 3.1
1982 function tag_get() {
1983 throw new coding_exception('tag_get() can not be used anymore. Please use ' .
1984 'core_tag_tag::get() or core_tag_tag::get_by_name().');
1988 * @deprecated since 3.1
1990 function tag_get_related_tags() {
1991 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
1992 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
1993 'core_tag_tag::get_manual_related_tags().');
1997 * @deprecated since 3.1
1999 function tag_delete() {
2000 throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
2001 'core_tag_tag::delete_tags().');
2005 * @deprecated since 3.1
2007 function tag_delete_instances() {
2008 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
2009 'core_tag_tag::delete_instances().');
2013 * @deprecated since 3.1
2015 function tag_cleanup() {
2016 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
2017 '\core\task\tag_cron_task::cleanup().');
2021 * @deprecated since 3.1
2023 function tag_bulk_delete_instances() {
2024 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
2025 '\core\task\tag_cron_task::bulk_delete_instances().');
2030 * @deprecated since 3.1
2032 function tag_compute_correlations() {
2033 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
2034 'use \core\task\tag_cron_task::compute_correlations().');
2038 * @deprecated since 3.1
2040 function tag_process_computed_correlation() {
2041 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
2042 'use \core\task\tag_cron_task::process_computed_correlation().');
2046 * @deprecated since 3.1
2048 function tag_cron() {
2049 throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
2050 'use \core\task\tag_cron_task::execute().');
2054 * @deprecated since 3.1
2056 function tag_find_tags() {
2057 throw new coding_exception('tag_find_tags() can not be used anymore.');
2061 * @deprecated since 3.1
2063 function tag_get_name() {
2064 throw new coding_exception('tag_get_name() can not be used anymore.');
2068 * @deprecated since 3.1
2070 function tag_get_correlated() {
2071 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
2072 'use core_tag_tag::get_correlated_tags().');
2077 * @deprecated since 3.1
2079 function tag_cloud_sort() {
2080 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
2081 'be found in core_tag_collection::cloud_sort().');
2085 * @deprecated since Moodle 3.1
2087 function events_load_def() {
2088 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2093 * @deprecated since Moodle 3.1
2095 function events_queue_handler() {
2096 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2100 * @deprecated since Moodle 3.1
2102 function events_dispatch() {
2103 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2107 * @deprecated since Moodle 3.1
2109 function events_process_queued_handler() {
2110 throw new coding_exception(
2111 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
2116 * @deprecated since Moodle 3.1
2118 function events_update_definition() {
2119 throw new coding_exception(
2120 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
2125 * @deprecated since Moodle 3.1
2127 function events_cron() {
2128 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2132 * @deprecated since Moodle 3.1
2134 function events_trigger_legacy() {
2135 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2139 * @deprecated since Moodle 3.1
2141 function events_is_registered() {
2142 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2146 * @deprecated since Moodle 3.1
2148 function events_pending_count() {
2149 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2153 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2155 function clam_message_admins() {
2156 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
2157 'message_admins() method of \antivirus_clamav\scanner class.');
2161 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2163 function get_clam_error_code() {
2164 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
2165 'get_clam_error_code() method of \antivirus_clamav\scanner class.');
2169 * @deprecated since 3.1
2171 function course_get_cm_rename_action() {
2172 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
2173 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
2178 * @deprecated since Moodle 3.1
2180 function course_scale_used() {
2181 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
2182 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2186 * @deprecated since Moodle 3.1
2188 function site_scale_used() {
2189 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
2190 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2194 * @deprecated since Moodle 3.1. Use external_api::external_function_info().
2196 function external_function_info() {
2197 throw new coding_exception('external_function_info() can not be used any'.
2198 'more. Please use external_api::external_function_info() instead.');
2202 * @deprecated since Moodle 3.2
2203 * @see csv_import_reader::load_csv_content()
2205 function get_records_csv() {
2206 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' .
2207 'lib/csvlib.class.php csv_import_reader() instead.');
2211 * @deprecated since Moodle 3.2
2212 * @see download_as_dataformat (lib/dataformatlib.php)
2214 function put_records_csv() {
2215 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' .
2216 'lib/dataformatlib.php download_as_dataformat() instead.');
2220 * @deprecated since Moodle 3.2
2222 function css_is_colour() {
2223 throw new coding_exception('css_is_colour() can not be used anymore.');
2227 * @deprecated since Moodle 3.2
2229 function css_is_width() {
2230 throw new coding_exception('css_is_width() can not be used anymore.');
2234 * @deprecated since Moodle 3.2
2236 function css_sort_by_count() {
2237 throw new coding_exception('css_sort_by_count() can not be used anymore.');
2241 * @deprecated since Moodle 3.2
2243 function message_get_course_contexts() {
2244 throw new coding_exception('message_get_course_contexts() can not be used anymore.');
2248 * @deprecated since Moodle 3.2
2250 function message_remove_url_params() {
2251 throw new coding_exception('message_remove_url_params() can not be used anymore.');
2255 * @deprecated since Moodle 3.2
2257 function message_count_messages() {
2258 throw new coding_exception('message_count_messages() can not be used anymore.');
2262 * @deprecated since Moodle 3.2
2264 function message_count_blocked_users() {
2265 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' .
2266 '\core_message\api::count_blocked_users() instead.');
2270 * @deprecated since Moodle 3.2
2272 function message_contact_link() {
2273 throw new coding_exception('message_contact_link() can not be used anymore.');
2277 * @deprecated since Moodle 3.2
2279 function message_get_recent_notifications() {
2280 throw new coding_exception('message_get_recent_notifications() can not be used anymore.');
2284 * @deprecated since Moodle 3.2
2286 function message_history_link() {
2287 throw new coding_exception('message_history_link() can not be used anymore.');
2291 * @deprecated since Moodle 3.2
2293 function message_search() {
2294 throw new coding_exception('message_search() can not be used anymore.');
2298 * @deprecated since Moodle 3.2
2300 function message_shorten_message() {
2301 throw new coding_exception('message_shorten_message() can not be used anymore.');
2305 * @deprecated since Moodle 3.2
2307 function message_get_fragment() {
2308 throw new coding_exception('message_get_fragment() can not be used anymore.');
2312 * @deprecated since Moodle 3.2
2314 function message_get_history() {
2315 throw new coding_exception('message_get_history() can not be used anymore.');
2319 * @deprecated since Moodle 3.2
2321 function message_get_contact_add_remove_link() {
2322 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.');
2326 * @deprecated since Moodle 3.2
2328 function message_get_contact_block_link() {
2329 throw new coding_exception('message_get_contact_block_link() can not be used anymore.');
2333 * @deprecated since Moodle 3.2
2335 function message_mark_messages_read() {
2336 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' .
2337 '\core_message\api::mark_all_messages_as_read() instead.');
2341 * @deprecated since Moodle 3.2
2343 function message_page_type_list() {
2344 throw new coding_exception('message_page_type_list() can not be used anymore.');
2348 * @deprecated since Moodle 3.2
2350 function message_can_post_message() {
2351 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' .
2352 '\core_message\api::can_send_message() instead.');
2356 * @deprecated since Moodle 3.2
2358 function message_is_user_non_contact_blocked() {
2359 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' .
2360 '\core_message\api::is_user_non_contact_blocked() instead.');
2364 * @deprecated since Moodle 3.2
2366 function message_is_user_blocked() {
2367 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' .
2368 '\core_message\api::is_user_blocked() instead.');
2372 * @deprecated since Moodle 3.2
2374 function print_log() {
2375 throw new coding_exception('print_log() can not be used anymore. Please use the ' .
2376 'report_log framework instead.');
2380 * @deprecated since Moodle 3.2
2382 function print_mnet_log() {
2383 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' .
2384 'report_log framework instead.');
2388 * @deprecated since Moodle 3.2
2390 function print_log_csv() {
2391 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' .
2392 'report_log framework instead.');
2396 * @deprecated since Moodle 3.2
2398 function print_log_xls() {
2399 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' .
2400 'report_log framework instead.');
2404 * @deprecated since Moodle 3.2
2406 function print_log_ods() {
2407 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' .
2408 'report_log framework instead.');
2412 * @deprecated since Moodle 3.2
2414 function build_logs_array() {
2415 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' .
2416 'report_log framework instead.');
2420 * @deprecated since Moodle 3.2
2422 function get_logs_usercourse() {
2423 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' .
2424 'report_log framework instead.');
2428 * @deprecated since Moodle 3.2
2430 function get_logs_userday() {
2431 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' .
2432 'report_log framework instead.');
2436 * @deprecated since Moodle 3.2
2438 function get_logs() {
2439 throw new coding_exception('get_logs() can not be used anymore. Please use the ' .
2440 'report_log framework instead.');
2444 * @deprecated since Moodle 3.2
2446 function prevent_form_autofill_password() {
2447 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.');
2451 * @deprecated since Moodle 3.3 MDL-57370
2453 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) {
2454 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' .
2455 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER
);
2459 * @deprecated since Moodle 3.2
2461 function calendar_preferences_button() {
2462 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' .
2463 'preferences are now linked to the user preferences page.');
2467 * @deprecated since 3.3
2469 function calendar_wday_name() {
2470 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.');
2474 * @deprecated since 3.3
2476 function calendar_get_block_upcoming() {
2477 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' .
2478 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2482 * @deprecated since 3.3
2484 function calendar_print_month_selector() {
2485 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.');
2489 * @deprecated since 3.3
2491 function calendar_cron() {
2492 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.');
2496 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2498 function load_course_context() {
2499 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
2503 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2505 function load_role_access_by_context() {
2506 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
2510 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2512 function dedupe_user_access() {
2513 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
2517 * @deprecated since Moodle 3.4. MDL-49398.
2519 function get_user_access_sitewide() {
2520 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.');
2524 * @deprecated since Moodle 3.4. MDL-59333
2526 function calendar_get_mini() {
2527 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.');
2531 * @deprecated since Moodle 3.4. MDL-59333
2533 function calendar_get_upcoming() {
2534 throw new coding_exception('calendar_get_upcoming() has been removed. ' .
2535 'Please see block_calendar_upcoming::get_content() for the correct API usage.');
2539 * @deprecated since Moodle 3.4. MDL-50666
2541 function allow_override() {
2542 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.');
2546 * @deprecated since Moodle 3.4. MDL-50666
2548 function allow_assign() {
2549 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.');
2553 * @deprecated since Moodle 3.4. MDL-50666
2555 function allow_switch() {
2556 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.');
2560 * @deprecated since Moodle 3.5. MDL-61132
2562 function question_add_tops() {
2563 throw new coding_exception(
2564 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().'
2569 * @deprecated since Moodle 3.5. MDL-61132
2571 function question_is_only_toplevel_category_in_context() {
2572 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. '
2573 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.');
2577 * @deprecated since Moodle 3.5
2579 function message_move_userfrom_unread2read() {
2580 throw new coding_exception('message_move_userfrom_unread2read() has been removed.');
2584 * @deprecated since Moodle 3.5
2586 function message_get_blocked_users() {
2587 throw new coding_exception(
2588 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.'
2593 * @deprecated since Moodle 3.5
2595 function message_get_contacts() {
2596 throw new coding_exception('message_get_contacts() has been removed.');
2600 * @deprecated since Moodle 3.5
2602 function message_mark_message_read() {
2603 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read()
2604 or \core_message\api::mark_notification_as_read().');
2608 * @deprecated since Moodle 3.5
2610 function message_can_delete_message() {
2611 throw new coding_exception(
2612 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.'
2617 * @deprecated since Moodle 3.5
2619 function message_delete_message() {
2620 throw new coding_exception(
2621 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.'
2626 * @deprecated since 3.6
2628 function calendar_get_all_allowed_types() {
2629 throw new coding_exception(
2630 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.'
2636 * @deprecated since Moodle 3.6.
2638 function groups_get_all_groups_for_courses() {
2639 throw new coding_exception(
2640 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.'
2645 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2647 function events_get_cached() {
2648 throw new coding_exception(
2649 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2654 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2656 function events_uninstall() {
2657 throw new coding_exception(
2658 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2663 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2665 function events_cleanup() {
2666 throw new coding_exception(
2667 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2672 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2674 function events_dequeue() {
2675 throw new coding_exception(
2676 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2681 * @deprecated since Moodle 3.6. Please use the Events 2 API.
2683 function events_get_handlers() {
2684 throw new coding_exception(
2685 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.'
2690 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2692 function get_roles_on_exact_context() {
2693 throw new coding_exception(
2694 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.'
2699 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
2701 function get_roles_with_assignment_on_context() {
2702 throw new coding_exception(
2703 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.'
2708 * @deprecated since Moodle 3.6
2710 function message_add_contact() {
2711 throw new coding_exception(
2712 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' .
2713 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' .
2714 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.'
2719 * @deprecated since Moodle 3.6
2721 function message_remove_contact() {
2722 throw new coding_exception(
2723 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.'
2728 * @deprecated since Moodle 3.6
2730 function message_unblock_contact() {
2731 throw new coding_exception(
2732 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.'
2737 * @deprecated since Moodle 3.6
2739 function message_block_contact() {
2740 throw new coding_exception(
2741 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' .
2742 '\core_message\api::block_user() instead.'
2747 * @deprecated since Moodle 3.6
2749 function message_get_contact() {
2750 throw new coding_exception(
2751 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.'
2756 * Returns list of courses, for whole site, or category
2758 * Similar to get_courses, but allows paging
2759 * Important: Using c.* for fields is extremely expensive because
2760 * we are using distinct. You almost _NEVER_ need all the fields
2761 * in such a large SELECT
2763 * @deprecated since Moodle 3.7
2764 * @todo The final deprecation of this function will take place in Moodle 3.11 - see MDL-65319.
2766 * @param string|int $categoryid Either a category id or 'all' for everything
2767 * @param string $sort A field and direction to sort by
2768 * @param string $fields The additional fields to return
2769 * @param int $totalcount Reference for the number of courses
2770 * @param string $limitfrom The course to start from
2771 * @param string $limitnum The number of courses to limit to
2772 * @return array Array of courses
2774 function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c.*",
2775 &$totalcount, $limitfrom="", $limitnum="") {
2776 debugging('Function get_courses_page() is deprecated. Please use core_course_category::get_courses() ' .
2777 'or core_course_category::search_courses()', DEBUG_DEVELOPER
);
2778 global $USER, $CFG, $DB;
2782 $categoryselect = "";
2783 if ($categoryid !== "all" && is_numeric($categoryid)) {
2784 $categoryselect = "WHERE c.category = :catid";
2785 $params['catid'] = $categoryid;
2787 $categoryselect = "";
2790 $ccselect = ', ' . context_helper
::get_preload_record_columns_sql('ctx');
2791 $ccjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
2792 $params['contextlevel'] = CONTEXT_COURSE
;
2798 $visiblecourses = array();
2800 $sql = "SELECT $fields $ccselect
2806 // Pull out all course matching the cat.
2807 $rs = $DB->get_recordset_sql($sql, $params);
2808 // Iteration will have to be done inside loop to keep track of the limitfrom and limitnum.
2809 foreach ($rs as $course) {
2810 context_helper
::preload_from_record($course);
2811 if (core_course_category
::can_view_course_info($course)) {
2813 if ($totalcount > $limitfrom && (!$limitnum or count($visiblecourses) < $limitnum)) {
2814 $visiblecourses [$course->id
] = $course;
2819 return $visiblecourses;
2823 * Returns the models that generated insights in the provided context.
2825 * @deprecated since Moodle 3.8 MDL-66091 - please do not use this function any more.
2826 * @todo MDL-65799 This will be deleted in Moodle 4.0
2827 * @see \core_analytics\manager::cached_models_with_insights
2828 * @param \context $context
2831 function report_insights_context_insights(\context
$context) {
2833 debugging('report_insights_context_insights is deprecated. Please use ' .
2834 '\core_analytics\manager::cached_models_with_insights instead', DEBUG_DEVELOPER
);
2836 return \core_analytics\manager
::cached_models_with_insights($context);
2840 * Retrieve all metadata for the requested modules
2842 * @deprecated since 3.9.
2843 * @param object $course The Course
2844 * @param array $modnames An array containing the list of modules and their
2846 * @param int $sectionreturn The section to return to
2847 * @return array A list of stdClass objects containing metadata about each
2850 function get_module_metadata($course, $modnames, $sectionreturn = null) {
2853 debugging('get_module_metadata is deprecated. Please use \core_course\local\service\content_item_service instead.');
2855 // get_module_metadata will be called once per section on the page and courses may show
2856 // different modules to one another
2857 static $modlist = array();
2858 if (!isset($modlist[$course->id
])) {
2859 $modlist[$course->id
] = array();
2863 $urlbase = new moodle_url('/course/mod.php', array('id' => $course->id
, 'sesskey' => sesskey()));
2864 if ($sectionreturn !== null) {
2865 $urlbase->param('sr', $sectionreturn);
2867 foreach($modnames as $modname => $modnamestr) {
2868 if (!course_allowed_module($course, $modname)) {
2871 if (isset($modlist[$course->id
][$modname])) {
2872 // This module is already cached
2873 $return +
= $modlist[$course->id
][$modname];
2876 $modlist[$course->id
][$modname] = array();
2878 // Create an object for a default representation of this module type in the activity chooser. It will be used
2879 // if module does not implement callback get_shortcuts() and it will also be passed to the callback if it exists.
2880 $defaultmodule = new stdClass();
2881 $defaultmodule->title
= $modnamestr;
2882 $defaultmodule->name
= $modname;
2883 $defaultmodule->link
= new moodle_url($urlbase, array('add' => $modname));
2884 $defaultmodule->icon
= $OUTPUT->pix_icon('icon', '', $defaultmodule->name
, array('class' => 'icon'));
2885 $sm = get_string_manager();
2886 if ($sm->string_exists('modulename_help', $modname)) {
2887 $defaultmodule->help
= get_string('modulename_help', $modname);
2888 if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs.
2889 $link = get_string('modulename_link', $modname);
2890 $linktext = get_string('morehelp');
2891 $defaultmodule->help
.= html_writer
::tag('div',
2892 $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink'));
2895 $defaultmodule->archetype
= plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE
, MOD_ARCHETYPE_OTHER
);
2897 // Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list
2898 // of elements to be added to activity chooser.
2899 $items = component_callback($modname, 'get_shortcuts', array($defaultmodule), null);
2900 if ($items !== null) {
2901 foreach ($items as $item) {
2902 // Add all items to the return array. All items must have different links, use them as a key in the return array.
2903 if (!isset($item->archetype
)) {
2904 $item->archetype
= $defaultmodule->archetype
;
2906 if (!isset($item->icon
)) {
2907 $item->icon
= $defaultmodule->icon
;
2909 // If plugin returned the only one item with the same link as default item - cache it as $modname,
2910 // otherwise append the link url to the module name.
2911 $item->name
= (count($items) == 1 &&
2912 $item->link
->out() === $defaultmodule->link
->out()) ?
$modname : $modname . ':' . $item->link
;
2914 // If the module provides the helptext property, append it to the help text to match the look and feel
2915 // of the default course modules.
2916 if (isset($item->help
) && isset($item->helplink
)) {
2917 $linktext = get_string('morehelp');
2918 $item->help
.= html_writer
::tag('div',
2919 $OUTPUT->doc_link($item->helplink
, $linktext, true), array('class' => 'helpdoclink'));
2921 $modlist[$course->id
][$modname][$item->name
] = $item;
2923 $return +
= $modlist[$course->id
][$modname];
2924 // If get_shortcuts() callback is defined, the default module action is not added.
2925 // It is a responsibility of the callback to add it to the return value unless it is not needed.
2929 // The callback get_shortcuts() was not found, use the default item for the activity chooser.
2930 $modlist[$course->id
][$modname][$modname] = $defaultmodule;
2931 $return[$modname] = $defaultmodule;
2934 core_collator
::asort_objects_by_property($return, 'title');
2939 * Runs a single cron task. This function assumes it is displaying output in pseudo-CLI mode.
2941 * The function will fail if the task is disabled.
2943 * Warning: Because this function closes the browser session, it may not be safe to continue
2944 * with other processing (other than displaying the rest of the page) after using this function!
2946 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task).
2947 * @todo final deprecation. To be removed in Moodle 4.1 MDL-63594.
2948 * @param \core\task\scheduled_task $task Task to run
2949 * @return bool True if cron run successful
2951 function cron_run_single_task(\core\task\scheduled_task
$task) {
2952 debugging('cron_run_single_task() is deprecated. Please use \\core\task\manager::run_from_cli() instead.',
2954 return \core\task\manager
::run_from_cli($task);
2958 * Executes cron functions for a specific type of plugin.
2960 * @param string $plugintype Plugin type (e.g. 'report')
2961 * @param string $description If specified, will display 'Starting (whatever)'
2962 * and 'Finished (whatever)' lines, otherwise does not display
2964 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2965 * @todo MDL-61165 This will be deleted in Moodle 4.1.
2967 function cron_execute_plugin_type($plugintype, $description = null) {
2970 // Get list from plugin => function for all plugins.
2971 $plugins = get_plugin_list_with_function($plugintype, 'cron');
2973 // Modify list for backward compatibility (different files/names).
2974 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins);
2976 // Return if no plugins with cron function to process.
2982 mtrace('Starting '.$description);
2985 foreach ($plugins as $component => $cronfunction) {
2986 $dir = core_component
::get_component_directory($component);
2988 // Get cron period if specified in version.php, otherwise assume every cron.
2990 if (file_exists("$dir/version.php")) {
2991 $plugin = new stdClass();
2992 include("$dir/version.php");
2993 if (isset($plugin->cron
)) {
2994 $cronperiod = $plugin->cron
;
2998 // Using last cron and cron period, don't run if it already ran recently.
2999 $lastcron = get_config($component, 'lastcron');
3000 if ($cronperiod && $lastcron) {
3001 if ($lastcron +
$cronperiod > time()) {
3002 // Do not execute cron yet.
3007 mtrace('Processing cron function for ' . $component . '...');
3008 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER
);
3009 cron_trace_time_and_memory();
3010 $pre_dbqueries = $DB->perf_get_queries();
3011 $pre_time = microtime(true);
3015 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " .
3016 round(microtime(true) - $pre_time, 2) . " seconds)");
3018 set_config('lastcron', time(), $component);
3019 core_php_time_limit
::raise();
3023 mtrace('Finished ' . $description);
3028 * Used to add in old-style cron functions within plugins that have not been converted to the
3029 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used
3030 * cron.php and some used a different name.)
3032 * @param string $plugintype Plugin type e.g. 'report'
3033 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g.
3034 * 'report_frog_cron') for plugin cron functions that were already found using the new API
3035 * @return array Revised version of $plugins that adds in any extra plugin functions found by
3036 * looking in the older location
3038 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
3039 * @todo MDL-61165 This will be deleted in Moodle 4.1.
3041 function cron_bc_hack_plugin_functions($plugintype, $plugins) {
3042 global $CFG; // Mandatory in case it is referenced by include()d PHP script.
3044 if ($plugintype === 'report') {
3045 // Admin reports only - not course report because course report was
3046 // never implemented before, so doesn't need BC.
3047 foreach (core_component
::get_plugin_list($plugintype) as $pluginname => $dir) {
3048 $component = $plugintype . '_' . $pluginname;
3049 if (isset($plugins[$component])) {
3050 // We already have detected the function using the new API.
3053 if (!file_exists("$dir/cron.php")) {
3054 // No old style cron file present.
3057 include_once("$dir/cron.php");
3058 $cronfunction = $component . '_cron';
3059 if (function_exists($cronfunction)) {
3060 $plugins[$component] = $cronfunction;
3062 debugging("Invalid legacy cron.php detected in $component, " .
3063 "please use lib.php instead");
3066 } else if (strpos($plugintype, 'grade') === 0) {
3067 // Detect old style cron function names.
3068 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of
3069 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport.
3070 foreach (core_component
::get_plugin_list($plugintype) as $pluginname => $dir) {
3071 $component = $plugintype.'_'.$pluginname;
3072 if (isset($plugins[$component])) {
3073 // We already have detected the function using the new API.
3076 if (!file_exists("$dir/lib.php")) {
3079 include_once("$dir/lib.php");
3080 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' .
3081 $pluginname . '_cron';
3082 if (function_exists($cronfunction)) {
3083 $plugins[$component] = $cronfunction;
3092 * Returns the SQL used by the participants table.
3094 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3095 * @param int $courseid The course id
3096 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3097 * @param int $accesssince The time since last access, 0 means any time
3098 * @param int $roleid The role id, 0 means all roles and -1 no roles
3099 * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned.
3100 * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed.
3101 * @param string|array $search The search that was performed, empty means perform no search
3102 * @param string $additionalwhere Any additional SQL to add to where
3103 * @param array $additionalparams The additional params
3106 function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3107 $search = '', $additionalwhere = '', $additionalparams = array()) {
3108 global $DB, $USER, $CFG;
3110 $deprecatedtext = __FUNCTION__
. '() is deprecated. ' .
3111 'Please use \core\table\participants_search::class with table filtersets instead.';
3112 debugging($deprecatedtext, DEBUG_DEVELOPER
);
3115 $context = \context_course
::instance($courseid, MUST_EXIST
);
3117 $isfrontpage = ($courseid == SITEID
);
3119 // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments.
3121 $onlysuspended = false;
3122 if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) {
3123 switch ($statusid) {
3124 case ENROL_USER_ACTIVE
:
3125 // Nothing to do here.
3127 case ENROL_USER_SUSPENDED
:
3128 $onlyactive = false;
3129 $onlysuspended = true;
3132 // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false.
3133 $onlyactive = false;
3138 list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid);
3140 $joins = array('FROM {user} u');
3143 $userfields = get_extra_user_fields($context);
3144 $userfieldssql = user_picture
::fields('u', $userfields);
3147 $select = "SELECT $userfieldssql, u.lastaccess";
3148 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually.
3150 $wheres[] = user_get_user_lastaccess_sql($accesssince);
3153 $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess";
3154 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only.
3155 // Not everybody has accessed the course yet.
3156 $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)';
3157 $params['courseid'] = $courseid;
3159 $wheres[] = user_get_course_lastaccess_sql($accesssince);
3163 // Performance hacks - we preload user contexts together with accounts.
3164 $ccselect = ', ' . context_helper
::get_preload_record_columns_sql('ctx');
3165 $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)';
3166 $params['contextlevel'] = CONTEXT_USER
;
3167 $select .= $ccselect;
3170 // Limit list to users with some role only.
3172 // We want to query both the current context and parent contexts.
3173 list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true),
3174 SQL_PARAMS_NAMED
, 'relatedctx');
3176 // Get users without any role.
3177 if ($roleid == -1) {
3178 $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)";
3179 $params = array_merge($params, $relatedctxparams);
3181 $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
3182 $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
3186 if (!empty($search)) {
3187 if (!is_array($search)) {
3188 $search = [$search];
3190 foreach ($search as $index => $keyword) {
3191 $searchkey1 = 'search' . $index . '1';
3192 $searchkey2 = 'search' . $index . '2';
3193 $searchkey3 = 'search' . $index . '3';
3194 $searchkey4 = 'search' . $index . '4';
3195 $searchkey5 = 'search' . $index . '5';
3196 $searchkey6 = 'search' . $index . '6';
3197 $searchkey7 = 'search' . $index . '7';
3199 $conditions = array();
3200 // Search by fullname.
3201 $fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
3202 $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false);
3205 $email = $DB->sql_like('email', ':' . $searchkey2, false, false);
3206 if (!in_array('email', $userfields)) {
3207 $maildisplay = 'maildisplay' . $index;
3208 $userid1 = 'userid' . $index . '1';
3209 // Prevent users who hide their email address from being found by others
3210 // who aren't allowed to see hidden email addresses.
3211 $email = "(". $email ." AND (" .
3212 "u.maildisplay <> :$maildisplay " .
3213 "OR u.id = :$userid1". // User can always find himself.
3215 $params[$maildisplay] = core_user
::MAILDISPLAY_HIDE
;
3216 $params[$userid1] = $USER->id
;
3218 $conditions[] = $email;
3220 // Search by idnumber.
3221 $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false);
3222 if (!in_array('idnumber', $userfields)) {
3223 $userid2 = 'userid' . $index . '2';
3224 // Users who aren't allowed to see idnumbers should at most find themselves
3225 // when searching for an idnumber.
3226 $idnumber = "(". $idnumber . " AND u.id = :$userid2)";
3227 $params[$userid2] = $USER->id
;
3229 $conditions[] = $idnumber;
3231 if (!empty($CFG->showuseridentity
)) {
3232 // Search all user identify fields.
3233 $extrasearchfields = explode(',', $CFG->showuseridentity
);
3234 foreach ($extrasearchfields as $extrasearchfield) {
3235 if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) {
3236 // Already covered above. Search by country not supported.
3239 $param = $searchkey3 . $extrasearchfield;
3240 $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false);
3241 $params[$param] = "%$keyword%";
3242 if (!in_array($extrasearchfield, $userfields)) {
3243 // User cannot see this field, but allow match if their own account.
3244 $userid3 = 'userid' . $index . '3' . $extrasearchfield;
3245 $condition = "(". $condition . " AND u.id = :$userid3)";
3246 $params[$userid3] = $USER->id
;
3248 $conditions[] = $condition;
3252 // Search by middlename.
3253 $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false);
3254 $conditions[] = $middlename;
3256 // Search by alternatename.
3257 $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false);
3258 $conditions[] = $alternatename;
3260 // Search by firstnamephonetic.
3261 $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false);
3262 $conditions[] = $firstnamephonetic;
3264 // Search by lastnamephonetic.
3265 $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false);
3266 $conditions[] = $lastnamephonetic;
3268 $wheres[] = "(". implode(" OR ", $conditions) .") ";
3269 $params[$searchkey1] = "%$keyword%";
3270 $params[$searchkey2] = "%$keyword%";
3271 $params[$searchkey3] = "%$keyword%";
3272 $params[$searchkey4] = "%$keyword%";
3273 $params[$searchkey5] = "%$keyword%";
3274 $params[$searchkey6] = "%$keyword%";
3275 $params[$searchkey7] = "%$keyword%";
3279 if (!empty($additionalwhere)) {
3280 $wheres[] = $additionalwhere;
3281 $params = array_merge($params, $additionalparams);
3284 $from = implode("\n", $joins);
3286 $where = 'WHERE ' . implode(' AND ', $wheres);
3291 return array($select, $from, $where, $params);
3295 * Returns the total number of participants for a given course.
3297 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3298 * @param int $courseid The course id
3299 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3300 * @param int $accesssince The time since last access, 0 means any time
3301 * @param int $roleid The role id, 0 means all roles
3302 * @param int $enrolid The applied filter for the user enrolment ID.
3303 * @param int $status The applied filter for the user's enrolment status.
3304 * @param string|array $search The search that was performed, empty means perform no search
3305 * @param string $additionalwhere Any additional SQL to add to where
3306 * @param array $additionalparams The additional params
3309 function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3310 $search = '', $additionalwhere = '', $additionalparams = array()) {
3313 $deprecatedtext = __FUNCTION__
. '() is deprecated. ' .
3314 'Please use \core\table\participants_search::class with table filtersets instead.';
3315 debugging($deprecatedtext, DEBUG_DEVELOPER
);
3317 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3318 $statusid, $search, $additionalwhere, $additionalparams);
3320 return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
3324 * Returns the participants for a given course.
3326 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3327 * @param int $courseid The course id
3328 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3329 * @param int $accesssince The time since last access
3330 * @param int $roleid The role id
3331 * @param int $enrolid The applied filter for the user enrolment ID.
3332 * @param int $status The applied filter for the user's enrolment status.
3333 * @param string $search The search that was performed
3334 * @param string $additionalwhere Any additional SQL to add to where
3335 * @param array $additionalparams The additional params
3336 * @param string $sort The SQL sort
3337 * @param int $limitfrom return a subset of records, starting at this point (optional).
3338 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
3339 * @return moodle_recordset
3341 function user_get_participants($courseid, $groupid = 0, $accesssince, $roleid, $enrolid = 0, $statusid, $search,
3342 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) {
3345 $deprecatedtext = __FUNCTION__
. '() is deprecated. ' .
3346 'Please use \core\table\participants_search::class with table filtersets instead.';
3347 debugging($deprecatedtext, DEBUG_DEVELOPER
);
3349 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3350 $statusid, $search, $additionalwhere, $additionalparams);
3352 return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
3356 * Returns the list of full course categories to be used in html_writer::select()
3358 * Calls {@see core_course_category::make_categories_list()} to build the list.
3360 * @deprecated since Moodle 3.10
3361 * @todo This will be finally removed for Moodle 4.2 as part of MDL-69124.
3362 * @return array array mapping course category id to the display name
3364 function make_categories_options() {
3365 $deprecatedtext = __FUNCTION__
. '() is deprecated. Please use \core_course_category::make_categories_list() instead.';
3366 debugging($deprecatedtext, DEBUG_DEVELOPER
);
3368 return core_course_category
::make_categories_list('', 0, ' / ');