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