Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 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. 14 // 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/>. 17 18 /** 19 * deprecatedlib.php - Old functions retained only for backward compatibility 20 * 21 * Old functions retained only for backward compatibility. New code should not 22 * use any of these functions. 23 * 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 29 */ 30 31 defined('MOODLE_INTERNAL') || die(); 32 33 /* === Functions that needs to be kept longer in deprecated lib than normal time period === */ 34 35 /** 36 * @deprecated since 2.7 use new events instead 37 */ 38 function add_to_log() { 39 throw new coding_exception('add_to_log() has been removed, please rewrite your code to the new events API'); 40 } 41 42 /** 43 * @deprecated since 2.6 44 */ 45 function events_trigger() { 46 throw new coding_exception('events_trigger() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 47 } 48 49 /** 50 * List all core subsystems and their location 51 * 52 * This is a list of components that are part of the core and their 53 * language strings are defined in /lang/en/<<subsystem>>.php. If a given 54 * plugin is not listed here and it does not have proper plugintype prefix, 55 * then it is considered as course activity module. 56 * 57 * The location is optionally dirroot relative path. NULL means there is no special 58 * directory for this subsystem. If the location is set, the subsystem's 59 * renderer.php is expected to be there. 60 * 61 * @deprecated since 2.6, use core_component::get_core_subsystems() 62 * 63 * @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons 64 * @return array of (string)name => (string|null)location 65 */ 66 function get_core_subsystems($fullpaths = false) { 67 global $CFG; 68 69 // NOTE: do not add any other debugging here, keep forever. 70 71 $subsystems = core_component::get_core_subsystems(); 72 73 if ($fullpaths) { 74 return $subsystems; 75 } 76 77 debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER); 78 79 $dlength = strlen($CFG->dirroot); 80 81 foreach ($subsystems as $k => $v) { 82 if ($v === null) { 83 continue; 84 } 85 $subsystems[$k] = substr($v, $dlength+1); 86 } 87 88 return $subsystems; 89 } 90 91 /** 92 * Lists all plugin types. 93 * 94 * @deprecated since 2.6, use core_component::get_plugin_types() 95 * 96 * @param bool $fullpaths false means relative paths from dirroot 97 * @return array Array of strings - name=>location 98 */ 99 function get_plugin_types($fullpaths = true) { 100 global $CFG; 101 102 // NOTE: do not add any other debugging here, keep forever. 103 104 $types = core_component::get_plugin_types(); 105 106 if ($fullpaths) { 107 return $types; 108 } 109 110 debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER); 111 112 $dlength = strlen($CFG->dirroot); 113 114 foreach ($types as $k => $v) { 115 if ($k === 'theme') { 116 $types[$k] = 'theme'; 117 continue; 118 } 119 $types[$k] = substr($v, $dlength+1); 120 } 121 122 return $types; 123 } 124 125 /** 126 * Use when listing real plugins of one type. 127 * 128 * @deprecated since 2.6, use core_component::get_plugin_list() 129 * 130 * @param string $plugintype type of plugin 131 * @return array name=>fulllocation pairs of plugins of given type 132 */ 133 function get_plugin_list($plugintype) { 134 135 // NOTE: do not add any other debugging here, keep forever. 136 137 if ($plugintype === '') { 138 $plugintype = 'mod'; 139 } 140 141 return core_component::get_plugin_list($plugintype); 142 } 143 144 /** 145 * Get a list of all the plugins of a given type that define a certain class 146 * in a certain file. The plugin component names and class names are returned. 147 * 148 * @deprecated since 2.6, use core_component::get_plugin_list_with_class() 149 * 150 * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'. 151 * @param string $class the part of the name of the class after the 152 * frankenstyle prefix. e.g 'thing' if you are looking for classes with 153 * names like report_courselist_thing. If you are looking for classes with 154 * the same name as the plugin name (e.g. qtype_multichoice) then pass ''. 155 * @param string $file the name of file within the plugin that defines the class. 156 * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum') 157 * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice'). 158 */ 159 function get_plugin_list_with_class($plugintype, $class, $file) { 160 161 // NOTE: do not add any other debugging here, keep forever. 162 163 return core_component::get_plugin_list_with_class($plugintype, $class, $file); 164 } 165 166 /** 167 * Returns the exact absolute path to plugin directory. 168 * 169 * @deprecated since 2.6, use core_component::get_plugin_directory() 170 * 171 * @param string $plugintype type of plugin 172 * @param string $name name of the plugin 173 * @return string full path to plugin directory; NULL if not found 174 */ 175 function get_plugin_directory($plugintype, $name) { 176 177 // NOTE: do not add any other debugging here, keep forever. 178 179 if ($plugintype === '') { 180 $plugintype = 'mod'; 181 } 182 183 return core_component::get_plugin_directory($plugintype, $name); 184 } 185 186 /** 187 * Normalize the component name using the "frankenstyle" names. 188 * 189 * @deprecated since 2.6, use core_component::normalize_component() 190 * 191 * @param string $component 192 * @return array two-items list of [(string)type, (string|null)name] 193 */ 194 function normalize_component($component) { 195 196 // NOTE: do not add any other debugging here, keep forever. 197 198 return core_component::normalize_component($component); 199 } 200 201 /** 202 * Return exact absolute path to a plugin directory. 203 * 204 * @deprecated since 2.6, use core_component::normalize_component() 205 * 206 * @param string $component name such as 'moodle', 'mod_forum' 207 * @return string full path to component directory; NULL if not found 208 */ 209 function get_component_directory($component) { 210 211 // NOTE: do not add any other debugging here, keep forever. 212 213 return core_component::get_component_directory($component); 214 } 215 216 /** 217 * Get the context instance as an object. This function will create the 218 * context instance if it does not exist yet. 219 * 220 * @deprecated since 2.2, use context_course::instance() or other relevant class instead 221 * @todo This will be deleted in Moodle 2.8, refer MDL-34472 222 * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE. 223 * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id, 224 * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0 225 * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; 226 * MUST_EXIST means throw exception if no record or multiple records found 227 * @return context The context object. 228 */ 229 function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) { 230 231 debugging('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER); 232 233 $instances = (array)$instance; 234 $contexts = array(); 235 236 $classname = context_helper::get_class_for_level($contextlevel); 237 238 // we do not load multiple contexts any more, PAGE should be responsible for any preloading 239 foreach ($instances as $inst) { 240 $contexts[$inst] = $classname::instance($inst, $strictness); 241 } 242 243 if (is_array($instance)) { 244 return $contexts; 245 } else { 246 return $contexts[$instance]; 247 } 248 } 249 /* === End of long term deprecated api list === */ 250 251 /** 252 * @deprecated since 2.7 - use new file picker instead 253 */ 254 function clam_log_upload() { 255 throw new coding_exception('clam_log_upload() can not be used any more, please use file picker instead'); 256 } 257 258 /** 259 * @deprecated since 2.7 - use new file picker instead 260 */ 261 function clam_log_infected() { 262 throw new coding_exception('clam_log_infected() can not be used any more, please use file picker instead'); 263 } 264 265 /** 266 * @deprecated since 2.7 - use new file picker instead 267 */ 268 function clam_change_log() { 269 throw new coding_exception('clam_change_log() can not be used any more, please use file picker instead'); 270 } 271 272 /** 273 * @deprecated since 2.7 - infected files are now deleted in file picker 274 */ 275 function clam_replace_infected_file() { 276 throw new coding_exception('clam_replace_infected_file() can not be used any more, please use file picker instead'); 277 } 278 279 /** 280 * @deprecated since 2.7 281 */ 282 function clam_handle_infected_file() { 283 throw new coding_exception('clam_handle_infected_file() can not be used any more, please use file picker instead'); 284 } 285 286 /** 287 * @deprecated since 2.7 288 */ 289 function clam_scan_moodle_file() { 290 throw new coding_exception('clam_scan_moodle_file() can not be used any more, please use file picker instead'); 291 } 292 293 294 /** 295 * @deprecated since 2.7 PHP 5.4.x should be always compatible. 296 */ 297 function password_compat_not_supported() { 298 throw new coding_exception('Do not use password_compat_not_supported() - bcrypt is now always available'); 299 } 300 301 /** 302 * @deprecated since 2.6 303 */ 304 function session_get_instance() { 305 throw new coding_exception('session_get_instance() is removed, use \core\session\manager instead'); 306 } 307 308 /** 309 * @deprecated since 2.6 310 */ 311 function session_is_legacy() { 312 throw new coding_exception('session_is_legacy() is removed, do not use any more'); 313 } 314 315 /** 316 * @deprecated since 2.6 317 */ 318 function session_kill_all() { 319 throw new coding_exception('session_kill_all() is removed, use \core\session\manager::kill_all_sessions() instead'); 320 } 321 322 /** 323 * @deprecated since 2.6 324 */ 325 function session_touch() { 326 throw new coding_exception('session_touch() is removed, use \core\session\manager::touch_session() instead'); 327 } 328 329 /** 330 * @deprecated since 2.6 331 */ 332 function session_kill() { 333 throw new coding_exception('session_kill() is removed, use \core\session\manager::kill_session() instead'); 334 } 335 336 /** 337 * @deprecated since 2.6 338 */ 339 function session_kill_user() { 340 throw new coding_exception('session_kill_user() is removed, use \core\session\manager::kill_user_sessions() instead'); 341 } 342 343 /** 344 * @deprecated since 2.6 345 */ 346 function session_set_user() { 347 throw new coding_exception('session_set_user() is removed, use \core\session\manager::set_user() instead'); 348 } 349 350 /** 351 * @deprecated since 2.6 352 */ 353 function session_is_loggedinas() { 354 throw new coding_exception('session_is_loggedinas() is removed, use \core\session\manager::is_loggedinas() instead'); 355 } 356 357 /** 358 * @deprecated since 2.6 359 */ 360 function session_get_realuser() { 361 throw new coding_exception('session_get_realuser() is removed, use \core\session\manager::get_realuser() instead'); 362 } 363 364 /** 365 * @deprecated since 2.6 366 */ 367 function session_loginas() { 368 throw new coding_exception('session_loginas() is removed, use \core\session\manager::loginas() instead'); 369 } 370 371 /** 372 * @deprecated since 2.6 373 */ 374 function js_minify() { 375 throw new coding_exception('js_minify() is removed, use core_minify::js_files() or core_minify::js() instead.'); 376 } 377 378 /** 379 * @deprecated since 2.6 380 */ 381 function css_minify_css() { 382 throw new coding_exception('css_minify_css() is removed, use core_minify::css_files() or core_minify::css() instead.'); 383 } 384 385 // === Deprecated before 2.6.0 === 386 387 /** 388 * @deprecated 389 */ 390 function check_gd_version() { 391 throw new coding_exception('check_gd_version() is removed, GD extension is always available now'); 392 } 393 394 /** 395 * @deprecated 396 */ 397 function update_login_count() { 398 throw new coding_exception('update_login_count() is removed, all calls need to be removed'); 399 } 400 401 /** 402 * @deprecated 403 */ 404 function reset_login_count() { 405 throw new coding_exception('reset_login_count() is removed, all calls need to be removed'); 406 } 407 408 /** 409 * @deprecated 410 */ 411 function update_log_display_entry() { 412 413 throw new coding_exception('The update_log_display_entry() is removed, please use db/log.php description file instead.'); 414 } 415 416 /** 417 * @deprecated use the text formatting in a standard way instead (http://docs.moodle.org/dev/Output_functions) 418 * this was abused mostly for embedding of attachments 419 */ 420 function filter_text() { 421 throw new coding_exception('filter_text() can not be used anymore, use format_text(), format_string() etc instead.'); 422 } 423 424 /** 425 * @deprecated Loginhttps is no longer supported 426 */ 427 function httpsrequired() { 428 throw new coding_exception('httpsrequired() can not be used any more. Loginhttps is no longer supported.'); 429 } 430 431 /** 432 * @deprecated since 3.1 - replacement legacy file API methods can be found on the moodle_url class, for example: 433 * The moodle_url::make_legacyfile_url() method can be used to generate a legacy course file url. To generate 434 * course module file.php url the moodle_url::make_file_url() should be used. 435 */ 436 function get_file_url() { 437 throw new coding_exception('get_file_url() can not be used anymore. Please use ' . 438 'moodle_url factory methods instead.'); 439 } 440 441 /** 442 * @deprecated use get_enrolled_users($context) instead. 443 */ 444 function get_course_participants() { 445 throw new coding_exception('get_course_participants() can not be used any more, use get_enrolled_users() instead.'); 446 } 447 448 /** 449 * @deprecated use is_enrolled($context, $userid) instead. 450 */ 451 function is_course_participant() { 452 throw new coding_exception('is_course_participant() can not be used any more, use is_enrolled() instead.'); 453 } 454 455 /** 456 * @deprecated 457 */ 458 function get_recent_enrolments() { 459 throw new coding_exception('get_recent_enrolments() is removed as it returned inaccurate results.'); 460 } 461 462 /** 463 * @deprecated use clean_param($string, PARAM_FILE) instead. 464 */ 465 function detect_munged_arguments() { 466 throw new coding_exception('detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.'); 467 } 468 469 470 /** 471 * Unzip one zip file to a destination dir 472 * Both parameters must be FULL paths 473 * If destination isn't specified, it will be the 474 * SAME directory where the zip file resides. 475 * 476 * @global object 477 * @param string $zipfile The zip file to unzip 478 * @param string $destination The location to unzip to 479 * @param bool $showstatus_ignored Unused 480 * @deprecated since 2.0 MDL-15919 481 */ 482 function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) { 483 debugging(__FUNCTION__ . '() is deprecated. ' 484 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER); 485 486 // Extract everything from zipfile. 487 $path_parts = pathinfo(cleardoubleslashes($zipfile)); 488 $zippath = $path_parts["dirname"]; //The path of the zip file 489 $zipfilename = $path_parts["basename"]; //The name of the zip file 490 $extension = $path_parts["extension"]; //The extension of the file 491 492 //If no file, error 493 if (empty($zipfilename)) { 494 return false; 495 } 496 497 //If no extension, error 498 if (empty($extension)) { 499 return false; 500 } 501 502 //Clear $zipfile 503 $zipfile = cleardoubleslashes($zipfile); 504 505 //Check zipfile exists 506 if (!file_exists($zipfile)) { 507 return false; 508 } 509 510 //If no destination, passed let's go with the same directory 511 if (empty($destination)) { 512 $destination = $zippath; 513 } 514 515 //Clear $destination 516 $destpath = rtrim(cleardoubleslashes($destination), "/"); 517 518 //Check destination path exists 519 if (!is_dir($destpath)) { 520 return false; 521 } 522 523 $packer = get_file_packer('application/zip'); 524 525 $result = $packer->extract_to_pathname($zipfile, $destpath); 526 527 if ($result === false) { 528 return false; 529 } 530 531 foreach ($result as $status) { 532 if ($status !== true) { 533 return false; 534 } 535 } 536 537 return true; 538 } 539 540 /** 541 * Zip an array of files/dirs to a destination zip file 542 * Both parameters must be FULL paths to the files/dirs 543 * 544 * @global object 545 * @param array $originalfiles Files to zip 546 * @param string $destination The destination path 547 * @return bool Outcome 548 * 549 * @deprecated since 2.0 MDL-15919 550 */ 551 function zip_files($originalfiles, $destination) { 552 debugging(__FUNCTION__ . '() is deprecated. ' 553 . 'Please use the application/zip file_packer implementation instead.', DEBUG_DEVELOPER); 554 555 // Extract everything from destination. 556 $path_parts = pathinfo(cleardoubleslashes($destination)); 557 $destpath = $path_parts["dirname"]; //The path of the zip file 558 $destfilename = $path_parts["basename"]; //The name of the zip file 559 $extension = $path_parts["extension"]; //The extension of the file 560 561 //If no file, error 562 if (empty($destfilename)) { 563 return false; 564 } 565 566 //If no extension, add it 567 if (empty($extension)) { 568 $extension = 'zip'; 569 $destfilename = $destfilename.'.'.$extension; 570 } 571 572 //Check destination path exists 573 if (!is_dir($destpath)) { 574 return false; 575 } 576 577 //Check destination path is writable. TODO!! 578 579 //Clean destination filename 580 $destfilename = clean_filename($destfilename); 581 582 //Now check and prepare every file 583 $files = array(); 584 $origpath = NULL; 585 586 foreach ($originalfiles as $file) { //Iterate over each file 587 //Check for every file 588 $tempfile = cleardoubleslashes($file); // no doubleslashes! 589 //Calculate the base path for all files if it isn't set 590 if ($origpath === NULL) { 591 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/"); 592 } 593 //See if the file is readable 594 if (!is_readable($tempfile)) { //Is readable 595 continue; 596 } 597 //See if the file/dir is in the same directory than the rest 598 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) { 599 continue; 600 } 601 //Add the file to the array 602 $files[] = $tempfile; 603 } 604 605 $zipfiles = array(); 606 $start = strlen($origpath)+1; 607 foreach($files as $file) { 608 $zipfiles[substr($file, $start)] = $file; 609 } 610 611 $packer = get_file_packer('application/zip'); 612 613 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename); 614 } 615 616 /** 617 * @deprecated use groups_get_all_groups() instead. 618 */ 619 function mygroupid() { 620 throw new coding_exception('mygroupid() can not be used any more, please use groups_get_all_groups() instead.'); 621 } 622 623 /** 624 * @deprecated since Moodle 2.0 MDL-14617 - please do not use this function any more. 625 */ 626 function groupmode() { 627 throw new coding_exception('groupmode() can not be used any more, please use groups_get_* instead.'); 628 } 629 630 /** 631 * @deprecated Since year 2006 - please do not use this function any more. 632 */ 633 function set_current_group() { 634 throw new coding_exception('set_current_group() can not be used anymore, please use $SESSION->currentgroup[$courseid] instead'); 635 } 636 637 /** 638 * @deprecated Since year 2006 - please do not use this function any more. 639 */ 640 function get_current_group() { 641 throw new coding_exception('get_current_group() can not be used any more, please use groups_get_* instead'); 642 } 643 644 /** 645 * @deprecated Since Moodle 2.8 646 */ 647 function groups_filter_users_by_course_module_visible() { 648 throw new coding_exception('groups_filter_users_by_course_module_visible() is removed. ' . 649 'Replace with a call to \core_availability\info_module::filter_user_list(), ' . 650 'which does basically the same thing but includes other restrictions such ' . 651 'as profile restrictions.'); 652 } 653 654 /** 655 * @deprecated Since Moodle 2.8 656 */ 657 function groups_course_module_visible() { 658 throw new coding_exception('groups_course_module_visible() is removed, use $cm->uservisible to decide whether the current 659 user can ' . 'access an activity.', DEBUG_DEVELOPER); 660 } 661 662 /** 663 * @deprecated since 2.0 664 */ 665 function error() { 666 throw new coding_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a removed, please call 667 print_error() instead of error()'); 668 } 669 670 671 /** 672 * @deprecated use $PAGE->theme->name instead. 673 */ 674 function current_theme() { 675 throw new coding_exception('current_theme() can not be used any more, please use $PAGE->theme->name instead'); 676 } 677 678 /** 679 * @deprecated 680 */ 681 function formerr() { 682 throw new coding_exception('formerr() is removed. Please change your code to use $OUTPUT->error_text($string).'); 683 } 684 685 /** 686 * @deprecated use $OUTPUT->skip_link_target() in instead. 687 */ 688 function skip_main_destination() { 689 throw new coding_exception('skip_main_destination() can not be used any more, please use $OUTPUT->skip_link_target() instead.'); 690 } 691 692 /** 693 * @deprecated use $OUTPUT->container() instead. 694 */ 695 function print_container() { 696 throw new coding_exception('print_container() can not be used any more. Please use $OUTPUT->container() instead.'); 697 } 698 699 /** 700 * @deprecated use $OUTPUT->container_start() instead. 701 */ 702 function print_container_start() { 703 throw new coding_exception('print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.'); 704 } 705 706 /** 707 * @deprecated use $OUTPUT->container_end() instead. 708 */ 709 function print_container_end() { 710 throw new coding_exception('print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.'); 711 } 712 713 /** 714 * @deprecated since Moodle 2.0 MDL-19077 - use $OUTPUT->notification instead. 715 */ 716 function notify() { 717 throw new coding_exception('notify() is removed, please use $OUTPUT->notification() instead'); 718 } 719 720 /** 721 * @deprecated use $OUTPUT->continue_button() instead. 722 */ 723 function print_continue() { 724 throw new coding_exception('print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.'); 725 } 726 727 /** 728 * @deprecated use $PAGE methods instead. 729 */ 730 function print_header() { 731 732 throw new coding_exception('print_header() can not be used any more. Please use $PAGE methods instead.'); 733 } 734 735 /** 736 * @deprecated use $PAGE methods instead. 737 */ 738 function print_header_simple() { 739 740 throw new coding_exception('print_header_simple() can not be used any more. Please use $PAGE methods instead.'); 741 } 742 743 /** 744 * @deprecated use $OUTPUT->block() instead. 745 */ 746 function print_side_block() { 747 throw new coding_exception('print_side_block() can not be used any more, please use $OUTPUT->block() instead.'); 748 } 749 750 /** 751 * @deprecated since Moodle 3.6 752 */ 753 function print_textarea() { 754 throw new coding_exception( 755 'print_textarea() has been removed. Please use $OUTPUT->print_textarea() instead.' 756 ); 757 } 758 759 /** 760 * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please 761 * provide this function with the language strings for sortasc and sortdesc. 762 * 763 * @deprecated use $OUTPUT->arrow() instead. 764 * @todo final deprecation of this function once MDL-45448 is resolved 765 * 766 * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned. 767 * 768 * @global object 769 * @param string $direction 'up' or 'down' 770 * @param string $strsort The language string used for the alt attribute of this image 771 * @param bool $return Whether to print directly or return the html string 772 * @return string|void depending on $return 773 * 774 */ 775 function print_arrow($direction='up', $strsort=null, $return=false) { 776 global $OUTPUT; 777 778 debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER); 779 780 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) { 781 return null; 782 } 783 784 $return = null; 785 786 switch ($direction) { 787 case 'up': 788 $sortdir = 'asc'; 789 break; 790 case 'down': 791 $sortdir = 'desc'; 792 break; 793 case 'move': 794 $sortdir = 'asc'; 795 break; 796 default: 797 $sortdir = null; 798 break; 799 } 800 801 // Prepare language string 802 $strsort = ''; 803 if (empty($strsort) && !empty($sortdir)) { 804 $strsort = get_string('sort' . $sortdir, 'grades'); 805 } 806 807 $return = ' ' . $OUTPUT->pix_icon('t/' . $direction, $strsort) . ' '; 808 809 if ($return) { 810 return $return; 811 } else { 812 echo $return; 813 } 814 } 815 816 /** 817 * @deprecated since Moodle 2.0 818 */ 819 function choose_from_menu() { 820 throw new coding_exception('choose_from_menu() is removed. Please change your code to use html_writer::select().'); 821 } 822 823 /** 824 * @deprecated use $OUTPUT->help_icon_scale($courseid, $scale) instead. 825 */ 826 function print_scale_menu_helpbutton() { 827 throw new coding_exception('print_scale_menu_helpbutton() can not be used any more. '. 828 'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.'); 829 } 830 831 /** 832 * @deprecated use html_writer::checkbox() instead. 833 */ 834 function print_checkbox() { 835 throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.'); 836 } 837 838 /** 839 * @deprecated since Moodle 3.2 840 */ 841 function update_module_button() { 842 throw new coding_exception('update_module_button() can not be used anymore. Activity modules should ' . 843 'not add the edit module button, the link is already available in the Administration block. Themes ' . 844 'can choose to display the link in the buttons row consistently for all module types.'); 845 } 846 847 /** 848 * @deprecated use $OUTPUT->navbar() instead 849 */ 850 function print_navigation () { 851 throw new coding_exception('print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.'); 852 } 853 854 /** 855 * @deprecated Please use $PAGE->navabar methods instead. 856 */ 857 function build_navigation() { 858 throw new coding_exception('build_navigation() can not be used any more, please use $PAGE->navbar methods instead.'); 859 } 860 861 /** 862 * @deprecated not relevant with global navigation in Moodle 2.x+ 863 */ 864 function navmenu() { 865 throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.'); 866 } 867 868 /// CALENDAR MANAGEMENT //////////////////////////////////////////////////////////////// 869 870 871 /** 872 * @deprecated please use calendar_event::create() instead. 873 */ 874 function add_event() { 875 throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.'); 876 } 877 878 /** 879 * @deprecated please calendar_event->update() instead. 880 */ 881 function update_event() { 882 throw new coding_exception('update_event() is removed, please use calendar_event->update() instead.'); 883 } 884 885 /** 886 * @deprecated please use calendar_event->delete() instead. 887 */ 888 function delete_event() { 889 throw new coding_exception('delete_event() can not be used any more, please use '. 890 'calendar_event->delete() instead.'); 891 } 892 893 /** 894 * @deprecated please use calendar_event->toggle_visibility(false) instead. 895 */ 896 function hide_event() { 897 throw new coding_exception('hide_event() can not be used any more, please use '. 898 'calendar_event->toggle_visibility(false) instead.'); 899 } 900 901 /** 902 * @deprecated please use calendar_event->toggle_visibility(true) instead. 903 */ 904 function show_event() { 905 throw new coding_exception('show_event() can not be used any more, please use '. 906 'calendar_event->toggle_visibility(true) instead.'); 907 } 908 909 /** 910 * @deprecated since Moodle 2.2 use core_text::xxxx() instead. 911 */ 912 function textlib_get_instance() { 913 throw new coding_exception('textlib_get_instance() can not be used any more, please use '. 914 'core_text::functioname() instead.'); 915 } 916 917 /** 918 * @deprecated since 2.4 919 */ 920 function get_generic_section_name() { 921 throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base'); 922 } 923 924 /** 925 * @deprecated since 2.4 926 */ 927 function get_all_sections() { 928 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function'); 929 } 930 931 /** 932 * @deprecated since 2.4 933 */ 934 function add_mod_to_section() { 935 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()'); 936 } 937 938 /** 939 * @deprecated since 2.4 940 */ 941 function get_all_mods() { 942 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details'); 943 } 944 945 /** 946 * @deprecated since 2.4 947 */ 948 function get_course_section() { 949 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.'); 950 } 951 952 /** 953 * @deprecated since 2.4 954 */ 955 function format_weeks_get_section_dates() { 956 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'. 957 ' use it outside of format_weeks plugin'); 958 } 959 960 /** 961 * @deprecated since 2.5 962 */ 963 function get_print_section_cm_text() { 964 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '. 965 'cm_info::get_formatted_content() and cm_info::get_formatted_name()'); 966 } 967 968 /** 969 * @deprecated since 2.5 970 */ 971 function print_section_add_menus() { 972 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '. 973 'function course_section_add_cm_control()'); 974 } 975 976 /** 977 * @deprecated since 2.5. Please use: 978 * $courserenderer = $PAGE->get_renderer('core', 'course'); 979 * $actions = course_get_cm_edit_actions($mod, $indent, $section); 980 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions); 981 */ 982 function make_editing_buttons() { 983 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '. 984 'lib/deprecatedlib.php on how to replace it'); 985 } 986 987 /** 988 * @deprecated since 2.5 989 */ 990 function print_section() { 991 throw new coding_exception('Function print_section() is removed. Please use course renderer function '. 992 'course_section_cm_list() instead.'); 993 } 994 995 /** 996 * @deprecated since 2.5 997 */ 998 function print_overview() { 999 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information'); 1000 } 1001 1002 /** 1003 * @deprecated since 2.5 1004 */ 1005 function print_recent_activity() { 1006 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'. 1007 ' use it outside of block_recent_activity'); 1008 } 1009 1010 /** 1011 * @deprecated since 2.5 1012 */ 1013 function delete_course_module() { 1014 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.'); 1015 } 1016 1017 /** 1018 * @deprecated since 2.5 1019 */ 1020 function update_category_button() { 1021 throw new coding_exception('Function update_category_button() is removed. Pages to view '. 1022 'and edit courses are now separate and no longer depend on editing mode.'); 1023 } 1024 1025 /** 1026 * @deprecated since 2.5 1027 */ 1028 function make_categories_list() { 1029 throw new coding_exception('Global function make_categories_list() is removed. Please use '. 1030 'core_course_category::make_categories_list() and core_course_category::get_parents()'); 1031 } 1032 1033 /** 1034 * @deprecated since 2.5 1035 */ 1036 function category_delete_move() { 1037 throw new coding_exception('Function category_delete_move() is removed. Please use ' . 1038 'core_course_category::delete_move() instead.'); 1039 } 1040 1041 /** 1042 * @deprecated since 2.5 1043 */ 1044 function category_delete_full() { 1045 throw new coding_exception('Function category_delete_full() is removed. Please use ' . 1046 'core_course_category::delete_full() instead.'); 1047 } 1048 1049 /** 1050 * @deprecated since 2.5 1051 */ 1052 function move_category() { 1053 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.'); 1054 } 1055 1056 /** 1057 * @deprecated since 2.5 1058 */ 1059 function course_category_hide() { 1060 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.'); 1061 } 1062 1063 /** 1064 * @deprecated since 2.5 1065 */ 1066 function course_category_show() { 1067 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.'); 1068 } 1069 1070 /** 1071 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or 1072 * core_course_category::get($catid, MUST_EXIST). 1073 */ 1074 function get_course_category() { 1075 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' . 1076 'see phpdocs for more details'); 1077 } 1078 1079 /** 1080 * @deprecated since 2.5 1081 */ 1082 function create_course_category() { 1083 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' . 1084 'see phpdocs for more details'); 1085 } 1086 1087 /** 1088 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children() 1089 */ 1090 function get_all_subcategories() { 1091 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '. 1092 'of core_course_category class. See phpdocs for more details'); 1093 } 1094 1095 /** 1096 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children(). 1097 */ 1098 function get_child_categories() { 1099 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' . 1100 'phpdocs for more details.'); 1101 } 1102 1103 /** 1104 * @deprecated since 2.5 1105 */ 1106 function get_categories() { 1107 throw new coding_exception('Function get_categories() is removed. Please use ' . 1108 'appropriate functions from class core_course_category'); 1109 } 1110 1111 /** 1112 * @deprecated since 2.5 1113 */ 1114 function print_course_search() { 1115 throw new coding_exception('Function print_course_search() is removed, please use course renderer'); 1116 } 1117 1118 /** 1119 * @deprecated since 2.5 1120 */ 1121 function print_my_moodle() { 1122 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' . 1123 'function frontpage_my_courses()'); 1124 } 1125 1126 /** 1127 * @deprecated since 2.5 1128 */ 1129 function print_remote_course() { 1130 throw new coding_exception('Function print_remote_course() is removed, please use course renderer'); 1131 } 1132 1133 /** 1134 * @deprecated since 2.5 1135 */ 1136 function print_remote_host() { 1137 throw new coding_exception('Function print_remote_host() is removed, please use course renderer'); 1138 } 1139 1140 /** 1141 * @deprecated since 2.5 1142 */ 1143 function print_whole_category_list() { 1144 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer'); 1145 } 1146 1147 /** 1148 * @deprecated since 2.5 1149 */ 1150 function print_category_info() { 1151 throw new coding_exception('Function print_category_info() is removed, please use course renderer'); 1152 } 1153 1154 /** 1155 * @deprecated since 2.5 1156 */ 1157 function get_course_category_tree() { 1158 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' . 1159 'renderer or core_course_category class, see function phpdocs for more info'); 1160 } 1161 1162 /** 1163 * @deprecated since 2.5 1164 */ 1165 function print_courses() { 1166 throw new coding_exception('Function print_courses() is removed, please use course renderer'); 1167 } 1168 1169 /** 1170 * @deprecated since 2.5 1171 */ 1172 function print_course() { 1173 throw new coding_exception('Function print_course() is removed, please use course renderer'); 1174 } 1175 1176 /** 1177 * @deprecated since 2.5 1178 */ 1179 function get_category_courses_array() { 1180 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' . 1181 'core_course_category class'); 1182 } 1183 1184 /** 1185 * @deprecated since 2.5 1186 */ 1187 function get_category_courses_array_recursively() { 1188 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' . 1189 'methods of core_course_category class', DEBUG_DEVELOPER); 1190 } 1191 1192 /** 1193 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more. 1194 */ 1195 function blog_get_context_url() { 1196 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.'); 1197 } 1198 1199 /** 1200 * @deprecated since 2.5 1201 */ 1202 function get_courses_wmanagers() { 1203 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' . 1204 'core_course_category::get_courses()'); 1205 } 1206 1207 /** 1208 * @deprecated since 2.5 1209 */ 1210 function convert_tree_to_html() { 1211 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()'); 1212 } 1213 1214 /** 1215 * @deprecated since 2.5 1216 */ 1217 function convert_tabrows_to_tree() { 1218 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree'); 1219 } 1220 1221 /** 1222 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically 1223 */ 1224 function can_use_rotated_text() { 1225 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.'); 1226 } 1227 1228 /** 1229 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more. 1230 */ 1231 function get_context_instance_by_id() { 1232 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.'); 1233 } 1234 1235 /** 1236 * Returns system context or null if can not be created yet. 1237 * 1238 * @see context_system::instance() 1239 * @deprecated since 2.2 1240 * @param bool $cache use caching 1241 * @return context system context (null if context table not created yet) 1242 */ 1243 function get_system_context($cache = true) { 1244 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); 1245 return context_system::instance(0, IGNORE_MISSING, $cache); 1246 } 1247 1248 /** 1249 * @deprecated since 2.2, use $context->get_parent_context_ids() instead 1250 */ 1251 function get_parent_contexts() { 1252 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.'); 1253 } 1254 1255 /** 1256 * @deprecated since Moodle 2.2 1257 */ 1258 function get_parent_contextid() { 1259 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.'); 1260 } 1261 1262 /** 1263 * @deprecated since 2.2 1264 */ 1265 function get_child_contexts() { 1266 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.'); 1267 } 1268 1269 /** 1270 * @deprecated since 2.2 1271 */ 1272 function create_contexts() { 1273 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.'); 1274 } 1275 1276 /** 1277 * @deprecated since 2.2 1278 */ 1279 function cleanup_contexts() { 1280 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.'); 1281 } 1282 1283 /** 1284 * @deprecated since 2.2 1285 */ 1286 function build_context_path() { 1287 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.'); 1288 } 1289 1290 /** 1291 * @deprecated since 2.2 1292 */ 1293 function rebuild_contexts() { 1294 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.'); 1295 } 1296 1297 /** 1298 * @deprecated since Moodle 2.2 1299 */ 1300 function preload_course_contexts() { 1301 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.'); 1302 } 1303 1304 /** 1305 * @deprecated since Moodle 2.2 1306 */ 1307 function context_moved() { 1308 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.'); 1309 } 1310 1311 /** 1312 * @deprecated since 2.2 1313 */ 1314 function fetch_context_capabilities() { 1315 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.'); 1316 } 1317 1318 /** 1319 * @deprecated since 2.2 1320 */ 1321 function context_instance_preload() { 1322 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.'); 1323 } 1324 1325 /** 1326 * @deprecated since 2.2 1327 */ 1328 function get_contextlevel_name() { 1329 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.'); 1330 } 1331 1332 /** 1333 * @deprecated since 2.2 1334 */ 1335 function print_context_name() { 1336 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.'); 1337 } 1338 1339 /** 1340 * @deprecated since 2.2, use $context->mark_dirty() instead 1341 */ 1342 function mark_context_dirty() { 1343 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.'); 1344 } 1345 1346 /** 1347 * @deprecated since Moodle 2.2 1348 */ 1349 function delete_context() { 1350 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' . 1351 'or $context->delete_content() instead.'); 1352 } 1353 1354 /** 1355 * @deprecated since 2.2 1356 */ 1357 function get_context_url() { 1358 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.'); 1359 } 1360 1361 /** 1362 * @deprecated since 2.2 1363 */ 1364 function get_course_context() { 1365 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.'); 1366 } 1367 1368 /** 1369 * @deprecated since 2.2 1370 */ 1371 function get_user_courses_bycap() { 1372 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.'); 1373 } 1374 1375 /** 1376 * @deprecated since Moodle 2.2 1377 */ 1378 function get_role_context_caps() { 1379 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.'); 1380 } 1381 1382 /** 1383 * @deprecated since 2.2 1384 */ 1385 function get_courseid_from_context() { 1386 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.'); 1387 } 1388 1389 /** 1390 * @deprecated since 2.2 1391 */ 1392 function context_instance_preload_sql() { 1393 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.'); 1394 } 1395 1396 /** 1397 * @deprecated since 2.2 1398 */ 1399 function get_related_contexts_string() { 1400 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.'); 1401 } 1402 1403 /** 1404 * @deprecated since 2.6 1405 */ 1406 function get_plugin_list_with_file() { 1407 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.'); 1408 } 1409 1410 /** 1411 * @deprecated since 2.6 1412 */ 1413 function check_browser_operating_system() { 1414 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.'); 1415 } 1416 1417 /** 1418 * @deprecated since 2.6 1419 */ 1420 function check_browser_version() { 1421 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.'); 1422 } 1423 1424 /** 1425 * @deprecated since 2.6 1426 */ 1427 function get_device_type() { 1428 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.'); 1429 } 1430 1431 /** 1432 * @deprecated since 2.6 1433 */ 1434 function get_device_type_list() { 1435 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.'); 1436 } 1437 1438 /** 1439 * @deprecated since 2.6 1440 */ 1441 function get_selected_theme_for_device_type() { 1442 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.'); 1443 } 1444 1445 /** 1446 * @deprecated since 2.6 1447 */ 1448 function get_device_cfg_var_name() { 1449 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.'); 1450 } 1451 1452 /** 1453 * @deprecated since 2.6 1454 */ 1455 function set_user_device_type() { 1456 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.'); 1457 } 1458 1459 /** 1460 * @deprecated since 2.6 1461 */ 1462 function get_user_device_type() { 1463 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.'); 1464 } 1465 1466 /** 1467 * @deprecated since 2.6 1468 */ 1469 function get_browser_version_classes() { 1470 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.'); 1471 } 1472 1473 /** 1474 * @deprecated since Moodle 2.6 1475 */ 1476 function generate_email_supportuser() { 1477 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user'); 1478 } 1479 1480 /** 1481 * @deprecated since Moodle 2.6 1482 */ 1483 function badges_get_issued_badge_info() { 1484 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.'); 1485 } 1486 1487 /** 1488 * @deprecated since 2.6 1489 */ 1490 function can_use_html_editor() { 1491 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.'); 1492 } 1493 1494 1495 /** 1496 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead. 1497 */ 1498 function count_login_failures() { 1499 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().'); 1500 } 1501 1502 /** 1503 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more. 1504 */ 1505 function ajaxenabled() { 1506 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.'); 1507 } 1508 1509 /** 1510 * @deprecated Since Moodle 2.7 MDL-44070 1511 */ 1512 function coursemodule_visible_for_user() { 1513 throw new coding_exception('coursemodule_visible_for_user() can not be used any more, 1514 please use \core_availability\info_module::is_user_visible()'); 1515 } 1516 1517 /** 1518 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed 1519 */ 1520 function enrol_cohort_get_cohorts() { 1521 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '. 1522 'cohort_get_available_cohorts() instead'); 1523 } 1524 1525 /** 1526 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort() 1527 */ 1528 function enrol_cohort_can_view_cohort() { 1529 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead'); 1530 } 1531 1532 /** 1533 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead 1534 */ 1535 function cohort_get_visible_list() { 1536 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ". 1537 "that correctly checks capabilities.'); 1538 } 1539 1540 /** 1541 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed 1542 */ 1543 function enrol_cohort_enrol_all_users() { 1544 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.'); 1545 } 1546 1547 /** 1548 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed 1549 */ 1550 function enrol_cohort_search_cohorts() { 1551 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.'); 1552 } 1553 1554 /* === Apis deprecated in since Moodle 2.9 === */ 1555 1556 /** 1557 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more. 1558 */ 1559 function message_current_user_is_involved() { 1560 throw new coding_exception('message_current_user_is_involved() can not be used any more.'); 1561 } 1562 1563 /** 1564 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more. 1565 */ 1566 function profile_display_badges() { 1567 throw new coding_exception('profile_display_badges() can not be used any more.'); 1568 } 1569 1570 /** 1571 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more. 1572 */ 1573 function useredit_shared_definition_preferences() { 1574 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.'); 1575 } 1576 1577 1578 /** 1579 * @deprecated since Moodle 2.9 1580 */ 1581 function calendar_normalize_tz() { 1582 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.'); 1583 } 1584 1585 /** 1586 * @deprecated since Moodle 2.9 1587 */ 1588 function get_user_timezone_offset() { 1589 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead'); 1590 1591 } 1592 1593 /** 1594 * @deprecated since Moodle 2.9 1595 */ 1596 function get_timezone_offset() { 1597 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead'); 1598 } 1599 1600 /** 1601 * @deprecated since Moodle 2.9 1602 */ 1603 function get_list_of_timezones() { 1604 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead'); 1605 } 1606 1607 /** 1608 * @deprecated since Moodle 2.9 1609 */ 1610 function update_timezone_records() { 1611 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead'); 1612 } 1613 1614 /** 1615 * @deprecated since Moodle 2.9 1616 */ 1617 function calculate_user_dst_table() { 1618 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead'); 1619 } 1620 1621 /** 1622 * @deprecated since Moodle 2.9 1623 */ 1624 function dst_changes_for_year() { 1625 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead'); 1626 } 1627 1628 /** 1629 * @deprecated since Moodle 2.9 1630 */ 1631 function get_timezone_record() { 1632 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead'); 1633 } 1634 1635 /* === Apis deprecated since Moodle 3.0 === */ 1636 /** 1637 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more. 1638 */ 1639 function get_referer() { 1640 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.'); 1641 } 1642 1643 /** 1644 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead. 1645 */ 1646 function is_web_crawler() { 1647 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.'); 1648 } 1649 1650 /** 1651 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more. 1652 */ 1653 function completion_cron() { 1654 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.'); 1655 } 1656 1657 /** 1658 * @deprecated since 3.0 1659 */ 1660 function coursetag_get_tags() { 1661 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' . 1662 'Userid is no longer used for tagging courses.'); 1663 } 1664 1665 /** 1666 * @deprecated since 3.0 1667 */ 1668 function coursetag_get_all_tags() { 1669 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' . 1670 'longer used for tagging courses.'); 1671 } 1672 1673 /** 1674 * @deprecated since 3.0 1675 */ 1676 function coursetag_get_jscript() { 1677 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.'); 1678 } 1679 1680 /** 1681 * @deprecated since 3.0 1682 */ 1683 function coursetag_get_jscript_links() { 1684 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.'); 1685 } 1686 1687 /** 1688 * @deprecated since 3.0 1689 */ 1690 function coursetag_get_records() { 1691 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' . 1692 'Userid is no longer used for tagging courses.'); 1693 } 1694 1695 /** 1696 * @deprecated since 3.0 1697 */ 1698 function coursetag_store_keywords() { 1699 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' . 1700 'Userid is no longer used for tagging courses.'); 1701 } 1702 1703 /** 1704 * @deprecated since 3.0 1705 */ 1706 function coursetag_delete_keyword() { 1707 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' . 1708 'Userid is no longer used for tagging courses.'); 1709 } 1710 1711 /** 1712 * @deprecated since 3.0 1713 */ 1714 function coursetag_get_tagged_courses() { 1715 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' . 1716 'Userid is no longer used for tagging courses.'); 1717 } 1718 1719 /** 1720 * @deprecated since 3.0 1721 */ 1722 function coursetag_delete_course_tags() { 1723 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' . 1724 'Use core_tag_tag::remove_all_item_tags().'); 1725 } 1726 1727 /** 1728 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead 1729 */ 1730 function tag_type_set() { 1731 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' . 1732 'core_tag_tag::get($tagid)->update().'); 1733 } 1734 1735 /** 1736 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead 1737 */ 1738 function tag_description_set() { 1739 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' . 1740 'core_tag_tag::get($tagid)->update().'); 1741 } 1742 1743 /** 1744 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead 1745 */ 1746 function tag_get_tags() { 1747 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' . 1748 'core_tag_tag::get_item_tags().'); 1749 } 1750 1751 /** 1752 * @deprecated since 3.1 1753 */ 1754 function tag_get_tags_array() { 1755 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' . 1756 'core_tag_tag::get_item_tags_array().'); 1757 } 1758 1759 /** 1760 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()) 1761 */ 1762 function tag_get_tags_csv() { 1763 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' . 1764 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).'); 1765 } 1766 1767 /** 1768 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead 1769 */ 1770 function tag_get_tags_ids() { 1771 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' . 1772 'core_tag_tag::get_item_tags() or similar methods.'); 1773 } 1774 1775 /** 1776 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk() 1777 */ 1778 function tag_get_id() { 1779 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' . 1780 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()'); 1781 } 1782 1783 /** 1784 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead 1785 */ 1786 function tag_rename() { 1787 throw new coding_exception('tag_rename() can not be used anymore. Please use ' . 1788 'core_tag_tag::get($tagid)->update()'); 1789 } 1790 1791 /** 1792 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead 1793 */ 1794 function tag_delete_instance() { 1795 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' . 1796 'core_tag_tag::remove_item_tag()'); 1797 } 1798 1799 /** 1800 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead 1801 */ 1802 function tag_find_records() { 1803 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' . 1804 'core_tag_tag::get_by_name()->get_tagged_items()'); 1805 } 1806 1807 /** 1808 * @deprecated since 3.1 1809 */ 1810 function tag_add() { 1811 throw new coding_exception('tag_add() can not be used anymore. You can use ' . 1812 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' . 1813 'created automatically when assigned to items'); 1814 } 1815 1816 /** 1817 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead 1818 */ 1819 function tag_assign() { 1820 throw new coding_exception('tag_assign() can not be used anymore. Please use ' . 1821 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' . 1822 'ordering should not be set manually'); 1823 } 1824 1825 /** 1826 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead 1827 */ 1828 function tag_record_count() { 1829 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' . 1830 'core_tag_tag::get($tagid)->count_tagged_items().'); 1831 } 1832 1833 /** 1834 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead 1835 */ 1836 function tag_record_tagged_with() { 1837 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' . 1838 'core_tag_tag::get($tagid)->is_item_tagged_with().'); 1839 } 1840 1841 /** 1842 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead 1843 */ 1844 function tag_set_flag() { 1845 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' . 1846 'core_tag_tag::get($tagid)->flag()'); 1847 } 1848 1849 /** 1850 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead 1851 */ 1852 function tag_unset_flag() { 1853 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' . 1854 'core_tag_tag::get($tagid)->reset_flag()'); 1855 } 1856 1857 /** 1858 * @deprecated since 3.1 1859 */ 1860 function tag_print_cloud() { 1861 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' . 1862 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' . 1863 'template core_tag/tagcloud.'); 1864 } 1865 1866 /** 1867 * @deprecated since 3.0 1868 */ 1869 function tag_autocomplete() { 1870 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' . 1871 'element "tags" does proper autocomplete.'); 1872 } 1873 1874 /** 1875 * @deprecated since 3.1 1876 */ 1877 function tag_print_description_box() { 1878 throw new coding_exception('tag_print_description_box() can not be used anymore. ' . 1879 'See core_tag_renderer for similar code'); 1880 } 1881 1882 /** 1883 * @deprecated since 3.1 1884 */ 1885 function tag_print_management_box() { 1886 throw new coding_exception('tag_print_management_box() can not be used anymore. ' . 1887 'See core_tag_renderer for similar code'); 1888 } 1889 1890 /** 1891 * @deprecated since 3.1 1892 */ 1893 function tag_print_search_box() { 1894 throw new coding_exception('tag_print_search_box() can not be used anymore. ' . 1895 'See core_tag_renderer for similar code'); 1896 } 1897 1898 /** 1899 * @deprecated since 3.1 1900 */ 1901 function tag_print_search_results() { 1902 throw new coding_exception('tag_print_search_results() can not be used anymore. ' . 1903 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.'); 1904 } 1905 1906 /** 1907 * @deprecated since 3.1 1908 */ 1909 function tag_print_tagged_users_table() { 1910 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' . 1911 'See core_user_renderer for similar code'); 1912 } 1913 1914 /** 1915 * @deprecated since 3.1 1916 */ 1917 function tag_print_user_box() { 1918 throw new coding_exception('tag_print_user_box() can not be used anymore. ' . 1919 'See core_user_renderer for similar code'); 1920 } 1921 1922 /** 1923 * @deprecated since 3.1 1924 */ 1925 function tag_print_user_list() { 1926 throw new coding_exception('tag_print_user_list() can not be used anymore. ' . 1927 'See core_user_renderer for similar code'); 1928 } 1929 1930 /** 1931 * @deprecated since 3.1 1932 */ 1933 function tag_display_name() { 1934 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' . 1935 'core_tag_tag::make_display_name().'); 1936 1937 } 1938 1939 /** 1940 * @deprecated since 3.1 1941 */ 1942 function tag_normalize() { 1943 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' . 1944 'core_tag_tag::normalize().'); 1945 } 1946 1947 /** 1948 * @deprecated since 3.1 1949 */ 1950 function tag_get_related_tags_csv() { 1951 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' . 1952 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).'); 1953 } 1954 1955 /** 1956 * @deprecated since 3.1 1957 */ 1958 function tag_set() { 1959 throw new coding_exception('tag_set() can not be used anymore. Please use ' . 1960 'core_tag_tag::set_item_tags().'); 1961 } 1962 1963 /** 1964 * @deprecated since 3.1 1965 */ 1966 function tag_set_add() { 1967 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' . 1968 'core_tag_tag::add_item_tag().'); 1969 } 1970 1971 /** 1972 * @deprecated since 3.1 1973 */ 1974 function tag_set_delete() { 1975 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' . 1976 'core_tag_tag::remove_item_tag().'); 1977 } 1978 1979 /** 1980 * @deprecated since 3.1 1981 */ 1982 function tag_get() { 1983 throw new coding_exception('tag_get() can not be used anymore. Please use ' . 1984 'core_tag_tag::get() or core_tag_tag::get_by_name().'); 1985 } 1986 1987 /** 1988 * @deprecated since 3.1 1989 */ 1990 function tag_get_related_tags() { 1991 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' . 1992 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' . 1993 'core_tag_tag::get_manual_related_tags().'); 1994 } 1995 1996 /** 1997 * @deprecated since 3.1 1998 */ 1999 function tag_delete() { 2000 throw new coding_exception('tag_delete() can not be used anymore. Please use ' . 2001 'core_tag_tag::delete_tags().'); 2002 } 2003 2004 /** 2005 * @deprecated since 3.1 2006 */ 2007 function tag_delete_instances() { 2008 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' . 2009 'core_tag_tag::delete_instances().'); 2010 } 2011 2012 /** 2013 * @deprecated since 3.1 2014 */ 2015 function tag_cleanup() { 2016 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' . 2017 '\core\task\tag_cron_task::cleanup().'); 2018 } 2019 2020 /** 2021 * @deprecated since 3.1 2022 */ 2023 function tag_bulk_delete_instances() { 2024 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' . 2025 '\core\task\tag_cron_task::bulk_delete_instances().'); 2026 2027 } 2028 2029 /** 2030 * @deprecated since 3.1 2031 */ 2032 function tag_compute_correlations() { 2033 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' . 2034 'use \core\task\tag_cron_task::compute_correlations().'); 2035 } 2036 2037 /** 2038 * @deprecated since 3.1 2039 */ 2040 function tag_process_computed_correlation() { 2041 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' . 2042 'use \core\task\tag_cron_task::process_computed_correlation().'); 2043 } 2044 2045 /** 2046 * @deprecated since 3.1 2047 */ 2048 function tag_cron() { 2049 throw new coding_exception('tag_cron() can not be used anymore. Please use ' . 2050 'use \core\task\tag_cron_task::execute().'); 2051 } 2052 2053 /** 2054 * @deprecated since 3.1 2055 */ 2056 function tag_find_tags() { 2057 throw new coding_exception('tag_find_tags() can not be used anymore.'); 2058 } 2059 2060 /** 2061 * @deprecated since 3.1 2062 */ 2063 function tag_get_name() { 2064 throw new coding_exception('tag_get_name() can not be used anymore.'); 2065 } 2066 2067 /** 2068 * @deprecated since 3.1 2069 */ 2070 function tag_get_correlated() { 2071 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' . 2072 'use core_tag_tag::get_correlated_tags().'); 2073 2074 } 2075 2076 /** 2077 * @deprecated since 3.1 2078 */ 2079 function tag_cloud_sort() { 2080 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' . 2081 'be found in core_tag_collection::cloud_sort().'); 2082 } 2083 2084 /** 2085 * @deprecated since Moodle 3.1 2086 */ 2087 function events_load_def() { 2088 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2089 2090 } 2091 2092 /** 2093 * @deprecated since Moodle 3.1 2094 */ 2095 function events_queue_handler() { 2096 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2097 } 2098 2099 /** 2100 * @deprecated since Moodle 3.1 2101 */ 2102 function events_dispatch() { 2103 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2104 } 2105 2106 /** 2107 * @deprecated since Moodle 3.1 2108 */ 2109 function events_process_queued_handler() { 2110 throw new coding_exception( 2111 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.' 2112 ); 2113 } 2114 2115 /** 2116 * @deprecated since Moodle 3.1 2117 */ 2118 function events_update_definition() { 2119 throw new coding_exception( 2120 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.' 2121 ); 2122 } 2123 2124 /** 2125 * @deprecated since Moodle 3.1 2126 */ 2127 function events_cron() { 2128 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2129 } 2130 2131 /** 2132 * @deprecated since Moodle 3.1 2133 */ 2134 function events_trigger_legacy() { 2135 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2136 } 2137 2138 /** 2139 * @deprecated since Moodle 3.1 2140 */ 2141 function events_is_registered() { 2142 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2143 } 2144 2145 /** 2146 * @deprecated since Moodle 3.1 2147 */ 2148 function events_pending_count() { 2149 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2150 } 2151 2152 /** 2153 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now. 2154 */ 2155 function clam_message_admins() { 2156 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' . 2157 'message_admins() method of \antivirus_clamav\scanner class.'); 2158 } 2159 2160 /** 2161 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now. 2162 */ 2163 function get_clam_error_code() { 2164 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' . 2165 'get_clam_error_code() method of \antivirus_clamav\scanner class.'); 2166 } 2167 2168 /** 2169 * @deprecated since 3.1 2170 */ 2171 function course_get_cm_rename_action() { 2172 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' . 2173 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.'); 2174 2175 } 2176 2177 /** 2178 * @deprecated since Moodle 3.1 2179 */ 2180 function course_scale_used() { 2181 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' . 2182 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored'); 2183 } 2184 2185 /** 2186 * @deprecated since Moodle 3.1 2187 */ 2188 function site_scale_used() { 2189 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' . 2190 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored'); 2191 } 2192 2193 /** 2194 * @deprecated since Moodle 3.1. Use external_api::external_function_info(). 2195 */ 2196 function external_function_info() { 2197 throw new coding_exception('external_function_info() can not be used any'. 2198 'more. Please use external_api::external_function_info() instead.'); 2199 } 2200 2201 /** 2202 * @deprecated since Moodle 3.2 2203 * @see csv_import_reader::load_csv_content() 2204 */ 2205 function get_records_csv() { 2206 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' . 2207 'lib/csvlib.class.php csv_import_reader() instead.'); 2208 } 2209 2210 /** 2211 * @deprecated since Moodle 3.2 2212 * @see download_as_dataformat (lib/dataformatlib.php) 2213 */ 2214 function put_records_csv() { 2215 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' . 2216 'lib/dataformatlib.php download_as_dataformat() instead.'); 2217 } 2218 2219 /** 2220 * @deprecated since Moodle 3.2 2221 */ 2222 function css_is_colour() { 2223 throw new coding_exception('css_is_colour() can not be used anymore.'); 2224 } 2225 2226 /** 2227 * @deprecated since Moodle 3.2 2228 */ 2229 function css_is_width() { 2230 throw new coding_exception('css_is_width() can not be used anymore.'); 2231 } 2232 2233 /** 2234 * @deprecated since Moodle 3.2 2235 */ 2236 function css_sort_by_count() { 2237 throw new coding_exception('css_sort_by_count() can not be used anymore.'); 2238 } 2239 2240 /** 2241 * @deprecated since Moodle 3.2 2242 */ 2243 function message_get_course_contexts() { 2244 throw new coding_exception('message_get_course_contexts() can not be used anymore.'); 2245 } 2246 2247 /** 2248 * @deprecated since Moodle 3.2 2249 */ 2250 function message_remove_url_params() { 2251 throw new coding_exception('message_remove_url_params() can not be used anymore.'); 2252 } 2253 2254 /** 2255 * @deprecated since Moodle 3.2 2256 */ 2257 function message_count_messages() { 2258 throw new coding_exception('message_count_messages() can not be used anymore.'); 2259 } 2260 2261 /** 2262 * @deprecated since Moodle 3.2 2263 */ 2264 function message_count_blocked_users() { 2265 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' . 2266 '\core_message\api::count_blocked_users() instead.'); 2267 } 2268 2269 /** 2270 * @deprecated since Moodle 3.2 2271 */ 2272 function message_contact_link() { 2273 throw new coding_exception('message_contact_link() can not be used anymore.'); 2274 } 2275 2276 /** 2277 * @deprecated since Moodle 3.2 2278 */ 2279 function message_get_recent_notifications() { 2280 throw new coding_exception('message_get_recent_notifications() can not be used anymore.'); 2281 } 2282 2283 /** 2284 * @deprecated since Moodle 3.2 2285 */ 2286 function message_history_link() { 2287 throw new coding_exception('message_history_link() can not be used anymore.'); 2288 } 2289 2290 /** 2291 * @deprecated since Moodle 3.2 2292 */ 2293 function message_search() { 2294 throw new coding_exception('message_search() can not be used anymore.'); 2295 } 2296 2297 /** 2298 * @deprecated since Moodle 3.2 2299 */ 2300 function message_shorten_message() { 2301 throw new coding_exception('message_shorten_message() can not be used anymore.'); 2302 } 2303 2304 /** 2305 * @deprecated since Moodle 3.2 2306 */ 2307 function message_get_fragment() { 2308 throw new coding_exception('message_get_fragment() can not be used anymore.'); 2309 } 2310 2311 /** 2312 * @deprecated since Moodle 3.2 2313 */ 2314 function message_get_history() { 2315 throw new coding_exception('message_get_history() can not be used anymore.'); 2316 } 2317 2318 /** 2319 * @deprecated since Moodle 3.2 2320 */ 2321 function message_get_contact_add_remove_link() { 2322 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.'); 2323 } 2324 2325 /** 2326 * @deprecated since Moodle 3.2 2327 */ 2328 function message_get_contact_block_link() { 2329 throw new coding_exception('message_get_contact_block_link() can not be used anymore.'); 2330 } 2331 2332 /** 2333 * @deprecated since Moodle 3.2 2334 */ 2335 function message_mark_messages_read() { 2336 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' . 2337 '\core_message\api::mark_all_messages_as_read() instead.'); 2338 } 2339 2340 /** 2341 * @deprecated since Moodle 3.2 2342 */ 2343 function message_can_post_message() { 2344 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' . 2345 '\core_message\api::can_send_message() instead.'); 2346 } 2347 2348 /** 2349 * @deprecated since Moodle 3.2 2350 */ 2351 function message_is_user_non_contact_blocked() { 2352 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' . 2353 '\core_message\api::is_user_non_contact_blocked() instead.'); 2354 } 2355 2356 /** 2357 * @deprecated since Moodle 3.2 2358 */ 2359 function message_is_user_blocked() { 2360 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' . 2361 '\core_message\api::is_user_blocked() instead.'); 2362 } 2363 2364 /** 2365 * @deprecated since Moodle 3.2 2366 */ 2367 function print_log() { 2368 throw new coding_exception('print_log() can not be used anymore. Please use the ' . 2369 'report_log framework instead.'); 2370 } 2371 2372 /** 2373 * @deprecated since Moodle 3.2 2374 */ 2375 function print_mnet_log() { 2376 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' . 2377 'report_log framework instead.'); 2378 } 2379 2380 /** 2381 * @deprecated since Moodle 3.2 2382 */ 2383 function print_log_csv() { 2384 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' . 2385 'report_log framework instead.'); 2386 } 2387 2388 /** 2389 * @deprecated since Moodle 3.2 2390 */ 2391 function print_log_xls() { 2392 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' . 2393 'report_log framework instead.'); 2394 } 2395 2396 /** 2397 * @deprecated since Moodle 3.2 2398 */ 2399 function print_log_ods() { 2400 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' . 2401 'report_log framework instead.'); 2402 } 2403 2404 /** 2405 * @deprecated since Moodle 3.2 2406 */ 2407 function build_logs_array() { 2408 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' . 2409 'report_log framework instead.'); 2410 } 2411 2412 /** 2413 * @deprecated since Moodle 3.2 2414 */ 2415 function get_logs_usercourse() { 2416 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' . 2417 'report_log framework instead.'); 2418 } 2419 2420 /** 2421 * @deprecated since Moodle 3.2 2422 */ 2423 function get_logs_userday() { 2424 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' . 2425 'report_log framework instead.'); 2426 } 2427 2428 /** 2429 * @deprecated since Moodle 3.2 2430 */ 2431 function get_logs() { 2432 throw new coding_exception('get_logs() can not be used anymore. Please use the ' . 2433 'report_log framework instead.'); 2434 } 2435 2436 /** 2437 * @deprecated since Moodle 3.2 2438 */ 2439 function prevent_form_autofill_password() { 2440 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.'); 2441 } 2442 2443 /** 2444 * @deprecated since Moodle 3.3 MDL-57370 2445 */ 2446 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) { 2447 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' . 2448 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER); 2449 } 2450 2451 /** 2452 * @deprecated since Moodle 3.2 2453 */ 2454 function calendar_preferences_button() { 2455 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' . 2456 'preferences are now linked to the user preferences page.'); 2457 } 2458 2459 /** 2460 * @deprecated since 3.3 2461 */ 2462 function calendar_wday_name() { 2463 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.'); 2464 } 2465 2466 /** 2467 * @deprecated since 3.3 2468 */ 2469 function calendar_get_block_upcoming() { 2470 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' . 2471 'Please see block_calendar_upcoming::get_content() for the correct API usage.'); 2472 } 2473 2474 /** 2475 * @deprecated since 3.3 2476 */ 2477 function calendar_print_month_selector() { 2478 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.'); 2479 } 2480 2481 /** 2482 * @deprecated since 3.3 2483 */ 2484 function calendar_cron() { 2485 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.'); 2486 } 2487 2488 /** 2489 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398. 2490 */ 2491 function load_course_context() { 2492 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.'); 2493 } 2494 2495 /** 2496 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398. 2497 */ 2498 function load_role_access_by_context() { 2499 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.'); 2500 } 2501 2502 /** 2503 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398. 2504 */ 2505 function dedupe_user_access() { 2506 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.'); 2507 } 2508 2509 /** 2510 * @deprecated since Moodle 3.4. MDL-49398. 2511 */ 2512 function get_user_access_sitewide() { 2513 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.'); 2514 } 2515 2516 /** 2517 * @deprecated since Moodle 3.4. MDL-59333 2518 */ 2519 function calendar_get_mini() { 2520 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.'); 2521 } 2522 2523 /** 2524 * @deprecated since Moodle 3.4. MDL-59333 2525 */ 2526 function calendar_get_upcoming() { 2527 throw new coding_exception('calendar_get_upcoming() has been removed. ' . 2528 'Please see block_calendar_upcoming::get_content() for the correct API usage.'); 2529 } 2530 2531 /** 2532 * @deprecated since Moodle 3.4. MDL-50666 2533 */ 2534 function allow_override() { 2535 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.'); 2536 } 2537 2538 /** 2539 * @deprecated since Moodle 3.4. MDL-50666 2540 */ 2541 function allow_assign() { 2542 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.'); 2543 } 2544 2545 /** 2546 * @deprecated since Moodle 3.4. MDL-50666 2547 */ 2548 function allow_switch() { 2549 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.'); 2550 } 2551 2552 /** 2553 * @deprecated since Moodle 3.5. MDL-61132 2554 */ 2555 function question_add_tops() { 2556 throw new coding_exception( 2557 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().' 2558 ); 2559 } 2560 2561 /** 2562 * @deprecated since Moodle 3.5. MDL-61132 2563 */ 2564 function question_is_only_toplevel_category_in_context() { 2565 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. ' 2566 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.'); 2567 } 2568 2569 /** 2570 * @deprecated since Moodle 3.5 2571 */ 2572 function message_move_userfrom_unread2read() { 2573 throw new coding_exception('message_move_userfrom_unread2read() has been removed.'); 2574 } 2575 2576 /** 2577 * @deprecated since Moodle 3.5 2578 */ 2579 function message_get_blocked_users() { 2580 throw new coding_exception( 2581 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.' 2582 ); 2583 } 2584 2585 /** 2586 * @deprecated since Moodle 3.5 2587 */ 2588 function message_get_contacts() { 2589 throw new coding_exception('message_get_contacts() has been removed.'); 2590 } 2591 2592 /** 2593 * @deprecated since Moodle 3.5 2594 */ 2595 function message_mark_message_read() { 2596 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read() 2597 or \core_message\api::mark_notification_as_read().'); 2598 } 2599 2600 /** 2601 * @deprecated since Moodle 3.5 2602 */ 2603 function message_can_delete_message() { 2604 throw new coding_exception( 2605 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.' 2606 ); 2607 } 2608 2609 /** 2610 * @deprecated since Moodle 3.5 2611 */ 2612 function message_delete_message() { 2613 throw new coding_exception( 2614 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.' 2615 ); 2616 } 2617 2618 /** 2619 * @deprecated since 3.6 2620 */ 2621 function calendar_get_all_allowed_types() { 2622 throw new coding_exception( 2623 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.' 2624 ); 2625 2626 } 2627 2628 /** 2629 * @deprecated since Moodle 3.6. 2630 */ 2631 function groups_get_all_groups_for_courses() { 2632 throw new coding_exception( 2633 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.' 2634 ); 2635 } 2636 2637 /** 2638 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2639 */ 2640 function events_get_cached() { 2641 throw new coding_exception( 2642 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2643 ); 2644 } 2645 2646 /** 2647 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2648 */ 2649 function events_uninstall() { 2650 throw new coding_exception( 2651 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2652 ); 2653 } 2654 2655 /** 2656 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2657 */ 2658 function events_cleanup() { 2659 throw new coding_exception( 2660 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2661 ); 2662 } 2663 2664 /** 2665 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2666 */ 2667 function events_dequeue() { 2668 throw new coding_exception( 2669 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2670 ); 2671 } 2672 2673 /** 2674 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2675 */ 2676 function events_get_handlers() { 2677 throw new coding_exception( 2678 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2679 ); 2680 } 2681 2682 /** 2683 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context(). 2684 */ 2685 function get_roles_on_exact_context() { 2686 throw new coding_exception( 2687 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.' 2688 ); 2689 } 2690 2691 /** 2692 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context(). 2693 */ 2694 function get_roles_with_assignment_on_context() { 2695 throw new coding_exception( 2696 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.' 2697 ); 2698 } 2699 2700 /** 2701 * @deprecated since Moodle 3.6 2702 */ 2703 function message_add_contact() { 2704 throw new coding_exception( 2705 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' . 2706 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' . 2707 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.' 2708 ); 2709 } 2710 2711 /** 2712 * @deprecated since Moodle 3.6 2713 */ 2714 function message_remove_contact() { 2715 throw new coding_exception( 2716 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.' 2717 ); 2718 } 2719 2720 /** 2721 * @deprecated since Moodle 3.6 2722 */ 2723 function message_unblock_contact() { 2724 throw new coding_exception( 2725 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.' 2726 ); 2727 } 2728 2729 /** 2730 * @deprecated since Moodle 3.6 2731 */ 2732 function message_block_contact() { 2733 throw new coding_exception( 2734 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' . 2735 '\core_message\api::block_user() instead.' 2736 ); 2737 } 2738 2739 /** 2740 * @deprecated since Moodle 3.6 2741 */ 2742 function message_get_contact() { 2743 throw new coding_exception( 2744 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.' 2745 ); 2746 } 2747 2748 /** 2749 * @deprecated since Moodle 3.7 2750 */ 2751 function get_courses_page() { 2752 throw new coding_exception( 2753 'Function get_courses_page() has been removed. Please use core_course_category::get_courses() ' . 2754 'or core_course_category::search_courses()' 2755 ); 2756 } 2757 2758 /** 2759 * Returns the models that generated insights in the provided context. 2760 * 2761 * @deprecated since Moodle 3.8 MDL-66091 - please do not use this function any more. 2762 * @todo MDL-65799 This will be deleted in Moodle 4.0 2763 * @see \core_analytics\manager::cached_models_with_insights 2764 * @param \context $context 2765 * @return int[] 2766 */ 2767 function report_insights_context_insights(\context $context) { 2768 2769 debugging('report_insights_context_insights is deprecated. Please use ' . 2770 '\core_analytics\manager::cached_models_with_insights instead', DEBUG_DEVELOPER); 2771 2772 return \core_analytics\manager::cached_models_with_insights($context); 2773 } 2774 2775 /** 2776 * Retrieve all metadata for the requested modules 2777 * 2778 * @deprecated since 3.9. 2779 * @param object $course The Course 2780 * @param array $modnames An array containing the list of modules and their 2781 * names 2782 * @param int $sectionreturn The section to return to 2783 * @return array A list of stdClass objects containing metadata about each 2784 * module 2785 */ 2786 function get_module_metadata($course, $modnames, $sectionreturn = null) { 2787 global $OUTPUT; 2788 2789 debugging('get_module_metadata is deprecated. Please use \core_course\local\service\content_item_service instead.'); 2790 2791 // get_module_metadata will be called once per section on the page and courses may show 2792 // different modules to one another 2793 static $modlist = array(); 2794 if (!isset($modlist[$course->id])) { 2795 $modlist[$course->id] = array(); 2796 } 2797 2798 $return = array(); 2799 $urlbase = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey())); 2800 if ($sectionreturn !== null) { 2801 $urlbase->param('sr', $sectionreturn); 2802 } 2803 foreach($modnames as $modname => $modnamestr) { 2804 if (!course_allowed_module($course, $modname)) { 2805 continue; 2806 } 2807 if (isset($modlist[$course->id][$modname])) { 2808 // This module is already cached 2809 $return += $modlist[$course->id][$modname]; 2810 continue; 2811 } 2812 $modlist[$course->id][$modname] = array(); 2813 2814 // Create an object for a default representation of this module type in the activity chooser. It will be used 2815 // if module does not implement callback get_shortcuts() and it will also be passed to the callback if it exists. 2816 $defaultmodule = new stdClass(); 2817 $defaultmodule->title = $modnamestr; 2818 $defaultmodule->name = $modname; 2819 $defaultmodule->link = new moodle_url($urlbase, array('add' => $modname)); 2820 $defaultmodule->icon = $OUTPUT->pix_icon('icon', '', $defaultmodule->name, array('class' => 'icon')); 2821 $sm = get_string_manager(); 2822 if ($sm->string_exists('modulename_help', $modname)) { 2823 $defaultmodule->help = get_string('modulename_help', $modname); 2824 if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs. 2825 $link = get_string('modulename_link', $modname); 2826 $linktext = get_string('morehelp'); 2827 $defaultmodule->help .= html_writer::tag('div', 2828 $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink')); 2829 } 2830 } 2831 $defaultmodule->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER); 2832 2833 // Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list 2834 // of elements to be added to activity chooser. 2835 $items = component_callback($modname, 'get_shortcuts', array($defaultmodule), null); 2836 if ($items !== null) { 2837 foreach ($items as $item) { 2838 // Add all items to the return array. All items must have different links, use them as a key in the return array. 2839 if (!isset($item->archetype)) { 2840 $item->archetype = $defaultmodule->archetype; 2841 } 2842 if (!isset($item->icon)) { 2843 $item->icon = $defaultmodule->icon; 2844 } 2845 // If plugin returned the only one item with the same link as default item - cache it as $modname, 2846 // otherwise append the link url to the module name. 2847 $item->name = (count($items) == 1 && 2848 $item->link->out() === $defaultmodule->link->out()) ? $modname : $modname . ':' . $item->link; 2849 2850 // If the module provides the helptext property, append it to the help text to match the look and feel 2851 // of the default course modules. 2852 if (isset($item->help) && isset($item->helplink)) { 2853 $linktext = get_string('morehelp'); 2854 $item->help .= html_writer::tag('div', 2855 $OUTPUT->doc_link($item->helplink, $linktext, true), array('class' => 'helpdoclink')); 2856 } 2857 $modlist[$course->id][$modname][$item->name] = $item; 2858 } 2859 $return += $modlist[$course->id][$modname]; 2860 // If get_shortcuts() callback is defined, the default module action is not added. 2861 // It is a responsibility of the callback to add it to the return value unless it is not needed. 2862 continue; 2863 } 2864 2865 // The callback get_shortcuts() was not found, use the default item for the activity chooser. 2866 $modlist[$course->id][$modname][$modname] = $defaultmodule; 2867 $return[$modname] = $defaultmodule; 2868 } 2869 2870 core_collator::asort_objects_by_property($return, 'title'); 2871 return $return; 2872 } 2873 2874 /** 2875 * Runs a single cron task. This function assumes it is displaying output in pseudo-CLI mode. 2876 * 2877 * The function will fail if the task is disabled. 2878 * 2879 * Warning: Because this function closes the browser session, it may not be safe to continue 2880 * with other processing (other than displaying the rest of the page) after using this function! 2881 * 2882 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task). 2883 * @todo final deprecation. To be removed in Moodle 4.1 MDL-63594. 2884 * @param \core\task\scheduled_task $task Task to run 2885 * @return bool True if cron run successful 2886 */ 2887 function cron_run_single_task(\core\task\scheduled_task $task) { 2888 debugging('cron_run_single_task() is deprecated. Please use \\core\task\manager::run_from_cli() instead.', 2889 DEBUG_DEVELOPER); 2890 return \core\task\manager::run_from_cli($task); 2891 } 2892 2893 /** 2894 * Executes cron functions for a specific type of plugin. 2895 * 2896 * @param string $plugintype Plugin type (e.g. 'report') 2897 * @param string $description If specified, will display 'Starting (whatever)' 2898 * and 'Finished (whatever)' lines, otherwise does not display 2899 * 2900 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API. 2901 * @todo MDL-61165 This will be deleted in Moodle 4.1. 2902 */ 2903 function cron_execute_plugin_type($plugintype, $description = null) { 2904 global $DB; 2905 2906 // Get list from plugin => function for all plugins. 2907 $plugins = get_plugin_list_with_function($plugintype, 'cron'); 2908 2909 // Modify list for backward compatibility (different files/names). 2910 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins); 2911 2912 // Return if no plugins with cron function to process. 2913 if (!$plugins) { 2914 return; 2915 } 2916 2917 if ($description) { 2918 mtrace('Starting '.$description); 2919 } 2920 2921 foreach ($plugins as $component => $cronfunction) { 2922 $dir = core_component::get_component_directory($component); 2923 2924 // Get cron period if specified in version.php, otherwise assume every cron. 2925 $cronperiod = 0; 2926 if (file_exists("$dir/version.php")) { 2927 $plugin = new stdClass(); 2928 include("$dir/version.php"); 2929 if (isset($plugin->cron)) { 2930 $cronperiod = $plugin->cron; 2931 } 2932 } 2933 2934 // Using last cron and cron period, don't run if it already ran recently. 2935 $lastcron = get_config($component, 'lastcron'); 2936 if ($cronperiod && $lastcron) { 2937 if ($lastcron + $cronperiod > time()) { 2938 // Do not execute cron yet. 2939 continue; 2940 } 2941 } 2942 2943 mtrace('Processing cron function for ' . $component . '...'); 2944 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER); 2945 cron_trace_time_and_memory(); 2946 $pre_dbqueries = $DB->perf_get_queries(); 2947 $pre_time = microtime(true); 2948 2949 $cronfunction(); 2950 2951 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " . 2952 round(microtime(true) - $pre_time, 2) . " seconds)"); 2953 2954 set_config('lastcron', time(), $component); 2955 core_php_time_limit::raise(); 2956 } 2957 2958 if ($description) { 2959 mtrace('Finished ' . $description); 2960 } 2961 } 2962 2963 /** 2964 * Used to add in old-style cron functions within plugins that have not been converted to the 2965 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used 2966 * cron.php and some used a different name.) 2967 * 2968 * @param string $plugintype Plugin type e.g. 'report' 2969 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g. 2970 * 'report_frog_cron') for plugin cron functions that were already found using the new API 2971 * @return array Revised version of $plugins that adds in any extra plugin functions found by 2972 * looking in the older location 2973 * 2974 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API. 2975 * @todo MDL-61165 This will be deleted in Moodle 4.1. 2976 */ 2977 function cron_bc_hack_plugin_functions($plugintype, $plugins) { 2978 global $CFG; // Mandatory in case it is referenced by include()d PHP script. 2979 2980 if ($plugintype === 'report') { 2981 // Admin reports only - not course report because course report was 2982 // never implemented before, so doesn't need BC. 2983 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) { 2984 $component = $plugintype . '_' . $pluginname; 2985 if (isset($plugins[$component])) { 2986 // We already have detected the function using the new API. 2987 continue; 2988 } 2989 if (!file_exists("$dir/cron.php")) { 2990 // No old style cron file present. 2991 continue; 2992 } 2993 include_once("$dir/cron.php"); 2994 $cronfunction = $component . '_cron'; 2995 if (function_exists($cronfunction)) { 2996 $plugins[$component] = $cronfunction; 2997 } else { 2998 debugging("Invalid legacy cron.php detected in $component, " . 2999 "please use lib.php instead"); 3000 } 3001 } 3002 } else if (strpos($plugintype, 'grade') === 0) { 3003 // Detect old style cron function names. 3004 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of 3005 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport. 3006 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) { 3007 $component = $plugintype.'_'.$pluginname; 3008 if (isset($plugins[$component])) { 3009 // We already have detected the function using the new API. 3010 continue; 3011 } 3012 if (!file_exists("$dir/lib.php")) { 3013 continue; 3014 } 3015 include_once("$dir/lib.php"); 3016 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' . 3017 $pluginname . '_cron'; 3018 if (function_exists($cronfunction)) { 3019 $plugins[$component] = $cronfunction; 3020 } 3021 } 3022 } 3023 3024 return $plugins; 3025 } 3026 3027 /** 3028 * Returns the SQL used by the participants table. 3029 * 3030 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants. 3031 * @param int $courseid The course id 3032 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group 3033 * @param int $accesssince The time since last access, 0 means any time 3034 * @param int $roleid The role id, 0 means all roles and -1 no roles 3035 * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned. 3036 * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed. 3037 * @param string|array $search The search that was performed, empty means perform no search 3038 * @param string $additionalwhere Any additional SQL to add to where 3039 * @param array $additionalparams The additional params 3040 * @return array 3041 */ 3042 function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1, 3043 $search = '', $additionalwhere = '', $additionalparams = array()) { 3044 global $DB, $USER, $CFG; 3045 3046 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' . 3047 'Please use \core\table\participants_search::class with table filtersets instead.'; 3048 debugging($deprecatedtext, DEBUG_DEVELOPER); 3049 3050 // Get the context. 3051 $context = \context_course::instance($courseid, MUST_EXIST); 3052 3053 $isfrontpage = ($courseid == SITEID); 3054 3055 // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments. 3056 $onlyactive = true; 3057 $onlysuspended = false; 3058 if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) { 3059 switch ($statusid) { 3060 case ENROL_USER_ACTIVE: 3061 // Nothing to do here. 3062 break; 3063 case ENROL_USER_SUSPENDED: 3064 $onlyactive = false; 3065 $onlysuspended = true; 3066 break; 3067 default: 3068 // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false. 3069 $onlyactive = false; 3070 break; 3071 } 3072 } 3073 3074 list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid); 3075 3076 $joins = array('FROM {user} u'); 3077 $wheres = array(); 3078 3079 // TODO Does not support custom user profile fields (MDL-70456). 3080 $userfields = \core_user\fields::get_identity_fields($context, false); 3081 $userfieldsapi = \core_user\fields::for_userpic()->including(...$userfields); 3082 $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false)->selects; 3083 3084 if ($isfrontpage) { 3085 $select = "SELECT $userfieldssql, u.lastaccess"; 3086 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually. 3087 if ($accesssince) { 3088 $wheres[] = user_get_user_lastaccess_sql($accesssince); 3089 } 3090 } else { 3091 $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess"; 3092 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only. 3093 // Not everybody has accessed the course yet. 3094 $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)'; 3095 $params['courseid'] = $courseid; 3096 if ($accesssince) { 3097 $wheres[] = user_get_course_lastaccess_sql($accesssince); 3098 } 3099 } 3100 3101 // Performance hacks - we preload user contexts together with accounts. 3102 $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); 3103 $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)'; 3104 $params['contextlevel'] = CONTEXT_USER; 3105 $select .= $ccselect; 3106 $joins[] = $ccjoin; 3107 3108 // Limit list to users with some role only. 3109 if ($roleid) { 3110 // We want to query both the current context and parent contexts. 3111 list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), 3112 SQL_PARAMS_NAMED, 'relatedctx'); 3113 3114 // Get users without any role. 3115 if ($roleid == -1) { 3116 $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)"; 3117 $params = array_merge($params, $relatedctxparams); 3118 } else { 3119 $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)"; 3120 $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams); 3121 } 3122 } 3123 3124 if (!empty($search)) { 3125 if (!is_array($search)) { 3126 $search = [$search]; 3127 } 3128 foreach ($search as $index => $keyword) { 3129 $searchkey1 = 'search' . $index . '1'; 3130 $searchkey2 = 'search' . $index . '2'; 3131 $searchkey3 = 'search' . $index . '3'; 3132 $searchkey4 = 'search' . $index . '4'; 3133 $searchkey5 = 'search' . $index . '5'; 3134 $searchkey6 = 'search' . $index . '6'; 3135 $searchkey7 = 'search' . $index . '7'; 3136 3137 $conditions = array(); 3138 // Search by fullname. 3139 $fullname = $DB->sql_fullname('u.firstname', 'u.lastname'); 3140 $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false); 3141 3142 // Search by email. 3143 $email = $DB->sql_like('email', ':' . $searchkey2, false, false); 3144 if (!in_array('email', $userfields)) { 3145 $maildisplay = 'maildisplay' . $index; 3146 $userid1 = 'userid' . $index . '1'; 3147 // Prevent users who hide their email address from being found by others 3148 // who aren't allowed to see hidden email addresses. 3149 $email = "(". $email ." AND (" . 3150 "u.maildisplay <> :$maildisplay " . 3151 "OR u.id = :$userid1". // User can always find himself. 3152 "))"; 3153 $params[$maildisplay] = core_user::MAILDISPLAY_HIDE; 3154 $params[$userid1] = $USER->id; 3155 } 3156 $conditions[] = $email; 3157 3158 // Search by idnumber. 3159 $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false); 3160 if (!in_array('idnumber', $userfields)) { 3161 $userid2 = 'userid' . $index . '2'; 3162 // Users who aren't allowed to see idnumbers should at most find themselves 3163 // when searching for an idnumber. 3164 $idnumber = "(". $idnumber . " AND u.id = :$userid2)"; 3165 $params[$userid2] = $USER->id; 3166 } 3167 $conditions[] = $idnumber; 3168 3169 // TODO Does not support custom user profile fields (MDL-70456). 3170 $extrasearchfields = \core_user\fields::get_identity_fields($context, false); 3171 if (!empty($extrasearchfields)) { 3172 // Search all user identify fields. 3173 foreach ($extrasearchfields as $extrasearchfield) { 3174 if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) { 3175 // Already covered above. Search by country not supported. 3176 continue; 3177 } 3178 $param = $searchkey3 . $extrasearchfield; 3179 $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false); 3180 $params[$param] = "%$keyword%"; 3181 if (!in_array($extrasearchfield, $userfields)) { 3182 // User cannot see this field, but allow match if their own account. 3183 $userid3 = 'userid' . $index . '3' . $extrasearchfield; 3184 $condition = "(". $condition . " AND u.id = :$userid3)"; 3185 $params[$userid3] = $USER->id; 3186 } 3187 $conditions[] = $condition; 3188 } 3189 } 3190 3191 // Search by middlename. 3192 $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false); 3193 $conditions[] = $middlename; 3194 3195 // Search by alternatename. 3196 $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false); 3197 $conditions[] = $alternatename; 3198 3199 // Search by firstnamephonetic. 3200 $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false); 3201 $conditions[] = $firstnamephonetic; 3202 3203 // Search by lastnamephonetic. 3204 $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false); 3205 $conditions[] = $lastnamephonetic; 3206 3207 $wheres[] = "(". implode(" OR ", $conditions) .") "; 3208 $params[$searchkey1] = "%$keyword%"; 3209 $params[$searchkey2] = "%$keyword%"; 3210 $params[$searchkey3] = "%$keyword%"; 3211 $params[$searchkey4] = "%$keyword%"; 3212 $params[$searchkey5] = "%$keyword%"; 3213 $params[$searchkey6] = "%$keyword%"; 3214 $params[$searchkey7] = "%$keyword%"; 3215 } 3216 } 3217 3218 if (!empty($additionalwhere)) { 3219 $wheres[] = $additionalwhere; 3220 $params = array_merge($params, $additionalparams); 3221 } 3222 3223 $from = implode("\n", $joins); 3224 if ($wheres) { 3225 $where = 'WHERE ' . implode(' AND ', $wheres); 3226 } else { 3227 $where = ''; 3228 } 3229 3230 return array($select, $from, $where, $params); 3231 } 3232 3233 /** 3234 * Returns the total number of participants for a given course. 3235 * 3236 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants. 3237 * @param int $courseid The course id 3238 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group 3239 * @param int $accesssince The time since last access, 0 means any time 3240 * @param int $roleid The role id, 0 means all roles 3241 * @param int $enrolid The applied filter for the user enrolment ID. 3242 * @param int $status The applied filter for the user's enrolment status. 3243 * @param string|array $search The search that was performed, empty means perform no search 3244 * @param string $additionalwhere Any additional SQL to add to where 3245 * @param array $additionalparams The additional params 3246 * @return int 3247 */ 3248 function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1, 3249 $search = '', $additionalwhere = '', $additionalparams = array()) { 3250 global $DB; 3251 3252 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' . 3253 'Please use \core\table\participants_search::class with table filtersets instead.'; 3254 debugging($deprecatedtext, DEBUG_DEVELOPER); 3255 3256 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid, 3257 $statusid, $search, $additionalwhere, $additionalparams); 3258 3259 return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params); 3260 } 3261 3262 /** 3263 * Returns the participants for a given course. 3264 * 3265 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants. 3266 * @param int $courseid The course id 3267 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group 3268 * @param int $accesssince The time since last access 3269 * @param int $roleid The role id 3270 * @param int $enrolid The applied filter for the user enrolment ID. 3271 * @param int $status The applied filter for the user's enrolment status. 3272 * @param string $search The search that was performed 3273 * @param string $additionalwhere Any additional SQL to add to where 3274 * @param array $additionalparams The additional params 3275 * @param string $sort The SQL sort 3276 * @param int $limitfrom return a subset of records, starting at this point (optional). 3277 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). 3278 * @return moodle_recordset 3279 */ 3280 function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enrolid, $statusid, $search, 3281 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) { 3282 global $DB; 3283 3284 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' . 3285 'Please use \core\table\participants_search::class with table filtersets instead.'; 3286 debugging($deprecatedtext, DEBUG_DEVELOPER); 3287 3288 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid, 3289 $statusid, $search, $additionalwhere, $additionalparams); 3290 3291 return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum); 3292 } 3293 3294 /** 3295 * Returns the list of full course categories to be used in html_writer::select() 3296 * 3297 * Calls {@see core_course_category::make_categories_list()} to build the list. 3298 * 3299 * @deprecated since Moodle 3.10 3300 * @todo This will be finally removed for Moodle 4.2 as part of MDL-69124. 3301 * @return array array mapping course category id to the display name 3302 */ 3303 function make_categories_options() { 3304 $deprecatedtext = __FUNCTION__ . '() is deprecated. Please use \core_course_category::make_categories_list() instead.'; 3305 debugging($deprecatedtext, DEBUG_DEVELOPER); 3306 3307 return core_course_category::make_categories_list('', 0, ' / '); 3308 } 3309 3310 /** 3311 * Checks if current user is shown any extra fields when listing users. 3312 * 3313 * Does not include any custom profile fields. 3314 * 3315 * @param object $context Context 3316 * @param array $already Array of fields that we're going to show anyway 3317 * so don't bother listing them 3318 * @return array Array of field names from user table, not including anything 3319 * listed in $already 3320 * @deprecated since Moodle 3.11 MDL-45242 3321 * @see \core_user\fields 3322 */ 3323 function get_extra_user_fields($context, $already = array()) { 3324 debugging('get_extra_user_fields() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER); 3325 3326 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already); 3327 return $fields->get_required_fields(); 3328 } 3329 3330 /** 3331 * If the current user is to be shown extra user fields when listing or 3332 * selecting users, returns a string suitable for including in an SQL select 3333 * clause to retrieve those fields. 3334 * 3335 * Does not include any custom profile fields. 3336 * 3337 * @param context $context Context 3338 * @param string $alias Alias of user table, e.g. 'u' (default none) 3339 * @param string $prefix Prefix for field names using AS, e.g. 'u_' (default none) 3340 * @param array $already Array of fields that we're going to include anyway so don't list them (default none) 3341 * @return string Partial SQL select clause, beginning with comma, for example ',u.idnumber,u.department' unless it is blank 3342 * @deprecated since Moodle 3.11 MDL-45242 3343 * @see \core_user\fields 3344 */ 3345 function get_extra_user_fields_sql($context, $alias='', $prefix='', $already = array()) { 3346 debugging('get_extra_user_fields_sql() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER); 3347 3348 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already); 3349 // Note: There will never be any joins or join params because we turned off profile fields. 3350 $selects = $fields->get_sql($alias, false, $prefix)->selects; 3351 3352 return $selects; 3353 } 3354 3355 /** 3356 * Returns the display name of a field in the user table. Works for most fields that are commonly displayed to users. 3357 * 3358 * Also works for custom fields. 3359 * 3360 * @param string $field Field name, e.g. 'phone1' 3361 * @return string Text description taken from language file, e.g. 'Phone number' 3362 * @deprecated since Moodle 3.11 MDL-45242 3363 * @see \core_user\fields 3364 */ 3365 function get_user_field_name($field) { 3366 debugging('get_user_field_name() is deprecated. Please use \core_user\fields::get_display_name() instead', DEBUG_DEVELOPER); 3367 3368 return \core_user\fields::get_display_name($field); 3369 } 3370 3371 /** 3372 * A centralised location for the all name fields. Returns an array / sql string snippet. 3373 * 3374 * @param bool $returnsql True for an sql select field snippet. 3375 * @param string $tableprefix table query prefix to use in front of each field. 3376 * @param string $prefix prefix added to the name fields e.g. authorfirstname. 3377 * @param string $fieldprefix sql field prefix e.g. id AS userid. 3378 * @param bool $order moves firstname and lastname to the top of the array / start of the string. 3379 * @return array|string All name fields. 3380 * @deprecated since Moodle 3.11 MDL-45242 3381 * @see \core_user\fields 3382 */ 3383 function get_all_user_name_fields($returnsql = false, $tableprefix = null, $prefix = null, $fieldprefix = null, $order = false) { 3384 debugging('get_all_user_name_fields() is deprecated. Please use the \core_user\fields API instead', DEBUG_DEVELOPER); 3385 3386 // This array is provided in this order because when called by fullname() (above) if firstname is before 3387 // firstnamephonetic str_replace() will change the wrong placeholder. 3388 $alternatenames = []; 3389 foreach (\core_user\fields::get_name_fields() as $field) { 3390 $alternatenames[$field] = $field; 3391 } 3392 3393 // Let's add a prefix to the array of user name fields if provided. 3394 if ($prefix) { 3395 foreach ($alternatenames as $key => $altname) { 3396 $alternatenames[$key] = $prefix . $altname; 3397 } 3398 } 3399 3400 // If we want the end result to have firstname and lastname at the front / top of the result. 3401 if ($order) { 3402 // Move the last two elements (firstname, lastname) off the array and put them at the top. 3403 for ($i = 0; $i < 2; $i++) { 3404 // Get the last element. 3405 $lastelement = end($alternatenames); 3406 // Remove it from the array. 3407 unset($alternatenames[$lastelement]); 3408 // Put the element back on the top of the array. 3409 $alternatenames = array_merge(array($lastelement => $lastelement), $alternatenames); 3410 } 3411 } 3412 3413 // Create an sql field snippet if requested. 3414 if ($returnsql) { 3415 if ($tableprefix) { 3416 if ($fieldprefix) { 3417 foreach ($alternatenames as $key => $altname) { 3418 $alternatenames[$key] = $tableprefix . '.' . $altname . ' AS ' . $fieldprefix . $altname; 3419 } 3420 } else { 3421 foreach ($alternatenames as $key => $altname) { 3422 $alternatenames[$key] = $tableprefix . '.' . $altname; 3423 } 3424 } 3425 } 3426 $alternatenames = implode(',', $alternatenames); 3427 } 3428 return $alternatenames; 3429 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body