Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402] [Versions 402 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 (https://moodledev.io/docs/apis/subsystems/output#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              throw new \moodle_exception() 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   * @deprecated since 3.9
2774   */
2775  function get_module_metadata() {
2776      throw new coding_exception(
2777          'get_module_metadata() has been removed. Please use \core_course\local\service\content_item_service instead.');
2778  }
2779  
2780  /**
2781   * @deprecated since Moodle 3.9 MDL-63580. Please use the \core\task\manager::run_from_cli($task).
2782   */
2783  function cron_run_single_task() {
2784      throw new coding_exception(
2785          'cron_run_single_task() has been removed. Please use \\core\task\manager::run_from_cli() instead.'
2786      );
2787  }
2788  
2789  /**
2790   * Executes cron functions for a specific type of plugin.
2791   *
2792   * @param string $plugintype Plugin type (e.g. 'report')
2793   * @param string $description If specified, will display 'Starting (whatever)'
2794   *   and 'Finished (whatever)' lines, otherwise does not display
2795   *
2796   * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2797   * @todo MDL-61165 This will be deleted in Moodle 4.1.
2798   */
2799  function cron_execute_plugin_type($plugintype, $description = null) {
2800      global $DB;
2801  
2802      // Get list from plugin => function for all plugins.
2803      $plugins = get_plugin_list_with_function($plugintype, 'cron');
2804  
2805      // Modify list for backward compatibility (different files/names).
2806      $plugins = cron_bc_hack_plugin_functions($plugintype, $plugins);
2807  
2808      // Return if no plugins with cron function to process.
2809      if (!$plugins) {
2810          return;
2811      }
2812  
2813      if ($description) {
2814          mtrace('Starting '.$description);
2815      }
2816  
2817      foreach ($plugins as $component => $cronfunction) {
2818          $dir = core_component::get_component_directory($component);
2819  
2820          // Get cron period if specified in version.php, otherwise assume every cron.
2821          $cronperiod = 0;
2822          if (file_exists("$dir/version.php")) {
2823              $plugin = new stdClass();
2824              include("$dir/version.php");
2825              if (isset($plugin->cron)) {
2826                  $cronperiod = $plugin->cron;
2827              }
2828          }
2829  
2830          // Using last cron and cron period, don't run if it already ran recently.
2831          $lastcron = get_config($component, 'lastcron');
2832          if ($cronperiod && $lastcron) {
2833              if ($lastcron + $cronperiod > time()) {
2834                  // Do not execute cron yet.
2835                  continue;
2836              }
2837          }
2838  
2839          mtrace('Processing cron function for ' . $component . '...');
2840          debugging("Use of legacy cron is deprecated ($cronfunction). Please use scheduled tasks.", DEBUG_DEVELOPER);
2841          \core\cron::trace_time_and_memory();
2842          $pre_dbqueries = $DB->perf_get_queries();
2843          $pre_time = microtime(true);
2844  
2845          $cronfunction();
2846  
2847          mtrace("done. (" . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries, " .
2848                  round(microtime(true) - $pre_time, 2) . " seconds)");
2849  
2850          set_config('lastcron', time(), $component);
2851          core_php_time_limit::raise();
2852      }
2853  
2854      if ($description) {
2855          mtrace('Finished ' . $description);
2856      }
2857  }
2858  
2859  /**
2860   * Used to add in old-style cron functions within plugins that have not been converted to the
2861   * new standard API. (The standard API is frankenstyle_name_cron() in lib.php; some types used
2862   * cron.php and some used a different name.)
2863   *
2864   * @param string $plugintype Plugin type e.g. 'report'
2865   * @param array $plugins Array from plugin name (e.g. 'report_frog') to function name (e.g.
2866   *   'report_frog_cron') for plugin cron functions that were already found using the new API
2867   * @return array Revised version of $plugins that adds in any extra plugin functions found by
2868   *   looking in the older location
2869   *
2870   * @deprecated since Moodle 3.9 MDL-52846. Please use new task API.
2871   * @todo MDL-61165 This will be deleted in Moodle 4.1.
2872   */
2873  function cron_bc_hack_plugin_functions($plugintype, $plugins) {
2874      global $CFG; // Mandatory in case it is referenced by include()d PHP script.
2875  
2876      if ($plugintype === 'report') {
2877          // Admin reports only - not course report because course report was
2878          // never implemented before, so doesn't need BC.
2879          foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
2880              $component = $plugintype . '_' . $pluginname;
2881              if (isset($plugins[$component])) {
2882                  // We already have detected the function using the new API.
2883                  continue;
2884              }
2885              if (!file_exists("$dir/cron.php")) {
2886                  // No old style cron file present.
2887                  continue;
2888              }
2889              include_once("$dir/cron.php");
2890              $cronfunction = $component . '_cron';
2891              if (function_exists($cronfunction)) {
2892                  $plugins[$component] = $cronfunction;
2893              } else {
2894                  debugging("Invalid legacy cron.php detected in $component, " .
2895                          "please use lib.php instead");
2896              }
2897          }
2898      } else if (strpos($plugintype, 'grade') === 0) {
2899          // Detect old style cron function names.
2900          // Plugin gradeexport_frog used to use grade_export_frog_cron() instead of
2901          // new standard API gradeexport_frog_cron(). Also applies to gradeimport, gradereport.
2902          foreach (core_component::get_plugin_list($plugintype) as $pluginname => $dir) {
2903              $component = $plugintype.'_'.$pluginname;
2904              if (isset($plugins[$component])) {
2905                  // We already have detected the function using the new API.
2906                  continue;
2907              }
2908              if (!file_exists("$dir/lib.php")) {
2909                  continue;
2910              }
2911              include_once("$dir/lib.php");
2912              $cronfunction = str_replace('grade', 'grade_', $plugintype) . '_' .
2913                      $pluginname . '_cron';
2914              if (function_exists($cronfunction)) {
2915                  $plugins[$component] = $cronfunction;
2916              }
2917          }
2918      }
2919  
2920      return $plugins;
2921  }
2922  
2923  /**
2924   * Returns the SQL used by the participants table.
2925   *
2926   * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
2927   * @param int $courseid The course id
2928   * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
2929   * @param int $accesssince The time since last access, 0 means any time
2930   * @param int $roleid The role id, 0 means all roles and -1 no roles
2931   * @param int $enrolid The enrolment id, 0 means all enrolment methods will be returned.
2932   * @param int $statusid The user enrolment status, -1 means all enrolments regardless of the status will be returned, if allowed.
2933   * @param string|array $search The search that was performed, empty means perform no search
2934   * @param string $additionalwhere Any additional SQL to add to where
2935   * @param array $additionalparams The additional params
2936   * @return array
2937   */
2938  function user_get_participants_sql($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
2939                                     $search = '', $additionalwhere = '', $additionalparams = array()) {
2940      global $DB, $USER, $CFG;
2941  
2942      $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
2943                   'Please use \core\table\participants_search::class with table filtersets instead.';
2944      debugging($deprecatedtext, DEBUG_DEVELOPER);
2945  
2946      // Get the context.
2947      $context = \context_course::instance($courseid, MUST_EXIST);
2948  
2949      $isfrontpage = ($courseid == SITEID);
2950  
2951      // Default filter settings. We only show active by default, especially if the user has no capability to review enrolments.
2952      $onlyactive = true;
2953      $onlysuspended = false;
2954      if (has_capability('moodle/course:enrolreview', $context) && (has_capability('moodle/course:viewsuspendedusers', $context))) {
2955          switch ($statusid) {
2956              case ENROL_USER_ACTIVE:
2957                  // Nothing to do here.
2958                  break;
2959              case ENROL_USER_SUSPENDED:
2960                  $onlyactive = false;
2961                  $onlysuspended = true;
2962                  break;
2963              default:
2964                  // If the user has capability to review user enrolments, but statusid is set to -1, set $onlyactive to false.
2965                  $onlyactive = false;
2966                  break;
2967          }
2968      }
2969  
2970      list($esql, $params) = get_enrolled_sql($context, null, $groupid, $onlyactive, $onlysuspended, $enrolid);
2971  
2972      $joins = array('FROM {user} u');
2973      $wheres = array();
2974  
2975      // TODO Does not support custom user profile fields (MDL-70456).
2976      $userfields = \core_user\fields::get_identity_fields($context, false);
2977      $userfieldsapi = \core_user\fields::for_userpic()->including(...$userfields);
2978      $userfieldssql = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
2979  
2980      if ($isfrontpage) {
2981          $select = "SELECT $userfieldssql, u.lastaccess";
2982          $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Everybody on the frontpage usually.
2983          if ($accesssince) {
2984              $wheres[] = user_get_user_lastaccess_sql($accesssince);
2985          }
2986      } else {
2987          $select = "SELECT $userfieldssql, COALESCE(ul.timeaccess, 0) AS lastaccess";
2988          $joins[] = "JOIN ($esql) e ON e.id = u.id"; // Course enrolled users only.
2989          // Not everybody has accessed the course yet.
2990          $joins[] = 'LEFT JOIN {user_lastaccess} ul ON (ul.userid = u.id AND ul.courseid = :courseid)';
2991          $params['courseid'] = $courseid;
2992          if ($accesssince) {
2993              $wheres[] = user_get_course_lastaccess_sql($accesssince);
2994          }
2995      }
2996  
2997      // Performance hacks - we preload user contexts together with accounts.
2998      $ccselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
2999      $ccjoin = 'LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)';
3000      $params['contextlevel'] = CONTEXT_USER;
3001      $select .= $ccselect;
3002      $joins[] = $ccjoin;
3003  
3004      // Limit list to users with some role only.
3005      if ($roleid) {
3006          // We want to query both the current context and parent contexts.
3007          list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($context->get_parent_context_ids(true),
3008              SQL_PARAMS_NAMED, 'relatedctx');
3009  
3010          // Get users without any role.
3011          if ($roleid == -1) {
3012              $wheres[] = "u.id NOT IN (SELECT userid FROM {role_assignments} WHERE contextid $relatedctxsql)";
3013              $params = array_merge($params, $relatedctxparams);
3014          } else {
3015              $wheres[] = "u.id IN (SELECT userid FROM {role_assignments} WHERE roleid = :roleid AND contextid $relatedctxsql)";
3016              $params = array_merge($params, array('roleid' => $roleid), $relatedctxparams);
3017          }
3018      }
3019  
3020      if (!empty($search)) {
3021          if (!is_array($search)) {
3022              $search = [$search];
3023          }
3024          foreach ($search as $index => $keyword) {
3025              $searchkey1 = 'search' . $index . '1';
3026              $searchkey2 = 'search' . $index . '2';
3027              $searchkey3 = 'search' . $index . '3';
3028              $searchkey4 = 'search' . $index . '4';
3029              $searchkey5 = 'search' . $index . '5';
3030              $searchkey6 = 'search' . $index . '6';
3031              $searchkey7 = 'search' . $index . '7';
3032  
3033              $conditions = array();
3034              // Search by fullname.
3035              $fullname = $DB->sql_fullname('u.firstname', 'u.lastname');
3036              $conditions[] = $DB->sql_like($fullname, ':' . $searchkey1, false, false);
3037  
3038              // Search by email.
3039              $email = $DB->sql_like('email', ':' . $searchkey2, false, false);
3040              if (!in_array('email', $userfields)) {
3041                  $maildisplay = 'maildisplay' . $index;
3042                  $userid1 = 'userid' . $index . '1';
3043                  // Prevent users who hide their email address from being found by others
3044                  // who aren't allowed to see hidden email addresses.
3045                  $email = "(". $email ." AND (" .
3046                          "u.maildisplay <> :$maildisplay " .
3047                          "OR u.id = :$userid1". // User can always find himself.
3048                          "))";
3049                  $params[$maildisplay] = core_user::MAILDISPLAY_HIDE;
3050                  $params[$userid1] = $USER->id;
3051              }
3052              $conditions[] = $email;
3053  
3054              // Search by idnumber.
3055              $idnumber = $DB->sql_like('idnumber', ':' . $searchkey3, false, false);
3056              if (!in_array('idnumber', $userfields)) {
3057                  $userid2 = 'userid' . $index . '2';
3058                  // Users who aren't allowed to see idnumbers should at most find themselves
3059                  // when searching for an idnumber.
3060                  $idnumber = "(". $idnumber . " AND u.id = :$userid2)";
3061                  $params[$userid2] = $USER->id;
3062              }
3063              $conditions[] = $idnumber;
3064  
3065              // TODO Does not support custom user profile fields (MDL-70456).
3066              $extrasearchfields = \core_user\fields::get_identity_fields($context, false);
3067              if (!empty($extrasearchfields)) {
3068                  // Search all user identify fields.
3069                  foreach ($extrasearchfields as $extrasearchfield) {
3070                      if (in_array($extrasearchfield, ['email', 'idnumber', 'country'])) {
3071                          // Already covered above. Search by country not supported.
3072                          continue;
3073                      }
3074                      $param = $searchkey3 . $extrasearchfield;
3075                      $condition = $DB->sql_like($extrasearchfield, ':' . $param, false, false);
3076                      $params[$param] = "%$keyword%";
3077                      if (!in_array($extrasearchfield, $userfields)) {
3078                          // User cannot see this field, but allow match if their own account.
3079                          $userid3 = 'userid' . $index . '3' . $extrasearchfield;
3080                          $condition = "(". $condition . " AND u.id = :$userid3)";
3081                          $params[$userid3] = $USER->id;
3082                      }
3083                      $conditions[] = $condition;
3084                  }
3085              }
3086  
3087              // Search by middlename.
3088              $middlename = $DB->sql_like('middlename', ':' . $searchkey4, false, false);
3089              $conditions[] = $middlename;
3090  
3091              // Search by alternatename.
3092              $alternatename = $DB->sql_like('alternatename', ':' . $searchkey5, false, false);
3093              $conditions[] = $alternatename;
3094  
3095              // Search by firstnamephonetic.
3096              $firstnamephonetic = $DB->sql_like('firstnamephonetic', ':' . $searchkey6, false, false);
3097              $conditions[] = $firstnamephonetic;
3098  
3099              // Search by lastnamephonetic.
3100              $lastnamephonetic = $DB->sql_like('lastnamephonetic', ':' . $searchkey7, false, false);
3101              $conditions[] = $lastnamephonetic;
3102  
3103              $wheres[] = "(". implode(" OR ", $conditions) .") ";
3104              $params[$searchkey1] = "%$keyword%";
3105              $params[$searchkey2] = "%$keyword%";
3106              $params[$searchkey3] = "%$keyword%";
3107              $params[$searchkey4] = "%$keyword%";
3108              $params[$searchkey5] = "%$keyword%";
3109              $params[$searchkey6] = "%$keyword%";
3110              $params[$searchkey7] = "%$keyword%";
3111          }
3112      }
3113  
3114      if (!empty($additionalwhere)) {
3115          $wheres[] = $additionalwhere;
3116          $params = array_merge($params, $additionalparams);
3117      }
3118  
3119      $from = implode("\n", $joins);
3120      if ($wheres) {
3121          $where = 'WHERE ' . implode(' AND ', $wheres);
3122      } else {
3123          $where = '';
3124      }
3125  
3126      return array($select, $from, $where, $params);
3127  }
3128  
3129  /**
3130   * Returns the total number of participants for a given course.
3131   *
3132   * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3133   * @param int $courseid The course id
3134   * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3135   * @param int $accesssince The time since last access, 0 means any time
3136   * @param int $roleid The role id, 0 means all roles
3137   * @param int $enrolid The applied filter for the user enrolment ID.
3138   * @param int $status The applied filter for the user's enrolment status.
3139   * @param string|array $search The search that was performed, empty means perform no search
3140   * @param string $additionalwhere Any additional SQL to add to where
3141   * @param array $additionalparams The additional params
3142   * @return int
3143   */
3144  function user_get_total_participants($courseid, $groupid = 0, $accesssince = 0, $roleid = 0, $enrolid = 0, $statusid = -1,
3145                                       $search = '', $additionalwhere = '', $additionalparams = array()) {
3146      global $DB;
3147  
3148      $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3149                        'Please use \core\table\participants_search::class with table filtersets instead.';
3150      debugging($deprecatedtext, DEBUG_DEVELOPER);
3151  
3152      list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3153          $statusid, $search, $additionalwhere, $additionalparams);
3154  
3155      return $DB->count_records_sql("SELECT COUNT(u.id) $from $where", $params);
3156  }
3157  
3158  /**
3159   * Returns the participants for a given course.
3160   *
3161   * @deprecated since Moodle 3.9 MDL-68612 - See \core_user\table\participants_search for an improved way to fetch participants.
3162   * @param int $courseid The course id
3163   * @param int $groupid The groupid, 0 means all groups and USERSWITHOUTGROUP no group
3164   * @param int $accesssince The time since last access
3165   * @param int $roleid The role id
3166   * @param int $enrolid The applied filter for the user enrolment ID.
3167   * @param int $status The applied filter for the user's enrolment status.
3168   * @param string $search The search that was performed
3169   * @param string $additionalwhere Any additional SQL to add to where
3170   * @param array $additionalparams The additional params
3171   * @param string $sort The SQL sort
3172   * @param int $limitfrom return a subset of records, starting at this point (optional).
3173   * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
3174   * @return moodle_recordset
3175   */
3176  function user_get_participants($courseid, $groupid, $accesssince, $roleid, $enrolid, $statusid, $search,
3177                                 $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) {
3178      global $DB;
3179  
3180      $deprecatedtext = __FUNCTION__ . '() is deprecated. ' .
3181                        'Please use \core\table\participants_search::class with table filtersets instead.';
3182      debugging($deprecatedtext, DEBUG_DEVELOPER);
3183  
3184      list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
3185          $statusid, $search, $additionalwhere, $additionalparams);
3186  
3187      return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
3188  }
3189  
3190  /**
3191   * @deprecated Since Moodle 3.9. MDL-65835
3192   */
3193  function plagiarism_save_form_elements() {
3194      throw new coding_exception(
3195          'Function plagiarism_save_form_elements() has been removed. ' .
3196          'Please use {plugin name}_coursemodule_edit_post_actions() instead.'
3197      );
3198  }
3199  
3200  /**
3201   * @deprecated Since Moodle 3.9. MDL-65835
3202   */
3203  function plagiarism_get_form_elements_module() {
3204      throw new coding_exception(
3205          'Function plagiarism_get_form_elements_module() has been removed. ' .
3206          'Please use {plugin name}_coursemodule_standard_elements() instead.'
3207      );
3208  }
3209  
3210  
3211  /**
3212   * @deprecated since Moodle 3.10
3213   */
3214  function make_categories_options() {
3215      throw new coding_exception(__FUNCTION__ . '() has been removed. ' .
3216          'Please use \core_course_category::make_categories_list() instead.');
3217  }
3218  
3219  /**
3220   * @deprecated since 3.10
3221   */
3222  function message_count_unread_messages() {
3223      throw new coding_exception('message_count_unread_messages has been removed.');
3224  }
3225  
3226  /**
3227   * @deprecated since 3.10
3228   */
3229  function serialise_tool_proxy() {
3230      throw new coding_exception('serialise_tool_proxy has been removed.');
3231  }
3232  
3233  /**
3234   * Checks if current user is shown any extra fields when listing users.
3235   *
3236   * Does not include any custom profile fields.
3237   *
3238   * @param object $context Context
3239   * @param array $already Array of fields that we're going to show anyway
3240   *   so don't bother listing them
3241   * @return array Array of field names from user table, not including anything
3242   *   listed in $already
3243   * @deprecated since Moodle 3.11 MDL-45242
3244   * @see \core_user\fields
3245   */
3246  function get_extra_user_fields($context, $already = array()) {
3247      debugging('get_extra_user_fields() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3248  
3249      $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3250      return $fields->get_required_fields();
3251  }
3252  
3253  /**
3254   * If the current user is to be shown extra user fields when listing or
3255   * selecting users, returns a string suitable for including in an SQL select
3256   * clause to retrieve those fields.
3257   *
3258   * Does not include any custom profile fields.
3259   *
3260   * @param context $context Context
3261   * @param string $alias Alias of user table, e.g. 'u' (default none)
3262   * @param string $prefix Prefix for field names using AS, e.g. 'u_' (default none)
3263   * @param array $already Array of fields that we're going to include anyway so don't list them (default none)
3264   * @return string Partial SQL select clause, beginning with comma, for example ',u.idnumber,u.department' unless it is blank
3265   * @deprecated since Moodle 3.11 MDL-45242
3266   * @see \core_user\fields
3267   */
3268  function get_extra_user_fields_sql($context, $alias='', $prefix='', $already = array()) {
3269      debugging('get_extra_user_fields_sql() is deprecated. Please use the \core_user\fields API instead.', DEBUG_DEVELOPER);
3270  
3271      $fields = \core_user\fields::for_identity($context, false)->excluding(...$already);
3272      // Note: There will never be any joins or join params because we turned off profile fields.
3273      $selects = $fields->get_sql($alias, false, $prefix)->selects;
3274  
3275      return $selects;
3276  }
3277  
3278  /**
3279   * Returns the display name of a field in the user table. Works for most fields that are commonly displayed to users.
3280   *
3281   * Also works for custom fields.
3282   *
3283   * @param string $field Field name, e.g. 'phone1'
3284   * @return string Text description taken from language file, e.g. 'Phone number'
3285   * @deprecated since Moodle 3.11 MDL-45242
3286   * @see \core_user\fields
3287   */
3288  function get_user_field_name($field) {
3289      debugging('get_user_field_name() is deprecated. Please use \core_user\fields::get_display_name() instead', DEBUG_DEVELOPER);
3290  
3291      return \core_user\fields::get_display_name($field);
3292  }
3293  
3294  /**
3295   * A centralised location for the all name fields. Returns an array / sql string snippet.
3296   *
3297   * @param bool $returnsql True for an sql select field snippet.
3298   * @param string $tableprefix table query prefix to use in front of each field.
3299   * @param string $prefix prefix added to the name fields e.g. authorfirstname.
3300   * @param string $fieldprefix sql field prefix e.g. id AS userid.
3301   * @param bool $order moves firstname and lastname to the top of the array / start of the string.
3302   * @return array|string All name fields.
3303   * @deprecated since Moodle 3.11 MDL-45242
3304   * @see \core_user\fields
3305   */
3306  function get_all_user_name_fields($returnsql = false, $tableprefix = null, $prefix = null, $fieldprefix = null, $order = false) {
3307      debugging('get_all_user_name_fields() is deprecated. Please use the \core_user\fields API instead', DEBUG_DEVELOPER);
3308  
3309      // This array is provided in this order because when called by fullname() (above) if firstname is before
3310      // firstnamephonetic str_replace() will change the wrong placeholder.
3311      $alternatenames = [];
3312      foreach (\core_user\fields::get_name_fields() as $field) {
3313          $alternatenames[$field] = $field;
3314      }
3315  
3316      // Let's add a prefix to the array of user name fields if provided.
3317      if ($prefix) {
3318          foreach ($alternatenames as $key => $altname) {
3319              $alternatenames[$key] = $prefix . $altname;
3320          }
3321      }
3322  
3323      // If we want the end result to have firstname and lastname at the front / top of the result.
3324      if ($order) {
3325          // Move the last two elements (firstname, lastname) off the array and put them at the top.
3326          for ($i = 0; $i < 2; $i++) {
3327              // Get the last element.
3328              $lastelement = end($alternatenames);
3329              // Remove it from the array.
3330              unset($alternatenames[$lastelement]);
3331              // Put the element back on the top of the array.
3332              $alternatenames = array_merge(array($lastelement => $lastelement), $alternatenames);
3333          }
3334      }
3335  
3336      // Create an sql field snippet if requested.
3337      if ($returnsql) {
3338          if ($tableprefix) {
3339              if ($fieldprefix) {
3340                  foreach ($alternatenames as $key => $altname) {
3341                      $alternatenames[$key] = $tableprefix . '.' . $altname . ' AS ' . $fieldprefix . $altname;
3342                  }
3343              } else {
3344                  foreach ($alternatenames as $key => $altname) {
3345                      $alternatenames[$key] = $tableprefix . '.' . $altname;
3346                  }
3347              }
3348          }
3349          $alternatenames = implode(',', $alternatenames);
3350      }
3351      return $alternatenames;
3352  }
3353  
3354  /**
3355   * Update a subscription from the form data in one of the rows in the existing subscriptions table.
3356   *
3357   * @param int $subscriptionid The ID of the subscription we are acting upon.
3358   * @param int $pollinterval The poll interval to use.
3359   * @param int $action The action to be performed. One of update or remove.
3360   * @throws dml_exception if invalid subscriptionid is provided
3361   * @return string A log of the import progress, including errors
3362   * @deprecated since Moodle 4.0 MDL-71953
3363   */
3364  function calendar_process_subscription_row($subscriptionid, $pollinterval, $action) {
3365      debugging('calendar_process_subscription_row() is deprecated.', DEBUG_DEVELOPER);
3366      // Fetch the subscription from the database making sure it exists.
3367      $sub = calendar_get_subscription($subscriptionid);
3368  
3369      // Update or remove the subscription, based on action.
3370      switch ($action) {
3371          case CALENDAR_SUBSCRIPTION_UPDATE:
3372              // Skip updating file subscriptions.
3373              if (empty($sub->url)) {
3374                  break;
3375              }
3376              $sub->pollinterval = $pollinterval;
3377              calendar_update_subscription($sub);
3378  
3379              // Update the events.
3380              return "<p>" . get_string('subscriptionupdated', 'calendar', $sub->name) . "</p>" .
3381                  calendar_update_subscription_events($subscriptionid);
3382          case CALENDAR_SUBSCRIPTION_REMOVE:
3383              calendar_delete_subscription($subscriptionid);
3384              return get_string('subscriptionremoved', 'calendar', $sub->name);
3385              break;
3386          default:
3387              break;
3388      }
3389      return '';
3390  }
3391  
3392  /**
3393   * Import events from an iCalendar object into a course calendar.
3394   *
3395   * @param iCalendar $ical The iCalendar object.
3396   * @param int $unused Deprecated
3397   * @param int $subscriptionid The subscription ID.
3398   * @return string A log of the import progress, including errors.
3399   */
3400  function calendar_import_icalendar_events($ical, $unused = null, $subscriptionid = null) {
3401      debugging('calendar_import_icalendar_events() is deprecated. Please use calendar_import_events_from_ical() instead.',
3402          DEBUG_DEVELOPER);
3403      global $DB;
3404  
3405      $return = '';
3406      $eventcount = 0;
3407      $updatecount = 0;
3408      $skippedcount = 0;
3409  
3410      // Large calendars take a while...
3411      if (!CLI_SCRIPT) {
3412          \core_php_time_limit::raise(300);
3413      }
3414  
3415      // Grab the timezone from the iCalendar file to be used later.
3416      if (isset($ical->properties['X-WR-TIMEZONE'][0]->value)) {
3417          $timezone = $ical->properties['X-WR-TIMEZONE'][0]->value;
3418      } else {
3419          $timezone = 'UTC';
3420      }
3421  
3422      $icaluuids = [];
3423      foreach ($ical->components['VEVENT'] as $event) {
3424          $icaluuids[] = $event->properties['UID'][0]->value;
3425          $res = calendar_add_icalendar_event($event, null, $subscriptionid, $timezone);
3426          switch ($res) {
3427              case CALENDAR_IMPORT_EVENT_UPDATED:
3428                  $updatecount++;
3429                  break;
3430              case CALENDAR_IMPORT_EVENT_INSERTED:
3431                  $eventcount++;
3432                  break;
3433              case CALENDAR_IMPORT_EVENT_SKIPPED:
3434                  $skippedcount++;
3435                  break;
3436              case 0:
3437                  $return .= '<p>' . get_string('erroraddingevent', 'calendar') . ': ';
3438                  if (empty($event->properties['SUMMARY'])) {
3439                      $return .= '(' . get_string('notitle', 'calendar') . ')';
3440                  } else {
3441                      $return .= $event->properties['SUMMARY'][0]->value;
3442                  }
3443                  $return .= "</p>\n";
3444                  break;
3445          }
3446      }
3447  
3448      $return .= html_writer::start_tag('ul');
3449      $existing = $DB->get_field('event_subscriptions', 'lastupdated', ['id' => $subscriptionid]);
3450      if (!empty($existing)) {
3451          $eventsuuids = $DB->get_records_menu('event', ['subscriptionid' => $subscriptionid], '', 'id, uuid');
3452  
3453          $icaleventscount = count($icaluuids);
3454          $tobedeleted = [];
3455          if (count($eventsuuids) > $icaleventscount) {
3456              foreach ($eventsuuids as $eventid => $eventuuid) {
3457                  if (!in_array($eventuuid, $icaluuids)) {
3458                      $tobedeleted[] = $eventid;
3459                  }
3460              }
3461              if (!empty($tobedeleted)) {
3462                  $DB->delete_records_list('event', 'id', $tobedeleted);
3463                  $return .= html_writer::tag('li', get_string('eventsdeleted', 'calendar', count($tobedeleted)));
3464              }
3465          }
3466      }
3467  
3468      $return .= html_writer::tag('li', get_string('eventsimported', 'calendar', $eventcount));
3469      $return .= html_writer::tag('li', get_string('eventsskipped', 'calendar', $skippedcount));
3470      $return .= html_writer::tag('li', get_string('eventsupdated', 'calendar', $updatecount));
3471      $return .= html_writer::end_tag('ul');
3472      return $return;
3473  }
3474  
3475  /**
3476   * Print grading plugin selection tab-based navigation.
3477   *
3478   * @deprecated since Moodle 4.0. Tabs navigation has been replaced with tertiary navigation.
3479   * @param string  $active_type type of plugin on current page - import, export, report or edit
3480   * @param string  $active_plugin active plugin type - grader, user, cvs, ...
3481   * @param array   $plugin_info Array of plugins
3482   * @param boolean $return return as string
3483   *
3484   * @return nothing or string if $return true
3485   */
3486  function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=false) {
3487      global $CFG, $COURSE;
3488  
3489      debugging('grade_print_tabs() has been deprecated. Tabs navigation has been replaced with tertiary navigation.',
3490          DEBUG_DEVELOPER);
3491  
3492      if (!isset($currenttab)) { //TODO: this is weird
3493          $currenttab = '';
3494      }
3495  
3496      $tabs = array();
3497      $top_row  = array();
3498      $bottom_row = array();
3499      $inactive = array($active_plugin);
3500      $activated = array($active_type);
3501  
3502      $count = 0;
3503      $active = '';
3504  
3505      foreach ($plugin_info as $plugin_type => $plugins) {
3506          if ($plugin_type == 'strings') {
3507              continue;
3508          }
3509  
3510          // If $plugins is actually the definition of a child-less parent link:
3511          if (!empty($plugins->id)) {
3512              $string = $plugins->string;
3513              if (!empty($plugin_info[$active_type]->parent)) {
3514                  $string = $plugin_info[$active_type]->parent->string;
3515              }
3516  
3517              $top_row[] = new tabobject($plugin_type, $plugins->link, $string);
3518              continue;
3519          }
3520  
3521          $first_plugin = reset($plugins);
3522          $url = $first_plugin->link;
3523  
3524          if ($plugin_type == 'report') {
3525              $url = $CFG->wwwroot.'/grade/report/index.php?id='.$COURSE->id;
3526          }
3527  
3528          $top_row[] = new tabobject($plugin_type, $url, $plugin_info['strings'][$plugin_type]);
3529  
3530          if ($active_type == $plugin_type) {
3531              foreach ($plugins as $plugin) {
3532                  $bottom_row[] = new tabobject($plugin->id, $plugin->link, $plugin->string);
3533                  if ($plugin->id == $active_plugin) {
3534                      $inactive = array($plugin->id);
3535                  }
3536              }
3537          }
3538      }
3539  
3540      // Do not display rows that contain only one item, they are not helpful.
3541      if (count($top_row) > 1) {
3542          $tabs[] = $top_row;
3543      }
3544      if (count($bottom_row) > 1) {
3545          $tabs[] = $bottom_row;
3546      }
3547      if (empty($tabs)) {
3548          return;
3549      }
3550  
3551      $rv = html_writer::div(print_tabs($tabs, $active_plugin, $inactive, $activated, true), 'grade-navigation');
3552  
3553      if ($return) {
3554          return $rv;
3555      } else {
3556          echo $rv;
3557      }
3558  }
3559  
3560  /**
3561   * Print grading plugin selection popup form.
3562   *
3563   * @deprecated since Moodle 4.0. Dropdown box navigation has been replaced with tertiary navigation.
3564   * @param array   $plugin_info An array of plugins containing information for the selector
3565   * @param boolean $return return as string
3566   *
3567   * @return nothing or string if $return true
3568   */
3569  function print_grade_plugin_selector($plugin_info, $active_type, $active_plugin, $return=false) {
3570      global $CFG, $OUTPUT, $PAGE;
3571  
3572      debugging('print_grade_plugin_selector() has been deprecated. Dropdown box navigation has been replaced ' .
3573          'with tertiary navigation.', DEBUG_DEVELOPER);
3574  
3575      $menu = array();
3576      $count = 0;
3577      $active = '';
3578  
3579      foreach ($plugin_info as $plugin_type => $plugins) {
3580          if ($plugin_type == 'strings') {
3581              continue;
3582          }
3583  
3584          $first_plugin = reset($plugins);
3585  
3586          $sectionname = $plugin_info['strings'][$plugin_type];
3587          $section = array();
3588  
3589          foreach ($plugins as $plugin) {
3590              $link = $plugin->link->out(false);
3591              $section[$link] = $plugin->string;
3592              $count++;
3593              if ($plugin_type === $active_type and $plugin->id === $active_plugin) {
3594                  $active = $link;
3595              }
3596          }
3597  
3598          if ($section) {
3599              $menu[] = array($sectionname=>$section);
3600          }
3601      }
3602  
3603      // finally print/return the popup form
3604      if ($count > 1) {
3605          $select = new url_select($menu, $active, null, 'choosepluginreport');
3606          $select->set_label(get_string('gradereport', 'grades'), array('class' => 'accesshide'));
3607          if ($return) {
3608              return $OUTPUT->render($select);
3609          } else {
3610              echo $OUTPUT->render($select);
3611          }
3612      } else {
3613          // only one option - no plugin selector needed
3614          return '';
3615      }
3616  
3617      /**
3618       * Purge the cache of a course section.
3619       *
3620       * $sectioninfo must have following attributes:
3621       *   - course: course id
3622       *   - section: section number
3623       *
3624       * @param object $sectioninfo section info
3625       * @return void
3626       * @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_section_cache_by_id()}
3627       *             or {@link course_modinfo::purge_course_section_cache_by_number()} instead.
3628       */
3629      function course_purge_section_cache(object $sectioninfo): void {
3630          debugging(__FUNCTION__ . '() is deprecated. ' .
3631              'Please use course_modinfo::purge_course_section_cache_by_id() ' .
3632              'or course_modinfo::purge_course_section_cache_by_number() instead.',
3633              DEBUG_DEVELOPER);
3634          $sectionid = $sectioninfo->section;
3635          $courseid = $sectioninfo->course;
3636          course_modinfo::purge_course_section_cache_by_id($courseid, $sectionid);
3637      }
3638  
3639      /**
3640       * Purge the cache of a course module.
3641       *
3642       * $cm must have following attributes:
3643       *   - id: cmid
3644       *   - course: course id
3645       *
3646       * @param cm_info|stdClass $cm course module
3647       * @return void
3648       * @deprecated since Moodle 4.0. Please use {@link course_modinfo::purge_course_module_cache()} instead.
3649       */
3650      function course_purge_module_cache($cm): void {
3651          debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::purge_course_module_cache() instead.',
3652              DEBUG_DEVELOPER);
3653          $cmid = $cm->id;
3654          $courseid = $cm->course;
3655          course_modinfo::purge_course_module_cache($courseid, $cmid);
3656      }
3657  }
3658  
3659  /**
3660   * For a given course, returns an array of course activity objects
3661   * Each item in the array contains he following properties:
3662   *
3663   * @param int $courseid course id
3664   * @param bool $usecache get activities from cache if modinfo exists when $usecache is true
3665   * @return array list of activities
3666   * @deprecated since Moodle 4.0. Please use {@link course_modinfo::get_array_of_activities()} instead.
3667   */
3668  function get_array_of_activities(int $courseid, bool $usecache = false): array {
3669      debugging(__FUNCTION__ . '() is deprecated. ' . 'Please use course_modinfo::get_array_of_activities() instead.',
3670          DEBUG_DEVELOPER);
3671      return course_modinfo::get_array_of_activities(get_course($courseid), $usecache);
3672  }
3673  
3674  /**
3675   * Abort execution by throwing of a general exception,
3676   * default exception handler displays the error message in most cases.
3677   *
3678   * @deprecated since Moodle 4.1
3679   * @todo MDL-74484 Final deprecation in Moodle 4.5.
3680   * @param string $errorcode The name of the language string containing the error message.
3681   *      Normally this should be in the error.php lang file.
3682   * @param string $module The language file to get the error message from.
3683   * @param string $link The url where the user will be prompted to continue.
3684   *      If no url is provided the user will be directed to the site index page.
3685   * @param object $a Extra words and phrases that might be required in the error string
3686   * @param string $debuginfo optional debugging information
3687   * @return void, always throws exception!
3688   */
3689  function print_error($errorcode, $module = 'error', $link = '', $a = null, $debuginfo = null) {
3690      debugging("The function print_error() is deprecated. " .
3691              "Please throw a new moodle_exception instance instead.", DEBUG_DEVELOPER);
3692      throw new \moodle_exception($errorcode, $module, $link, $a, $debuginfo);
3693  }
3694  
3695  /**
3696   * Execute cron tasks
3697   *
3698   * @param int|null $keepalive The keepalive time for this cron run.
3699   * @deprecated since 4.2 Use \core\cron::run_main_process() instead.
3700   */
3701  function cron_run(?int $keepalive = null): void {
3702      debugging(
3703          'The cron_run() function is deprecated. Please use \core\cron::run_main_process() instead.',
3704          DEBUG_DEVELOPER
3705      );
3706      \core\cron::run_main_process($keepalive);
3707  }
3708  
3709  /**
3710   * Execute all queued scheduled tasks, applying necessary concurrency limits and time limits.
3711   *
3712   * @param   int     $timenow The time this process started.
3713   * @deprecated since 4.2 Use \core\cron::run_scheduled_tasks() instead.
3714   */
3715  function cron_run_scheduled_tasks(int $timenow) {
3716      debugging(
3717          'The cron_run_scheduled_tasks() function is deprecated. Please use \core\cron::run_scheduled_tasks() instead.',
3718          DEBUG_DEVELOPER
3719      );
3720      \core\cron::run_scheduled_tasks($timenow);
3721  }
3722  
3723  /**
3724   * Execute all queued adhoc tasks, applying necessary concurrency limits and time limits.
3725   *
3726   * @param   int     $timenow The time this process started.
3727   * @param   int     $keepalive Keep this function alive for N seconds and poll for new adhoc tasks.
3728   * @param   bool    $checklimits Should we check limits?
3729   * @deprecated since 4.2 Use \core\cron::run_adhoc_tasks() instead.
3730   */
3731  function cron_run_adhoc_tasks(int $timenow, $keepalive = 0, $checklimits = true) {
3732      debugging(
3733          'The cron_run_adhoc_tasks() function is deprecated. Please use \core\cron::run_adhoc_tasks() instead.',
3734          DEBUG_DEVELOPER
3735      );
3736      \core\cron::run_adhoc_tasks($timenow, $keepalive, $checklimits);
3737  }
3738  
3739  /**
3740   * Shared code that handles running of a single scheduled task within the cron.
3741   *
3742   * Not intended for calling directly outside of this library!
3743   *
3744   * @param \core\task\task_base $task
3745   * @deprecated since 4.2 Use \core\cron::run_inner_scheduled_task() instead.
3746   */
3747  function cron_run_inner_scheduled_task(\core\task\task_base $task) {
3748      debugging(
3749          'The cron_run_inner_scheduled_task() function is deprecated. Please use \core\cron::run_inner_scheduled_task() instead.',
3750          DEBUG_DEVELOPER
3751      );
3752      \core\cron::run_inner_scheduled_task($task);
3753  }
3754  
3755  /**
3756   * Shared code that handles running of a single adhoc task within the cron.
3757   *
3758   * @param \core\task\adhoc_task $task
3759   * @deprecated since 4.2 Use \core\cron::run_inner_adhoc_task() instead.
3760   */
3761  function cron_run_inner_adhoc_task(\core\task\adhoc_task $task) {
3762      debugging(
3763          'The cron_run_inner_adhoc_task() function is deprecated. Please use \core\cron::run_inner_adhoc_task() instead.',
3764          DEBUG_DEVELOPER
3765      );
3766      \core\cron::run_inner_adhoc_task($task);
3767  }
3768  
3769  /**
3770   * Sets the process title
3771   *
3772   * This makes it very easy for a sysadmin to immediately see what task
3773   * a cron process is running at any given moment.
3774   *
3775   * @param string $title process status title
3776   * @deprecated since 4.2 Use \core\cron::set_process_title() instead.
3777   */
3778  function cron_set_process_title(string $title) {
3779      debugging(
3780          'The cron_set_process_title() function is deprecated. Please use \core\cron::set_process_title() instead.',
3781          DEBUG_DEVELOPER
3782      );
3783      \core\cron::set_process_title($title);
3784  }
3785  
3786  /**
3787   * Output some standard information during cron runs. Specifically current time
3788   * and memory usage. This method also does gc_collect_cycles() (before displaying
3789   * memory usage) to try to help PHP manage memory better.
3790   *
3791   * @deprecated since 4.2 Use \core\cron::trace_time_and_memory() instead.
3792   */
3793  function cron_trace_time_and_memory() {
3794      debugging(
3795          'The cron_trace_time_and_memory() function is deprecated. Please use \core\cron::trace_time_and_memory() instead.',
3796          DEBUG_DEVELOPER
3797      );
3798      \core\cron::trace_time_and_memory();
3799  }
3800  
3801  /**
3802   * Prepare the output renderer for the cron run.
3803   *
3804   * This involves creating a new $PAGE, and $OUTPUT fresh for each task and prevents any one task from influencing
3805   * any other.
3806   *
3807   * @param   bool    $restore Whether to restore the original PAGE and OUTPUT
3808   * @deprecated since 4.2 Use \core\cron::prepare_core_renderer() instead.
3809   */
3810  function cron_prepare_core_renderer($restore = false) {
3811      debugging(
3812          'The cron_prepare_core_renderer() function is deprecated. Please use \core\cron::prepare_core_renderer() instead.',
3813          DEBUG_DEVELOPER
3814      );
3815      \core\cron::prepare_core_renderer($restore);
3816  }
3817  
3818  /**
3819   * Sets up current user and course environment (lang, etc.) in cron.
3820   * Do not use outside of cron script!
3821   *
3822   * @param stdClass $user full user object, null means default cron user (admin),
3823   *                 value 'reset' means reset internal static caches.
3824   * @param stdClass $course full course record, null means $SITE
3825   * @param bool $leavepagealone If specified, stops it messing with global page object
3826   * @deprecated since 4.2. Use \core\core::setup_user() instead.
3827   * @return void
3828   */
3829  function cron_setup_user($user = null, $course = null, $leavepagealone = false) {
3830      debugging(
3831          'The cron_setup_user() function is deprecated. ' .
3832              'Please use \core\cron::setup_user() and reset_user_cache() as appropriate instead.',
3833          DEBUG_DEVELOPER
3834      );
3835  
3836      if ($user === 'reset') {
3837          \core\cron::reset_user_cache();
3838          return;
3839      }
3840  
3841      \core\cron::setup_user($user, $course, $leavepagealone);
3842  }