Merge branch 'MDL-50225_master' of git://github.com/markn86/moodle
[moodle.git] / lib / deprecatedlib.php
blob1298165e48958dd3e51801f375fa5b61b68d7b0d
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 * Add an entry to the legacy log table.
38 * @deprecated since 2.7 use new events instead
40 * @param int $courseid The course id
41 * @param string $module The module name e.g. forum, journal, resource, course, user etc
42 * @param string $action 'view', 'update', 'add' or 'delete', possibly followed by another word to clarify.
43 * @param string $url The file and parameters used to see the results of the action
44 * @param string $info Additional description information
45 * @param int $cm The course_module->id if there is one
46 * @param int|stdClass $user If log regards $user other than $USER
47 * @return void
49 function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user=0) {
50 debugging('add_to_log() has been deprecated, please rewrite your code to the new events API', DEBUG_DEVELOPER);
52 // This is a nasty hack that allows us to put all the legacy stuff into legacy storage,
53 // this way we may move all the legacy settings there too.
54 $manager = get_log_manager();
55 if (method_exists($manager, 'legacy_add_to_log')) {
56 $manager->legacy_add_to_log($courseid, $module, $action, $url, $info, $cm, $user);
60 /**
61 * @deprecated since 2.6
63 function events_trigger() {
64 throw new coding_exception('events_trigger() has been deprecated along with all Events 1 API in favour of Events 2 API.');
67 /**
68 * List all core subsystems and their location
70 * This is a whitelist of components that are part of the core and their
71 * language strings are defined in /lang/en/<<subsystem>>.php. If a given
72 * plugin is not listed here and it does not have proper plugintype prefix,
73 * then it is considered as course activity module.
75 * The location is optionally dirroot relative path. NULL means there is no special
76 * directory for this subsystem. If the location is set, the subsystem's
77 * renderer.php is expected to be there.
79 * @deprecated since 2.6, use core_component::get_core_subsystems()
81 * @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons
82 * @return array of (string)name => (string|null)location
84 function get_core_subsystems($fullpaths = false) {
85 global $CFG;
87 // NOTE: do not add any other debugging here, keep forever.
89 $subsystems = core_component::get_core_subsystems();
91 if ($fullpaths) {
92 return $subsystems;
95 debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
97 $dlength = strlen($CFG->dirroot);
99 foreach ($subsystems as $k => $v) {
100 if ($v === null) {
101 continue;
103 $subsystems[$k] = substr($v, $dlength+1);
106 return $subsystems;
110 * Lists all plugin types.
112 * @deprecated since 2.6, use core_component::get_plugin_types()
114 * @param bool $fullpaths false means relative paths from dirroot
115 * @return array Array of strings - name=>location
117 function get_plugin_types($fullpaths = true) {
118 global $CFG;
120 // NOTE: do not add any other debugging here, keep forever.
122 $types = core_component::get_plugin_types();
124 if ($fullpaths) {
125 return $types;
128 debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
130 $dlength = strlen($CFG->dirroot);
132 foreach ($types as $k => $v) {
133 if ($k === 'theme') {
134 $types[$k] = 'theme';
135 continue;
137 $types[$k] = substr($v, $dlength+1);
140 return $types;
144 * Use when listing real plugins of one type.
146 * @deprecated since 2.6, use core_component::get_plugin_list()
148 * @param string $plugintype type of plugin
149 * @return array name=>fulllocation pairs of plugins of given type
151 function get_plugin_list($plugintype) {
153 // NOTE: do not add any other debugging here, keep forever.
155 if ($plugintype === '') {
156 $plugintype = 'mod';
159 return core_component::get_plugin_list($plugintype);
163 * Get a list of all the plugins of a given type that define a certain class
164 * in a certain file. The plugin component names and class names are returned.
166 * @deprecated since 2.6, use core_component::get_plugin_list_with_class()
168 * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
169 * @param string $class the part of the name of the class after the
170 * frankenstyle prefix. e.g 'thing' if you are looking for classes with
171 * names like report_courselist_thing. If you are looking for classes with
172 * the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
173 * @param string $file the name of file within the plugin that defines the class.
174 * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
175 * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
177 function get_plugin_list_with_class($plugintype, $class, $file) {
179 // NOTE: do not add any other debugging here, keep forever.
181 return core_component::get_plugin_list_with_class($plugintype, $class, $file);
185 * Returns the exact absolute path to plugin directory.
187 * @deprecated since 2.6, use core_component::get_plugin_directory()
189 * @param string $plugintype type of plugin
190 * @param string $name name of the plugin
191 * @return string full path to plugin directory; NULL if not found
193 function get_plugin_directory($plugintype, $name) {
195 // NOTE: do not add any other debugging here, keep forever.
197 if ($plugintype === '') {
198 $plugintype = 'mod';
201 return core_component::get_plugin_directory($plugintype, $name);
205 * Normalize the component name using the "frankenstyle" names.
207 * @deprecated since 2.6, use core_component::normalize_component()
209 * @param string $component
210 * @return array two-items list of [(string)type, (string|null)name]
212 function normalize_component($component) {
214 // NOTE: do not add any other debugging here, keep forever.
216 return core_component::normalize_component($component);
220 * Return exact absolute path to a plugin directory.
222 * @deprecated since 2.6, use core_component::normalize_component()
224 * @param string $component name such as 'moodle', 'mod_forum'
225 * @return string full path to component directory; NULL if not found
227 function get_component_directory($component) {
229 // NOTE: do not add any other debugging here, keep forever.
231 return core_component::get_component_directory($component);
235 * Get the context instance as an object. This function will create the
236 * context instance if it does not exist yet.
238 * @deprecated since 2.2, use context_course::instance() or other relevant class instead
239 * @todo This will be deleted in Moodle 2.8, refer MDL-34472
240 * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
241 * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
242 * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
243 * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
244 * MUST_EXIST means throw exception if no record or multiple records found
245 * @return context The context object.
247 function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) {
249 debugging('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER);
251 $instances = (array)$instance;
252 $contexts = array();
254 $classname = context_helper::get_class_for_level($contextlevel);
256 // we do not load multiple contexts any more, PAGE should be responsible for any preloading
257 foreach ($instances as $inst) {
258 $contexts[$inst] = $classname::instance($inst, $strictness);
261 if (is_array($instance)) {
262 return $contexts;
263 } else {
264 return $contexts[$instance];
267 /* === End of long term deprecated api list === */
270 * @deprecated since 2.7 - use new file picker instead
272 function clam_log_upload() {
273 throw new coding_exception('clam_log_upload() can not be used any more, please use file picker instead');
277 * @deprecated since 2.7 - use new file picker instead
279 function clam_log_infected() {
280 throw new coding_exception('clam_log_infected() can not be used any more, please use file picker instead');
284 * @deprecated since 2.7 - use new file picker instead
286 function clam_change_log() {
287 throw new coding_exception('clam_change_log() can not be used any more, please use file picker instead');
291 * @deprecated since 2.7 - infected files are now deleted in file picker
293 function clam_replace_infected_file() {
294 throw new coding_exception('clam_replace_infected_file() can not be used any more, please use file picker instead');
298 * @deprecated since 2.7
300 function clam_handle_infected_file() {
301 throw new coding_exception('clam_handle_infected_file() can not be used any more, please use file picker instead');
305 * @deprecated since 2.7
307 function clam_scan_moodle_file() {
308 throw new coding_exception('clam_scan_moodle_file() can not be used any more, please use file picker instead');
313 * @deprecated since 2.7 PHP 5.4.x should be always compatible.
315 function password_compat_not_supported() {
316 throw new coding_exception('Do not use password_compat_not_supported() - bcrypt is now always available');
320 * @deprecated since 2.6
322 function session_get_instance() {
323 throw new coding_exception('session_get_instance() is removed, use \core\session\manager instead');
327 * @deprecated since 2.6
329 function session_is_legacy() {
330 throw new coding_exception('session_is_legacy() is removed, do not use any more');
334 * @deprecated since 2.6
336 function session_kill_all() {
337 throw new coding_exception('session_kill_all() is removed, use \core\session\manager::kill_all_sessions() instead');
341 * @deprecated since 2.6
343 function session_touch() {
344 throw new coding_exception('session_touch() is removed, use \core\session\manager::touch_session() instead');
348 * @deprecated since 2.6
350 function session_kill() {
351 throw new coding_exception('session_kill() is removed, use \core\session\manager::kill_session() instead');
355 * @deprecated since 2.6
357 function session_kill_user() {
358 throw new coding_exception('session_kill_user() is removed, use \core\session\manager::kill_user_sessions() instead');
362 * @deprecated since 2.6
364 function session_set_user() {
365 throw new coding_exception('session_set_user() is removed, use \core\session\manager::set_user() instead');
369 * @deprecated since 2.6
371 function session_is_loggedinas() {
372 throw new coding_exception('session_is_loggedinas() is removed, use \core\session\manager::is_loggedinas() instead');
376 * @deprecated since 2.6
378 function session_get_realuser() {
379 throw new coding_exception('session_get_realuser() is removed, use \core\session\manager::get_realuser() instead');
383 * @deprecated since 2.6
385 function session_loginas() {
386 throw new coding_exception('session_loginas() is removed, use \core\session\manager::loginas() instead');
390 * @deprecated since 2.6
392 function js_minify() {
393 throw new coding_exception('js_minify() is removed, use core_minify::js_files() or core_minify::js() instead.');
397 * @deprecated since 2.6
399 function css_minify_css() {
400 throw new coding_exception('css_minify_css() is removed, use core_minify::css_files() or core_minify::css() instead.');
403 // === Deprecated before 2.6.0 ===
406 * @deprecated
408 function check_gd_version() {
409 throw new coding_exception('check_gd_version() is removed, GD extension is always available now');
413 * @deprecated
415 function update_login_count() {
416 throw new coding_exception('update_login_count() is removed, all calls need to be removed');
420 * @deprecated
422 function reset_login_count() {
423 throw new coding_exception('reset_login_count() is removed, all calls need to be removed');
427 * @deprecated
429 function update_log_display_entry() {
431 throw new coding_exception('The update_log_display_entry() is removed, please use db/log.php description file instead.');
435 * @deprecated use the text formatting in a standard way instead (http://docs.moodle.org/dev/Output_functions)
436 * this was abused mostly for embedding of attachments
438 function filter_text() {
439 throw new coding_exception('filter_text() can not be used anymore, use format_text(), format_string() etc instead.');
443 * @deprecated Loginhttps is no longer supported
445 function httpsrequired() {
446 throw new coding_exception('httpsrequired() can not be used any more. Loginhttps is no longer supported.');
450 * @deprecated since 3.1 - replacement legacy file API methods can be found on the moodle_url class, for example:
451 * The moodle_url::make_legacyfile_url() method can be used to generate a legacy course file url. To generate
452 * course module file.php url the moodle_url::make_file_url() should be used.
454 function get_file_url() {
455 throw new coding_exception('get_file_url() can not be used anymore. Please use ' .
456 'moodle_url factory methods instead.');
460 * @deprecated use get_enrolled_users($context) instead.
462 function get_course_participants() {
463 throw new coding_exception('get_course_participants() can not be used any more, use get_enrolled_users() instead.');
467 * @deprecated use is_enrolled($context, $userid) instead.
469 function is_course_participant() {
470 throw new coding_exception('is_course_participant() can not be used any more, use is_enrolled() instead.');
474 * @deprecated
476 function get_recent_enrolments() {
477 throw new coding_exception('get_recent_enrolments() is removed as it returned inaccurate results.');
481 * @deprecated use clean_param($string, PARAM_FILE) instead.
483 function detect_munged_arguments() {
484 throw new coding_exception('detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.');
489 * Unzip one zip file to a destination dir
490 * Both parameters must be FULL paths
491 * If destination isn't specified, it will be the
492 * SAME directory where the zip file resides.
494 * @global object
495 * @param string $zipfile The zip file to unzip
496 * @param string $destination The location to unzip to
497 * @param bool $showstatus_ignored Unused
498 * @deprecated since 2.0 MDL-15919
500 function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
501 debugging(__FUNCTION__ . '() is deprecated. '
502 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER);
504 // Extract everything from zipfile.
505 $path_parts = pathinfo(cleardoubleslashes($zipfile));
506 $zippath = $path_parts["dirname"]; //The path of the zip file
507 $zipfilename = $path_parts["basename"]; //The name of the zip file
508 $extension = $path_parts["extension"]; //The extension of the file
510 //If no file, error
511 if (empty($zipfilename)) {
512 return false;
515 //If no extension, error
516 if (empty($extension)) {
517 return false;
520 //Clear $zipfile
521 $zipfile = cleardoubleslashes($zipfile);
523 //Check zipfile exists
524 if (!file_exists($zipfile)) {
525 return false;
528 //If no destination, passed let's go with the same directory
529 if (empty($destination)) {
530 $destination = $zippath;
533 //Clear $destination
534 $destpath = rtrim(cleardoubleslashes($destination), "/");
536 //Check destination path exists
537 if (!is_dir($destpath)) {
538 return false;
541 $packer = get_file_packer('application/zip');
543 $result = $packer->extract_to_pathname($zipfile, $destpath);
545 if ($result === false) {
546 return false;
549 foreach ($result as $status) {
550 if ($status !== true) {
551 return false;
555 return true;
559 * Zip an array of files/dirs to a destination zip file
560 * Both parameters must be FULL paths to the files/dirs
562 * @global object
563 * @param array $originalfiles Files to zip
564 * @param string $destination The destination path
565 * @return bool Outcome
567 * @deprecated since 2.0 MDL-15919
569 function zip_files($originalfiles, $destination) {
570 debugging(__FUNCTION__ . '() is deprecated. '
571 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER);
573 // Extract everything from destination.
574 $path_parts = pathinfo(cleardoubleslashes($destination));
575 $destpath = $path_parts["dirname"]; //The path of the zip file
576 $destfilename = $path_parts["basename"]; //The name of the zip file
577 $extension = $path_parts["extension"]; //The extension of the file
579 //If no file, error
580 if (empty($destfilename)) {
581 return false;
584 //If no extension, add it
585 if (empty($extension)) {
586 $extension = 'zip';
587 $destfilename = $destfilename.'.'.$extension;
590 //Check destination path exists
591 if (!is_dir($destpath)) {
592 return false;
595 //Check destination path is writable. TODO!!
597 //Clean destination filename
598 $destfilename = clean_filename($destfilename);
600 //Now check and prepare every file
601 $files = array();
602 $origpath = NULL;
604 foreach ($originalfiles as $file) { //Iterate over each file
605 //Check for every file
606 $tempfile = cleardoubleslashes($file); // no doubleslashes!
607 //Calculate the base path for all files if it isn't set
608 if ($origpath === NULL) {
609 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
611 //See if the file is readable
612 if (!is_readable($tempfile)) { //Is readable
613 continue;
615 //See if the file/dir is in the same directory than the rest
616 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
617 continue;
619 //Add the file to the array
620 $files[] = $tempfile;
623 $zipfiles = array();
624 $start = strlen($origpath)+1;
625 foreach($files as $file) {
626 $zipfiles[substr($file, $start)] = $file;
629 $packer = get_file_packer('application/zip');
631 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
635 * @deprecated use groups_get_all_groups() instead.
637 function mygroupid() {
638 throw new coding_exception('mygroupid() can not be used any more, please use groups_get_all_groups() instead.');
642 * @deprecated since Moodle 2.0 MDL-14617 - please do not use this function any more.
644 function groupmode() {
645 throw new coding_exception('groupmode() can not be used any more, please use groups_get_* instead.');
649 * @deprecated Since year 2006 - please do not use this function any more.
651 function set_current_group() {
652 throw new coding_exception('set_current_group() can not be used anymore, please use $SESSION->currentgroup[$courseid] instead');
656 * @deprecated Since year 2006 - please do not use this function any more.
658 function get_current_group() {
659 throw new coding_exception('get_current_group() can not be used any more, please use groups_get_* instead');
663 * @deprecated Since Moodle 2.8
665 function groups_filter_users_by_course_module_visible() {
666 throw new coding_exception('groups_filter_users_by_course_module_visible() is removed. ' .
667 'Replace with a call to \core_availability\info_module::filter_user_list(), ' .
668 'which does basically the same thing but includes other restrictions such ' .
669 'as profile restrictions.');
673 * @deprecated Since Moodle 2.8
675 function groups_course_module_visible() {
676 throw new coding_exception('groups_course_module_visible() is removed, use $cm->uservisible to decide whether the current
677 user can ' . 'access an activity.', DEBUG_DEVELOPER);
681 * @deprecated since 2.0
683 function error() {
684 throw new coding_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a removed, please call
685 print_error() instead of error()');
690 * @deprecated use $PAGE->theme->name instead.
692 function current_theme() {
693 throw new coding_exception('current_theme() can not be used any more, please use $PAGE->theme->name instead');
697 * @deprecated
699 function formerr() {
700 throw new coding_exception('formerr() is removed. Please change your code to use $OUTPUT->error_text($string).');
704 * @deprecated use $OUTPUT->skip_link_target() in instead.
706 function skip_main_destination() {
707 throw new coding_exception('skip_main_destination() can not be used any more, please use $OUTPUT->skip_link_target() instead.');
711 * @deprecated use $OUTPUT->container() instead.
713 function print_container() {
714 throw new coding_exception('print_container() can not be used any more. Please use $OUTPUT->container() instead.');
718 * @deprecated use $OUTPUT->container_start() instead.
720 function print_container_start() {
721 throw new coding_exception('print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.');
725 * @deprecated use $OUTPUT->container_end() instead.
727 function print_container_end() {
728 throw new coding_exception('print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.');
732 * @deprecated since Moodle 2.0 MDL-19077 - use $OUTPUT->notification instead.
734 function notify() {
735 throw new coding_exception('notify() is removed, please use $OUTPUT->notification() instead');
739 * @deprecated use $OUTPUT->continue_button() instead.
741 function print_continue() {
742 throw new coding_exception('print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.');
746 * @deprecated use $PAGE methods instead.
748 function print_header() {
750 throw new coding_exception('print_header() can not be used any more. Please use $PAGE methods instead.');
754 * @deprecated use $PAGE methods instead.
756 function print_header_simple() {
758 throw new coding_exception('print_header_simple() can not be used any more. Please use $PAGE methods instead.');
762 * @deprecated use $OUTPUT->block() instead.
764 function print_side_block() {
765 throw new coding_exception('print_side_block() can not be used any more, please use $OUTPUT->block() instead.');
769 * Prints a basic textarea field.
771 * This was 'deprecated' in 2.0, but not properly (there was no alternative) so the
772 * debugging message was commented out.
774 * @deprecated since Moodle 3.6
776 * When using this function, you should
778 * @global object
779 * @param bool $unused No longer used.
780 * @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
781 * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
782 * @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
783 * @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
784 * @param string $name Name to use for the textarea element.
785 * @param string $value Initial content to display in the textarea.
786 * @param int $obsolete deprecated
787 * @param bool $return If false, will output string. If true, will return string value.
788 * @param string $id CSS ID to add to the textarea element.
789 * @return string|void depending on the value of $return
791 function print_textarea($unused, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
792 /// $width and height are legacy fields and no longer used as pixels like they used to be.
793 /// However, you can set them to zero to override the mincols and minrows values below.
795 // Disabling because there is not yet a viable $OUTPUT option for cases when mforms can't be used
796 debugging('print_textarea() is deprecated. Please use $OUTPUT->print_textarea() instead.', DEBUG_DEVELOPER);
798 global $OUTPUT;
800 $mincols = 65;
801 $minrows = 10;
803 if ($id === '') {
804 $id = 'edit-'.$name;
807 if ($height && ($rows < $minrows)) {
808 $rows = $minrows;
810 if ($width && ($cols < $mincols)) {
811 $cols = $mincols;
814 $textarea = $OUTPUT->print_textarea($name, $id, $value, $rows, $cols);
815 if ($return) {
816 return $textarea;
819 echo $textarea;
823 * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
824 * provide this function with the language strings for sortasc and sortdesc.
826 * @deprecated use $OUTPUT->arrow() instead.
827 * @todo final deprecation of this function once MDL-45448 is resolved
829 * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
831 * @global object
832 * @param string $direction 'up' or 'down'
833 * @param string $strsort The language string used for the alt attribute of this image
834 * @param bool $return Whether to print directly or return the html string
835 * @return string|void depending on $return
838 function print_arrow($direction='up', $strsort=null, $return=false) {
839 global $OUTPUT;
841 debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER);
843 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
844 return null;
847 $return = null;
849 switch ($direction) {
850 case 'up':
851 $sortdir = 'asc';
852 break;
853 case 'down':
854 $sortdir = 'desc';
855 break;
856 case 'move':
857 $sortdir = 'asc';
858 break;
859 default:
860 $sortdir = null;
861 break;
864 // Prepare language string
865 $strsort = '';
866 if (empty($strsort) && !empty($sortdir)) {
867 $strsort = get_string('sort' . $sortdir, 'grades');
870 $return = ' ' . $OUTPUT->pix_icon('t/' . $direction, $strsort) . ' ';
872 if ($return) {
873 return $return;
874 } else {
875 echo $return;
880 * @deprecated since Moodle 2.0
882 function choose_from_menu() {
883 throw new coding_exception('choose_from_menu() is removed. Please change your code to use html_writer::select().');
887 * @deprecated use $OUTPUT->help_icon_scale($courseid, $scale) instead.
889 function print_scale_menu_helpbutton() {
890 throw new coding_exception('print_scale_menu_helpbutton() can not be used any more. '.
891 'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.');
895 * @deprecated use html_writer::checkbox() instead.
897 function print_checkbox() {
898 throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.');
902 * @deprecated since Moodle 3.2
904 function update_module_button() {
905 throw new coding_exception('update_module_button() can not be used anymore. Activity modules should ' .
906 'not add the edit module button, the link is already available in the Administration block. Themes ' .
907 'can choose to display the link in the buttons row consistently for all module types.');
911 * @deprecated use $OUTPUT->navbar() instead
913 function print_navigation () {
914 throw new coding_exception('print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.');
918 * @deprecated Please use $PAGE->navabar methods instead.
920 function build_navigation() {
921 throw new coding_exception('build_navigation() can not be used any more, please use $PAGE->navbar methods instead.');
925 * @deprecated not relevant with global navigation in Moodle 2.x+
927 function navmenu() {
928 throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.');
931 /// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
935 * @deprecated please use calendar_event::create() instead.
937 function add_event() {
938 throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.');
942 * @deprecated please calendar_event->update() instead.
944 function update_event() {
945 throw new coding_exception('update_event() is removed, please use calendar_event->update() instead.');
949 * @deprecated please use calendar_event->delete() instead.
951 function delete_event() {
952 throw new coding_exception('delete_event() can not be used any more, please use '.
953 'calendar_event->delete() instead.');
957 * @deprecated please use calendar_event->toggle_visibility(false) instead.
959 function hide_event() {
960 throw new coding_exception('hide_event() can not be used any more, please use '.
961 'calendar_event->toggle_visibility(false) instead.');
965 * @deprecated please use calendar_event->toggle_visibility(true) instead.
967 function show_event() {
968 throw new coding_exception('show_event() can not be used any more, please use '.
969 'calendar_event->toggle_visibility(true) instead.');
973 * @deprecated since Moodle 2.2 use core_text::xxxx() instead.
975 function textlib_get_instance() {
976 throw new coding_exception('textlib_get_instance() can not be used any more, please use '.
977 'core_text::functioname() instead.');
981 * @deprecated since 2.4
983 function get_generic_section_name() {
984 throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base');
988 * @deprecated since 2.4
990 function get_all_sections() {
991 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function');
995 * @deprecated since 2.4
997 function add_mod_to_section() {
998 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()');
1002 * @deprecated since 2.4
1004 function get_all_mods() {
1005 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
1009 * @deprecated since 2.4
1011 function get_course_section() {
1012 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
1016 * @deprecated since 2.4
1018 function format_weeks_get_section_dates() {
1019 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'.
1020 ' use it outside of format_weeks plugin');
1024 * @deprecated since 2.5
1026 function get_print_section_cm_text() {
1027 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '.
1028 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
1032 * @deprecated since 2.5
1034 function print_section_add_menus() {
1035 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '.
1036 'function course_section_add_cm_control()');
1040 * @deprecated since 2.5. Please use:
1041 * $courserenderer = $PAGE->get_renderer('core', 'course');
1042 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
1043 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
1045 function make_editing_buttons() {
1046 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '.
1047 'lib/deprecatedlib.php on how to replace it');
1051 * @deprecated since 2.5
1053 function print_section() {
1054 throw new coding_exception('Function print_section() is removed. Please use course renderer function '.
1055 'course_section_cm_list() instead.');
1059 * @deprecated since 2.5
1061 function print_overview() {
1062 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information');
1066 * @deprecated since 2.5
1068 function print_recent_activity() {
1069 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'.
1070 ' use it outside of block_recent_activity');
1074 * @deprecated since 2.5
1076 function delete_course_module() {
1077 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.');
1081 * @deprecated since 2.5
1083 function update_category_button() {
1084 throw new coding_exception('Function update_category_button() is removed. Pages to view '.
1085 'and edit courses are now separate and no longer depend on editing mode.');
1089 * @deprecated since 2.5
1091 function make_categories_list() {
1092 throw new coding_exception('Global function make_categories_list() is removed. Please use '.
1093 'coursecat::make_categories_list() and coursecat::get_parents()');
1097 * @deprecated since 2.5
1099 function category_delete_move() {
1100 throw new coding_exception('Function category_delete_move() is removed. Please use coursecat::delete_move() instead.');
1104 * @deprecated since 2.5
1106 function category_delete_full() {
1107 throw new coding_exception('Function category_delete_full() is removed. Please use coursecat::delete_full() instead.');
1111 * @deprecated since 2.5
1113 function move_category() {
1114 throw new coding_exception('Function move_category() is removed. Please use coursecat::change_parent() instead.');
1118 * @deprecated since 2.5
1120 function course_category_hide() {
1121 throw new coding_exception('Function course_category_hide() is removed. Please use coursecat::hide() instead.');
1125 * @deprecated since 2.5
1127 function course_category_show() {
1128 throw new coding_exception('Function course_category_show() is removed. Please use coursecat::show() instead.');
1132 * @deprecated since 2.5. Please use coursecat::get($catid, IGNORE_MISSING) or coursecat::get($catid, MUST_EXIST).
1134 function get_course_category() {
1135 throw new coding_exception('Function get_course_category() is removed. Please use coursecat::get(), see phpdocs for more details');
1139 * @deprecated since 2.5
1141 function create_course_category() {
1142 throw new coding_exception('Function create_course_category() is removed. Please use coursecat::create()');
1146 * @deprecated since 2.5. Please use coursecat::get() and coursecat::get_children()
1148 function get_all_subcategories() {
1149 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() ' .
1150 'of coursecat class.');
1154 * @deprecated since 2.5. Please use coursecat::get($parentid)->get_children().
1156 function get_child_categories() {
1157 throw new coding_exception('Function get_child_categories() is removed. Use coursecat::get_children().');
1161 * @deprecated since 2.5
1163 function get_categories() {
1164 throw new coding_exception('Function get_categories() is removed. Please use ' .
1165 'appropriate functions from class coursecat');
1169 * @deprecated since 2.5
1171 function print_course_search() {
1172 throw new coding_exception('Function print_course_search() is removed, please use course renderer');
1176 * @deprecated since 2.5
1178 function print_my_moodle() {
1179 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' .
1180 'function frontpage_my_courses()');
1184 * @deprecated since 2.5
1186 function print_remote_course() {
1187 throw new coding_exception('Function print_remote_course() is removed, please use course renderer');
1191 * @deprecated since 2.5
1193 function print_remote_host() {
1194 throw new coding_exception('Function print_remote_host() is removed, please use course renderer');
1198 * @deprecated since 2.5
1200 function print_whole_category_list() {
1201 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer');
1205 * @deprecated since 2.5
1207 function print_category_info() {
1208 throw new coding_exception('Function print_category_info() is removed, please use course renderer');
1212 * @deprecated since 2.5
1214 function get_course_category_tree() {
1215 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' .
1216 'renderer or coursecat class, see function phpdocs for more info');
1220 * @deprecated since 2.5
1222 function print_courses() {
1223 throw new coding_exception('Function print_courses() is removed, please use course renderer');
1227 * @deprecated since 2.5
1229 function print_course() {
1230 throw new coding_exception('Function print_course() is removed, please use course renderer');
1234 * @deprecated since 2.5
1236 function get_category_courses_array() {
1237 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of coursecat class');
1241 * @deprecated since 2.5
1243 function get_category_courses_array_recursively() {
1244 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use methods of coursecat class', DEBUG_DEVELOPER);
1248 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
1250 function blog_get_context_url() {
1251 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.');
1255 * @deprecated since 2.5
1257 function get_courses_wmanagers() {
1258 throw new coding_exception('Function get_courses_wmanagers() is removed, please use coursecat::get_courses()');
1262 * @deprecated since 2.5
1264 function convert_tree_to_html() {
1265 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()');
1269 * @deprecated since 2.5
1271 function convert_tabrows_to_tree() {
1272 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree');
1276 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
1278 function can_use_rotated_text() {
1279 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.');
1283 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
1285 function get_context_instance_by_id() {
1286 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
1290 * Returns system context or null if can not be created yet.
1292 * @see context_system::instance()
1293 * @deprecated since 2.2
1294 * @param bool $cache use caching
1295 * @return context system context (null if context table not created yet)
1297 function get_system_context($cache = true) {
1298 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
1299 return context_system::instance(0, IGNORE_MISSING, $cache);
1303 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
1305 function get_parent_contexts() {
1306 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.');
1310 * @deprecated since Moodle 2.2
1312 function get_parent_contextid() {
1313 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.');
1317 * @deprecated since 2.2
1319 function get_child_contexts() {
1320 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.');
1324 * @deprecated since 2.2
1326 function create_contexts() {
1327 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.');
1331 * @deprecated since 2.2
1333 function cleanup_contexts() {
1334 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.');
1338 * @deprecated since 2.2
1340 function build_context_path() {
1341 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.');
1345 * @deprecated since 2.2
1347 function rebuild_contexts() {
1348 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.');
1352 * @deprecated since Moodle 2.2
1354 function preload_course_contexts() {
1355 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.');
1359 * @deprecated since Moodle 2.2
1361 function context_moved() {
1362 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.');
1366 * @deprecated since 2.2
1368 function fetch_context_capabilities() {
1369 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.');
1373 * @deprecated since 2.2
1375 function context_instance_preload() {
1376 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.');
1380 * @deprecated since 2.2
1382 function get_contextlevel_name() {
1383 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.');
1387 * @deprecated since 2.2
1389 function print_context_name() {
1390 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.');
1394 * @deprecated since 2.2, use $context->mark_dirty() instead
1396 function mark_context_dirty() {
1397 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.');
1401 * @deprecated since Moodle 2.2
1403 function delete_context() {
1404 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' .
1405 'or $context->delete_content() instead.');
1409 * @deprecated since 2.2
1411 function get_context_url() {
1412 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.');
1416 * @deprecated since 2.2
1418 function get_course_context() {
1419 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.');
1423 * @deprecated since 2.2
1425 function get_user_courses_bycap() {
1426 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.');
1430 * @deprecated since Moodle 2.2
1432 function get_role_context_caps() {
1433 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.');
1437 * @deprecated since 2.2
1439 function get_courseid_from_context() {
1440 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.');
1444 * @deprecated since 2.2
1446 function context_instance_preload_sql() {
1447 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.');
1451 * @deprecated since 2.2
1453 function get_related_contexts_string() {
1454 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.');
1458 * @deprecated since 2.6
1460 function get_plugin_list_with_file() {
1461 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.');
1465 * @deprecated since 2.6
1467 function check_browser_operating_system() {
1468 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.');
1472 * @deprecated since 2.6
1474 function check_browser_version() {
1475 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.');
1479 * @deprecated since 2.6
1481 function get_device_type() {
1482 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.');
1486 * @deprecated since 2.6
1488 function get_device_type_list() {
1489 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.');
1493 * @deprecated since 2.6
1495 function get_selected_theme_for_device_type() {
1496 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.');
1500 * @deprecated since 2.6
1502 function get_device_cfg_var_name() {
1503 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.');
1507 * @deprecated since 2.6
1509 function set_user_device_type() {
1510 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.');
1514 * @deprecated since 2.6
1516 function get_user_device_type() {
1517 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.');
1521 * @deprecated since 2.6
1523 function get_browser_version_classes() {
1524 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.');
1528 * @deprecated since Moodle 2.6
1530 function generate_email_supportuser() {
1531 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user');
1535 * @deprecated since Moodle 2.6
1537 function badges_get_issued_badge_info() {
1538 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.');
1542 * @deprecated since 2.6
1544 function can_use_html_editor() {
1545 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.');
1550 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
1552 function count_login_failures() {
1553 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
1557 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
1559 function ajaxenabled() {
1560 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
1564 * @deprecated Since Moodle 2.7 MDL-44070
1566 function coursemodule_visible_for_user() {
1567 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
1568 please use \core_availability\info_module::is_user_visible()');
1572 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
1574 function enrol_cohort_get_cohorts() {
1575 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '.
1576 'cohort_get_available_cohorts() instead');
1580 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
1582 function enrol_cohort_can_view_cohort() {
1583 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead');
1587 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
1589 function cohort_get_visible_list() {
1590 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ".
1591 "that correctly checks capabilities.');
1595 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1597 function enrol_cohort_enrol_all_users() {
1598 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.');
1602 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
1604 function enrol_cohort_search_cohorts() {
1605 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.');
1608 /* === Apis deprecated in since Moodle 2.9 === */
1611 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
1613 function message_current_user_is_involved() {
1614 throw new coding_exception('message_current_user_is_involved() can not be used any more.');
1618 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
1620 function profile_display_badges() {
1621 throw new coding_exception('profile_display_badges() can not be used any more.');
1625 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
1627 function useredit_shared_definition_preferences() {
1628 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.');
1633 * @deprecated since Moodle 2.9
1635 function calendar_normalize_tz() {
1636 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.');
1640 * @deprecated since Moodle 2.9
1642 function get_user_timezone_offset() {
1643 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1648 * @deprecated since Moodle 2.9
1650 function get_timezone_offset() {
1651 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead');
1655 * @deprecated since Moodle 2.9
1657 function get_list_of_timezones() {
1658 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead');
1662 * @deprecated since Moodle 2.9
1664 function update_timezone_records() {
1665 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead');
1669 * @deprecated since Moodle 2.9
1671 function calculate_user_dst_table() {
1672 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead');
1676 * @deprecated since Moodle 2.9
1678 function dst_changes_for_year() {
1679 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead');
1683 * @deprecated since Moodle 2.9
1685 function get_timezone_record() {
1686 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead');
1689 /* === Apis deprecated since Moodle 3.0 === */
1691 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more.
1693 function get_referer() {
1694 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.');
1698 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead.
1700 function is_web_crawler() {
1701 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.');
1705 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more.
1707 function completion_cron() {
1708 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.');
1712 * @deprecated since 3.0
1714 function coursetag_get_tags() {
1715 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' .
1716 'Userid is no longer used for tagging courses.');
1720 * @deprecated since 3.0
1722 function coursetag_get_all_tags() {
1723 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' .
1724 'longer used for tagging courses.');
1728 * @deprecated since 3.0
1730 function coursetag_get_jscript() {
1731 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.');
1735 * @deprecated since 3.0
1737 function coursetag_get_jscript_links() {
1738 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.');
1742 * @deprecated since 3.0
1744 function coursetag_get_records() {
1745 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' .
1746 'Userid is no longer used for tagging courses.');
1750 * @deprecated since 3.0
1752 function coursetag_store_keywords() {
1753 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' .
1754 'Userid is no longer used for tagging courses.');
1758 * @deprecated since 3.0
1760 function coursetag_delete_keyword() {
1761 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' .
1762 'Userid is no longer used for tagging courses.');
1766 * @deprecated since 3.0
1768 function coursetag_get_tagged_courses() {
1769 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' .
1770 'Userid is no longer used for tagging courses.');
1774 * @deprecated since 3.0
1776 function coursetag_delete_course_tags() {
1777 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' .
1778 'Use core_tag_tag::remove_all_item_tags().');
1782 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1784 function tag_type_set() {
1785 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' .
1786 'core_tag_tag::get($tagid)->update().');
1790 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1792 function tag_description_set() {
1793 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' .
1794 'core_tag_tag::get($tagid)->update().');
1798 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1800 function tag_get_tags() {
1801 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' .
1802 'core_tag_tag::get_item_tags().');
1806 * @deprecated since 3.1
1808 function tag_get_tags_array() {
1809 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' .
1810 'core_tag_tag::get_item_tags_array().');
1814 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags())
1816 function tag_get_tags_csv() {
1817 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' .
1818 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
1822 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead
1824 function tag_get_tags_ids() {
1825 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' .
1826 'core_tag_tag::get_item_tags() or similar methods.');
1830 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()
1832 function tag_get_id() {
1833 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' .
1834 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()');
1838 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead
1840 function tag_rename() {
1841 throw new coding_exception('tag_rename() can not be used anymore. Please use ' .
1842 'core_tag_tag::get($tagid)->update()');
1846 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead
1848 function tag_delete_instance() {
1849 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' .
1850 'core_tag_tag::remove_item_tag()');
1854 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead
1856 function tag_find_records() {
1857 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' .
1858 'core_tag_tag::get_by_name()->get_tagged_items()');
1862 * @deprecated since 3.1
1864 function tag_add() {
1865 throw new coding_exception('tag_add() can not be used anymore. You can use ' .
1866 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' .
1867 'created automatically when assigned to items');
1871 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead
1873 function tag_assign() {
1874 throw new coding_exception('tag_assign() can not be used anymore. Please use ' .
1875 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' .
1876 'ordering should not be set manually');
1880 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead
1882 function tag_record_count() {
1883 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' .
1884 'core_tag_tag::get($tagid)->count_tagged_items().');
1888 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead
1890 function tag_record_tagged_with() {
1891 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' .
1892 'core_tag_tag::get($tagid)->is_item_tagged_with().');
1896 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead
1898 function tag_set_flag() {
1899 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' .
1900 'core_tag_tag::get($tagid)->flag()');
1904 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead
1906 function tag_unset_flag() {
1907 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' .
1908 'core_tag_tag::get($tagid)->reset_flag()');
1912 * @deprecated since 3.1
1914 function tag_print_cloud() {
1915 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' .
1916 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' .
1917 'template core_tag/tagcloud.');
1921 * @deprecated since 3.0
1923 function tag_autocomplete() {
1924 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' .
1925 'element "tags" does proper autocomplete.');
1929 * @deprecated since 3.1
1931 function tag_print_description_box() {
1932 throw new coding_exception('tag_print_description_box() can not be used anymore. ' .
1933 'See core_tag_renderer for similar code');
1937 * @deprecated since 3.1
1939 function tag_print_management_box() {
1940 throw new coding_exception('tag_print_management_box() can not be used anymore. ' .
1941 'See core_tag_renderer for similar code');
1945 * @deprecated since 3.1
1947 function tag_print_search_box() {
1948 throw new coding_exception('tag_print_search_box() can not be used anymore. ' .
1949 'See core_tag_renderer for similar code');
1953 * @deprecated since 3.1
1955 function tag_print_search_results() {
1956 throw new coding_exception('tag_print_search_results() can not be used anymore. ' .
1957 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.');
1961 * @deprecated since 3.1
1963 function tag_print_tagged_users_table() {
1964 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' .
1965 'See core_user_renderer for similar code');
1969 * @deprecated since 3.1
1971 function tag_print_user_box() {
1972 throw new coding_exception('tag_print_user_box() can not be used anymore. ' .
1973 'See core_user_renderer for similar code');
1977 * @deprecated since 3.1
1979 function tag_print_user_list() {
1980 throw new coding_exception('tag_print_user_list() can not be used anymore. ' .
1981 'See core_user_renderer for similar code');
1985 * @deprecated since 3.1
1987 function tag_display_name() {
1988 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' .
1989 'core_tag_tag::make_display_name().');
1994 * @deprecated since 3.1
1996 function tag_normalize() {
1997 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' .
1998 'core_tag_tag::normalize().');
2002 * @deprecated since 3.1
2004 function tag_get_related_tags_csv() {
2005 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' .
2006 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).');
2010 * @deprecated since 3.1
2012 function tag_set() {
2013 throw new coding_exception('tag_set() can not be used anymore. Please use ' .
2014 'core_tag_tag::set_item_tags().');
2018 * @deprecated since 3.1
2020 function tag_set_add() {
2021 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' .
2022 'core_tag_tag::add_item_tag().');
2026 * @deprecated since 3.1
2028 function tag_set_delete() {
2029 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' .
2030 'core_tag_tag::remove_item_tag().');
2034 * @deprecated since 3.1
2036 function tag_get() {
2037 throw new coding_exception('tag_get() can not be used anymore. Please use ' .
2038 'core_tag_tag::get() or core_tag_tag::get_by_name().');
2042 * @deprecated since 3.1
2044 function tag_get_related_tags() {
2045 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' .
2046 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' .
2047 'core_tag_tag::get_manual_related_tags().');
2051 * @deprecated since 3.1
2053 function tag_delete() {
2054 throw new coding_exception('tag_delete() can not be used anymore. Please use ' .
2055 'core_tag_tag::delete_tags().');
2059 * @deprecated since 3.1
2061 function tag_delete_instances() {
2062 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' .
2063 'core_tag_tag::delete_instances().');
2067 * @deprecated since 3.1
2069 function tag_cleanup() {
2070 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' .
2071 '\core\task\tag_cron_task::cleanup().');
2075 * @deprecated since 3.1
2077 function tag_bulk_delete_instances() {
2078 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' .
2079 '\core\task\tag_cron_task::bulk_delete_instances().');
2084 * @deprecated since 3.1
2086 function tag_compute_correlations() {
2087 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' .
2088 'use \core\task\tag_cron_task::compute_correlations().');
2092 * @deprecated since 3.1
2094 function tag_process_computed_correlation() {
2095 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' .
2096 'use \core\task\tag_cron_task::process_computed_correlation().');
2100 * @deprecated since 3.1
2102 function tag_cron() {
2103 throw new coding_exception('tag_cron() can not be used anymore. Please use ' .
2104 'use \core\task\tag_cron_task::execute().');
2108 * @deprecated since 3.1
2110 function tag_find_tags() {
2111 throw new coding_exception('tag_find_tags() can not be used anymore.');
2115 * @deprecated since 3.1
2117 function tag_get_name() {
2118 throw new coding_exception('tag_get_name() can not be used anymore.');
2122 * @deprecated since 3.1
2124 function tag_get_correlated() {
2125 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' .
2126 'use core_tag_tag::get_correlated_tags().');
2131 * @deprecated since 3.1
2133 function tag_cloud_sort() {
2134 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' .
2135 'be found in core_tag_collection::cloud_sort().');
2139 * @deprecated since Moodle 3.1
2141 function events_load_def() {
2142 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2147 * @deprecated since Moodle 3.1
2149 function events_queue_handler() {
2150 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2154 * @deprecated since Moodle 3.1
2156 function events_dispatch() {
2157 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2161 * @deprecated since Moodle 3.1
2163 function events_process_queued_handler() {
2164 throw new coding_exception(
2165 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'
2170 * @deprecated since Moodle 3.1
2172 function events_update_definition() {
2173 throw new coding_exception(
2174 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.'
2179 * @deprecated since Moodle 3.1
2181 function events_cron() {
2182 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2186 * @deprecated since Moodle 3.1
2188 function events_trigger_legacy() {
2189 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2193 * @deprecated since Moodle 3.1
2195 function events_is_registered() {
2196 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2200 * @deprecated since Moodle 3.1
2202 function events_pending_count() {
2203 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.');
2207 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2209 function clam_message_admins() {
2210 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' .
2211 'message_admins() method of \antivirus_clamav\scanner class.');
2215 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now.
2217 function get_clam_error_code() {
2218 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' .
2219 'get_clam_error_code() method of \antivirus_clamav\scanner class.');
2223 * @deprecated since 3.1
2225 function course_get_cm_rename_action() {
2226 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' .
2227 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.');
2232 * @deprecated since Moodle 3.1
2234 function course_scale_used() {
2235 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' .
2236 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2240 * @deprecated since Moodle 3.1
2242 function site_scale_used() {
2243 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' .
2244 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
2248 * @deprecated since Moodle 3.1. Use external_api::external_function_info().
2250 function external_function_info() {
2251 throw new coding_exception('external_function_info() can not be used any'.
2252 'more. Please use external_api::external_function_info() instead.');
2256 * @deprecated since Moodle 3.2
2257 * @see csv_import_reader::load_csv_content()
2259 function get_records_csv() {
2260 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' .
2261 'lib/csvlib.class.php csv_import_reader() instead.');
2265 * @deprecated since Moodle 3.2
2266 * @see download_as_dataformat (lib/dataformatlib.php)
2268 function put_records_csv() {
2269 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' .
2270 'lib/dataformatlib.php download_as_dataformat() instead.');
2274 * @deprecated since Moodle 3.2
2276 function css_is_colour() {
2277 throw new coding_exception('css_is_colour() can not be used anymore.');
2281 * @deprecated since Moodle 3.2
2283 function css_is_width() {
2284 throw new coding_exception('css_is_width() can not be used anymore.');
2288 * @deprecated since Moodle 3.2
2290 function css_sort_by_count() {
2291 throw new coding_exception('css_sort_by_count() can not be used anymore.');
2295 * @deprecated since Moodle 3.2
2297 function message_get_course_contexts() {
2298 throw new coding_exception('message_get_course_contexts() can not be used anymore.');
2302 * @deprecated since Moodle 3.2
2304 function message_remove_url_params() {
2305 throw new coding_exception('message_remove_url_params() can not be used anymore.');
2309 * @deprecated since Moodle 3.2
2311 function message_count_messages() {
2312 throw new coding_exception('message_count_messages() can not be used anymore.');
2316 * @deprecated since Moodle 3.2
2318 function message_count_blocked_users() {
2319 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' .
2320 '\core_message\api::count_blocked_users() instead.');
2324 * @deprecated since Moodle 3.2
2326 function message_contact_link() {
2327 throw new coding_exception('message_contact_link() can not be used anymore.');
2331 * @deprecated since Moodle 3.2
2333 function message_get_recent_notifications() {
2334 throw new coding_exception('message_get_recent_notifications() can not be used anymore.');
2338 * @deprecated since Moodle 3.2
2340 function message_history_link() {
2341 throw new coding_exception('message_history_link() can not be used anymore.');
2345 * @deprecated since Moodle 3.2
2347 function message_search() {
2348 throw new coding_exception('message_search() can not be used anymore.');
2352 * @deprecated since Moodle 3.2
2354 function message_shorten_message() {
2355 throw new coding_exception('message_shorten_message() can not be used anymore.');
2359 * @deprecated since Moodle 3.2
2361 function message_get_fragment() {
2362 throw new coding_exception('message_get_fragment() can not be used anymore.');
2366 * @deprecated since Moodle 3.2
2368 function message_get_history() {
2369 throw new coding_exception('message_get_history() can not be used anymore.');
2373 * @deprecated since Moodle 3.2
2375 function message_get_contact_add_remove_link() {
2376 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.');
2380 * @deprecated since Moodle 3.2
2382 function message_get_contact_block_link() {
2383 throw new coding_exception('message_get_contact_block_link() can not be used anymore.');
2387 * @deprecated since Moodle 3.2
2389 function message_mark_messages_read() {
2390 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' .
2391 '\core_message\api::mark_all_messages_as_read() instead.');
2395 * @deprecated since Moodle 3.2
2397 function message_page_type_list() {
2398 throw new coding_exception('message_page_type_list() can not be used anymore.');
2402 * @deprecated since Moodle 3.2
2404 function message_can_post_message() {
2405 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' .
2406 '\core_message\api::can_post_message() instead.');
2410 * @deprecated since Moodle 3.2
2412 function message_is_user_non_contact_blocked() {
2413 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' .
2414 '\core_message\api::is_user_non_contact_blocked() instead.');
2418 * @deprecated since Moodle 3.2
2420 function message_is_user_blocked() {
2421 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' .
2422 '\core_message\api::is_user_blocked() instead.');
2426 * @deprecated since Moodle 3.2
2428 function print_log() {
2429 throw new coding_exception('print_log() can not be used anymore. Please use the ' .
2430 'report_log framework instead.');
2434 * @deprecated since Moodle 3.2
2436 function print_mnet_log() {
2437 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' .
2438 'report_log framework instead.');
2442 * @deprecated since Moodle 3.2
2444 function print_log_csv() {
2445 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' .
2446 'report_log framework instead.');
2450 * @deprecated since Moodle 3.2
2452 function print_log_xls() {
2453 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' .
2454 'report_log framework instead.');
2458 * @deprecated since Moodle 3.2
2460 function print_log_ods() {
2461 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' .
2462 'report_log framework instead.');
2466 * @deprecated since Moodle 3.2
2468 function build_logs_array() {
2469 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' .
2470 'report_log framework instead.');
2474 * @deprecated since Moodle 3.2
2476 function get_logs_usercourse() {
2477 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' .
2478 'report_log framework instead.');
2482 * @deprecated since Moodle 3.2
2484 function get_logs_userday() {
2485 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' .
2486 'report_log framework instead.');
2490 * @deprecated since Moodle 3.2
2492 function get_logs() {
2493 throw new coding_exception('get_logs() can not be used anymore. Please use the ' .
2494 'report_log framework instead.');
2498 * @deprecated since Moodle 3.2
2500 function prevent_form_autofill_password() {
2501 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.');
2505 * @deprecated since Moodle 3.3 MDL-57370
2507 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) {
2508 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' .
2509 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER);
2513 * @deprecated since Moodle 3.2
2515 function calendar_preferences_button() {
2516 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' .
2517 'preferences are now linked to the user preferences page.');
2521 * Return the name of the weekday
2523 * @deprecated since 3.3
2524 * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57617.
2525 * @param string $englishname
2526 * @return string of the weekeday
2528 function calendar_wday_name($englishname) {
2529 debugging(__FUNCTION__ . '() is deprecated and no longer used in core.', DEBUG_DEVELOPER);
2530 return get_string(strtolower($englishname), 'calendar');
2534 * Get the upcoming event block.
2536 * @deprecated since 3.3
2537 * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57617.
2538 * @param array $events list of events
2539 * @param moodle_url|string $linkhref link to event referer
2540 * @param boolean $showcourselink whether links to courses should be shown
2541 * @return string|null $content html block content
2543 function calendar_get_block_upcoming($events, $linkhref = null, $showcourselink = false) {
2544 global $CFG;
2546 debugging(
2547 __FUNCTION__ . '() has been deprecated. ' .
2548 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
2549 DEBUG_DEVELOPER
2552 require_once($CFG->dirroot . '/blocks/moodleblock.class.php');
2553 require_once($CFG->dirroot . '/blocks/calendar_upcoming/block_calendar_upcoming.php');
2554 return block_calendar_upcoming::get_upcoming_content($events, $linkhref, $showcourselink);
2558 * Display month selector options.
2560 * @deprecated since 3.3
2561 * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57617.
2562 * @param string $name for the select element
2563 * @param string|array $selected options for select elements
2565 function calendar_print_month_selector($name, $selected) {
2566 debugging(__FUNCTION__ . '() is deprecated and no longer used in core.', DEBUG_DEVELOPER);
2567 $months = array();
2568 for ($i = 1; $i <= 12; $i++) {
2569 $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), '%B');
2571 echo html_writer::label(get_string('months'), 'menu'. $name, false, array('class' => 'accesshide'));
2572 echo html_writer::select($months, $name, $selected, false);
2576 * Update calendar subscriptions.
2578 * @deprecated since 3.3
2579 * @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57617.
2580 * @return bool
2582 function calendar_cron() {
2583 debugging(__FUNCTION__ . '() is deprecated and should not be used. Please use the core\task\calendar_cron_task instead.',
2584 DEBUG_DEVELOPER);
2586 global $CFG, $DB;
2588 require_once($CFG->dirroot . '/calendar/lib.php');
2589 // In order to execute this we need bennu.
2590 require_once($CFG->libdir.'/bennu/bennu.inc.php');
2592 mtrace('Updating calendar subscriptions:');
2593 cron_trace_time_and_memory();
2595 $time = time();
2596 $subscriptions = $DB->get_records_sql('SELECT * FROM {event_subscriptions} WHERE pollinterval > 0
2597 AND lastupdated + pollinterval < ?', array($time));
2598 foreach ($subscriptions as $sub) {
2599 mtrace("Updating calendar subscription {$sub->name} in course {$sub->courseid}");
2600 try {
2601 $log = calendar_update_subscription_events($sub->id);
2602 mtrace(trim(strip_tags($log)));
2603 } catch (moodle_exception $ex) {
2604 mtrace('Error updating calendar subscription: ' . $ex->getMessage());
2608 mtrace('Finished updating calendar subscriptions.');
2610 return true;
2614 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2616 function load_course_context() {
2617 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.');
2621 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2623 function load_role_access_by_context() {
2624 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.');
2628 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398.
2630 function dedupe_user_access() {
2631 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.');
2635 * Previous internal API, it was not supposed to be used anywhere.
2636 * Return a nested array showing role assignments
2637 * and all relevant role capabilities for the user.
2639 * [ra] => [/path][roleid]=roleid
2640 * [rdef] => ["$contextpath:$roleid"][capability]=permission
2642 * @access private
2643 * @deprecated since Moodle 3.4. MDL-49398.
2644 * @param int $userid - the id of the user
2645 * @return array access info array
2647 function get_user_access_sitewide($userid) {
2648 debugging('get_user_access_sitewide() is deprecated. Do not use private functions or data structures.', DEBUG_DEVELOPER);
2650 $accessdata = get_user_accessdata($userid);
2651 $accessdata['rdef'] = array();
2652 $roles = array();
2654 foreach ($accessdata['ra'] as $path => $pathroles) {
2655 $roles = array_merge($pathroles, $roles);
2658 $rdefs = get_role_definitions($roles);
2660 foreach ($rdefs as $roleid => $rdef) {
2661 foreach ($rdef as $path => $caps) {
2662 $accessdata['rdef']["$path:$roleid"] = $caps;
2666 return $accessdata;
2670 * Generates the HTML for a miniature calendar.
2672 * @param array $courses list of course to list events from
2673 * @param array $groups list of group
2674 * @param array $users user's info
2675 * @param int|bool $calmonth calendar month in numeric, default is set to false
2676 * @param int|bool $calyear calendar month in numeric, default is set to false
2677 * @param string|bool $placement the place/page the calendar is set to appear - passed on the the controls function
2678 * @param int|bool $courseid id of the course the calendar is displayed on - passed on the the controls function
2679 * @param int $time the unixtimestamp representing the date we want to view, this is used instead of $calmonth
2680 * and $calyear to support multiple calendars
2681 * @return string $content return html table for mini calendar
2682 * @deprecated since Moodle 3.4. MDL-59333
2684 function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyear = false, $placement = false,
2685 $courseid = false, $time = 0) {
2686 global $PAGE;
2688 debugging('calendar_get_mini() has been deprecated. Please update your code to use calendar_get_view.',
2689 DEBUG_DEVELOPER);
2691 if (!empty($calmonth) && !empty($calyear)) {
2692 // Do this check for backwards compatibility.
2693 // The core should be passing a timestamp rather than month and year.
2694 // If a month and year are passed they will be in Gregorian.
2695 // Ensure it is a valid date, else we will just set it to the current timestamp.
2696 if (checkdate($calmonth, 1, $calyear)) {
2697 $time = make_timestamp($calyear, $calmonth, 1);
2698 } else {
2699 $time = time();
2701 } else if (empty($time)) {
2702 // Get the current date in the calendar type being used.
2703 $time = time();
2706 if ($courseid == SITEID) {
2707 $course = get_site();
2708 } else {
2709 $course = get_course($courseid);
2711 $calendar = new calendar_information(0, 0, 0, $time);
2712 $calendar->prepare_for_view($course, $courses);
2714 $renderer = $PAGE->get_renderer('core_calendar');
2715 list($data, $template) = calendar_get_view($calendar, 'mini');
2716 return $renderer->render_from_template($template, $data);
2720 * Gets the calendar upcoming event.
2722 * @param array $courses array of courses
2723 * @param array|int|bool $groups array of groups, group id or boolean for all/no group events
2724 * @param array|int|bool $users array of users, user id or boolean for all/no user events
2725 * @param int $daysinfuture number of days in the future we 'll look
2726 * @param int $maxevents maximum number of events
2727 * @param int $fromtime start time
2728 * @return array $output array of upcoming events
2729 * @deprecated since Moodle 3.4. MDL-59333
2731 function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
2732 debugging(
2733 'calendar_get_upcoming() has been deprecated. ' .
2734 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
2735 DEBUG_DEVELOPER
2738 global $COURSE;
2740 $display = new \stdClass;
2741 $display->range = $daysinfuture; // How many days in the future we 'll look.
2742 $display->maxevents = $maxevents;
2744 $output = array();
2746 $processed = 0;
2747 $now = time(); // We 'll need this later.
2748 $usermidnighttoday = usergetmidnight($now);
2750 if ($fromtime) {
2751 $display->tstart = $fromtime;
2752 } else {
2753 $display->tstart = $usermidnighttoday;
2756 // This works correctly with respect to the user's DST, but it is accurate
2757 // only because $fromtime is always the exact midnight of some day!
2758 $display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
2760 // Get the events matching our criteria.
2761 $events = calendar_get_legacy_events($display->tstart, $display->tend, $users, $groups, $courses);
2763 // This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
2764 // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
2765 // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
2766 // arguments to this function.
2767 $hrefparams = array();
2768 if (!empty($courses)) {
2769 $courses = array_diff($courses, array(SITEID));
2770 if (count($courses) == 1) {
2771 $hrefparams['course'] = reset($courses);
2775 if ($events !== false) {
2776 foreach ($events as $event) {
2777 if (!empty($event->modulename)) {
2778 $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
2779 if (empty($instances[$event->instance]->uservisible)) {
2780 continue;
2784 if ($processed >= $display->maxevents) {
2785 break;
2788 $event->time = calendar_format_event_time($event, $now, $hrefparams);
2789 $output[] = $event;
2790 $processed++;
2794 return $output;
2798 * Creates a record in the role_allow_override table
2800 * @param int $sroleid source roleid
2801 * @param int $troleid target roleid
2802 * @return void
2803 * @deprecated since Moodle 3.4. MDL-50666
2805 function allow_override($sroleid, $troleid) {
2806 debugging('allow_override() has been deprecated. Please update your code to use core_role_set_override_allowed.',
2807 DEBUG_DEVELOPER);
2809 core_role_set_override_allowed($sroleid, $troleid);
2813 * Creates a record in the role_allow_assign table
2815 * @param int $fromroleid source roleid
2816 * @param int $targetroleid target roleid
2817 * @return void
2818 * @deprecated since Moodle 3.4. MDL-50666
2820 function allow_assign($fromroleid, $targetroleid) {
2821 debugging('allow_assign() has been deprecated. Please update your code to use core_role_set_assign_allowed.',
2822 DEBUG_DEVELOPER);
2824 core_role_set_assign_allowed($fromroleid, $targetroleid);
2828 * Creates a record in the role_allow_switch table
2830 * @param int $fromroleid source roleid
2831 * @param int $targetroleid target roleid
2832 * @return void
2833 * @deprecated since Moodle 3.4. MDL-50666
2835 function allow_switch($fromroleid, $targetroleid) {
2836 debugging('allow_switch() has been deprecated. Please update your code to use core_role_set_switch_allowed.',
2837 DEBUG_DEVELOPER);
2839 core_role_set_switch_allowed($fromroleid, $targetroleid);
2843 * Organise categories into a single parent category (called the 'Top' category) per context.
2845 * @param array $categories List of question categories in the format of ["$categoryid,$contextid" => $category].
2846 * @param array $pcontexts List of context ids.
2847 * @return array
2848 * @deprecated since Moodle 3.5. MDL-61132
2850 function question_add_tops($categories, $pcontexts) {
2851 debugging('question_add_tops() has been deprecated. You may want to pass $top = true to get_categories_for_contexts().',
2852 DEBUG_DEVELOPER);
2854 $topcats = array();
2855 foreach ($pcontexts as $contextid) {
2856 $topcat = question_get_top_category($contextid, true);
2857 $context = context::instance_by_id($contextid);
2859 $newcat = new stdClass();
2860 $newcat->id = "{$topcat->id},$contextid";
2861 $newcat->name = get_string('topfor', 'question', $context->get_context_name(false));
2862 $newcat->parent = 0;
2863 $newcat->contextid = $contextid;
2864 $topcats["{$topcat->id},$contextid"] = $newcat;
2866 // Put topcats in at beginning of array - they'll be sorted into different contexts later.
2867 return array_merge($topcats, $categories);
2871 * Checks if the question category is the highest-level category in the context that can be edited, and has no siblings.
2873 * @param int $categoryid a category id.
2874 * @return bool
2875 * @deprecated since Moodle 3.5. MDL-61132
2877 function question_is_only_toplevel_category_in_context($categoryid) {
2878 debugging('question_is_only_toplevel_category_in_context() has been deprecated. '
2879 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.',
2880 DEBUG_DEVELOPER);
2882 return question_is_only_child_of_top_category_in_context($categoryid);
2886 * Moves messages from a particular user from the message table (unread messages) to message_read
2887 * This is typically only used when a user is deleted
2889 * @param object $userid User id
2890 * @return boolean success
2891 * @deprecated since Moodle 3.5
2893 function message_move_userfrom_unread2read($userid) {
2894 debugging('message_move_userfrom_unread2read() is deprecated and is no longer used.', DEBUG_DEVELOPER);
2896 global $DB;
2898 // Move all unread messages from message table to message_read.
2899 if ($messages = $DB->get_records_select('message', 'useridfrom = ?', array($userid), 'timecreated')) {
2900 foreach ($messages as $message) {
2901 message_mark_message_read($message, 0); // Set timeread to 0 as the message was never read.
2904 return true;
2908 * Retrieve users blocked by $user1
2910 * @param object $user1 the user whose messages are being viewed
2911 * @param object $user2 the user $user1 is talking to. If they are being blocked
2912 * they will have a variable called 'isblocked' added to their user object
2913 * @return array the users blocked by $user1
2914 * @deprecated since Moodle 3.5
2916 function message_get_blocked_users($user1=null, $user2=null) {
2917 debugging('message_get_blocked_users() is deprecated, please use \core_message\api::get_blocked_users() instead.',
2918 DEBUG_DEVELOPER);
2920 global $USER;
2922 if (empty($user1)) {
2923 $user1 = new stdClass();
2924 $user1->id = $USER->id;
2927 return \core_message\api::get_blocked_users($user1->id);
2931 * Retrieve $user1's contacts (online, offline and strangers)
2933 * @param object $user1 the user whose messages are being viewed
2934 * @param object $user2 the user $user1 is talking to. If they are a contact
2935 * they will have a variable called 'iscontact' added to their user object
2936 * @return array containing 3 arrays. array($onlinecontacts, $offlinecontacts, $strangers)
2937 * @deprecated since Moodle 3.5
2939 function message_get_contacts($user1=null, $user2=null) {
2940 debugging('message_get_contacts() is deprecated and is no longer used.', DEBUG_DEVELOPER);
2942 global $DB, $CFG, $USER;
2944 if (empty($user1)) {
2945 $user1 = $USER;
2948 if (!empty($user2)) {
2949 $user2->iscontact = false;
2952 $timetoshowusers = 300; // Seconds default.
2953 if (isset($CFG->block_online_users_timetosee)) {
2954 $timetoshowusers = $CFG->block_online_users_timetosee * 60;
2957 // Rime which a user is counting as being active since.
2958 $timefrom = time() - $timetoshowusers;
2960 // People in our contactlist who are online.
2961 $onlinecontacts = array();
2962 // People in our contactlist who are offline.
2963 $offlinecontacts = array();
2964 // People who are not in our contactlist but have sent us a message.
2965 $strangers = array();
2967 // Get all in our contact list who are not blocked in our and count messages we have waiting from each of them.
2968 $rs = \core_message\api::get_contacts_with_unread_message_count($user1->id);
2969 foreach ($rs as $rd) {
2970 if ($rd->lastaccess >= $timefrom) {
2971 // They have been active recently, so are counted online.
2972 $onlinecontacts[] = $rd;
2974 } else {
2975 $offlinecontacts[] = $rd;
2978 if (!empty($user2) && $user2->id == $rd->id) {
2979 $user2->iscontact = true;
2983 // Get messages from anyone who isn't in our contact list and count the number of messages we have from each of them.
2984 $rs = \core_message\api::get_non_contacts_with_unread_message_count($user1->id);
2985 // Add user id as array index, so supportuser and noreply user don't get duplicated (if they are real users).
2986 foreach ($rs as $rd) {
2987 $strangers[$rd->id] = $rd;
2990 // Add noreply user and support user to the list, if they don't exist.
2991 $supportuser = core_user::get_support_user();
2992 if (!isset($strangers[$supportuser->id]) && !$supportuser->deleted) {
2993 $supportuser->messagecount = message_count_unread_messages($USER, $supportuser);
2994 if ($supportuser->messagecount > 0) {
2995 $strangers[$supportuser->id] = $supportuser;
2999 $noreplyuser = core_user::get_noreply_user();
3000 if (!isset($strangers[$noreplyuser->id]) && !$noreplyuser->deleted) {
3001 $noreplyuser->messagecount = message_count_unread_messages($USER, $noreplyuser);
3002 if ($noreplyuser->messagecount > 0) {
3003 $strangers[$noreplyuser->id] = $noreplyuser;
3007 return array($onlinecontacts, $offlinecontacts, $strangers);
3011 * Mark a single message as read
3013 * @param stdClass $message An object with an object property ie $message->id which is an id in the message table
3014 * @param int $timeread the timestamp for when the message should be marked read. Usually time().
3015 * @param bool $messageworkingempty Is the message_working table already confirmed empty for this message?
3016 * @return int the ID of the message in the messags table
3017 * @deprecated since Moodle 3.5
3019 function message_mark_message_read($message, $timeread, $messageworkingempty=false) {
3020 debugging('message_mark_message_read() is deprecated, please use \core_message\api::mark_message_as_read()
3021 or \core_message\api::mark_notification_as_read().', DEBUG_DEVELOPER);
3023 if (!empty($message->notification)) {
3024 \core_message\api::mark_notification_as_read($message, $timeread);
3025 } else {
3026 \core_message\api::mark_message_as_read($message->useridto, $message, $timeread);
3029 return $message->id;
3034 * Checks if a user can delete a message.
3036 * @param stdClass $message the message to delete
3037 * @param string $userid the user id of who we want to delete the message for (this may be done by the admin
3038 * but will still seem as if it was by the user)
3039 * @return bool Returns true if a user can delete the message, false otherwise.
3040 * @deprecated since Moodle 3.5
3042 function message_can_delete_message($message, $userid) {
3043 debugging('message_can_delete_message() is deprecated, please use \core_message\api::can_delete_message() instead.',
3044 DEBUG_DEVELOPER);
3046 return \core_message\api::can_delete_message($userid, $message->id);
3050 * Deletes a message.
3052 * This function does not verify any permissions.
3054 * @param stdClass $message the message to delete
3055 * @param string $userid the user id of who we want to delete the message for (this may be done by the admin
3056 * but will still seem as if it was by the user)
3057 * @return bool
3058 * @deprecated since Moodle 3.5
3060 function message_delete_message($message, $userid) {
3061 debugging('message_delete_message() is deprecated, please use \core_message\api::delete_message() instead.',
3062 DEBUG_DEVELOPER);
3064 return \core_message\api::delete_message($userid, $message->id);
3068 * Get all of the allowed types for all of the courses and groups
3069 * the logged in user belongs to.
3071 * The returned array will optionally have 5 keys:
3072 * 'user' : true if the logged in user can create user events
3073 * 'site' : true if the logged in user can create site events
3074 * 'category' : array of course categories that the user can create events for
3075 * 'course' : array of courses that the user can create events for
3076 * 'group': array of groups that the user can create events for
3077 * 'groupcourses' : array of courses that the groups belong to (can
3078 * be different from the list in 'course'.
3079 * @deprecated since 3.6
3080 * @return array The array of allowed types.
3082 function calendar_get_all_allowed_types() {
3083 debugging('calendar_get_all_allowed_types() is deprecated. Please use calendar_get_allowed_types() instead.',
3084 DEBUG_DEVELOPER);
3086 global $CFG, $USER, $DB;
3088 require_once($CFG->libdir . '/enrollib.php');
3090 $types = [];
3092 $allowed = new stdClass();
3094 calendar_get_allowed_types($allowed);
3096 if ($allowed->user) {
3097 $types['user'] = true;
3100 if ($allowed->site) {
3101 $types['site'] = true;
3104 if (coursecat::has_manage_capability_on_any()) {
3105 $types['category'] = coursecat::make_categories_list('moodle/category:manage');
3108 // This function warms the context cache for the course so the calls
3109 // to load the course context in calendar_get_allowed_types don't result
3110 // in additional DB queries.
3111 $courses = calendar_get_default_courses(null, 'id, groupmode, groupmodeforce', true);
3113 // We want to pre-fetch all of the groups for each course in a single
3114 // query to avoid calendar_get_allowed_types from hitting the DB for
3115 // each separate course.
3116 $groups = groups_get_all_groups_for_courses($courses);
3118 foreach ($courses as $course) {
3119 $coursegroups = isset($groups[$course->id]) ? $groups[$course->id] : null;
3120 calendar_get_allowed_types($allowed, $course, $coursegroups);
3122 if (!empty($allowed->courses)) {
3123 $types['course'][$course->id] = $course;
3126 if (!empty($allowed->groups)) {
3127 $types['groupcourses'][$course->id] = $course;
3129 if (!isset($types['group'])) {
3130 $types['group'] = array_values($allowed->groups);
3131 } else {
3132 $types['group'] = array_merge($types['group'], array_values($allowed->groups));
3137 return $types;
3141 * Gets array of all groups in a set of course.
3143 * @category group
3144 * @param array $courses Array of course objects or course ids.
3145 * @return array Array of groups indexed by course id.
3147 function groups_get_all_groups_for_courses($courses) {
3148 global $DB;
3150 if (empty($courses)) {
3151 return [];
3154 $groups = [];
3155 $courseids = [];
3157 foreach ($courses as $course) {
3158 $courseid = is_object($course) ? $course->id : $course;
3159 $groups[$courseid] = [];
3160 $courseids[] = $courseid;
3163 $groupfields = [
3164 'g.id as gid',
3165 'g.courseid',
3166 'g.idnumber',
3167 'g.name',
3168 'g.description',
3169 'g.descriptionformat',
3170 'g.enrolmentkey',
3171 'g.picture',
3172 'g.hidepicture',
3173 'g.timecreated',
3174 'g.timemodified'
3177 $groupsmembersfields = [
3178 'gm.id as gmid',
3179 'gm.groupid',
3180 'gm.userid',
3181 'gm.timeadded',
3182 'gm.component',
3183 'gm.itemid'
3186 $concatidsql = $DB->sql_concat_join("'-'", ['g.id', 'COALESCE(gm.id, 0)']) . ' AS uniqid';
3187 list($courseidsql, $params) = $DB->get_in_or_equal($courseids);
3188 $groupfieldssql = implode(',', $groupfields);
3189 $groupmembersfieldssql = implode(',', $groupsmembersfields);
3190 $sql = "SELECT {$concatidsql}, {$groupfieldssql}, {$groupmembersfieldssql}
3191 FROM {groups} g
3192 LEFT JOIN {groups_members} gm
3193 ON gm.groupid = g.id
3194 WHERE g.courseid {$courseidsql}";
3196 $results = $DB->get_records_sql($sql, $params);
3198 // The results will come back as a flat dataset thanks to the left
3199 // join so we will need to do some post processing to blow it out
3200 // into a more usable data structure.
3202 // This loop will extract the distinct groups from the result set
3203 // and add it's list of members to the object as a property called
3204 // 'members'. Then each group will be added to the result set indexed
3205 // by it's course id.
3207 // The resulting data structure for $groups should be:
3208 // $groups = [
3209 // '1' = [
3210 // '1' => (object) [
3211 // 'id' => 1,
3212 // <rest of group properties>
3213 // 'members' => [
3214 // '1' => (object) [
3215 // <group member properties>
3216 // ],
3217 // '2' => (object) [
3218 // <group member properties>
3219 // ]
3220 // ]
3221 // ],
3222 // '2' => (object) [
3223 // 'id' => 2,
3224 // <rest of group properties>
3225 // 'members' => [
3226 // '1' => (object) [
3227 // <group member properties>
3228 // ],
3229 // '3' => (object) [
3230 // <group member properties>
3231 // ]
3232 // ]
3233 // ]
3234 // ]
3235 // ]
3237 foreach ($results as $key => $result) {
3238 $groupid = $result->gid;
3239 $courseid = $result->courseid;
3240 $coursegroups = $groups[$courseid];
3241 $groupsmembersid = $result->gmid;
3242 $reducefunc = function($carry, $field) use ($result) {
3243 // Iterate over the groups properties and pull
3244 // them out into a separate object.
3245 list($prefix, $field) = explode('.', $field);
3247 if (property_exists($result, $field)) {
3248 $carry[$field] = $result->{$field};
3251 return $carry;
3254 if (isset($coursegroups[$groupid])) {
3255 $group = $coursegroups[$groupid];
3256 } else {
3257 $initial = [
3258 'id' => $groupid,
3259 'members' => []
3261 $group = (object) array_reduce(
3262 $groupfields,
3263 $reducefunc,
3264 $initial
3268 if (!empty($groupsmembersid)) {
3269 $initial = ['id' => $groupsmembersid];
3270 $groupsmembers = (object) array_reduce(
3271 $groupsmembersfields,
3272 $reducefunc,
3273 $initial
3276 $group->members[$groupsmembers->userid] = $groupsmembers;
3279 $coursegroups[$groupid] = $group;
3280 $groups[$courseid] = $coursegroups;
3283 return $groups;
3287 * Gets the capabilities that have been cached in the database for this
3288 * component.
3289 * @deprecated since Moodle 3.6. Please use the Events 2 API.
3290 * @todo final deprecation. To be removed in Moodle 4.0
3292 * @access protected To be used from eventslib only
3294 * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
3295 * @return array of events
3297 function events_get_cached($component) {
3298 global $DB;
3300 debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
3301 DEBUG_DEVELOPER);
3303 $cachedhandlers = array();
3305 if ($storedhandlers = $DB->get_records('events_handlers', array('component'=>$component))) {
3306 foreach ($storedhandlers as $handler) {
3307 $cachedhandlers[$handler->eventname] = array (
3308 'id' => $handler->id,
3309 'handlerfile' => $handler->handlerfile,
3310 'handlerfunction' => $handler->handlerfunction,
3311 'schedule' => $handler->schedule,
3312 'internal' => $handler->internal);
3316 return $cachedhandlers;
3320 * Remove all event handlers and queued events
3321 * @deprecated since Moodle 3.6. Please use the Events 2 API.
3322 * @todo final deprecation. To be removed in Moodle 4.0
3324 * @category event
3325 * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
3327 function events_uninstall($component) {
3328 debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
3329 DEBUG_DEVELOPER);
3330 $cachedhandlers = events_get_cached($component);
3331 events_cleanup($component, $cachedhandlers);
3333 events_get_handlers('reset');
3337 * Deletes cached events that are no longer needed by the component.
3338 * @deprecated since Moodle 3.6. Please use the Events 2 API.
3339 * @todo final deprecation. To be removed in Moodle 4.0
3341 * @access protected To be used from eventslib only
3343 * @param string $component examples: 'moodle', 'mod_forum', 'block_quiz_results'
3344 * @param array $cachedhandlers array of the cached events definitions that will be
3345 * @return int number of unused handlers that have been removed
3347 function events_cleanup($component, $cachedhandlers) {
3348 global $DB;
3349 debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
3350 DEBUG_DEVELOPER);
3351 $deletecount = 0;
3352 foreach ($cachedhandlers as $eventname => $cachedhandler) {
3353 if ($qhandlers = $DB->get_records('events_queue_handlers', array('handlerid'=>$cachedhandler['id']))) {
3354 //debugging("Removing pending events from queue before deleting of event handler: $component - $eventname");
3355 foreach ($qhandlers as $qhandler) {
3356 events_dequeue($qhandler);
3359 $DB->delete_records('events_handlers', array('eventname'=>$eventname, 'component'=>$component));
3360 $deletecount++;
3363 return $deletecount;
3367 * Removes this queued handler from the events_queued_handler table
3369 * Removes events_queue record from events_queue if no more references to this event object exists
3370 * @deprecated since Moodle 3.6. Please use the Events 2 API.
3371 * @todo final deprecation. To be removed in Moodle 4.0
3373 * @access protected To be used from eventslib only
3375 * @param stdClass $qhandler A row from the events_queued_handler table
3377 function events_dequeue($qhandler) {
3378 global $DB;
3379 debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
3380 DEBUG_DEVELOPER);
3381 // first delete the queue handler
3382 $DB->delete_records('events_queue_handlers', array('id'=>$qhandler->id));
3384 // if no more queued handler is pointing to the same event - delete the event too
3385 if (!$DB->record_exists('events_queue_handlers', array('queuedeventid'=>$qhandler->queuedeventid))) {
3386 $DB->delete_records('events_queue', array('id'=>$qhandler->queuedeventid));
3391 * Returns handlers for given event. Uses caching for better perf.
3392 * @deprecated since Moodle 3.6. Please use the Events 2 API.
3393 * @todo final deprecation. To be removed in Moodle 4.0
3395 * @access protected To be used from eventslib only
3397 * @staticvar array $handlers
3398 * @param string $eventname name of event or 'reset'
3399 * @return array|false array of handlers or false otherwise
3401 function events_get_handlers($eventname) {
3402 global $DB;
3403 static $handlers = array();
3404 debugging('Events API using $handlers array has been deprecated in favour of Events 2 API, please use it instead.',
3405 DEBUG_DEVELOPER);
3407 if ($eventname === 'reset') {
3408 $handlers = array();
3409 return false;
3412 if (!array_key_exists($eventname, $handlers)) {
3413 $handlers[$eventname] = $DB->get_records('events_handlers', array('eventname'=>$eventname));
3416 return $handlers[$eventname];
3420 * This function finds the roles assigned directly to this context only
3421 * i.e. no roles in parent contexts
3423 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
3424 * @todo final deprecation. To be removed in Moodle 4.0
3425 * @param context $context
3426 * @return array
3428 function get_roles_on_exact_context(context $context) {
3429 debugging('get_roles_on_exact_context() is deprecated, please use get_roles_used_in_context() instead.',
3430 DEBUG_DEVELOPER);
3432 return get_roles_used_in_context($context, false);
3436 * Find out which roles has assignment on this context
3438 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context().
3439 * @todo final deprecation. To be removed in Moodle 4.0
3440 * @param context $context
3441 * @return array
3443 function get_roles_with_assignment_on_context(context $context) {
3444 debugging('get_roles_with_assignment_on_context() is deprecated, please use get_roles_used_in_context() instead.',
3445 DEBUG_DEVELOPER);
3447 return get_roles_used_in_context($context, false);