Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
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 ' 922 .'from class core_courseformat\\base'); 923 } 924 925 /** 926 * @deprecated since 2.4 927 */ 928 function get_all_sections() { 929 throw new coding_exception('get_all_sections() is removed. See phpdocs for this function'); 930 } 931 932 /** 933 * @deprecated since 2.4 934 */ 935 function add_mod_to_section() { 936 throw new coding_exception('Function add_mod_to_section() is removed, please use course_add_cm_to_section()'); 937 } 938 939 /** 940 * @deprecated since 2.4 941 */ 942 function get_all_mods() { 943 throw new coding_exception('Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details'); 944 } 945 946 /** 947 * @deprecated since 2.4 948 */ 949 function get_course_section() { 950 throw new coding_exception('Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.'); 951 } 952 953 /** 954 * @deprecated since 2.4 955 */ 956 function format_weeks_get_section_dates() { 957 throw new coding_exception('Function format_weeks_get_section_dates() is removed. It is not recommended to'. 958 ' use it outside of format_weeks plugin'); 959 } 960 961 /** 962 * @deprecated since 2.5 963 */ 964 function get_print_section_cm_text() { 965 throw new coding_exception('Function get_print_section_cm_text() is removed. Please use '. 966 'cm_info::get_formatted_content() and cm_info::get_formatted_name()'); 967 } 968 969 /** 970 * @deprecated since 2.5 971 */ 972 function print_section_add_menus() { 973 throw new coding_exception('Function print_section_add_menus() is removed. Please use course renderer '. 974 'function course_section_add_cm_control()'); 975 } 976 977 /** 978 * @deprecated since 2.5. Please use: 979 * $courserenderer = $PAGE->get_renderer('core', 'course'); 980 * $actions = course_get_cm_edit_actions($mod, $indent, $section); 981 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions); 982 */ 983 function make_editing_buttons() { 984 throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '. 985 'lib/deprecatedlib.php on how to replace it'); 986 } 987 988 /** 989 * @deprecated since 2.5 990 */ 991 function print_section() { 992 throw new coding_exception( 993 'Function print_section() is removed.' . 994 ' Please use core_courseformat\\output\\local\\content\\section' . 995 ' to render a course section instead.' 996 ); 997 } 998 999 /** 1000 * @deprecated since 2.5 1001 */ 1002 function print_overview() { 1003 throw new coding_exception('Function print_overview() is removed. Use block course_overview to display this information'); 1004 } 1005 1006 /** 1007 * @deprecated since 2.5 1008 */ 1009 function print_recent_activity() { 1010 throw new coding_exception('Function print_recent_activity() is removed. It is not recommended to'. 1011 ' use it outside of block_recent_activity'); 1012 } 1013 1014 /** 1015 * @deprecated since 2.5 1016 */ 1017 function delete_course_module() { 1018 throw new coding_exception('Function delete_course_module() is removed. Please use course_delete_module() instead.'); 1019 } 1020 1021 /** 1022 * @deprecated since 2.5 1023 */ 1024 function update_category_button() { 1025 throw new coding_exception('Function update_category_button() is removed. Pages to view '. 1026 'and edit courses are now separate and no longer depend on editing mode.'); 1027 } 1028 1029 /** 1030 * @deprecated since 2.5 1031 */ 1032 function make_categories_list() { 1033 throw new coding_exception('Global function make_categories_list() is removed. Please use '. 1034 'core_course_category::make_categories_list() and core_course_category::get_parents()'); 1035 } 1036 1037 /** 1038 * @deprecated since 2.5 1039 */ 1040 function category_delete_move() { 1041 throw new coding_exception('Function category_delete_move() is removed. Please use ' . 1042 'core_course_category::delete_move() instead.'); 1043 } 1044 1045 /** 1046 * @deprecated since 2.5 1047 */ 1048 function category_delete_full() { 1049 throw new coding_exception('Function category_delete_full() is removed. Please use ' . 1050 'core_course_category::delete_full() instead.'); 1051 } 1052 1053 /** 1054 * @deprecated since 2.5 1055 */ 1056 function move_category() { 1057 throw new coding_exception('Function move_category() is removed. Please use core_course_category::change_parent() instead.'); 1058 } 1059 1060 /** 1061 * @deprecated since 2.5 1062 */ 1063 function course_category_hide() { 1064 throw new coding_exception('Function course_category_hide() is removed. Please use core_course_category::hide() instead.'); 1065 } 1066 1067 /** 1068 * @deprecated since 2.5 1069 */ 1070 function course_category_show() { 1071 throw new coding_exception('Function course_category_show() is removed. Please use core_course_category::show() instead.'); 1072 } 1073 1074 /** 1075 * @deprecated since 2.5. Please use core_course_category::get($catid, IGNORE_MISSING) or 1076 * core_course_category::get($catid, MUST_EXIST). 1077 */ 1078 function get_course_category() { 1079 throw new coding_exception('Function get_course_category() is removed. Please use core_course_category::get(), ' . 1080 'see phpdocs for more details'); 1081 } 1082 1083 /** 1084 * @deprecated since 2.5 1085 */ 1086 function create_course_category() { 1087 throw new coding_exception('Function create_course_category() is removed. Please use core_course_category::create(), ' . 1088 'see phpdocs for more details'); 1089 } 1090 1091 /** 1092 * @deprecated since 2.5. Please use core_course_category::get() and core_course_category::get_children() 1093 */ 1094 function get_all_subcategories() { 1095 throw new coding_exception('Function get_all_subcategories() is removed. Please use appropriate methods() '. 1096 'of core_course_category class. See phpdocs for more details'); 1097 } 1098 1099 /** 1100 * @deprecated since 2.5. Please use core_course_category::get($parentid)->get_children(). 1101 */ 1102 function get_child_categories() { 1103 throw new coding_exception('Function get_child_categories() is removed. Use core_course_category::get_children() or see ' . 1104 'phpdocs for more details.'); 1105 } 1106 1107 /** 1108 * @deprecated since 2.5 1109 */ 1110 function get_categories() { 1111 throw new coding_exception('Function get_categories() is removed. Please use ' . 1112 'appropriate functions from class core_course_category'); 1113 } 1114 1115 /** 1116 * @deprecated since 2.5 1117 */ 1118 function print_course_search() { 1119 throw new coding_exception('Function print_course_search() is removed, please use course renderer'); 1120 } 1121 1122 /** 1123 * @deprecated since 2.5 1124 */ 1125 function print_my_moodle() { 1126 throw new coding_exception('Function print_my_moodle() is removed, please use course renderer ' . 1127 'function frontpage_my_courses()'); 1128 } 1129 1130 /** 1131 * @deprecated since 2.5 1132 */ 1133 function print_remote_course() { 1134 throw new coding_exception('Function print_remote_course() is removed, please use course renderer'); 1135 } 1136 1137 /** 1138 * @deprecated since 2.5 1139 */ 1140 function print_remote_host() { 1141 throw new coding_exception('Function print_remote_host() is removed, please use course renderer'); 1142 } 1143 1144 /** 1145 * @deprecated since 2.5 1146 */ 1147 function print_whole_category_list() { 1148 throw new coding_exception('Function print_whole_category_list() is removed, please use course renderer'); 1149 } 1150 1151 /** 1152 * @deprecated since 2.5 1153 */ 1154 function print_category_info() { 1155 throw new coding_exception('Function print_category_info() is removed, please use course renderer'); 1156 } 1157 1158 /** 1159 * @deprecated since 2.5 1160 */ 1161 function get_course_category_tree() { 1162 throw new coding_exception('Function get_course_category_tree() is removed, please use course ' . 1163 'renderer or core_course_category class, see function phpdocs for more info'); 1164 } 1165 1166 /** 1167 * @deprecated since 2.5 1168 */ 1169 function print_courses() { 1170 throw new coding_exception('Function print_courses() is removed, please use course renderer'); 1171 } 1172 1173 /** 1174 * @deprecated since 2.5 1175 */ 1176 function print_course() { 1177 throw new coding_exception('Function print_course() is removed, please use course renderer'); 1178 } 1179 1180 /** 1181 * @deprecated since 2.5 1182 */ 1183 function get_category_courses_array() { 1184 throw new coding_exception('Function get_category_courses_array() is removed, please use methods of ' . 1185 'core_course_category class'); 1186 } 1187 1188 /** 1189 * @deprecated since 2.5 1190 */ 1191 function get_category_courses_array_recursively() { 1192 throw new coding_exception('Function get_category_courses_array_recursively() is removed, please use ' . 1193 'methods of core_course_category class', DEBUG_DEVELOPER); 1194 } 1195 1196 /** 1197 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more. 1198 */ 1199 function blog_get_context_url() { 1200 throw new coding_exception('Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.'); 1201 } 1202 1203 /** 1204 * @deprecated since 2.5 1205 */ 1206 function get_courses_wmanagers() { 1207 throw new coding_exception('Function get_courses_wmanagers() is removed, please use ' . 1208 'core_course_category::get_courses()'); 1209 } 1210 1211 /** 1212 * @deprecated since 2.5 1213 */ 1214 function convert_tree_to_html() { 1215 throw new coding_exception('Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()'); 1216 } 1217 1218 /** 1219 * @deprecated since 2.5 1220 */ 1221 function convert_tabrows_to_tree() { 1222 throw new coding_exception('Function convert_tabrows_to_tree() is removed. Consider using class tabtree'); 1223 } 1224 1225 /** 1226 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically 1227 */ 1228 function can_use_rotated_text() { 1229 debugging('can_use_rotated_text() is removed. JS feature detection is used automatically.'); 1230 } 1231 1232 /** 1233 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more. 1234 */ 1235 function get_context_instance_by_id() { 1236 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.'); 1237 } 1238 1239 /** 1240 * Returns system context or null if can not be created yet. 1241 * 1242 * @see context_system::instance() 1243 * @deprecated since 2.2 1244 * @param bool $cache use caching 1245 * @return context system context (null if context table not created yet) 1246 */ 1247 function get_system_context($cache = true) { 1248 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER); 1249 return context_system::instance(0, IGNORE_MISSING, $cache); 1250 } 1251 1252 /** 1253 * @deprecated since 2.2, use $context->get_parent_context_ids() instead 1254 */ 1255 function get_parent_contexts() { 1256 throw new coding_exception('get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.'); 1257 } 1258 1259 /** 1260 * @deprecated since Moodle 2.2 1261 */ 1262 function get_parent_contextid() { 1263 throw new coding_exception('get_parent_contextid() is removed, please use $context->get_parent_context() instead.'); 1264 } 1265 1266 /** 1267 * @deprecated since 2.2 1268 */ 1269 function get_child_contexts() { 1270 throw new coding_exception('get_child_contexts() is removed, please use $context->get_child_contexts() instead.'); 1271 } 1272 1273 /** 1274 * @deprecated since 2.2 1275 */ 1276 function create_contexts() { 1277 throw new coding_exception('create_contexts() is removed, please use context_helper::create_instances() instead.'); 1278 } 1279 1280 /** 1281 * @deprecated since 2.2 1282 */ 1283 function cleanup_contexts() { 1284 throw new coding_exception('cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.'); 1285 } 1286 1287 /** 1288 * @deprecated since 2.2 1289 */ 1290 function build_context_path() { 1291 throw new coding_exception('build_context_path() is removed, please use context_helper::build_all_paths() instead.'); 1292 } 1293 1294 /** 1295 * @deprecated since 2.2 1296 */ 1297 function rebuild_contexts() { 1298 throw new coding_exception('rebuild_contexts() is removed, please use $context->reset_paths(true) instead.'); 1299 } 1300 1301 /** 1302 * @deprecated since Moodle 2.2 1303 */ 1304 function preload_course_contexts() { 1305 throw new coding_exception('preload_course_contexts() is removed, please use context_helper::preload_course() instead.'); 1306 } 1307 1308 /** 1309 * @deprecated since Moodle 2.2 1310 */ 1311 function context_moved() { 1312 throw new coding_exception('context_moved() is removed, please use context::update_moved() instead.'); 1313 } 1314 1315 /** 1316 * @deprecated since 2.2 1317 */ 1318 function fetch_context_capabilities() { 1319 throw new coding_exception('fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.'); 1320 } 1321 1322 /** 1323 * @deprecated since 2.2 1324 */ 1325 function context_instance_preload() { 1326 throw new coding_exception('context_instance_preload() is removed, please use context_helper::preload_from_record() instead.'); 1327 } 1328 1329 /** 1330 * @deprecated since 2.2 1331 */ 1332 function get_contextlevel_name() { 1333 throw new coding_exception('get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.'); 1334 } 1335 1336 /** 1337 * @deprecated since 2.2 1338 */ 1339 function print_context_name() { 1340 throw new coding_exception('print_context_name() is removed, please use $context->get_context_name() instead.'); 1341 } 1342 1343 /** 1344 * @deprecated since 2.2, use $context->mark_dirty() instead 1345 */ 1346 function mark_context_dirty() { 1347 throw new coding_exception('mark_context_dirty() is removed, please use $context->mark_dirty() instead.'); 1348 } 1349 1350 /** 1351 * @deprecated since Moodle 2.2 1352 */ 1353 function delete_context() { 1354 throw new coding_exception('delete_context() is removed, please use context_helper::delete_instance() ' . 1355 'or $context->delete_content() instead.'); 1356 } 1357 1358 /** 1359 * @deprecated since 2.2 1360 */ 1361 function get_context_url() { 1362 throw new coding_exception('get_context_url() is removed, please use $context->get_url() instead.'); 1363 } 1364 1365 /** 1366 * @deprecated since 2.2 1367 */ 1368 function get_course_context() { 1369 throw new coding_exception('get_course_context() is removed, please use $context->get_course_context(true) instead.'); 1370 } 1371 1372 /** 1373 * @deprecated since 2.2 1374 */ 1375 function get_user_courses_bycap() { 1376 throw new coding_exception('get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.'); 1377 } 1378 1379 /** 1380 * @deprecated since Moodle 2.2 1381 */ 1382 function get_role_context_caps() { 1383 throw new coding_exception('get_role_context_caps() is removed, it is really slow. Don\'t use it.'); 1384 } 1385 1386 /** 1387 * @deprecated since 2.2 1388 */ 1389 function get_courseid_from_context() { 1390 throw new coding_exception('get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.'); 1391 } 1392 1393 /** 1394 * @deprecated since 2.2 1395 */ 1396 function context_instance_preload_sql() { 1397 throw new coding_exception('context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.'); 1398 } 1399 1400 /** 1401 * @deprecated since 2.2 1402 */ 1403 function get_related_contexts_string() { 1404 throw new coding_exception('get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.'); 1405 } 1406 1407 /** 1408 * @deprecated since 2.6 1409 */ 1410 function get_plugin_list_with_file() { 1411 throw new coding_exception('get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.'); 1412 } 1413 1414 /** 1415 * @deprecated since 2.6 1416 */ 1417 function check_browser_operating_system() { 1418 throw new coding_exception('check_browser_operating_system is removed, please update your code to use core_useragent instead.'); 1419 } 1420 1421 /** 1422 * @deprecated since 2.6 1423 */ 1424 function check_browser_version() { 1425 throw new coding_exception('check_browser_version is removed, please update your code to use core_useragent instead.'); 1426 } 1427 1428 /** 1429 * @deprecated since 2.6 1430 */ 1431 function get_device_type() { 1432 throw new coding_exception('get_device_type is removed, please update your code to use core_useragent instead.'); 1433 } 1434 1435 /** 1436 * @deprecated since 2.6 1437 */ 1438 function get_device_type_list() { 1439 throw new coding_exception('get_device_type_list is removed, please update your code to use core_useragent instead.'); 1440 } 1441 1442 /** 1443 * @deprecated since 2.6 1444 */ 1445 function get_selected_theme_for_device_type() { 1446 throw new coding_exception('get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.'); 1447 } 1448 1449 /** 1450 * @deprecated since 2.6 1451 */ 1452 function get_device_cfg_var_name() { 1453 throw new coding_exception('get_device_cfg_var_name is removed, please update your code to use core_useragent instead.'); 1454 } 1455 1456 /** 1457 * @deprecated since 2.6 1458 */ 1459 function set_user_device_type() { 1460 throw new coding_exception('set_user_device_type is removed, please update your code to use core_useragent instead.'); 1461 } 1462 1463 /** 1464 * @deprecated since 2.6 1465 */ 1466 function get_user_device_type() { 1467 throw new coding_exception('get_user_device_type is removed, please update your code to use core_useragent instead.'); 1468 } 1469 1470 /** 1471 * @deprecated since 2.6 1472 */ 1473 function get_browser_version_classes() { 1474 throw new coding_exception('get_browser_version_classes is removed, please update your code to use core_useragent instead.'); 1475 } 1476 1477 /** 1478 * @deprecated since Moodle 2.6 1479 */ 1480 function generate_email_supportuser() { 1481 throw new coding_exception('generate_email_supportuser is removed, please use core_user::get_support_user'); 1482 } 1483 1484 /** 1485 * @deprecated since Moodle 2.6 1486 */ 1487 function badges_get_issued_badge_info() { 1488 throw new coding_exception('Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.'); 1489 } 1490 1491 /** 1492 * @deprecated since 2.6 1493 */ 1494 function can_use_html_editor() { 1495 throw new coding_exception('can_use_html_editor is removed, please update your code to assume it returns true.'); 1496 } 1497 1498 1499 /** 1500 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead. 1501 */ 1502 function count_login_failures() { 1503 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().'); 1504 } 1505 1506 /** 1507 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more. 1508 */ 1509 function ajaxenabled() { 1510 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.'); 1511 } 1512 1513 /** 1514 * @deprecated Since Moodle 2.7 MDL-44070 1515 */ 1516 function coursemodule_visible_for_user() { 1517 throw new coding_exception('coursemodule_visible_for_user() can not be used any more, 1518 please use \core_availability\info_module::is_user_visible()'); 1519 } 1520 1521 /** 1522 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed 1523 */ 1524 function enrol_cohort_get_cohorts() { 1525 throw new coding_exception('Function enrol_cohort_get_cohorts() is removed, use '. 1526 'cohort_get_available_cohorts() instead'); 1527 } 1528 1529 /** 1530 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort() 1531 */ 1532 function enrol_cohort_can_view_cohort() { 1533 throw new coding_exception('Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead'); 1534 } 1535 1536 /** 1537 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead 1538 */ 1539 function cohort_get_visible_list() { 1540 throw new coding_exception('Function cohort_get_visible_list() is removed. Please use function cohort_get_available_cohorts() ". 1541 "that correctly checks capabilities.'); 1542 } 1543 1544 /** 1545 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed 1546 */ 1547 function enrol_cohort_enrol_all_users() { 1548 throw new coding_exception('enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.'); 1549 } 1550 1551 /** 1552 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed 1553 */ 1554 function enrol_cohort_search_cohorts() { 1555 throw new coding_exception('enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.'); 1556 } 1557 1558 /* === Apis deprecated in since Moodle 2.9 === */ 1559 1560 /** 1561 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more. 1562 */ 1563 function message_current_user_is_involved() { 1564 throw new coding_exception('message_current_user_is_involved() can not be used any more.'); 1565 } 1566 1567 /** 1568 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more. 1569 */ 1570 function profile_display_badges() { 1571 throw new coding_exception('profile_display_badges() can not be used any more.'); 1572 } 1573 1574 /** 1575 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more. 1576 */ 1577 function useredit_shared_definition_preferences() { 1578 throw new coding_exception('useredit_shared_definition_preferences() can not be used any more.'); 1579 } 1580 1581 1582 /** 1583 * @deprecated since Moodle 2.9 1584 */ 1585 function calendar_normalize_tz() { 1586 throw new coding_exception('calendar_normalize_tz() can not be used any more, please use core_date::normalise_timezone() instead.'); 1587 } 1588 1589 /** 1590 * @deprecated since Moodle 2.9 1591 */ 1592 function get_user_timezone_offset() { 1593 throw new coding_exception('get_user_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead'); 1594 1595 } 1596 1597 /** 1598 * @deprecated since Moodle 2.9 1599 */ 1600 function get_timezone_offset() { 1601 throw new coding_exception('get_timezone_offset() can not be used any more, please use standard PHP DateTimeZone class instead'); 1602 } 1603 1604 /** 1605 * @deprecated since Moodle 2.9 1606 */ 1607 function get_list_of_timezones() { 1608 throw new coding_exception('get_list_of_timezones() can not be used any more, please use core_date::get_list_of_timezones() instead'); 1609 } 1610 1611 /** 1612 * @deprecated since Moodle 2.9 1613 */ 1614 function update_timezone_records() { 1615 throw new coding_exception('update_timezone_records() can not be used any more, please use standard PHP DateTime class instead'); 1616 } 1617 1618 /** 1619 * @deprecated since Moodle 2.9 1620 */ 1621 function calculate_user_dst_table() { 1622 throw new coding_exception('calculate_user_dst_table() can not be used any more, please use standard PHP DateTime class instead'); 1623 } 1624 1625 /** 1626 * @deprecated since Moodle 2.9 1627 */ 1628 function dst_changes_for_year() { 1629 throw new coding_exception('dst_changes_for_year() can not be used any more, please use standard DateTime class instead'); 1630 } 1631 1632 /** 1633 * @deprecated since Moodle 2.9 1634 */ 1635 function get_timezone_record() { 1636 throw new coding_exception('get_timezone_record() can not be used any more, please use standard PHP DateTime class instead'); 1637 } 1638 1639 /* === Apis deprecated since Moodle 3.0 === */ 1640 /** 1641 * @deprecated since Moodle 3.0 MDL-49360 - please do not use this function any more. 1642 */ 1643 function get_referer() { 1644 throw new coding_exception('get_referer() can not be used any more. Please use get_local_referer() instead.'); 1645 } 1646 1647 /** 1648 * @deprecated since Moodle 3.0 use \core_useragent::is_web_crawler instead. 1649 */ 1650 function is_web_crawler() { 1651 throw new coding_exception('is_web_crawler() can not be used any more. Please use core_useragent::is_web_crawler() instead.'); 1652 } 1653 1654 /** 1655 * @deprecated since Moodle 3.0 MDL-50287 - please do not use this function any more. 1656 */ 1657 function completion_cron() { 1658 throw new coding_exception('completion_cron() can not be used any more. Functionality has been moved to scheduled tasks.'); 1659 } 1660 1661 /** 1662 * @deprecated since 3.0 1663 */ 1664 function coursetag_get_tags() { 1665 throw new coding_exception('Function coursetag_get_tags() can not be used any more. ' . 1666 'Userid is no longer used for tagging courses.'); 1667 } 1668 1669 /** 1670 * @deprecated since 3.0 1671 */ 1672 function coursetag_get_all_tags() { 1673 throw new coding_exception('Function coursetag_get_all_tags() can not be used any more. Userid is no ' . 1674 'longer used for tagging courses.'); 1675 } 1676 1677 /** 1678 * @deprecated since 3.0 1679 */ 1680 function coursetag_get_jscript() { 1681 throw new coding_exception('Function coursetag_get_jscript() can not be used any more and is obsolete.'); 1682 } 1683 1684 /** 1685 * @deprecated since 3.0 1686 */ 1687 function coursetag_get_jscript_links() { 1688 throw new coding_exception('Function coursetag_get_jscript_links() can not be used any more and is obsolete.'); 1689 } 1690 1691 /** 1692 * @deprecated since 3.0 1693 */ 1694 function coursetag_get_records() { 1695 throw new coding_exception('Function coursetag_get_records() can not be used any more. ' . 1696 'Userid is no longer used for tagging courses.'); 1697 } 1698 1699 /** 1700 * @deprecated since 3.0 1701 */ 1702 function coursetag_store_keywords() { 1703 throw new coding_exception('Function coursetag_store_keywords() can not be used any more. ' . 1704 'Userid is no longer used for tagging courses.'); 1705 } 1706 1707 /** 1708 * @deprecated since 3.0 1709 */ 1710 function coursetag_delete_keyword() { 1711 throw new coding_exception('Function coursetag_delete_keyword() can not be used any more. ' . 1712 'Userid is no longer used for tagging courses.'); 1713 } 1714 1715 /** 1716 * @deprecated since 3.0 1717 */ 1718 function coursetag_get_tagged_courses() { 1719 throw new coding_exception('Function coursetag_get_tagged_courses() can not be used any more. ' . 1720 'Userid is no longer used for tagging courses.'); 1721 } 1722 1723 /** 1724 * @deprecated since 3.0 1725 */ 1726 function coursetag_delete_course_tags() { 1727 throw new coding_exception('Function coursetag_delete_course_tags() is deprecated. ' . 1728 'Use core_tag_tag::remove_all_item_tags().'); 1729 } 1730 1731 /** 1732 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead 1733 */ 1734 function tag_type_set() { 1735 throw new coding_exception('tag_type_set() can not be used anymore. Please use ' . 1736 'core_tag_tag::get($tagid)->update().'); 1737 } 1738 1739 /** 1740 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead 1741 */ 1742 function tag_description_set() { 1743 throw new coding_exception('tag_description_set() can not be used anymore. Please use ' . 1744 'core_tag_tag::get($tagid)->update().'); 1745 } 1746 1747 /** 1748 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead 1749 */ 1750 function tag_get_tags() { 1751 throw new coding_exception('tag_get_tags() can not be used anymore. Please use ' . 1752 'core_tag_tag::get_item_tags().'); 1753 } 1754 1755 /** 1756 * @deprecated since 3.1 1757 */ 1758 function tag_get_tags_array() { 1759 throw new coding_exception('tag_get_tags_array() can not be used anymore. Please use ' . 1760 'core_tag_tag::get_item_tags_array().'); 1761 } 1762 1763 /** 1764 * @deprecated since 3.1. Use core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()) 1765 */ 1766 function tag_get_tags_csv() { 1767 throw new coding_exception('tag_get_tags_csv() can not be used anymore. Please use ' . 1768 'core_tag_tag::get_item_tags_array() or $OUTPUT->tag_list(core_tag_tag::get_item_tags()).'); 1769 } 1770 1771 /** 1772 * @deprecated since 3.1. Use core_tag_tag::get_item_tags() instead 1773 */ 1774 function tag_get_tags_ids() { 1775 throw new coding_exception('tag_get_tags_ids() can not be used anymore. Please consider using ' . 1776 'core_tag_tag::get_item_tags() or similar methods.'); 1777 } 1778 1779 /** 1780 * @deprecated since 3.1. Use core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk() 1781 */ 1782 function tag_get_id() { 1783 throw new coding_exception('tag_get_id() can not be used anymore. Please use ' . 1784 'core_tag_tag::get_by_name() or core_tag_tag::get_by_name_bulk()'); 1785 } 1786 1787 /** 1788 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->update() instead 1789 */ 1790 function tag_rename() { 1791 throw new coding_exception('tag_rename() can not be used anymore. Please use ' . 1792 'core_tag_tag::get($tagid)->update()'); 1793 } 1794 1795 /** 1796 * @deprecated since 3.1. Use core_tag_tag::remove_item_tag() instead 1797 */ 1798 function tag_delete_instance() { 1799 throw new coding_exception('tag_delete_instance() can not be used anymore. Please use ' . 1800 'core_tag_tag::remove_item_tag()'); 1801 } 1802 1803 /** 1804 * @deprecated since 3.1. Use core_tag_tag::get_by_name()->get_tagged_items() instead 1805 */ 1806 function tag_find_records() { 1807 throw new coding_exception('tag_find_records() can not be used anymore. Please use ' . 1808 'core_tag_tag::get_by_name()->get_tagged_items()'); 1809 } 1810 1811 /** 1812 * @deprecated since 3.1 1813 */ 1814 function tag_add() { 1815 throw new coding_exception('tag_add() can not be used anymore. You can use ' . 1816 'core_tag_tag::create_if_missing(), however it should not be necessary since tags are ' . 1817 'created automatically when assigned to items'); 1818 } 1819 1820 /** 1821 * @deprecated since 3.1. Use core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead 1822 */ 1823 function tag_assign() { 1824 throw new coding_exception('tag_assign() can not be used anymore. Please use ' . 1825 'core_tag_tag::set_item_tags() or core_tag_tag::add_item_tag() instead. Tag instance ' . 1826 'ordering should not be set manually'); 1827 } 1828 1829 /** 1830 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->count_tagged_items() instead 1831 */ 1832 function tag_record_count() { 1833 throw new coding_exception('tag_record_count() can not be used anymore. Please use ' . 1834 'core_tag_tag::get($tagid)->count_tagged_items().'); 1835 } 1836 1837 /** 1838 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->is_item_tagged_with() instead 1839 */ 1840 function tag_record_tagged_with() { 1841 throw new coding_exception('tag_record_tagged_with() can not be used anymore. Please use ' . 1842 'core_tag_tag::get($tagid)->is_item_tagged_with().'); 1843 } 1844 1845 /** 1846 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->flag() instead 1847 */ 1848 function tag_set_flag() { 1849 throw new coding_exception('tag_set_flag() can not be used anymore. Please use ' . 1850 'core_tag_tag::get($tagid)->flag()'); 1851 } 1852 1853 /** 1854 * @deprecated since 3.1. Use core_tag_tag::get($tagid)->reset_flag() instead 1855 */ 1856 function tag_unset_flag() { 1857 throw new coding_exception('tag_unset_flag() can not be used anymore. Please use ' . 1858 'core_tag_tag::get($tagid)->reset_flag()'); 1859 } 1860 1861 /** 1862 * @deprecated since 3.1 1863 */ 1864 function tag_print_cloud() { 1865 throw new coding_exception('tag_print_cloud() can not be used anymore. Please use ' . 1866 'core_tag_collection::get_tag_cloud(), templateable core_tag\output\tagcloud and ' . 1867 'template core_tag/tagcloud.'); 1868 } 1869 1870 /** 1871 * @deprecated since 3.0 1872 */ 1873 function tag_autocomplete() { 1874 throw new coding_exception('tag_autocomplete() can not be used anymore. New form ' . 1875 'element "tags" does proper autocomplete.'); 1876 } 1877 1878 /** 1879 * @deprecated since 3.1 1880 */ 1881 function tag_print_description_box() { 1882 throw new coding_exception('tag_print_description_box() can not be used anymore. ' . 1883 'See core_tag_renderer for similar code'); 1884 } 1885 1886 /** 1887 * @deprecated since 3.1 1888 */ 1889 function tag_print_management_box() { 1890 throw new coding_exception('tag_print_management_box() can not be used anymore. ' . 1891 'See core_tag_renderer for similar code'); 1892 } 1893 1894 /** 1895 * @deprecated since 3.1 1896 */ 1897 function tag_print_search_box() { 1898 throw new coding_exception('tag_print_search_box() can not be used anymore. ' . 1899 'See core_tag_renderer for similar code'); 1900 } 1901 1902 /** 1903 * @deprecated since 3.1 1904 */ 1905 function tag_print_search_results() { 1906 throw new coding_exception('tag_print_search_results() can not be used anymore. ' . 1907 'In /tag/search.php the search results are printed using the core_tag/tagcloud template.'); 1908 } 1909 1910 /** 1911 * @deprecated since 3.1 1912 */ 1913 function tag_print_tagged_users_table() { 1914 throw new coding_exception('tag_print_tagged_users_table() can not be used anymore. ' . 1915 'See core_user_renderer for similar code'); 1916 } 1917 1918 /** 1919 * @deprecated since 3.1 1920 */ 1921 function tag_print_user_box() { 1922 throw new coding_exception('tag_print_user_box() can not be used anymore. ' . 1923 'See core_user_renderer for similar code'); 1924 } 1925 1926 /** 1927 * @deprecated since 3.1 1928 */ 1929 function tag_print_user_list() { 1930 throw new coding_exception('tag_print_user_list() can not be used anymore. ' . 1931 'See core_user_renderer for similar code'); 1932 } 1933 1934 /** 1935 * @deprecated since 3.1 1936 */ 1937 function tag_display_name() { 1938 throw new coding_exception('tag_display_name() can not be used anymore. Please use ' . 1939 'core_tag_tag::make_display_name().'); 1940 1941 } 1942 1943 /** 1944 * @deprecated since 3.1 1945 */ 1946 function tag_normalize() { 1947 throw new coding_exception('tag_normalize() can not be used anymore. Please use ' . 1948 'core_tag_tag::normalize().'); 1949 } 1950 1951 /** 1952 * @deprecated since 3.1 1953 */ 1954 function tag_get_related_tags_csv() { 1955 throw new coding_exception('tag_get_related_tags_csv() can not be used anymore. Please ' . 1956 'consider looping through array or using $OUTPUT->tag_list(core_tag_tag::get_item_tags()).'); 1957 } 1958 1959 /** 1960 * @deprecated since 3.1 1961 */ 1962 function tag_set() { 1963 throw new coding_exception('tag_set() can not be used anymore. Please use ' . 1964 'core_tag_tag::set_item_tags().'); 1965 } 1966 1967 /** 1968 * @deprecated since 3.1 1969 */ 1970 function tag_set_add() { 1971 throw new coding_exception('tag_set_add() can not be used anymore. Please use ' . 1972 'core_tag_tag::add_item_tag().'); 1973 } 1974 1975 /** 1976 * @deprecated since 3.1 1977 */ 1978 function tag_set_delete() { 1979 throw new coding_exception('tag_set_delete() can not be used anymore. Please use ' . 1980 'core_tag_tag::remove_item_tag().'); 1981 } 1982 1983 /** 1984 * @deprecated since 3.1 1985 */ 1986 function tag_get() { 1987 throw new coding_exception('tag_get() can not be used anymore. Please use ' . 1988 'core_tag_tag::get() or core_tag_tag::get_by_name().'); 1989 } 1990 1991 /** 1992 * @deprecated since 3.1 1993 */ 1994 function tag_get_related_tags() { 1995 throw new coding_exception('tag_get_related_tags() can not be used anymore. Please use ' . 1996 'core_tag_tag::get_correlated_tags(), core_tag_tag::get_related_tags() or ' . 1997 'core_tag_tag::get_manual_related_tags().'); 1998 } 1999 2000 /** 2001 * @deprecated since 3.1 2002 */ 2003 function tag_delete() { 2004 throw new coding_exception('tag_delete() can not be used anymore. Please use ' . 2005 'core_tag_tag::delete_tags().'); 2006 } 2007 2008 /** 2009 * @deprecated since 3.1 2010 */ 2011 function tag_delete_instances() { 2012 throw new coding_exception('tag_delete_instances() can not be used anymore. Please use ' . 2013 'core_tag_tag::delete_instances().'); 2014 } 2015 2016 /** 2017 * @deprecated since 3.1 2018 */ 2019 function tag_cleanup() { 2020 throw new coding_exception('tag_cleanup() can not be used anymore. Please use ' . 2021 '\core\task\tag_cron_task::cleanup().'); 2022 } 2023 2024 /** 2025 * @deprecated since 3.1 2026 */ 2027 function tag_bulk_delete_instances() { 2028 throw new coding_exception('tag_bulk_delete_instances() can not be used anymore. Please use ' . 2029 '\core\task\tag_cron_task::bulk_delete_instances().'); 2030 2031 } 2032 2033 /** 2034 * @deprecated since 3.1 2035 */ 2036 function tag_compute_correlations() { 2037 throw new coding_exception('tag_compute_correlations() can not be used anymore. Please use ' . 2038 'use \core\task\tag_cron_task::compute_correlations().'); 2039 } 2040 2041 /** 2042 * @deprecated since 3.1 2043 */ 2044 function tag_process_computed_correlation() { 2045 throw new coding_exception('tag_process_computed_correlation() can not be used anymore. Please use ' . 2046 'use \core\task\tag_cron_task::process_computed_correlation().'); 2047 } 2048 2049 /** 2050 * @deprecated since 3.1 2051 */ 2052 function tag_cron() { 2053 throw new coding_exception('tag_cron() can not be used anymore. Please use ' . 2054 'use \core\task\tag_cron_task::execute().'); 2055 } 2056 2057 /** 2058 * @deprecated since 3.1 2059 */ 2060 function tag_find_tags() { 2061 throw new coding_exception('tag_find_tags() can not be used anymore.'); 2062 } 2063 2064 /** 2065 * @deprecated since 3.1 2066 */ 2067 function tag_get_name() { 2068 throw new coding_exception('tag_get_name() can not be used anymore.'); 2069 } 2070 2071 /** 2072 * @deprecated since 3.1 2073 */ 2074 function tag_get_correlated() { 2075 throw new coding_exception('tag_get_correlated() can not be used anymore. Please use ' . 2076 'use core_tag_tag::get_correlated_tags().'); 2077 2078 } 2079 2080 /** 2081 * @deprecated since 3.1 2082 */ 2083 function tag_cloud_sort() { 2084 throw new coding_exception('tag_cloud_sort() can not be used anymore. Similar method can ' . 2085 'be found in core_tag_collection::cloud_sort().'); 2086 } 2087 2088 /** 2089 * @deprecated since Moodle 3.1 2090 */ 2091 function events_load_def() { 2092 throw new coding_exception('events_load_def() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2093 2094 } 2095 2096 /** 2097 * @deprecated since Moodle 3.1 2098 */ 2099 function events_queue_handler() { 2100 throw new coding_exception('events_queue_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2101 } 2102 2103 /** 2104 * @deprecated since Moodle 3.1 2105 */ 2106 function events_dispatch() { 2107 throw new coding_exception('events_dispatch() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2108 } 2109 2110 /** 2111 * @deprecated since Moodle 3.1 2112 */ 2113 function events_process_queued_handler() { 2114 throw new coding_exception( 2115 'events_process_queued_handler() has been deprecated along with all Events 1 API in favour of Events 2 API.' 2116 ); 2117 } 2118 2119 /** 2120 * @deprecated since Moodle 3.1 2121 */ 2122 function events_update_definition() { 2123 throw new coding_exception( 2124 'events_update_definition has been deprecated along with all Events 1 API in favour of Events 2 API.' 2125 ); 2126 } 2127 2128 /** 2129 * @deprecated since Moodle 3.1 2130 */ 2131 function events_cron() { 2132 throw new coding_exception('events_cron() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2133 } 2134 2135 /** 2136 * @deprecated since Moodle 3.1 2137 */ 2138 function events_trigger_legacy() { 2139 throw new coding_exception('events_trigger_legacy() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2140 } 2141 2142 /** 2143 * @deprecated since Moodle 3.1 2144 */ 2145 function events_is_registered() { 2146 throw new coding_exception('events_is_registered() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2147 } 2148 2149 /** 2150 * @deprecated since Moodle 3.1 2151 */ 2152 function events_pending_count() { 2153 throw new coding_exception('events_pending_count() has been deprecated along with all Events 1 API in favour of Events 2 API.'); 2154 } 2155 2156 /** 2157 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now. 2158 */ 2159 function clam_message_admins() { 2160 throw new coding_exception('clam_message_admins() can not be used anymore. Please use ' . 2161 'message_admins() method of \antivirus_clamav\scanner class.'); 2162 } 2163 2164 /** 2165 * @deprecated since Moodle 3.0 - this is a part of clamav plugin now. 2166 */ 2167 function get_clam_error_code() { 2168 throw new coding_exception('get_clam_error_code() can not be used anymore. Please use ' . 2169 'get_clam_error_code() method of \antivirus_clamav\scanner class.'); 2170 } 2171 2172 /** 2173 * @deprecated since 3.1 2174 */ 2175 function course_get_cm_rename_action() { 2176 throw new coding_exception('course_get_cm_rename_action() can not be used anymore. Please use ' . 2177 'inplace_editable https://docs.moodle.org/dev/Inplace_editable.'); 2178 2179 } 2180 2181 /** 2182 * @deprecated since Moodle 3.1 2183 */ 2184 function course_scale_used() { 2185 throw new coding_exception('course_scale_used() can not be used anymore. Plugins can ' . 2186 'implement <modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored'); 2187 } 2188 2189 /** 2190 * @deprecated since Moodle 3.1 2191 */ 2192 function site_scale_used() { 2193 throw new coding_exception('site_scale_used() can not be used anymore. Plugins can implement ' . 2194 '<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored'); 2195 } 2196 2197 /** 2198 * @deprecated since Moodle 3.1. Use external_api::external_function_info(). 2199 */ 2200 function external_function_info() { 2201 throw new coding_exception('external_function_info() can not be used any'. 2202 'more. Please use external_api::external_function_info() instead.'); 2203 } 2204 2205 /** 2206 * @deprecated since Moodle 3.2 2207 * @see csv_import_reader::load_csv_content() 2208 */ 2209 function get_records_csv() { 2210 throw new coding_exception('get_records_csv() can not be used anymore. Please use ' . 2211 'lib/csvlib.class.php csv_import_reader() instead.'); 2212 } 2213 2214 /** 2215 * @deprecated since Moodle 3.2 2216 * @see download_as_dataformat (lib/dataformatlib.php) 2217 */ 2218 function put_records_csv() { 2219 throw new coding_exception('put_records_csv() can not be used anymore. Please use ' . 2220 'lib/dataformatlib.php download_as_dataformat() instead.'); 2221 } 2222 2223 /** 2224 * @deprecated since Moodle 3.2 2225 */ 2226 function css_is_colour() { 2227 throw new coding_exception('css_is_colour() can not be used anymore.'); 2228 } 2229 2230 /** 2231 * @deprecated since Moodle 3.2 2232 */ 2233 function css_is_width() { 2234 throw new coding_exception('css_is_width() can not be used anymore.'); 2235 } 2236 2237 /** 2238 * @deprecated since Moodle 3.2 2239 */ 2240 function css_sort_by_count() { 2241 throw new coding_exception('css_sort_by_count() can not be used anymore.'); 2242 } 2243 2244 /** 2245 * @deprecated since Moodle 3.2 2246 */ 2247 function message_get_course_contexts() { 2248 throw new coding_exception('message_get_course_contexts() can not be used anymore.'); 2249 } 2250 2251 /** 2252 * @deprecated since Moodle 3.2 2253 */ 2254 function message_remove_url_params() { 2255 throw new coding_exception('message_remove_url_params() can not be used anymore.'); 2256 } 2257 2258 /** 2259 * @deprecated since Moodle 3.2 2260 */ 2261 function message_count_messages() { 2262 throw new coding_exception('message_count_messages() can not be used anymore.'); 2263 } 2264 2265 /** 2266 * @deprecated since Moodle 3.2 2267 */ 2268 function message_count_blocked_users() { 2269 throw new coding_exception('message_count_blocked_users() can not be used anymore. Please use ' . 2270 '\core_message\api::count_blocked_users() instead.'); 2271 } 2272 2273 /** 2274 * @deprecated since Moodle 3.2 2275 */ 2276 function message_contact_link() { 2277 throw new coding_exception('message_contact_link() can not be used anymore.'); 2278 } 2279 2280 /** 2281 * @deprecated since Moodle 3.2 2282 */ 2283 function message_get_recent_notifications() { 2284 throw new coding_exception('message_get_recent_notifications() can not be used anymore.'); 2285 } 2286 2287 /** 2288 * @deprecated since Moodle 3.2 2289 */ 2290 function message_history_link() { 2291 throw new coding_exception('message_history_link() can not be used anymore.'); 2292 } 2293 2294 /** 2295 * @deprecated since Moodle 3.2 2296 */ 2297 function message_search() { 2298 throw new coding_exception('message_search() can not be used anymore.'); 2299 } 2300 2301 /** 2302 * @deprecated since Moodle 3.2 2303 */ 2304 function message_shorten_message() { 2305 throw new coding_exception('message_shorten_message() can not be used anymore.'); 2306 } 2307 2308 /** 2309 * @deprecated since Moodle 3.2 2310 */ 2311 function message_get_fragment() { 2312 throw new coding_exception('message_get_fragment() can not be used anymore.'); 2313 } 2314 2315 /** 2316 * @deprecated since Moodle 3.2 2317 */ 2318 function message_get_history() { 2319 throw new coding_exception('message_get_history() can not be used anymore.'); 2320 } 2321 2322 /** 2323 * @deprecated since Moodle 3.2 2324 */ 2325 function message_get_contact_add_remove_link() { 2326 throw new coding_exception('message_get_contact_add_remove_link() can not be used anymore.'); 2327 } 2328 2329 /** 2330 * @deprecated since Moodle 3.2 2331 */ 2332 function message_get_contact_block_link() { 2333 throw new coding_exception('message_get_contact_block_link() can not be used anymore.'); 2334 } 2335 2336 /** 2337 * @deprecated since Moodle 3.2 2338 */ 2339 function message_mark_messages_read() { 2340 throw new coding_exception('message_mark_messages_read() can not be used anymore. Please use ' . 2341 '\core_message\api::mark_all_messages_as_read() instead.'); 2342 } 2343 2344 /** 2345 * @deprecated since Moodle 3.2 2346 */ 2347 function message_can_post_message() { 2348 throw new coding_exception('message_can_post_message() can not be used anymore. Please use ' . 2349 '\core_message\api::can_send_message() instead.'); 2350 } 2351 2352 /** 2353 * @deprecated since Moodle 3.2 2354 */ 2355 function message_is_user_non_contact_blocked() { 2356 throw new coding_exception('message_is_user_non_contact_blocked() can not be used anymore. Please use ' . 2357 '\core_message\api::is_user_non_contact_blocked() instead.'); 2358 } 2359 2360 /** 2361 * @deprecated since Moodle 3.2 2362 */ 2363 function message_is_user_blocked() { 2364 throw new coding_exception('message_is_user_blocked() can not be used anymore. Please use ' . 2365 '\core_message\api::is_user_blocked() instead.'); 2366 } 2367 2368 /** 2369 * @deprecated since Moodle 3.2 2370 */ 2371 function print_log() { 2372 throw new coding_exception('print_log() can not be used anymore. Please use the ' . 2373 'report_log framework instead.'); 2374 } 2375 2376 /** 2377 * @deprecated since Moodle 3.2 2378 */ 2379 function print_mnet_log() { 2380 throw new coding_exception('print_mnet_log() can not be used anymore. Please use the ' . 2381 'report_log framework instead.'); 2382 } 2383 2384 /** 2385 * @deprecated since Moodle 3.2 2386 */ 2387 function print_log_csv() { 2388 throw new coding_exception('print_log_csv() can not be used anymore. Please use the ' . 2389 'report_log framework instead.'); 2390 } 2391 2392 /** 2393 * @deprecated since Moodle 3.2 2394 */ 2395 function print_log_xls() { 2396 throw new coding_exception('print_log_xls() can not be used anymore. Please use the ' . 2397 'report_log framework instead.'); 2398 } 2399 2400 /** 2401 * @deprecated since Moodle 3.2 2402 */ 2403 function print_log_ods() { 2404 throw new coding_exception('print_log_ods() can not be used anymore. Please use the ' . 2405 'report_log framework instead.'); 2406 } 2407 2408 /** 2409 * @deprecated since Moodle 3.2 2410 */ 2411 function build_logs_array() { 2412 throw new coding_exception('build_logs_array() can not be used anymore. Please use the ' . 2413 'report_log framework instead.'); 2414 } 2415 2416 /** 2417 * @deprecated since Moodle 3.2 2418 */ 2419 function get_logs_usercourse() { 2420 throw new coding_exception('get_logs_usercourse() can not be used anymore. Please use the ' . 2421 'report_log framework instead.'); 2422 } 2423 2424 /** 2425 * @deprecated since Moodle 3.2 2426 */ 2427 function get_logs_userday() { 2428 throw new coding_exception('get_logs_userday() can not be used anymore. Please use the ' . 2429 'report_log framework instead.'); 2430 } 2431 2432 /** 2433 * @deprecated since Moodle 3.2 2434 */ 2435 function get_logs() { 2436 throw new coding_exception('get_logs() can not be used anymore. Please use the ' . 2437 'report_log framework instead.'); 2438 } 2439 2440 /** 2441 * @deprecated since Moodle 3.2 2442 */ 2443 function prevent_form_autofill_password() { 2444 throw new coding_exception('prevent_form_autofill_password() can not be used anymore.'); 2445 } 2446 2447 /** 2448 * @deprecated since Moodle 3.3 MDL-57370 2449 */ 2450 function message_get_recent_conversations($userorid, $limitfrom = 0, $limitto = 100) { 2451 throw new coding_exception('message_get_recent_conversations() can not be used any more. ' . 2452 'Please use \core_message\api::get_conversations() instead.', DEBUG_DEVELOPER); 2453 } 2454 2455 /** 2456 * @deprecated since Moodle 3.2 2457 */ 2458 function calendar_preferences_button() { 2459 throw new coding_exception('calendar_preferences_button() can not be used anymore. The calendar ' . 2460 'preferences are now linked to the user preferences page.'); 2461 } 2462 2463 /** 2464 * @deprecated since 3.3 2465 */ 2466 function calendar_wday_name() { 2467 throw new coding_exception('Function calendar_wday_name() is removed and no longer used in core.'); 2468 } 2469 2470 /** 2471 * @deprecated since 3.3 2472 */ 2473 function calendar_get_block_upcoming() { 2474 throw new coding_exception('Function calendar_get_block_upcoming() is removed,' . 2475 'Please see block_calendar_upcoming::get_content() for the correct API usage.'); 2476 } 2477 2478 /** 2479 * @deprecated since 3.3 2480 */ 2481 function calendar_print_month_selector() { 2482 throw new coding_exception('Function calendar_print_month_selector() is removed and can no longer used in core.'); 2483 } 2484 2485 /** 2486 * @deprecated since 3.3 2487 */ 2488 function calendar_cron() { 2489 throw new coding_exception('Function calendar_cron() is removed. Please use the core\task\calendar_cron_task instead.'); 2490 } 2491 2492 /** 2493 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398. 2494 */ 2495 function load_course_context() { 2496 throw new coding_exception('load_course_context() is removed. Do not use private functions or data structures.'); 2497 } 2498 2499 /** 2500 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398. 2501 */ 2502 function load_role_access_by_context() { 2503 throw new coding_exception('load_role_access_by_context() is removed. Do not use private functions or data structures.'); 2504 } 2505 2506 /** 2507 * @deprecated since Moodle 3.4 and removed immediately. MDL-49398. 2508 */ 2509 function dedupe_user_access() { 2510 throw new coding_exception('dedupe_user_access() is removed. Do not use private functions or data structures.'); 2511 } 2512 2513 /** 2514 * @deprecated since Moodle 3.4. MDL-49398. 2515 */ 2516 function get_user_access_sitewide() { 2517 throw new coding_exception('get_user_access_sitewide() is removed. Do not use private functions or data structures.'); 2518 } 2519 2520 /** 2521 * @deprecated since Moodle 3.4. MDL-59333 2522 */ 2523 function calendar_get_mini() { 2524 throw new coding_exception('calendar_get_mini() has been removed. Please update your code to use calendar_get_view.'); 2525 } 2526 2527 /** 2528 * @deprecated since Moodle 3.4. MDL-59333 2529 */ 2530 function calendar_get_upcoming() { 2531 throw new coding_exception('calendar_get_upcoming() has been removed. ' . 2532 'Please see block_calendar_upcoming::get_content() for the correct API usage.'); 2533 } 2534 2535 /** 2536 * @deprecated since Moodle 3.4. MDL-50666 2537 */ 2538 function allow_override() { 2539 throw new coding_exception('allow_override() has been removed. Please update your code to use core_role_set_override_allowed.'); 2540 } 2541 2542 /** 2543 * @deprecated since Moodle 3.4. MDL-50666 2544 */ 2545 function allow_assign() { 2546 throw new coding_exception('allow_assign() has been removed. Please update your code to use core_role_set_assign_allowed.'); 2547 } 2548 2549 /** 2550 * @deprecated since Moodle 3.4. MDL-50666 2551 */ 2552 function allow_switch() { 2553 throw new coding_exception('allow_switch() has been removed. Please update your code to use core_role_set_switch_allowed.'); 2554 } 2555 2556 /** 2557 * @deprecated since Moodle 3.5. MDL-61132 2558 */ 2559 function question_add_tops() { 2560 throw new coding_exception( 2561 'question_add_tops() has been removed. You may want to pass $top = true to get_categories_for_contexts().' 2562 ); 2563 } 2564 2565 /** 2566 * @deprecated since Moodle 3.5. MDL-61132 2567 */ 2568 function question_is_only_toplevel_category_in_context() { 2569 throw new coding_exception('question_is_only_toplevel_category_in_context() has been removed. ' 2570 . 'Please update your code to use question_is_only_child_of_top_category_in_context() instead.'); 2571 } 2572 2573 /** 2574 * @deprecated since Moodle 3.5 2575 */ 2576 function message_move_userfrom_unread2read() { 2577 throw new coding_exception('message_move_userfrom_unread2read() has been removed.'); 2578 } 2579 2580 /** 2581 * @deprecated since Moodle 3.5 2582 */ 2583 function message_get_blocked_users() { 2584 throw new coding_exception( 2585 'message_get_blocked_users() has been removed, please use \core_message\api::get_blocked_users() instead.' 2586 ); 2587 } 2588 2589 /** 2590 * @deprecated since Moodle 3.5 2591 */ 2592 function message_get_contacts() { 2593 throw new coding_exception('message_get_contacts() has been removed.'); 2594 } 2595 2596 /** 2597 * @deprecated since Moodle 3.5 2598 */ 2599 function message_mark_message_read() { 2600 throw new coding_exception('message_mark_message_read() has been removed, please use \core_message\api::mark_message_as_read() 2601 or \core_message\api::mark_notification_as_read().'); 2602 } 2603 2604 /** 2605 * @deprecated since Moodle 3.5 2606 */ 2607 function message_can_delete_message() { 2608 throw new coding_exception( 2609 'message_can_delete_message() has been removed, please use \core_message\api::can_delete_message() instead.' 2610 ); 2611 } 2612 2613 /** 2614 * @deprecated since Moodle 3.5 2615 */ 2616 function message_delete_message() { 2617 throw new coding_exception( 2618 'message_delete_message() has been removed, please use \core_message\api::delete_message() instead.' 2619 ); 2620 } 2621 2622 /** 2623 * @deprecated since 3.6 2624 */ 2625 function calendar_get_all_allowed_types() { 2626 throw new coding_exception( 2627 'calendar_get_all_allowed_types() has been removed. Please use calendar_get_allowed_types() instead.' 2628 ); 2629 2630 } 2631 2632 /** 2633 * @deprecated since Moodle 3.6. 2634 */ 2635 function groups_get_all_groups_for_courses() { 2636 throw new coding_exception( 2637 'groups_get_all_groups_for_courses() has been removed and can not be used anymore.' 2638 ); 2639 } 2640 2641 /** 2642 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2643 */ 2644 function events_get_cached() { 2645 throw new coding_exception( 2646 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2647 ); 2648 } 2649 2650 /** 2651 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2652 */ 2653 function events_uninstall() { 2654 throw new coding_exception( 2655 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2656 ); 2657 } 2658 2659 /** 2660 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2661 */ 2662 function events_cleanup() { 2663 throw new coding_exception( 2664 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2665 ); 2666 } 2667 2668 /** 2669 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2670 */ 2671 function events_dequeue() { 2672 throw new coding_exception( 2673 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2674 ); 2675 } 2676 2677 /** 2678 * @deprecated since Moodle 3.6. Please use the Events 2 API. 2679 */ 2680 function events_get_handlers() { 2681 throw new coding_exception( 2682 'Events API using $handlers array has been removed in favour of Events 2 API, please use it instead.' 2683 ); 2684 } 2685 2686 /** 2687 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context(). 2688 */ 2689 function get_roles_on_exact_context() { 2690 throw new coding_exception( 2691 'get_roles_on_exact_context() has been removed, please use get_roles_used_in_context() instead.' 2692 ); 2693 } 2694 2695 /** 2696 * @deprecated since Moodle 3.6. Please use the get_roles_used_in_context(). 2697 */ 2698 function get_roles_with_assignment_on_context() { 2699 throw new coding_exception( 2700 'get_roles_with_assignment_on_context() has been removed, please use get_roles_used_in_context() instead.' 2701 ); 2702 } 2703 2704 /** 2705 * @deprecated since Moodle 3.6 2706 */ 2707 function message_add_contact() { 2708 throw new coding_exception( 2709 'message_add_contact() has been removed. Please use \core_message\api::create_contact_request() instead. ' . 2710 'If you wish to block or unblock a user please use \core_message\api::is_blocked() and ' . 2711 '\core_message\api::block_user() or \core_message\api::unblock_user() respectively.' 2712 ); 2713 } 2714 2715 /** 2716 * @deprecated since Moodle 3.6 2717 */ 2718 function message_remove_contact() { 2719 throw new coding_exception( 2720 'message_remove_contact() has been removed. Please use \core_message\api::remove_contact() instead.' 2721 ); 2722 } 2723 2724 /** 2725 * @deprecated since Moodle 3.6 2726 */ 2727 function message_unblock_contact() { 2728 throw new coding_exception( 2729 'message_unblock_contact() has been removed. Please use \core_message\api::unblock_user() instead.' 2730 ); 2731 } 2732 2733 /** 2734 * @deprecated since Moodle 3.6 2735 */ 2736 function message_block_contact() { 2737 throw new coding_exception( 2738 'message_block_contact() has been removed. Please use \core_message\api::is_blocked() and ' . 2739 '\core_message\api::block_user() instead.' 2740 ); 2741 } 2742 2743 /** 2744 * @deprecated since Moodle 3.6 2745 */ 2746 function message_get_contact() { 2747 throw new coding_exception( 2748 'message_get_contact() has been removed. Please use \core_message\api::get_contact() instead.' 2749 ); 2750 } 2751 2752 /** 2753 * @deprecated since Moodle 3.7 2754 */ 2755 function get_courses_page() { 2756 throw new coding_exception( 2757 'Function get_courses_page() has been removed. Please use core_course_category::get_courses() ' . 2758 'or core_course_category::search_courses()' 2759 ); 2760 } 2761 2762 /** 2763 * @deprecated since Moodle 3.8 2764 */ 2765 function report_insights_context_insights(\context $context) { 2766 throw new coding_exception( 2767 'Function report_insights_context_insights() ' . 2768 'has been removed. Please use \core_analytics\manager::cached_models_with_insights instead' 2769 ); 2770 } 2771 2772 /** 2773 * Retrieve all metadata for the requested modules 2774 * 2775 * @deprecated since 3.9. 2776 * @param object $course The Course 2777 * @param array $modnames An array containing the list of modules and their 2778 * names 2779 * @param int $sectionreturn The section to return to 2780 * @return array A list of stdClass objects containing metadata about each 2781 * module 2782 */ 2783 function get_module_metadata($course, $modnames, $sectionreturn = null) { 2784 global $OUTPUT; 2785 2786 debugging('get_module_metadata is deprecated. Please use \core_course\local\service\content_item_service instead.'); 2787 2788 // get_module_metadata will be called once per section on the page and courses may show 2789 // different modules to one another 2790 static $modlist = array(); 2791 if (!isset($modlist[$course->id])) { 2792 $modlist[$course->id] = array(); 2793 } 2794 2795 $return = array(); 2796 $urlbase = new moodle_url('/course/mod.php', array('id' => $course->id, 'sesskey' => sesskey())); 2797 if ($sectionreturn !== null) { 2798 $urlbase->param('sr', $sectionreturn); 2799 } 2800 foreach($modnames as $modname => $modnamestr) { 2801 if (!course_allowed_module($course, $modname)) { 2802 continue; 2803 } 2804 if (isset($modlist[$course->id][$modname])) { 2805 // This module is already cached 2806 $return += $modlist[$course->id][$modname]; 2807 continue; 2808 } 2809 $modlist[$course->id][$modname] = array(); 2810 2811 // Create an object for a default representation of this module type in the activity chooser. It will be used 2812 // if module does not implement callback get_shortcuts() and it will also be passed to the callback if it exists. 2813 $defaultmodule = new stdClass(); 2814 $defaultmodule->title = $modnamestr; 2815 $defaultmodule->name = $modname; 2816 $defaultmodule->link = new moodle_url($urlbase, array('add' => $modname)); 2817 $defaultmodule->icon = $OUTPUT->pix_icon('icon', '', $defaultmodule->name, array('class' => 'icon')); 2818 $sm = get_string_manager(); 2819 if ($sm->string_exists('modulename_help', $modname)) { 2820 $defaultmodule->help = get_string('modulename_help', $modname); 2821 if ($sm->string_exists('modulename_link', $modname)) { // Link to further info in Moodle docs. 2822 $link = get_string('modulename_link', $modname); 2823 $linktext = get_string('morehelp'); 2824 $defaultmodule->help .= html_writer::tag('div', 2825 $OUTPUT->doc_link($link, $linktext, true), array('class' => 'helpdoclink')); 2826 } 2827 } 2828 $defaultmodule->archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER); 2829 2830 // Each module can implement callback modulename_get_shortcuts() in its lib.php and return the list 2831 // of elements to be added to activity chooser. 2832 $items = component_callback($modname, 'get_shortcuts', array($defaultmodule), null); 2833 if ($items !== null) { 2834 foreach ($items as $item) { 2835 // Add all items to the return array. All items must have different links, use them as a key in the return array. 2836 if (!isset($item->archetype)) { 2837 $item->archetype = $defaultmodule->archetype; 2838 } 2839 if (!isset($item->icon)) { 2840 $item->icon = $defaultmodule->icon; 2841 } 2842 // If plugin returned the only one item with the same link as default item - cache it as $modname, 2843 // otherwise append the link url to the module name. 2844 $item->name = (count($items) == 1 && 2845 $item->link->out() === $defaultmodule->link->out()) ? $modname : $modname . ':' . $item->link; 2846 2847 // If the module provides the helptext property, append it to the help text to match the look and feel 2848 // of the default course modules. 2849 if (isset($item->help) && isset($item->helplink)) { 2850 $linktext = get_string('morehelp'); 2851 $item->help .= html_writer::tag('div', 2852 $OUTPUT->doc_link($item->helplink, $linktext, true), array('class' => 'helpdoclink')); 2853 } 2854 $modlist[$course->id][$modname][$item->name] = $item; 2855 } 2856 $return += $modlist[$course->id][$modname]; 2857 // If get_shortcuts() callback is defined, the default module action is not added. 2858 // It is a responsibility of the callback to add it to the return value unless it is not needed. 2859 continue; 2860 } 2861 2862 // The callback get_shortcuts() was not found, use the default item for the activity chooser. 2863 $modlist[$course->id][$modname][$modname] = $defaultmodule; 2864 $return[$modname] = $defaultmodule; 2865 } 2866 2867 core_collator::asort_objects_by_property($return, 'title'); 2868 return $return; 2869 } 2870 2871 /** 2872 * Runs a single cron task. This function assumes it is displaying output in pseudo-CLI mode. 2873 * 2874 * The function will fail if the task is disabled. 2875 * 2876 * Warning: Because this function closes the browser session, it may not be safe to continue 2877 * with other processing (other than displaying the rest of the page) after using this function! 2878 * 2879 * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task). 2880 * @todo final deprecation. To be removed in Moodle 4.1 MDL-63594. 2881 * @param \core\task\scheduled_task $task Task to run 2882 * @return bool True if cron run successful 2883 */ 2884 function cron_run_single_task(\core\task\scheduled_task $task) { 2885 debugging('cron_run_single_task() is deprecated. Please use \\core\task\manager::run_from_cli() instead.', 2886 DEBUG_DEVELOPER); 2887 return \core\task\manager::run_from_cli($task); 2888 } 2889 2890 /** 2891 * Executes cron functions for a specific type of plugin. 2892 * 2893 * @param string $plugintype Plugin type (e.g. 'report') 2894 * @param string $description If specified, will display 'Starting (whatever)' 2895 * and 'Finished (whatever)' lines, otherwise does not display 2896 * 2897 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API. 2898 * @todo MDL-61165 This will be deleted in Moodle 4.1. 2899 */ 2900 function cron_execute_plugin_type($plugintype, $description = null) { 2901 global $DB; 2902 2903 // Get list from plugin => function for all plugins. 2904 $plugins = get_plugin_list_with_function($plugintype, 'cron'); 2905 2906 // Modify list for backward compatibility (different files/names). 2907 $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins); 2908 2909 // Return if no plugins with cron function to process. 2910 if (!$plugins) { 2911 return; 2912 } 2913 2914 if ($description) { 2915 mtrace('Starting '.$description); 2916 } 2917 2918 foreach ($plugins as $component => $cronfunction) { 2919 $dir = core_component::get_component_directory($component); 2920 2921 // Get cron period if specified in version.php, otherwise assume every cron. 2922 $cronperiod = 0; 2923 if (file_exists("$dir/version.php")) { 2924 $plugin = new stdClass(); 2925 include("$dir/version.php"); 2926 if (isset($plugin->cron)) { 2927 $cronperiod = $plugin->cron; 2928 } 2929 } 2930 2931 // Using last cron and cron period, don't run if it already ran recently. 2932 $lastcron = get_config($component, 'lastcron'); 2933 if ($cronperiod && $lastcron) { 2934 if ($lastcron + $cronperiod > time()) { 2935 // Do not execute cron yet. 2936 continue; 2937 } 2938 } 2939 2940 mtrace('Processing cron function for ' . $component . '...'); 2941 debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER); 2942 cron_trace_time_and_memory(); 2943 $pre_dbqueries = $DB->perf_get_queries(); 2944 $pre_time = microtime(true); 2945 2946 $cronfunction(); 2947 2948 mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " . 2949 round(microtime(true) - $pre_time, 2) . " seconds)"); 2950 2951 set_config('lastcron', time(), $component); 2952 core_php_time_limit::raise(); 2953 } 2954 2955 if ($description) { 2956 mtrace('Finished ' . $description); 2957 } 2958 } 2959 2960 /** 2961 * Used to add in old-style cron functions within plugins that have not been converted to the 2962 * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used 2963 * cron.php and some used a different name.) 2964 * 2965 * @param string $plugintype Plugin type e.g. 'report' 2966 * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g. 2967 * 'report_frog_cron') for plugin cron functions that were already found using the new API 2968 * @return array Revised version of $plugins that adds in any extra plugin functions found by 2969 * looking in the older location 2970 * 2971 * @deprecated since Moodle 3.9 MDL-52846. Please use new task API. 2972 * @todo MDL-61165 This will be deleted in Moodle 4.1. 2973 */ 2974 function cron_bc_hack_plugin_functions($plugintype, $plugins) { 2975 global $CFG; // Mandatory in case it is referenced by include()d PHP script. 2976 2977 if ($plugintype === 'report') { 2978 // Admin reports only - not course report because course report was 2979 // never implemented before, so doesn't need BC. 2980 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) { 2981 $component = $plugintype . '_' . $pluginname; 2982 if (isset($plugins[$component])) { 2983 // We already have detected the function using the new API. 2984 continue; 2985 } 2986 if (!file_exists("$dir/cron.php")) { 2987 // No old style cron file present. 2988 continue; 2989 } 2990 include_once("$dir/cron.php"); 2991 $cronfunction = $component . '_cron'; 2992 if (function_exists($cronfunction)) { 2993 $plugins[$component] = $cronfunction; 2994 } else { 2995 debugging("Invalid legacy cron.php detected in $component, " . 2996 "please use lib.php instead"); 2997 } 2998 } 2999 } else if (strpos($plugintype, 'grade') === 0) { 3000 // Detect old style cron function names. 3001 // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of 3002 // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport. 3003 foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) { 3004 $component = $plugintype.'_'.$pluginname; 3005 if (isset($plugins[$component])) { 3006 // We already have detected the function using the new API. 3007 continue; 3008 } 3009 if (!file_exists("$dir/lib.php")) { 3010 continue; 3011 } 3012 include_once("$dir/lib.php"); 3013 $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' . 3014 $pluginname . '_cron'; 3015 if (function_exists($cronfunction)) { 3016 $plugins[$component] = $cronfunction; 3017 } 3018 } 3019 } 3020 3021 return $plugins; 3022 } 3023 3024 /** 3025 * Returns the SQL used by the participants table. 3026 * 3027 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants. 3028 * @param int $courseid The course id 3029 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group 3030 * @param int $accesssince The time since last access, 0 means any time 3031 * @param int $roleid The role id, 0 means all roles and -1 no roles 3032 * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned. 3033 * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed. 3034 * @param string|array $search The search that was performed, empty means perform no search 3035 * @param string $additionalwhere Any additional SQL to add to where 3036 * @param array $additionalparams The additional params 3037 * @return array 3038 */ 3039 function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1, 3040 $search = '', $additionalwhere = '', $additionalparams = array()) { 3041 global $DB, $USER, $CFG; 3042 3043 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' . 3044 'Please use \core\table\participants_search::class with table filtersets instead.'; 3045 debugging($deprecatedtext, DEBUG_DEVELOPER); 3046 3047 // Get the context. 3048 $context = \context_course::instance($courseid, MUST_EXIST); 3049 3050 $isfrontpage = ($courseid == SITEID); 3051 3052 // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments. 3053 $onlyactive = true; 3054 $onlysuspended = false; 3055 if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) { 3056 switch ($statusid) { 3057 case ENROL_USER_ACTIVE: 3058 // Nothing to do here. 3059 break; 3060 case ENROL_USER_SUSPENDED: 3061 $onlyactive = false; 3062 $onlysuspended = true; 3063 break; 3064 default: 3065 // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false. 3066 $onlyactive = false; 3067 break; 3068 } 3069 } 3070 3071 list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid); 3072 3073 $joins = array('FROM {user} u'); 3074 $wheres = array(); 3075 3076 // TODO Does not support custom user profile fields (MDL-70456). 3077 $userfields = \core_user\fields::get_identity_fields($context, false); 3078 $userfieldsapi = \core_user\fields::for_userpic()->including(...$userfields); 3079 $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false)->selects; 3080 3081 if ($isfrontpage) { 3082 $select = "SELECT $userfieldssql, u.lastaccess"; 3083 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually. 3084 if ($accesssince) { 3085 $wheres[] = user_get_user_lastaccess_sql($accesssince); 3086 } 3087 } else { 3088 $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess"; 3089 $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only. 3090 // Not everybody has accessed the course yet. 3091 $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)'; 3092 $params['courseid'] = $courseid; 3093 if ($accesssince) { 3094 $wheres[] = user_get_course_lastaccess_sql($accesssince); 3095 } 3096 } 3097 3098 // Performance hacks - we preload user contexts together with accounts. 3099 $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); 3100 $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)'; 3101 $params['contextlevel'] = CONTEXT_USER; 3102 $select .= $ccselect; 3103 $joins[] = $ccjoin; 3104 3105 // Limit list to users with some role only. 3106 if ($roleid) { 3107 // We want to query both the current context and parent contexts. 3108 list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true), 3109 SQL_PARAMS_NAMED, 'relatedctx'); 3110 3111 // Get users without any role. 3112 if ($roleid == -1) { 3113 $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)"; 3114 $params = array_merge($params, $relatedctxparams); 3115 } else { 3116 $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)"; 3117 $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams); 3118 } 3119 } 3120 3121 if (!empty($search)) { 3122 if (!is_array($search)) { 3123 $search = [$search]; 3124 } 3125 foreach ($search as $index => $keyword) { 3126 $searchkey1 = 'search' . $index . '1'; 3127 $searchkey2 = 'search' . $index . '2'; 3128 $searchkey3 = 'search' . $index . '3'; 3129 $searchkey4 = 'search' . $index . '4'; 3130 $searchkey5 = 'search' . $index . '5'; 3131 $searchkey6 = 'search' . $index . '6'; 3132 $searchkey7 = 'search' . $index . '7'; 3133 3134 $conditions = array(); 3135 // Search by fullname. 3136 $fullname = $DB->sql_fullname('u.firstname', 'u.lastname'); 3137 $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false); 3138 3139 // Search by email. 3140 $email = $DB->sql_like('email', ':' . $searchkey2, false, false); 3141 if (!in_array('email', $userfields)) { 3142 $maildisplay = 'maildisplay' . $index; 3143 $userid1 = 'userid' . $index . '1'; 3144 // Prevent users who hide their email address from being found by others 3145 // who aren't allowed to see hidden email addresses. 3146 $email = "(". $email ." AND (" . 3147 "u.maildisplay <> :$maildisplay " . 3148 "OR u.id = :$userid1". // User can always find himself. 3149 "))"; 3150 $params[$maildisplay] = core_user::MAILDISPLAY_HIDE; 3151 $params[$userid1] = $USER->id; 3152 } 3153 $conditions[] = $email; 3154 3155 // Search by idnumber. 3156 $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false); 3157 if (!in_array('idnumber', $userfields)) { 3158 $userid2 = 'userid' . $index . '2'; 3159 // Users who aren't allowed to see idnumbers should at most find themselves 3160 // when searching for an idnumber. 3161 $idnumber = "(". $idnumber . " AND u.id = :$userid2)"; 3162 $params[$userid2] = $USER->id; 3163 } 3164 $conditions[] = $idnumber; 3165 3166 // TODO Does not support custom user profile fields (MDL-70456). 3167 $extrasearchfields = \core_user\fields::get_identity_fields($context, false); 3168 if (!empty($extrasearchfields)) { 3169 // Search all user identify fields. 3170 foreach ($extrasearchfields as $extrasearchfield) { 3171 if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) { 3172 // Already covered above. Search by country not supported. 3173 continue; 3174 } 3175 $param = $searchkey3 . $extrasearchfield; 3176 $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false); 3177 $params[$param] = "%$keyword%"; 3178 if (!in_array($extrasearchfield, $userfields)) { 3179 // User cannot see this field, but allow match if their own account. 3180 $userid3 = 'userid' . $index . '3' . $extrasearchfield; 3181 $condition = "(". $condition . " AND u.id = :$userid3)"; 3182 $params[$userid3] = $USER->id; 3183 } 3184 $conditions[] = $condition; 3185 } 3186 } 3187 3188 // Search by middlename. 3189 $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false); 3190 $conditions[] = $middlename; 3191 3192 // Search by alternatename. 3193 $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false); 3194 $conditions[] = $alternatename; 3195 3196 // Search by firstnamephonetic. 3197 $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false); 3198 $conditions[] = $firstnamephonetic; 3199 3200 // Search by lastnamephonetic. 3201 $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false); 3202 $conditions[] = $lastnamephonetic; 3203 3204 $wheres[] = "(". implode(" OR ", $conditions) .") "; 3205 $params[$searchkey1] = "%$keyword%"; 3206 $params[$searchkey2] = "%$keyword%"; 3207 $params[$searchkey3] = "%$keyword%"; 3208 $params[$searchkey4] = "%$keyword%"; 3209 $params[$searchkey5] = "%$keyword%"; 3210 $params[$searchkey6] = "%$keyword%"; 3211 $params[$searchkey7] = "%$keyword%"; 3212 } 3213 } 3214 3215 if (!empty($additionalwhere)) { 3216 $wheres[] = $additionalwhere; 3217 $params = array_merge($params, $additionalparams); 3218 } 3219 3220 $from = implode("\n", $joins); 3221 if ($wheres) { 3222 $where = 'WHERE ' . implode(' AND ', $wheres); 3223 } else { 3224 $where = ''; 3225 } 3226 3227 return array($select, $from, $where, $params); 3228 } 3229 3230 /** 3231 * Returns the total number of participants for a given course. 3232 * 3233 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants. 3234 * @param int $courseid The course id 3235 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group 3236 * @param int $accesssince The time since last access, 0 means any time 3237 * @param int $roleid The role id, 0 means all roles 3238 * @param int $enrolid The applied filter for the user enrolment ID. 3239 * @param int $status The applied filter for the user's enrolment status. 3240 * @param string|array $search The search that was performed, empty means perform no search 3241 * @param string $additionalwhere Any additional SQL to add to where 3242 * @param array $additionalparams The additional params 3243 * @return int 3244 */ 3245 function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1, 3246 $search = '', $additionalwhere = '', $additionalparams = array()) { 3247 global $DB; 3248 3249 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' . 3250 'Please use \core\table\participants_search::class with table filtersets instead.'; 3251 debugging($deprecatedtext, DEBUG_DEVELOPER); 3252 3253 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid, 3254 $statusid, $search, $additionalwhere, $additionalparams); 3255 3256 return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params); 3257 } 3258 3259 /** 3260 * Returns the participants for a given course. 3261 * 3262 * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants. 3263 * @param int $courseid The course id 3264 * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group 3265 * @param int $accesssince The time since last access 3266 * @param int $roleid The role id 3267 * @param int $enrolid The applied filter for the user enrolment ID. 3268 * @param int $status The applied filter for the user's enrolment status. 3269 * @param string $search The search that was performed 3270 * @param string $additionalwhere Any additional SQL to add to where 3271 * @param array $additionalparams The additional params 3272 * @param string $sort The SQL sort 3273 * @param int $limitfrom return a subset of records, starting at this point (optional). 3274 * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). 3275 * @return moodle_recordset 3276 */ 3277 function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enrolid, $statusid, $search, 3278 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) { 3279 global $DB; 3280 3281 $deprecatedtext = __FUNCTION__ . '() is deprecated. ' . 3282 'Please use \core\table\participants_search::class with table filtersets instead.'; 3283 debugging($deprecatedtext, DEBUG_DEVELOPER); 3284 3285 list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid, 3286 $statusid, $search, $additionalwhere, $additionalparams); 3287 3288 return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum); 3289 } 3290 3291 /** 3292 * Returns the list of full course categories to be used in html_writer::select() 3293 * 3294 * Calls {@see core_course_category::make_categories_list()} to build the list. 3295 * 3296 * @deprecated since Moodle 3.10 3297 * @todo This will be finally removed for Moodle 4.2 as part of MDL-69124. 3298 * @return array array mapping course category id to the display name 3299 */ 3300 function make_categories_options() { 3301 $deprecatedtext = __FUNCTION__ . '() is deprecated. Please use \core_course_category::make_categories_list() instead.'; 3302 debugging($deprecatedtext, DEBUG_DEVELOPER); 3303 3304 return core_course_category::make_categories_list('', 0, ' / '); 3305 } 3306 3307 /** 3308 * Checks if current user is shown any extra fields when listing users. 3309 * 3310 * Does not include any custom profile fields. 3311 * 3312 * @param object $context Context 3313 * @param array $already Array of fields that we're going to show anyway 3314 * so don't bother listing them 3315 * @return array Array of field names from user table, not including anything 3316 * listed in $already 3317 * @deprecated since Moodle 3.11 MDL-45242 3318 * @see \core_user\fields 3319 */ 3320 function get_extra_user_fields($context, $already = array()) { 3321 debugging('get_extra_user_fields() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER); 3322 3323 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already); 3324 return $fields->get_required_fields(); 3325 } 3326 3327 /** 3328 * If the current user is to be shown extra user fields when listing or 3329 * selecting users, returns a string suitable for including in an SQL select 3330 * clause to retrieve those fields. 3331 * 3332 * Does not include any custom profile fields. 3333 * 3334 * @param context $context Context 3335 * @param string $alias Alias of user table, e.g. 'u' (default none) 3336 * @param string $prefix Prefix for field names using AS, e.g. 'u_' (default none) 3337 * @param array $already Array of fields that we're going to include anyway so don't list them (default none) 3338 * @return string Partial SQL select clause, beginning with comma, for example ',u.idnumber,u.department' unless it is blank 3339 * @deprecated since Moodle 3.11 MDL-45242 3340 * @see \core_user\fields 3341 */ 3342 function get_extra_user_fields_sql($context, $alias='', $prefix='', $already = array()) { 3343 debugging('get_extra_user_fields_sql() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER); 3344 3345 $fields = \core_user\fields::for_identity($context, false)->excluding(...$already); 3346 // Note: There will never be any joins or join params because we turned off profile fields. 3347 $selects = $fields->get_sql($alias, false, $prefix)->selects; 3348 3349 return $selects; 3350 } 3351 3352 /** 3353 * Returns the display name of a field in the user table. Works for most fields that are commonly displayed to users. 3354 * 3355 * Also works for custom fields. 3356 * 3357 * @param string $field Field name, e.g. 'phone1' 3358 * @return string Text description taken from language file, e.g. 'Phone number' 3359 * @deprecated since Moodle 3.11 MDL-45242 3360 * @see \core_user\fields 3361 */ 3362 function get_user_field_name($field) { 3363 debugging('get_user_field_name() is deprecated. Please use \core_user\fields::get_display_name() instead', DEBUG_DEVELOPER); 3364 3365 return \core_user\fields::get_display_name($field); 3366 } 3367 3368 /** 3369 * A centralised location for the all name fields. Returns an array / sql string snippet. 3370 * 3371 * @param bool $returnsql True for an sql select field snippet. 3372 * @param string $tableprefix table query prefix to use in front of each field. 3373 * @param string $prefix prefix added to the name fields e.g. authorfirstname. 3374 * @param string $fieldprefix sql field prefix e.g. id AS userid. 3375 * @param bool $order moves firstname and lastname to the top of the array / start of the string. 3376 * @return array|string All name fields. 3377 * @deprecated since Moodle 3.11 MDL-45242 3378 * @see \core_user\fields 3379 */ 3380 function get_all_user_name_fields($returnsql = false, $tableprefix = null, $prefix = null, $fieldprefix = null, $order = false) { 3381 debugging('get_all_user_name_fields() is deprecated. Please use the \core_user\fields API instead', DEBUG_DEVELOPER); 3382 3383 // This array is provided in this order because when called by fullname() (above) if firstname is before 3384 // firstnamephonetic str_replace() will change the wrong placeholder. 3385 $alternatenames = []; 3386 foreach (\core_user\fields::get_name_fields() as $field) { 3387 $alternatenames[$field] = $field; 3388 } 3389 3390 // Let's add a prefix to the array of user name fields if provided. 3391 if ($prefix) { 3392 foreach ($alternatenames as $key => $altname) { 3393 $alternatenames[$key] = $prefix . $altname; 3394 } 3395 } 3396 3397 // If we want the end result to have firstname and lastname at the front / top of the result. 3398 if ($order) { 3399 // Move the last two elements (firstname, lastname) off the array and put them at the top. 3400 for ($i = 0; $i < 2; $i++) { 3401 // Get the last element. 3402 $lastelement = end($alternatenames); 3403 // Remove it from the array. 3404 unset($alternatenames[$lastelement]); 3405 // Put the element back on the top of the array. 3406 $alternatenames = array_merge(array($lastelement => $lastelement), $alternatenames); 3407 } 3408 } 3409 3410 // Create an sql field snippet if requested. 3411 if ($returnsql) { 3412 if ($tableprefix) { 3413 if ($fieldprefix) { 3414 foreach ($alternatenames as $key => $altname) { 3415 $alternatenames[$key] = $tableprefix . '.' . $altname . ' AS ' . $fieldprefix . $altname; 3416 } 3417 } else { 3418 foreach ($alternatenames as $key => $altname) { 3419 $alternatenames[$key] = $tableprefix . '.' . $altname; 3420 } 3421 } 3422 } 3423 $alternatenames = implode(',', $alternatenames); 3424 } 3425 return $alternatenames; 3426 } 3427 3428 /** 3429 * Update a subscription from the form data in one of the rows in the existing subscriptions table. 3430 * 3431 * @param int $subscriptionid The ID of the subscription we are acting upon. 3432 * @param int $pollinterval The poll interval to use. 3433 * @param int $action The action to be performed. One of update or remove. 3434 * @throws dml_exception if invalid subscriptionid is provided 3435 * @return string A log of the import progress, including errors 3436 * @deprecated since Moodle 4.0 MDL-71953 3437 */ 3438 function calendar_process_subscription_row($subscriptionid, $pollinterval, $action) { 3439 debugging('calendar_process_subscription_row() is deprecated.', DEBUG_DEVELOPER); 3440 // Fetch the subscription from the database making sure it exists. 3441 $sub = calendar_get_subscription($subscriptionid); 3442 3443 // Update or remove the subscription, based on action. 3444 switch ($action) { 3445 case CALENDAR_SUBSCRIPTION_UPDATE: 3446 // Skip updating file subscriptions. 3447 if (empty($sub->url)) { 3448 break; 3449 } 3450 $sub->pollinterval = $pollinterval; 3451 calendar_update_subscription($sub); 3452 3453 // Update the events. 3454 return "<p>" . get_string('subscriptionupdated', 'calendar', $sub->name) . "</p>" . 3455 calendar_update_subscription_events($subscriptionid); 3456 case CALENDAR_SUBSCRIPTION_REMOVE: 3457 calendar_delete_subscription($subscriptionid); 3458 return get_string('subscriptionremoved', 'calendar', $sub->name); 3459 break; 3460 default: 3461 break; 3462 } 3463 return ''; 3464 } 3465 3466 /** 3467 * Import events from an iCalendar object into a course calendar. 3468 * 3469 * @param iCalendar $ical The iCalendar object. 3470 * @param int $unused Deprecated 3471 * @param int $subscriptionid The subscription ID. 3472 * @return string A log of the import progress, including errors. 3473 */ 3474 function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid = null) { 3475 debugging('calendar_import_icalendar_events() is deprecated. Please use calendar_import_events_from_ical() instead.', 3476 DEBUG_DEVELOPER); 3477 global $DB; 3478 3479 $return = ''; 3480 $eventcount = 0; 3481 $updatecount = 0; 3482 $skippedcount = 0; 3483 3484 // Large calendars take a while... 3485 if (!CLI_SCRIPT) { 3486 \core_php_time_limit::raise(300); 3487 } 3488 3489 // Grab the timezone from the iCalendar file to be used later. 3490 if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) { 3491 $timezone = $ical->properties['X-WR-TIMEZONE'][0]->value; 3492 } else { 3493 $timezone = 'UTC'; 3494 } 3495 3496 $icaluuids = []; 3497 foreach ($ical->components['VEVENT'] as $event) { 3498 $icaluuids[] = $event->properties['UID'][0]->value; 3499 $res = calendar_add_icalendar_event($event, null, $subscriptionid, $timezone); 3500 switch ($res) { 3501 case CALENDAR_IMPORT_EVENT_UPDATED: 3502 $updatecount++; 3503 break; 3504 case CALENDAR_IMPORT_EVENT_INSERTED: 3505 $eventcount++; 3506 break; 3507 case CALENDAR_IMPORT_EVENT_SKIPPED: 3508 $skippedcount++; 3509 break; 3510 case 0: 3511 $return .= '<p>' . get_string('erroraddingevent', 'calendar') . ': '; 3512 if (empty($event->properties['SUMMARY'])) { 3513 $return .= '(' . get_string('notitle', 'calendar') . ')'; 3514 } else { 3515 $return .= $event->properties['SUMMARY'][0]->value; 3516 } 3517 $return .= "</p>\n"; 3518 break; 3519 } 3520 } 3521 3522 $return .= html_writer::start_tag('ul'); 3523 $existing = $DB->get_field('event_subscriptions', 'lastupdated', ['id' => $subscriptionid]); 3524 if (!empty($existing)) { 3525 $eventsuuids = $DB->get_records_menu('event', ['subscriptionid' => $subscriptionid], '', 'id, uuid'); 3526 3527 $icaleventscount = count($icaluuids); 3528 $tobedeleted = []; 3529 if (count($eventsuuids) > $icaleventscount) { 3530 foreach ($eventsuuids as $eventid => $eventuuid) { 3531 if (!in_array($eventuuid, $icaluuids)) { 3532 $tobedeleted[] = $eventid; 3533 } 3534 } 3535 if (!empty($tobedeleted)) { 3536 $DB->delete_records_list('event', 'id', $tobedeleted); 3537 $return .= html_writer::tag('li', get_string('eventsdeleted', 'calendar', count($tobedeleted))); 3538 } 3539 } 3540 } 3541 3542 $return .= html_writer::tag('li', get_string('eventsimported', 'calendar', $eventcount)); 3543 $return .= html_writer::tag('li', get_string('eventsskipped', 'calendar', $skippedcount)); 3544 $return .= html_writer::tag('li', get_string('eventsupdated', 'calendar', $updatecount)); 3545 $return .= html_writer::end_tag('ul'); 3546 return $return; 3547 } 3548 3549 /** 3550 * Print grading plugin selection tab-based navigation. 3551 * 3552 * @deprecated since Moodle 4.0. Tabs navigation has been replaced with tertiary navigation. 3553 * @param string $active_type type of plugin on current page - import, export, report or edit 3554 * @param string $active_plugin active plugin type - grader, user, cvs, ... 3555 * @param array $plugin_info Array of plugins 3556 * @param boolean $return return as string 3557 * 3558 * @return nothing or string if $return true 3559 */ 3560 function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false) { 3561 global $CFG, $COURSE; 3562 3563 debugging('grade_print_tabs() has been deprecated. Tabs navigation has been replaced with tertiary navigation.', 3564 DEBUG_DEVELOPER); 3565 3566 if (!isset($currenttab)) { //TODO: this is weird 3567 $currenttab = ''; 3568 } 3569 3570 $tabs = array(); 3571 $top_row = array(); 3572 $bottom_row = array(); 3573 $inactive = array($active_plugin); 3574 $activated = array($active_type); 3575 3576 $count = 0; 3577 $active = ''; 3578 3579 foreach ($plugin_info as $plugin_type => $plugins) { 3580 if ($plugin_type == 'strings') { 3581 continue; 3582 } 3583 3584 // If $plugins is actually the definition of a child-less parent link: 3585 if (!empty($plugins->id)) { 3586 $string = $plugins->string; 3587 if (!empty($plugin_info[$active_type]->parent)) { 3588 $string = $plugin_info[$active_type]->parent->string; 3589 } 3590 3591 $top_row[] = new tabobject($plugin_type, $plugins->link, $string); 3592 continue; 3593 } 3594 3595 $first_plugin = reset($plugins); 3596 $url = $first_plugin->link; 3597 3598 if ($plugin_type == 'report') { 3599 $url = $CFG->wwwroot.'/grade/report/index.php?id='.$COURSE->id; 3600 } 3601 3602 $top_row[] = new tabobject($plugin_type, $url, $plugin_info['strings'][$plugin_type]); 3603 3604 if ($active_type == $plugin_type) { 3605 foreach ($plugins as $plugin) { 3606 $bottom_row[] = new tabobject($plugin->id, $plugin->link, $plugin->string); 3607 if ($plugin->id == $active_plugin) { 3608 $inactive = array($plugin->id); 3609 } 3610 } 3611 } 3612 } 3613 3614 // Do not display rows that contain only one item, they are not helpful. 3615 if (count($top_row) > 1) { 3616 $tabs[] = $top_row; 3617 } 3618 if (count($bottom_row) > 1) { 3619 $tabs[] = $bottom_row; 3620 } 3621 if (empty($tabs)) { 3622 return; 3623 } 3624 3625 $rv = html_writer::div(print_tabs($tabs, $active_plugin, $inactive, $activated, true), 'grade-navigation'); 3626 3627 if ($return) { 3628 return $rv; 3629 } else { 3630 echo $rv; 3631 } 3632 } 3633 3634 /** 3635 * Print grading plugin selection popup form. 3636 * 3637 * @deprecated since Moodle 4.0. Dropdown box navigation has been replaced with tertiary navigation. 3638 * @param array $plugin_info An array of plugins containing information for the selector 3639 * @param boolean $return return as string 3640 * 3641 * @return nothing or string if $return true 3642 */ 3643 function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return=false) { 3644 global $CFG, $OUTPUT, $PAGE; 3645 3646 debugging('print_grade_plugin_selector() has been deprecated. Dropdown box navigation has been replaced ' . 3647 'with tertiary navigation.', DEBUG_DEVELOPER); 3648 3649 $menu = array(); 3650 $count = 0; 3651 $active = ''; 3652 3653 foreach ($plugin_info as $plugin_type => $plugins) { 3654 if ($plugin_type == 'strings') { 3655 continue; 3656 } 3657 3658 $first_plugin = reset($plugins); 3659 3660 $sectionname = $plugin_info['strings'][$plugin_type]; 3661 $section = array(); 3662 3663 foreach ($plugins as $plugin) { 3664 $link = $plugin->link->out(false); 3665 $section[$link] = $plugin->string; 3666 $count++; 3667 if ($plugin_type === $active_type and $plugin->id === $active_plugin) { 3668 $active = $link; 3669 } 3670 } 3671 3672 if ($section) { 3673 $menu[] = array($sectionname=>$section); 3674 } 3675 } 3676 3677 // finally print/return the popup form 3678 if ($count > 1) { 3679 $select = new url_select($menu, $active, null, 'choosepluginreport'); 3680 $select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide')); 3681 if ($return) { 3682 return $OUTPUT->render($select); 3683 } else { 3684 echo $OUTPUT->render($select); 3685 } 3686 } else { 3687 // only one option - no plugin selector needed 3688 return ''; 3689 } 3690 3691 /** 3692 * Purge the cache of a course section. 3693 * 3694 * $sectioninfo must have following attributes: 3695 * - course: course id 3696 * - section: section number 3697 * 3698 * @param object $sectioninfo section info 3699 * @return void 3700 * @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_section_cache_by_id()} 3701 * or {@link course_modinfo::purge_course_section_cache_by_number()} instead. 3702 */ 3703 function course_purge_section_cache(object $sectioninfo): void { 3704 debugging(__FUNCTION__ . '() is deprecated. ' . 3705 'Please use course_modinfo::purge_course_section_cache_by_id() ' . 3706 'or course_modinfo::purge_course_section_cache_by_number() instead.', 3707 DEBUG_DEVELOPER); 3708 $sectionid = $sectioninfo->section; 3709 $courseid = $sectioninfo->course; 3710 course_modinfo::purge_course_section_cache_by_id($courseid, $sectionid); 3711 } 3712 3713 /** 3714 * Purge the cache of a course module. 3715 * 3716 * $cm must have following attributes: 3717 * - id: cmid 3718 * - course: course id 3719 * 3720 * @param cm_info|stdClass $cm course module 3721 * @return void 3722 * @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_module_cache()} instead. 3723 */ 3724 function course_purge_module_cache($cm): void { 3725 debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::purge_course_module_cache() instead.', 3726 DEBUG_DEVELOPER); 3727 $cmid = $cm->id; 3728 $courseid = $cm->course; 3729 course_modinfo::purge_course_module_cache($courseid, $cmid); 3730 } 3731 } 3732 3733 /** 3734 * For a given course, returns an array of course activity objects 3735 * Each item in the array contains he following properties: 3736 * 3737 * @param int $courseid course id 3738 * @param bool $usecache get activities from cache if modinfo exists when $usecache is true 3739 * @return array list of activities 3740 * @deprecated since Moodle 4.0. Please use {@link course_modinfo::get_array_of_activities()} instead. 3741 */ 3742 function get_array_of_activities(int $courseid, bool $usecache = false): array { 3743 debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::get_array_of_activities() instead.', 3744 DEBUG_DEVELOPER); 3745 return course_modinfo::get_array_of_activities(get_course($courseid), $usecache); 3746 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body