MDL-50049 deprecation: Rearrange deprecated apis for better future management
[moodle.git] / lib / deprecatedlib.php
CommitLineData
c861fe2f 1<?php
2
a5cb8d69 3// This file is part of Moodle - http://moodle.org/
4//
c861fe2f 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.
a5cb8d69 14//
c861fe2f 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/>.
c4d0753b 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 *
78bfb562 24 * @package core
c861fe2f 25 * @subpackage deprecated
78bfb562
PS
26 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
c861fe2f 28 * @deprecated
c4d0753b 29 */
30
78bfb562
PS
31defined('MOODLE_INTERNAL') || die();
32
33c46db5
AA
33/* === Functions that needs to be kept longer in deprecated lib than normal time period === */
34
35/**
36 * Add an entry to the legacy log table.
37 *
38 * @deprecated since 2.7 use new events instead
39 *
40 * @param int $courseid The course id
41 * @param string $module The module name e.g. forum, journal, resource, course, user etc
42 * @param string $action 'view', 'update', 'add' or 'delete', possibly followed by another word to clarify.
43 * @param string $url The file and parameters used to see the results of the action
44 * @param string $info Additional description information
45 * @param int $cm The course_module->id if there is one
46 * @param int|stdClass $user If log regards $user other than $USER
47 * @return void
48 */
49function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user=0) {
50 debugging('add_to_log() has been deprecated, please rewrite your code to the new events API', DEBUG_DEVELOPER);
51
52 // This is a nasty hack that allows us to put all the legacy stuff into legacy storage,
53 // this way we may move all the legacy settings there too.
54 $manager = get_log_manager();
55 if (method_exists($manager, 'legacy_add_to_log')) {
56 $manager->legacy_add_to_log($courseid, $module, $action, $url, $info, $cm, $user);
57 }
58}
59
60/**
61 * Function to call all event handlers when triggering an event
62 *
63 * @deprecated since 2.6
64 *
65 * @param string $eventname name of the event
66 * @param mixed $eventdata event data object
67 * @return int number of failed events
68 */
69function events_trigger($eventname, $eventdata) {
70 debugging('events_trigger() is deprecated, please use new events instead', DEBUG_DEVELOPER);
71 return events_trigger_legacy($eventname, $eventdata);
72}
73
74/**
75 * List all core subsystems and their location
76 *
77 * This is a whitelist of components that are part of the core and their
78 * language strings are defined in /lang/en/<<subsystem>>.php. If a given
79 * plugin is not listed here and it does not have proper plugintype prefix,
80 * then it is considered as course activity module.
81 *
82 * The location is optionally dirroot relative path. NULL means there is no special
83 * directory for this subsystem. If the location is set, the subsystem's
84 * renderer.php is expected to be there.
85 *
86 * @deprecated since 2.6, use core_component::get_core_subsystems()
87 *
88 * @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons
89 * @return array of (string)name => (string|null)location
90 */
91function get_core_subsystems($fullpaths = false) {
92 global $CFG;
93
94 // NOTE: do not add any other debugging here, keep forever.
95
96 $subsystems = core_component::get_core_subsystems();
97
98 if ($fullpaths) {
99 return $subsystems;
100 }
101
102 debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
103
104 $dlength = strlen($CFG->dirroot);
105
106 foreach ($subsystems as $k => $v) {
107 if ($v === null) {
108 continue;
109 }
110 $subsystems[$k] = substr($v, $dlength+1);
111 }
112
113 return $subsystems;
114}
115
116/**
117 * Lists all plugin types.
118 *
119 * @deprecated since 2.6, use core_component::get_plugin_types()
120 *
121 * @param bool $fullpaths false means relative paths from dirroot
122 * @return array Array of strings - name=>location
123 */
124function get_plugin_types($fullpaths = true) {
125 global $CFG;
126
127 // NOTE: do not add any other debugging here, keep forever.
128
129 $types = core_component::get_plugin_types();
130
131 if ($fullpaths) {
132 return $types;
133 }
134
135 debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
136
137 $dlength = strlen($CFG->dirroot);
138
139 foreach ($types as $k => $v) {
140 if ($k === 'theme') {
141 $types[$k] = 'theme';
142 continue;
143 }
144 $types[$k] = substr($v, $dlength+1);
145 }
146
147 return $types;
148}
149
150/**
151 * Use when listing real plugins of one type.
152 *
153 * @deprecated since 2.6, use core_component::get_plugin_list()
154 *
155 * @param string $plugintype type of plugin
156 * @return array name=>fulllocation pairs of plugins of given type
157 */
158function get_plugin_list($plugintype) {
159
160 // NOTE: do not add any other debugging here, keep forever.
161
162 if ($plugintype === '') {
163 $plugintype = 'mod';
164 }
165
166 return core_component::get_plugin_list($plugintype);
167}
168
169/**
170 * Get a list of all the plugins of a given type that define a certain class
171 * in a certain file. The plugin component names and class names are returned.
172 *
173 * @deprecated since 2.6, use core_component::get_plugin_list_with_class()
174 *
175 * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
176 * @param string $class the part of the name of the class after the
177 * frankenstyle prefix. e.g 'thing' if you are looking for classes with
178 * names like report_courselist_thing. If you are looking for classes with
179 * the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
180 * @param string $file the name of file within the plugin that defines the class.
181 * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
182 * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
183 */
184function get_plugin_list_with_class($plugintype, $class, $file) {
185
186 // NOTE: do not add any other debugging here, keep forever.
187
188 return core_component::get_plugin_list_with_class($plugintype, $class, $file);
189}
190
191/**
192 * Returns the exact absolute path to plugin directory.
193 *
194 * @deprecated since 2.6, use core_component::get_plugin_directory()
195 *
196 * @param string $plugintype type of plugin
197 * @param string $name name of the plugin
198 * @return string full path to plugin directory; NULL if not found
199 */
200function get_plugin_directory($plugintype, $name) {
201
202 // NOTE: do not add any other debugging here, keep forever.
203
204 if ($plugintype === '') {
205 $plugintype = 'mod';
206 }
207
208 return core_component::get_plugin_directory($plugintype, $name);
209}
210
211/**
212 * Normalize the component name using the "frankenstyle" names.
213 *
214 * @deprecated since 2.6, use core_component::normalize_component()
215 *
216 * @param string $component
217 * @return array as (string)$type => (string)$plugin
218 */
219function normalize_component($component) {
220
221 // NOTE: do not add any other debugging here, keep forever.
222
223 return core_component::normalize_component($component);
224}
225
226/**
227 * Return exact absolute path to a plugin directory.
228 *
229 * @deprecated since 2.6, use core_component::normalize_component()
230 *
231 * @param string $component name such as 'moodle', 'mod_forum'
232 * @return string full path to component directory; NULL if not found
233 */
234function get_component_directory($component) {
235
236 // NOTE: do not add any other debugging here, keep forever.
237
238 return core_component::get_component_directory($component);
239}
240
241/**
242 * Get the context instance as an object. This function will create the
243 * context instance if it does not exist yet.
244 *
245 * @deprecated since 2.2, use context_course::instance() or other relevant class instead
246 * @todo This will be deleted in Moodle 2.8, refer MDL-34472
247 * @param integer $contextlevel The context level, for example CONTEXT_COURSE, or CONTEXT_MODULE.
248 * @param integer $instance The instance id. For $level = CONTEXT_COURSE, this would be $course->id,
249 * for $level = CONTEXT_MODULE, this would be $cm->id. And so on. Defaults to 0
250 * @param int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found;
251 * MUST_EXIST means throw exception if no record or multiple records found
252 * @return context The context object.
253 */
254function get_context_instance($contextlevel, $instance = 0, $strictness = IGNORE_MISSING) {
255
256 debugging('get_context_instance() is deprecated, please use context_xxxx::instance() instead.', DEBUG_DEVELOPER);
257
258 $instances = (array)$instance;
259 $contexts = array();
260
261 $classname = context_helper::get_class_for_level($contextlevel);
262
263 // we do not load multiple contexts any more, PAGE should be responsible for any preloading
264 foreach ($instances as $inst) {
265 $contexts[$inst] = $classname::instance($inst, $strictness);
266 }
267
268 if (is_array($instance)) {
269 return $contexts;
270 } else {
271 return $contexts[$instance];
272 }
273}
274/* === End of long term deprecated api list === */
275
114e3209
276/**
277 * Adds a file upload to the log table so that clam can resolve the filename to the user later if necessary
278 *
279 * @deprecated since 2.7 - use new file picker instead
280 *
114e3209
281 */
282function clam_log_upload($newfilepath, $course=null, $nourl=false) {
6dd7175a 283 throw new coding_exception('clam_log_upload() can not be used any more, please use file picker instead');
114e3209
284}
285
286/**
287 * This function logs to error_log and to the log table that an infected file has been found and what's happened to it.
288 *
289 * @deprecated since 2.7 - use new file picker instead
290 *
114e3209
291 */
292function clam_log_infected($oldfilepath='', $newfilepath='', $userid=0) {
6dd7175a 293 throw new coding_exception('clam_log_infected() can not be used any more, please use file picker instead');
114e3209
294}
295
296/**
297 * Some of the modules allow moving attachments (glossary), in which case we need to hunt down an original log and change the path.
298 *
299 * @deprecated since 2.7 - use new file picker instead
300 *
114e3209
301 */
302function clam_change_log($oldpath, $newpath, $update=true) {
6dd7175a 303 throw new coding_exception('clam_change_log() can not be used any more, please use file picker instead');
114e3209
304}
305
306/**
307 * Replaces the given file with a string.
308 *
309 * @deprecated since 2.7 - infected files are now deleted in file picker
310 *
114e3209
311 */
312function clam_replace_infected_file($file) {
6dd7175a 313 throw new coding_exception('clam_replace_infected_file() can not be used any more, please use file picker instead');
114e3209
314}
315
7293a1aa
DP
316/**
317 * Deals with an infected file - either moves it to a quarantinedir
318 * (specified in CFG->quarantinedir) or deletes it.
319 *
320 * If moving it fails, it deletes it.
321 *
322 * @deprecated since 2.7
323 */
324function clam_handle_infected_file($file, $userid=0, $basiconly=false) {
325 throw new coding_exception('clam_handle_infected_file() can not be used any more, please use file picker instead');
326}
327
328/**
329 * If $CFG->runclamonupload is set, we scan a given file. (called from {@link preprocess_files()})
330 *
331 * @deprecated since 2.7
332 */
333function clam_scan_moodle_file(&$file, $course) {
334 throw new coding_exception('clam_scan_moodle_file() can not be used any more, please use file picker instead');
335}
336
337
6780a1d3
338/**
339 * Checks whether the password compatibility library will work with the current
340 * version of PHP. This cannot be done using PHP version numbers since the fix
341 * has been backported to earlier versions in some distributions.
342 *
343 * See https://github.com/ircmaxell/password_compat/issues/10 for more details.
344 *
345 * @deprecated since 2.7 PHP 5.4.x should be always compatible.
346 *
6780a1d3
347 */
348function password_compat_not_supported() {
1ac1d29b 349 throw new coding_exception('Do not use password_compat_not_supported() - bcrypt is now always available');
6780a1d3
350}
351
d79d5ac2
PS
352/**
353 * Factory method that was returning moodle_session object.
354 *
355 * @deprecated since 2.6
d79d5ac2
PS
356 */
357function session_get_instance() {
1ac1d29b 358 throw new coding_exception('session_get_instance() is deprecated, use \core\session\manager instead');
d79d5ac2
PS
359}
360
361/**
362 * Returns true if legacy session used.
363 *
364 * @deprecated since 2.6
d79d5ac2
PS
365 */
366function session_is_legacy() {
1ac1d29b 367 throw new coding_exception('session_is_legacy() is deprecated, do not use any more');
d79d5ac2
PS
368}
369
370/**
371 * Terminates all sessions, auth hooks are not executed.
d79d5ac2
PS
372 *
373 * @deprecated since 2.6
374 */
375function session_kill_all() {
1ac1d29b 376 throw new coding_exception('session_kill_all() is deprecated, use \core\session\manager::kill_all_sessions() instead');
d79d5ac2
PS
377}
378
379/**
380 * Mark session as accessed, prevents timeouts.
381 *
382 * @deprecated since 2.6
d79d5ac2
PS
383 */
384function session_touch($sid) {
1ac1d29b 385 throw new coding_exception('session_touch() is deprecated, use \core\session\manager::touch_session() instead');
d79d5ac2
PS
386}
387
388/**
389 * Terminates one sessions, auth hooks are not executed.
390 *
391 * @deprecated since 2.6
d79d5ac2
PS
392 */
393function session_kill($sid) {
1ac1d29b 394 throw new coding_exception('session_kill() is deprecated, use \core\session\manager::kill_session() instead');
d79d5ac2
PS
395}
396
397/**
398 * Terminates all sessions of one user, auth hooks are not executed.
d79d5ac2
PS
399 *
400 * @deprecated since 2.6
d79d5ac2
PS
401 */
402function session_kill_user($userid) {
1ac1d29b 403 throw new coding_exception('session_kill_user() is deprecated, use \core\session\manager::kill_user_sessions() instead');
d79d5ac2
PS
404}
405
d79d5ac2
PS
406/**
407 * Setup $USER object - called during login, loginas, etc.
408 *
409 * Call sync_user_enrolments() manually after log-in, or log-in-as.
410 *
411 * @deprecated since 2.6
d79d5ac2
PS
412 */
413function session_set_user($user) {
1ac1d29b 414 throw new coding_exception('session_set_user() is deprecated, use \core\session\manager::set_user() instead');
d79d5ac2
PS
415}
416
417/**
418 * Is current $USER logged-in-as somebody else?
419 * @deprecated since 2.6
d79d5ac2
PS
420 */
421function session_is_loggedinas() {
1ac1d29b 422 throw new coding_exception('session_is_loggedinas() is deprecated, use \core\session\manager::is_loggedinas() instead');
d79d5ac2
PS
423}
424
425/**
426 * Returns the $USER object ignoring current login-as session
427 * @deprecated since 2.6
d79d5ac2
PS
428 */
429function session_get_realuser() {
1ac1d29b 430 throw new coding_exception('session_get_realuser() is deprecated, use \core\session\manager::get_realuser() instead');
d79d5ac2
PS
431}
432
433/**
434 * Login as another user - no security checks here.
435 * @deprecated since 2.6
d79d5ac2
PS
436 */
437function session_loginas($userid, $context) {
1ac1d29b 438 throw new coding_exception('session_loginas() is deprecated, use \core\session\manager::loginas() instead');
d79d5ac2
PS
439}
440
6b32d6bc
PS
441/**
442 * Minify JavaScript files.
443 *
444 * @deprecated since 2.6
6b32d6bc
PS
445 */
446function js_minify($files) {
1ac1d29b 447 throw new coding_exception('js_minify() is deprecated, use core_minify::js_files() or core_minify::js() instead.');
6b32d6bc
PS
448}
449
450/**
451 * Minify CSS files.
452 *
453 * @deprecated since 2.6
6b32d6bc
PS
454 */
455function css_minify_css($files) {
1ac1d29b 456 throw new coding_exception('css_minify_css() is deprecated, use core_minify::css_files() or core_minify::css() instead.');
6b32d6bc
PS
457}
458
9e19a0f0
PS
459
460
461// === Deprecated before 2.6.0 ===
462
689096bc
PS
463/**
464 * Hack to find out the GD version by parsing phpinfo output
689096bc
PS
465 */
466function check_gd_version() {
1ac1d29b 467 throw new coding_exception('check_gd_version() is deprecated, GD extension is always available now');
689096bc
PS
468}
469
b28247fe
PS
470/**
471 * Not used any more, the account lockout handling is now
472 * part of authenticate_user_login().
473 * @deprecated
474 */
475function update_login_count() {
1ac1d29b 476 throw new coding_exception('update_login_count() is deprecated, all calls need to be removed');
b28247fe
PS
477}
478
479/**
480 * Not used any more, replaced by proper account lockout.
481 * @deprecated
482 */
483function reset_login_count() {
1ac1d29b 484 throw new coding_exception('reset_login_count() is deprecated, all calls need to be removed');
b28247fe
PS
485}
486
c6d75bff 487/**
c6d75bff 488 * @deprecated
c6d75bff
PS
489 */
490function update_log_display_entry($module, $action, $mtable, $field) {
c6d75bff 491
1ac1d29b 492 throw new coding_exception('The update_log_display_entry() is deprecated, please use db/log.php description file instead.');
c6d75bff
PS
493}
494
35716b86 495/**
05226d76 496 * @deprecated use the text formatting in a standard way instead (http://docs.moodle.org/dev/Output_functions)
35716b86 497 * this was abused mostly for embedding of attachments
35716b86
PS
498 */
499function filter_text($text, $courseid = NULL) {
e4d9185e 500 throw new coding_exception('filter_text() can not be used anymore, use format_text(), format_string() etc instead.');
35716b86
PS
501}
502
17c70aa0 503/**
17c70aa0
PS
504 * @deprecated use $PAGE->https_required() instead
505 */
506function httpsrequired() {
e4d9185e 507 throw new coding_exception('httpsrequired() can not be used any more use $PAGE->https_required() instead.');
17c70aa0
PS
508}
509
50a8bd6c
PS
510/**
511 * Given a physical path to a file, returns the URL through which it can be reached in Moodle.
512 *
513 * @deprecated use moodle_url factory methods instead
514 *
515 * @param string $path Physical path to a file
516 * @param array $options associative array of GET variables to append to the URL
517 * @param string $type (questionfile|rssfile|httpscoursefile|coursefile)
518 * @return string URL to file
519 */
520function get_file_url($path, $options=null, $type='coursefile') {
17c70aa0 521 global $CFG;
50a8bd6c
PS
522
523 $path = str_replace('//', '/', $path);
524 $path = trim($path, '/'); // no leading and trailing slashes
525
526 // type of file
527 switch ($type) {
528 case 'questionfile':
529 $url = $CFG->wwwroot."/question/exportfile.php";
530 break;
531 case 'rssfile':
532 $url = $CFG->wwwroot."/rss/file.php";
533 break;
534 case 'httpscoursefile':
535 $url = $CFG->httpswwwroot."/file.php";
536 break;
537 case 'coursefile':
538 default:
539 $url = $CFG->wwwroot."/file.php";
540 }
541
542 if ($CFG->slasharguments) {
543 $parts = explode('/', $path);
544 foreach ($parts as $key => $part) {
545 /// anchor dash character should not be encoded
546 $subparts = explode('#', $part);
547 $subparts = array_map('rawurlencode', $subparts);
548 $parts[$key] = implode('#', $subparts);
549 }
550 $path = implode('/', $parts);
551 $ffurl = $url.'/'.$path;
552 $separator = '?';
553 } else {
554 $path = rawurlencode('/'.$path);
555 $ffurl = $url.'?file='.$path;
556 $separator = '&amp;';
557 }
558
559 if ($options) {
560 foreach ($options as $name=>$value) {
561 $ffurl = $ffurl.$separator.$name.'='.$value;
562 $separator = '&amp;';
563 }
564 }
565
566 return $ffurl;
567}
568
613bbd7c 569/**
05226d76 570 * @deprecated use get_enrolled_users($context) instead.
613bbd7c 571 */
4f0c2d00 572function get_course_participants($courseid) {
e4d9185e 573 throw new coding_exception('get_course_participants() can not be used any more, use get_enrolled_users() instead.');
613bbd7c 574}
575
613bbd7c 576/**
05226d76 577 * @deprecated use is_enrolled($context, $userid) instead.
613bbd7c 578 */
4f0c2d00 579function is_course_participant($userid, $courseid) {
e4d9185e 580 throw new coding_exception('is_course_participant() can not be used any more, use is_enrolled() instead.');
613bbd7c 581}
582
583/**
1ac1d29b 584 * @deprecated
613bbd7c 585 */
586function get_recent_enrolments($courseid, $timestart) {
1ac1d29b 587 throw new coding_exception('get_recent_enrolments() is deprecated as it returned inaccurate results.');
613bbd7c 588}
589
ed5dd29f 590/**
05226d76 591 * @deprecated use clean_param($string, PARAM_FILE) instead.
ed5dd29f 592 */
593function detect_munged_arguments($string, $allowdots=1) {
e4d9185e 594 throw new coding_exception('detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.');
ed5dd29f 595}
596
9152fc99 597
0c6d2dd4 598/**
599 * Unzip one zip file to a destination dir
600 * Both parameters must be FULL paths
601 * If destination isn't specified, it will be the
602 * SAME directory where the zip file resides.
c861fe2f 603 *
604 * @global object
605 * @param string $zipfile The zip file to unzip
606 * @param string $destination The location to unzip to
607 * @param bool $showstatus_ignored Unused
0c6d2dd4 608 */
609function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
610 global $CFG;
611
612 //Extract everything from zipfile
613 $path_parts = pathinfo(cleardoubleslashes($zipfile));
614 $zippath = $path_parts["dirname"]; //The path of the zip file
615 $zipfilename = $path_parts["basename"]; //The name of the zip file
616 $extension = $path_parts["extension"]; //The extension of the file
617
618 //If no file, error
619 if (empty($zipfilename)) {
620 return false;
621 }
622
623 //If no extension, error
624 if (empty($extension)) {
625 return false;
626 }
627
628 //Clear $zipfile
629 $zipfile = cleardoubleslashes($zipfile);
630
631 //Check zipfile exists
632 if (!file_exists($zipfile)) {
633 return false;
634 }
635
636 //If no destination, passed let's go with the same directory
637 if (empty($destination)) {
638 $destination = $zippath;
639 }
640
641 //Clear $destination
642 $destpath = rtrim(cleardoubleslashes($destination), "/");
643
644 //Check destination path exists
645 if (!is_dir($destpath)) {
646 return false;
647 }
648
0b0bfa93 649 $packer = get_file_packer('application/zip');
650
651 $result = $packer->extract_to_pathname($zipfile, $destpath);
0c6d2dd4 652
653 if ($result === false) {
654 return false;
655 }
656
657 foreach ($result as $status) {
658 if ($status !== true) {
659 return false;
660 }
661 }
662
663 return true;
664}
665
ed94cb66 666/**
667 * Zip an array of files/dirs to a destination zip file
668 * Both parameters must be FULL paths to the files/dirs
c861fe2f 669 *
670 * @global object
671 * @param array $originalfiles Files to zip
672 * @param string $destination The destination path
673 * @return bool Outcome
ed94cb66 674 */
675function zip_files ($originalfiles, $destination) {
676 global $CFG;
677
678 //Extract everything from destination
679 $path_parts = pathinfo(cleardoubleslashes($destination));
680 $destpath = $path_parts["dirname"]; //The path of the zip file
681 $destfilename = $path_parts["basename"]; //The name of the zip file
682 $extension = $path_parts["extension"]; //The extension of the file
683
684 //If no file, error
685 if (empty($destfilename)) {
686 return false;
687 }
688
689 //If no extension, add it
690 if (empty($extension)) {
691 $extension = 'zip';
692 $destfilename = $destfilename.'.'.$extension;
693 }
694
695 //Check destination path exists
696 if (!is_dir($destpath)) {
697 return false;
698 }
699
700 //Check destination path is writable. TODO!!
701
702 //Clean destination filename
703 $destfilename = clean_filename($destfilename);
704
705 //Now check and prepare every file
706 $files = array();
707 $origpath = NULL;
708
709 foreach ($originalfiles as $file) { //Iterate over each file
710 //Check for every file
711 $tempfile = cleardoubleslashes($file); // no doubleslashes!
712 //Calculate the base path for all files if it isn't set
713 if ($origpath === NULL) {
714 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
715 }
716 //See if the file is readable
717 if (!is_readable($tempfile)) { //Is readable
718 continue;
719 }
720 //See if the file/dir is in the same directory than the rest
721 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
722 continue;
723 }
724 //Add the file to the array
725 $files[] = $tempfile;
726 }
727
728 $zipfiles = array();
729 $start = strlen($origpath)+1;
730 foreach($files as $file) {
731 $zipfiles[substr($file, $start)] = $file;
732 }
733
0b0bfa93 734 $packer = get_file_packer('application/zip');
ed94cb66 735
3ed22f1a 736 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
ed94cb66 737}
738
5bf243d1 739/**
05226d76 740 * @deprecated use groups_get_all_groups() instead.
5bf243d1 741 */
742function mygroupid($courseid) {
e4d9185e 743 throw new coding_exception('mygroupid() can not be used any more, please use groups_get_all_groups() instead.');
5bf243d1 744}
745
5bf243d1 746
5bf243d1 747/**
748 * Returns the current group mode for a given course or activity module
364fffda 749 *
5bf243d1 750 * Could be false, SEPARATEGROUPS or VISIBLEGROUPS (<-- Martin)
c861fe2f 751 *
752 * @param object $course Course Object
753 * @param object $cm Course Manager Object
754 * @return mixed $course->groupmode
5bf243d1 755 */
756function groupmode($course, $cm=null) {
757
758 if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
759 return $cm->groupmode;
760 }
761 return $course->groupmode;
762}
763
c584346c 764/**
765 * Sets the current group in the session variable
766 * When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups.
767 * Sets currentgroup[$courseid] in the session variable appropriately.
768 * Does not do any permission checking.
c861fe2f 769 *
770 * @global object
c584346c 771 * @param int $courseid The course being examined - relates to id field in
772 * 'course' table.
773 * @param int $groupid The group being examined.
774 * @return int Current group id which was set by this function
775 */
776function set_current_group($courseid, $groupid) {
777 global $SESSION;
778 return $SESSION->currentgroup[$courseid] = $groupid;
779}
780
5bf243d1 781/**
364fffda 782 * Gets the current group - either from the session variable or from the database.
5bf243d1 783 *
c861fe2f 784 * @global object
364fffda 785 * @param int $courseid The course being examined - relates to id field in
5bf243d1 786 * 'course' table.
364fffda 787 * @param bool $full If true, the return value is a full record object.
5bf243d1 788 * If false, just the id of the record.
c861fe2f 789 * @return int|bool
5bf243d1 790 */
791function get_current_group($courseid, $full = false) {
792 global $SESSION;
793
794 if (isset($SESSION->currentgroup[$courseid])) {
795 if ($full) {
796 return groups_get_group($SESSION->currentgroup[$courseid]);
797 } else {
798 return $SESSION->currentgroup[$courseid];
799 }
800 }
801
802 $mygroupid = mygroupid($courseid);
803 if (is_array($mygroupid)) {
804 $mygroupid = array_shift($mygroupid);
805 set_current_group($courseid, $mygroupid);
806 if ($full) {
807 return groups_get_group($mygroupid);
808 } else {
809 return $mygroupid;
810 }
811 }
812
813 if ($full) {
814 return false;
815 } else {
816 return 0;
817 }
818}
819
061e6b28 820/**
061e6b28 821 * @deprecated Since Moodle 2.8
822 */
823function groups_filter_users_by_course_module_visible($cm, $users) {
1ac1d29b 824 throw new coding_exception('groups_filter_users_by_course_module_visible() is deprecated. ' .
061e6b28 825 'Replace with a call to \core_availability\info_module::filter_user_list(), ' .
826 'which does basically the same thing but includes other restrictions such ' .
1ac1d29b 827 'as profile restrictions.');
061e6b28 828}
829
830/**
061e6b28 831 * @deprecated Since Moodle 2.8
832 */
833function groups_course_module_visible($cm, $userid=null) {
1ac1d29b 834 throw new coding_exception('groups_course_module_visible() is deprecated and always returns ' .
061e6b28 835 'true; use $cm->uservisible to decide whether the current user can ' .
836 'access an activity.', DEBUG_DEVELOPER);
061e6b28 837}
5bf243d1 838
8ec50604 839/**
1ac1d29b 840 * @deprecated since 2.0
8ec50604 841 */
245ac557 842function error($message, $link='') {
1ac1d29b
AA
843 throw new coding_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a deprecated function, please call
844 print_error() instead of error()');
251387d0 845}
8ec50604 846
8ec50604 847
b7009474 848/**
849 * @deprecated use $PAGE->theme->name instead.
b7009474 850 */
851function current_theme() {
e4d9185e 852 throw new coding_exception('current_theme() can not be used any more, please use $PAGE->theme->name instead');
b7009474 853}
854
8954245a 855/**
8954245a 856 * @deprecated
8954245a 857 */
858function formerr($error) {
1ac1d29b 859 throw new coding_exception('formerr() has been deprecated. Please change your code to use $OUTPUT->error_text($string).');
8954245a 860}
861
34a2777c 862/**
34a2777c 863 * @deprecated use $OUTPUT->skip_link_target() in instead.
34a2777c 864 */
865function skip_main_destination() {
e4d9185e 866 throw new coding_exception('skip_main_destination() can not be used any more, please use $OUTPUT->skip_link_target() instead.');
34a2777c 867}
868
34a2777c 869/**
05226d76 870 * @deprecated use $OUTPUT->container() instead.
34a2777c 871 */
872function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) {
e4d9185e 873 throw new coding_exception('print_container() can not be used any more. Please use $OUTPUT->container() instead.');
34a2777c 874}
875
876/**
05226d76 877 * @deprecated use $OUTPUT->container_start() instead.
34a2777c 878 */
879function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) {
e4d9185e 880 throw new coding_exception('print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.');
34a2777c 881}
882
883/**
05226d76 884 * @deprecated use $OUTPUT->container_end() instead.
34a2777c 885 */
886function print_container_end($return=false) {
e4d9185e 887 throw new coding_exception('print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.');
34a2777c 888}
889
890/**
891 * Print a bold message in an optional color.
892 *
893 * @deprecated use $OUTPUT->notification instead.
894 * @param string $message The message to print out
895 * @param string $style Optional style to display message text in
896 * @param string $align Alignment option
897 * @param bool $return whether to return an output string or echo now
a5cb8d69 898 * @return string|bool Depending on $result
34a2777c 899 */
900function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) {
901 global $OUTPUT;
902
903 if ($classes == 'green') {
904 debugging('Use of deprecated class name "green" in notify. Please change to "notifysuccess".', DEBUG_DEVELOPER);
905 $classes = 'notifysuccess'; // Backward compatible with old color system
906 }
907
908 $output = $OUTPUT->notification($message, $classes);
909 if ($return) {
910 return $output;
911 } else {
912 echo $output;
913 }
914}
915
916/**
05226d76 917 * @deprecated use $OUTPUT->continue_button() instead.
34a2777c 918 */
919function print_continue($link, $return = false) {
e4d9185e 920 throw new coding_exception('print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.');
34a2777c 921}
922
34a2777c 923/**
05226d76 924 * @deprecated use $PAGE methods instead.
34a2777c 925 */
926function print_header($title='', $heading='', $navigation='', $focus='',
e120c61d 927 $meta='', $cache=true, $button='&nbsp;', $menu=null,
34a2777c 928 $usexml=false, $bodytags='', $return=false) {
34a2777c 929
e4d9185e 930 throw new coding_exception('print_header() can not be used any more. Please use $PAGE methods instead.');
34a2777c 931}
932
47a1aa45 933/**
05226d76 934 * @deprecated use $PAGE methods instead.
47a1aa45 935 */
936function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
937 $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='', $return=false) {
938
e4d9185e 939 throw new coding_exception('print_header_simple() can not be used any more. Please use $PAGE methods instead.');
47a1aa45 940}
941
a5cb8d69 942/**
05226d76 943 * @deprecated use $OUTPUT->block() instead.
a5cb8d69 944 */
945function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
e4d9185e 946 throw new coding_exception('print_side_block() can not be used any more, please use $OUTPUT->block() instead.');
a5cb8d69 947}
948
f8065dd2 949/**
950 * Prints a basic textarea field.
951 *
952 * @deprecated since Moodle 2.0
953 *
954 * When using this function, you should
955 *
956 * @global object
3d27180e 957 * @param bool $unused No longer used.
f8065dd2 958 * @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
959 * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
960 * @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
961 * @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
962 * @param string $name Name to use for the textarea element.
963 * @param string $value Initial content to display in the textarea.
964 * @param int $obsolete deprecated
965 * @param bool $return If false, will output string. If true, will return string value.
966 * @param string $id CSS ID to add to the textarea element.
967 * @return string|void depending on the value of $return
968 */
3d27180e 969function print_textarea($unused, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
f8065dd2 970 /// $width and height are legacy fields and no longer used as pixels like they used to be.
971 /// However, you can set them to zero to override the mincols and minrows values below.
972
3d8a479b
MD
973 // Disabling because there is not yet a viable $OUTPUT option for cases when mforms can't be used
974 // debugging('print_textarea() has been deprecated. You should be using mforms and the editor element.');
f8065dd2 975
976 global $CFG;
977
978 $mincols = 65;
979 $minrows = 10;
980 $str = '';
981
982 if ($id === '') {
983 $id = 'edit-'.$name;
984 }
985
3d27180e
DW
986 if ($height && ($rows < $minrows)) {
987 $rows = $minrows;
f8065dd2 988 }
3d27180e
DW
989 if ($width && ($cols < $mincols)) {
990 $cols = $mincols;
f8065dd2 991 }
992
3d27180e
DW
993 editors_head_setup();
994 $editor = editors_get_preferred_editor(FORMAT_HTML);
995 $editor->use_editor($id, array('legacy'=>true));
996
0ac97084 997 $str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'" spellcheck="true">'."\n";
3d27180e 998 $str .= htmlspecialchars($value); // needed for editing of cleaned text!
f8065dd2 999 $str .= '</textarea>'."\n";
1000
1001 if ($return) {
1002 return $str;
1003 }
1004 echo $str;
1005}
1006
f8065dd2 1007/**
1008 * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
1009 * provide this function with the language strings for sortasc and sortdesc.
1010 *
05226d76 1011 * @deprecated use $OUTPUT->arrow() instead.
e4d9185e 1012 * @todo final deprecation of this function once MDL-45448 is resolved
f8065dd2 1013 *
f8065dd2 1014 * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
1015 *
1016 * @global object
1017 * @param string $direction 'up' or 'down'
1018 * @param string $strsort The language string used for the alt attribute of this image
1019 * @param bool $return Whether to print directly or return the html string
1020 * @return string|void depending on $return
1021 *
1022 */
1023function print_arrow($direction='up', $strsort=null, $return=false) {
f8065dd2 1024 global $OUTPUT;
1025
05226d76
DP
1026 debugging('print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.', DEBUG_DEVELOPER);
1027
f8065dd2 1028 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
1029 return null;
1030 }
1031
1032 $return = null;
1033
1034 switch ($direction) {
1035 case 'up':
1036 $sortdir = 'asc';
1037 break;
1038 case 'down':
1039 $sortdir = 'desc';
1040 break;
1041 case 'move':
1042 $sortdir = 'asc';
1043 break;
1044 default:
1045 $sortdir = null;
1046 break;
1047 }
1048
1049 // Prepare language string
1050 $strsort = '';
1051 if (empty($strsort) && !empty($sortdir)) {
1052 $strsort = get_string('sort' . $sortdir, 'grades');
1053 }
1054
b5d0cafc 1055 $return = ' <img src="'.$OUTPUT->pix_url('t/' . $direction) . '" alt="'.$strsort.'" /> ';
f8065dd2 1056
1057 if ($return) {
1058 return $return;
1059 } else {
1060 echo $return;
1061 }
1062}
1063
8100c169 1064/**
8100c169 1065 * @deprecated since Moodle 2.0
8100c169 1066 */
1067function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='',
1068 $nothingvalue='0', $return=false, $disabled=false, $tabindex=0,
1069 $id='', $listbox=false, $multiple=false, $class='') {
1ac1d29b 1070 throw new coding_exception('choose_from_menu() has been deprecated. Please change your code to use html_writer::select().');
053203a8 1071
053203a8 1072}
1073
c68e4098 1074/**
05226d76 1075 * @deprecated use $OUTPUT->help_icon_scale($courseid, $scale) instead.
c68e4098 1076 */
1077function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
e4d9185e
DP
1078 throw new coding_exception('print_scale_menu_helpbutton() can not be used any more. '.
1079 'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.');
c68e4098 1080}
1081
49c8c8d2 1082/**
05226d76 1083 * @deprecated use html_writer::checkbox() instead.
49c8c8d2 1084 */
916276fc 1085function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) {
e4d9185e 1086 throw new coding_exception('print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.');
49c8c8d2 1087}
6a5c71b9 1088
c351150f 1089/**
1090 * Prints the 'update this xxx' button that appears on module pages.
1091 *
1092 * @deprecated since Moodle 2.0
1093 *
1094 * @param string $cmid the course_module id.
1095 * @param string $ignored not used any more. (Used to be courseid.)
1096 * @param string $string the module name - get_string('modulename', 'xxx')
1097 * @return string the HTML for the button, if this user has permission to edit it, else an empty string.
1098 */
1099function update_module_button($cmid, $ignored, $string) {
d1f06fb5 1100 global $CFG, $OUTPUT;
c351150f 1101
bc2e0484 1102 // debugging('update_module_button() has been deprecated. Please change your code to use $OUTPUT->update_module_button().');
c351150f 1103
d1f06fb5 1104 //NOTE: DO NOT call new output method because it needs the module name we do not have here!
1105
b0c6dc1c 1106 if (has_capability('moodle/course:manageactivities', context_module::instance($cmid))) {
d1f06fb5 1107 $string = get_string('updatethis', '', $string);
1108
5c2ed7e2
PS
1109 $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey()));
1110 return $OUTPUT->single_button($url, $string);
d1f06fb5 1111 } else {
1112 return '';
1113 }
c351150f 1114}
1115
7d2a0492 1116/**
05226d76 1117 * @deprecated use $OUTPUT->navbar() instead
7d2a0492 1118 */
1119function print_navigation ($navigation, $separator=0, $return=false) {
e4d9185e 1120 throw new coding_exception('print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.');
7d2a0492 1121}
1122
1123/**
05226d76 1124 * @deprecated Please use $PAGE->navabar methods instead.
7d2a0492 1125 */
1126function build_navigation($extranavlinks, $cm = null) {
e4d9185e 1127 throw new coding_exception('build_navigation() can not be used any more, please use $PAGE->navbar methods instead.');
7d2a0492 1128}
1129
1130/**
05226d76 1131 * @deprecated not relevant with global navigation in Moodle 2.x+
7d2a0492 1132 */
1133function navmenu($course, $cm=NULL, $targetwindow='self') {
e4d9185e 1134 throw new coding_exception('navmenu() can not be used any more, it is no longer relevant with global navigation.');
f43cdceb 1135}
76d9df3f
SH
1136
1137/// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
1138
1139
1140/**
05226d76 1141 * @deprecated please use calendar_event::create() instead.
76d9df3f
SH
1142 */
1143 function add_event($event) {
e4d9185e 1144 throw new coding_exception('add_event() can not be used any more, please use calendar_event::create() instead.');
76d9df3f
SH
1145}
1146
1147/**
05226d76 1148 * @deprecated please calendar_event->update() instead.
76d9df3f
SH
1149 */
1150function update_event($event) {
1ac1d29b 1151 throw new coding_exception('update_event() is deprecated, please use calendar_event->update() instead.');
76d9df3f
SH
1152}
1153
1154/**
05226d76 1155 * @deprecated please use calendar_event->delete() instead.
76d9df3f
SH
1156 */
1157function delete_event($id) {
e4d9185e
DP
1158 throw new coding_exception('delete_event() can not be used any more, please use '.
1159 'calendar_event->delete() instead.');
76d9df3f
SH
1160}
1161
1162/**
05226d76 1163 * @deprecated please use calendar_event->toggle_visibility(false) instead.
76d9df3f
SH
1164 */
1165function hide_event($event) {
e4d9185e
DP
1166 throw new coding_exception('hide_event() can not be used any more, please use '.
1167 'calendar_event->toggle_visibility(false) instead.');
76d9df3f
SH
1168}
1169
1170/**
05226d76 1171 * @deprecated please use calendar_event->toggle_visibility(true) instead.
76d9df3f
SH
1172 */
1173function show_event($event) {
e4d9185e
DP
1174 throw new coding_exception('show_event() can not be used any more, please use '.
1175 'calendar_event->toggle_visibility(true) instead.');
0189bf77 1176}
6f3451e5 1177
3fed29a7 1178/**
6b61c2c4
FM
1179 * @deprecated since Moodle 2.2 use core_text::xxxx() instead.
1180 * @see core_text
3fed29a7
PS
1181 */
1182function textlib_get_instance() {
6b61c2c4
FM
1183 throw new coding_exception('textlib_get_instance() can not be used any more, please use '.
1184 'core_text::functioname() instead.');
3fed29a7
PS
1185}
1186
ee7084e9 1187/**
ee7084e9
MG
1188 * @deprecated since 2.4
1189 * @see get_section_name()
1190 * @see format_base::get_section_name()
1ac1d29b 1191
ee7084e9
MG
1192 */
1193function get_generic_section_name($format, stdClass $section) {
1ac1d29b 1194 throw new coding_exception('get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base');
ee7084e9 1195}
99e9f9a6
MG
1196
1197/**
1198 * Returns an array of sections for the requested course id
1199 *
1200 * It is usually not recommended to display the list of sections used
1201 * in course because the course format may have it's own way to do it.
1202 *
1203 * If you need to just display the name of the section please call:
1204 * get_section_name($course, $section)
1205 * {@link get_section_name()}
1206 * from 2.4 $section may also be just the field course_sections.section
1207 *
1208 * If you need the list of all sections it is more efficient to get this data by calling
b46be6ad 1209 * $modinfo = get_fast_modinfo($courseorid);
99e9f9a6
MG
1210 * $sections = $modinfo->get_section_info_all()
1211 * {@link get_fast_modinfo()}
1212 * {@link course_modinfo::get_section_info_all()}
1213 *
1214 * Information about one section (instance of section_info):
b46be6ad 1215 * get_fast_modinfo($courseorid)->get_sections_info($section)
99e9f9a6
MG
1216 * {@link course_modinfo::get_section_info()}
1217 *
1218 * @deprecated since 2.4
99e9f9a6
MG
1219 */
1220function get_all_sections($courseid) {
1ac1d29b
AA
1221
1222 throw new coding_exception('get_all_sections() is deprecated. See phpdocs for this function');
99e9f9a6 1223}
722e6ba9
MG
1224
1225/**
722e6ba9
MG
1226 * This function is deprecated, please use {@link course_add_cm_to_section()}
1227 * Note that course_add_cm_to_section() also updates field course_modules.section and
1228 * calls rebuild_course_cache()
1229 *
1230 * @deprecated since 2.4
722e6ba9 1231 */
44aa854e 1232function add_mod_to_section($mod, $beforemod = null) {
1ac1d29b 1233 throw new coding_exception('Function add_mod_to_section() is deprecated, please use course_add_cm_to_section()');
722e6ba9 1234}
d57aa283
MG
1235
1236/**
1237 * Returns a number of useful structures for course displays
1238 *
1239 * Function get_all_mods() is deprecated in 2.4
1240 * Instead of:
1241 * <code>
b46be6ad 1242 * get_all_mods($courseid, $mods, $modnames, $modnamesplural, $modnamesused);
d57aa283
MG
1243 * </code>
1244 * please use:
1245 * <code>
b46be6ad 1246 * $mods = get_fast_modinfo($courseorid)->get_cms();
d57aa283
MG
1247 * $modnames = get_module_types_names();
1248 * $modnamesplural = get_module_types_names(true);
b46be6ad 1249 * $modnamesused = get_fast_modinfo($courseorid)->get_used_module_names();
d57aa283
MG
1250 * </code>
1251 *
1252 * @deprecated since 2.4
d57aa283
MG
1253 */
1254function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) {
1ac1d29b 1255 throw new coding_exception('Function get_all_mods() is deprecated. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details');
d57aa283 1256}
4ede27b2
MG
1257
1258/**
1259 * Returns course section - creates new if does not exist yet
1260 *
1261 * This function is deprecated. To create a course section call:
b46be6ad 1262 * course_create_sections_if_missing($courseorid, $sections);
4ede27b2 1263 * to get the section call:
b46be6ad 1264 * get_fast_modinfo($courseorid)->get_section_info($sectionnum);
4ede27b2
MG
1265 *
1266 * @see course_create_sections_if_missing()
1267 * @see get_fast_modinfo()
1268 * @deprecated since 2.4
4ede27b2
MG
1269 */
1270function get_course_section($section, $courseid) {
1271 global $DB;
1ac1d29b 1272 throw new coding_exception('Function get_course_section() is deprecated. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.');
4ede27b2 1273}
1b2581f4
MG
1274
1275/**
1b2581f4
MG
1276 * @deprecated since 2.4
1277 * @see format_weeks::get_section_dates()
1b2581f4
MG
1278 */
1279function format_weeks_get_section_dates($section, $course) {
1ac1d29b
AA
1280 throw new coding_exception('Function format_weeks_get_section_dates() is deprecated. It is not recommended to'.
1281 ' use it outside of format_weeks plugin');
1b2581f4 1282}
9a36be73
MG
1283
1284/**
9a36be73
MG
1285 * Deprecated. Instead of:
1286 * list($content, $name) = get_print_section_cm_text($cm, $course);
1287 * use:
1288 * $content = $cm->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
1289 * $name = $cm->get_formatted_name();
1290 *
1291 * @deprecated since 2.5
1292 * @see cm_info::get_formatted_content()
1293 * @see cm_info::get_formatted_name()
9a36be73
MG
1294 */
1295function get_print_section_cm_text(cm_info $cm, $course) {
1ac1d29b
AA
1296 throw new coding_exception('Function get_print_section_cm_text() is deprecated. Please use '.
1297 'cm_info::get_formatted_content() and cm_info::get_formatted_name()');
9a36be73
MG
1298}
1299
1300/**
9a36be73
MG
1301 * Deprecated. Please use:
1302 * $courserenderer = $PAGE->get_renderer('core', 'course');
1303 * $output = $courserenderer->course_section_add_cm_control($course, $section, $sectionreturn,
1304 * array('inblock' => $vertical));
1305 * echo $output; // if $return argument in print_section_add_menus() set to false
1306 *
1307 * @deprecated since 2.5
1308 * @see core_course_renderer::course_section_add_cm_control()
9a36be73
MG
1309 */
1310function print_section_add_menus($course, $section, $modnames = null, $vertical=false, $return=false, $sectionreturn=null) {
1ac1d29b
AA
1311 throw new coding_exception('Function print_section_add_menus() is deprecated. Please use course renderer '.
1312 'function course_section_add_cm_control()');
9a36be73
MG
1313}
1314
1315/**
9a36be73
MG
1316 * Deprecated. Please use:
1317 * $courserenderer = $PAGE->get_renderer('core', 'course');
1318 * $actions = course_get_cm_edit_actions($mod, $indent, $section);
1319 * return ' ' . $courserenderer->course_section_cm_edit_actions($actions);
1320 *
1321 * @deprecated since 2.5
1322 * @see course_get_cm_edit_actions()
1323 * @see core_course_renderer->course_section_cm_edit_actions()
9a36be73
MG
1324 */
1325function make_editing_buttons(stdClass $mod, $absolute_ignored = true, $moveselect = true, $indent=-1, $section=null) {
1ac1d29b
AA
1326 throw new coding_exception('Function make_editing_buttons() is deprecated, please see PHPdocs in '.
1327 'lib/deprecatedlib.php on how to replace it');
9a36be73
MG
1328}
1329
1330/**
9a36be73
MG
1331 * Deprecated. Please use:
1332 * $courserenderer = $PAGE->get_renderer('core', 'course');
1333 * echo $courserenderer->course_section_cm_list($course, $section, $sectionreturn,
1334 * array('hidecompletion' => $hidecompletion));
1335 *
1336 * @deprecated since 2.5
1337 * @see core_course_renderer::course_section_cm_list()
9a36be73
MG
1338 */
1339function print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false, $sectionreturn=null) {
1ac1d29b
AA
1340 throw new coding_exception('Function print_section() is deprecated. Please use course renderer function '.
1341 'course_section_cm_list() instead.');
9a36be73 1342}
00ba185d 1343
ff233851 1344/**
ff233851 1345 * @deprecated since 2.5
ff233851
MG
1346 */
1347function print_overview($courses, array $remote_courses=array()) {
1ac1d29b 1348 throw new coding_exception('Function print_overview() is deprecated. Use block course_overview to display this information');
ff233851 1349}
a3f66bde
MG
1350
1351/**
a3f66bde 1352 * @deprecated since 2.5
a3f66bde
MG
1353 */
1354function print_recent_activity($course) {
1ac1d29b
AA
1355 throw new coding_exception('Function print_recent_activity() is deprecated. It is not recommended to'.
1356 ' use it outside of block_recent_activity');
a3f66bde 1357}
a347aee3
MN
1358
1359/**
a347aee3 1360 * @deprecated since 2.5
a347aee3
MN
1361 */
1362function delete_course_module($id) {
1ac1d29b 1363 throw new coding_exception('Function delete_course_module() is deprecated. Please use course_delete_module() instead.');
a347aee3 1364}
2c49fb4c
MG
1365
1366/**
2c49fb4c 1367 * @deprecated since 2.5
2c49fb4c
MG
1368 */
1369function update_category_button($categoryid = 0) {
1ac1d29b
AA
1370 throw new coding_exception('Function update_category_button() is deprecated. Pages to view '.
1371 'and edit courses are now separate and no longer depend on editing mode.');
2c49fb4c 1372}
4e0b6025
MG
1373
1374/**
4e0b6025
MG
1375 * This function is deprecated! For list of categories use
1376 * coursecat::make_all_categories($requiredcapability, $excludeid, $separator)
1377 * For parents of one particular category use
1378 * coursecat::get($id)->get_parents()
1379 *
1380 * @deprecated since 2.5
4e0b6025
MG
1381 */
1382function make_categories_list(&$list, &$parents, $requiredcapability = '',
1383 $excludeid = 0, $category = NULL, $path = "") {
1ac1d29b
AA
1384 throw new coding_exception('Global function make_categories_list() is deprecated. Please use '.
1385 'coursecat::make_categories_list() and coursecat::get_parents()');
4e0b6025 1386}
deb65ced
MG
1387
1388/**
deb65ced 1389 * @deprecated since 2.5
deb65ced
MG
1390 */
1391function category_delete_move($category, $newparentid, $showfeedback=true) {
1ac1d29b 1392 throw new coding_exception('Function category_delete_move() is deprecated. Please use coursecat::delete_move() instead.');
deb65ced
MG
1393}
1394
1395/**
deb65ced 1396 * @deprecated since 2.5
deb65ced
MG
1397 */
1398function category_delete_full($category, $showfeedback=true) {
1ac1d29b 1399 throw new coding_exception('Function category_delete_full() is deprecated. Please use coursecat::delete_full() instead.');
deb65ced 1400}
6e1d1ee0
MG
1401
1402/**
6e1d1ee0
MG
1403 * This function is deprecated. Please use
1404 * $coursecat = coursecat::get($category->id);
1405 * if ($coursecat->can_change_parent($newparentcat->id)) {
1406 * $coursecat->change_parent($newparentcat->id);
1407 * }
1408 *
1409 * Alternatively you can use
1410 * $coursecat->update(array('parent' => $newparentcat->id));
1411 *
6e1d1ee0
MG
1412 * @see coursecat::change_parent()
1413 * @see coursecat::update()
1414 * @deprecated since 2.5
6e1d1ee0
MG
1415 */
1416function move_category($category, $newparentcat) {
1ac1d29b 1417 throw new coding_exception('Function move_category() is deprecated. Please use coursecat::change_parent() instead.');
6e1d1ee0
MG
1418}
1419
1420/**
6e1d1ee0
MG
1421 * This function is deprecated. Please use
1422 * coursecat::get($category->id)->hide();
1423 *
1424 * @see coursecat::hide()
1425 * @deprecated since 2.5
6e1d1ee0
MG
1426 */
1427function course_category_hide($category) {
1ac1d29b 1428 throw new coding_exception('Function course_category_hide() is deprecated. Please use coursecat::hide() instead.');
6e1d1ee0
MG
1429}
1430
1431/**
6e1d1ee0
MG
1432 * This function is deprecated. Please use
1433 * coursecat::get($category->id)->show();
1434 *
1435 * @see coursecat::show()
1436 * @deprecated since 2.5
6e1d1ee0
MG
1437 */
1438function course_category_show($category) {
1ac1d29b 1439 throw new coding_exception('Function course_category_show() is deprecated. Please use coursecat::show() instead.');
6e1d1ee0 1440}
2d8a275b
MG
1441
1442/**
2d8a275b
MG
1443 * This function is deprecated.
1444 * To get the category with the specified it please use:
1445 * coursecat::get($catid, IGNORE_MISSING);
1446 * or
1447 * coursecat::get($catid, MUST_EXIST);
1448 *
1449 * To get the first available category please use
1450 * coursecat::get_default();
1451 *
2d8a275b 1452 * @deprecated since 2.5
2d8a275b
MG
1453 */
1454function get_course_category($catid=0) {
1ac1d29b 1455 throw new coding_exception('Function get_course_category() is deprecated. Please use coursecat::get(), see phpdocs for more details');
2d8a275b 1456}
9bad61db
MG
1457
1458/**
9bad61db
MG
1459 * This function is deprecated. It is replaced with the method create() in class coursecat.
1460 * {@link coursecat::create()} also verifies the data, fixes sortorder and logs the action
1461 *
1462 * @deprecated since 2.5
9bad61db
MG
1463 */
1464function create_course_category($category) {
1ac1d29b 1465 throw new coding_exception('Function create_course_category() is deprecated. Please use coursecat::create(), see phpdocs for more details');
9bad61db 1466}
bc81b006
MG
1467
1468/**
bc81b006
MG
1469 * This function is deprecated.
1470 *
1471 * To get visible children categories of the given category use:
1472 * coursecat::get($categoryid)->get_children();
1473 * This function will return the array or coursecat objects, on each of them
1474 * you can call get_children() again
1475 *
1476 * @see coursecat::get()
1477 * @see coursecat::get_children()
1478 *
1479 * @deprecated since 2.5
bc81b006
MG
1480 */
1481function get_all_subcategories($catid) {
1ac1d29b
AA
1482 throw new coding_exception('Function get_all_subcategories() is deprecated. Please use appropriate methods() of coursecat
1483 class. See phpdocs for more details');
bc81b006 1484}
8db5dcb7
MG
1485
1486/**
8db5dcb7
MG
1487 * This function is deprecated. Please use functions in class coursecat:
1488 * - coursecat::get($parentid)->has_children()
1489 * tells if the category has children (visible or not to the current user)
1490 *
1491 * - coursecat::get($parentid)->get_children()
1492 * returns an array of coursecat objects, each of them represents a children category visible
1493 * to the current user (i.e. visible=1 or user has capability to view hidden categories)
1494 *
1495 * - coursecat::get($parentid)->get_children_count()
1496 * returns number of children categories visible to the current user
1497 *
1498 * - coursecat::count_all()
1499 * returns total count of all categories in the system (both visible and not)
1500 *
1501 * - coursecat::get_default()
1502 * returns the first category (usually to be used if count_all() == 1)
1503 *
1504 * @deprecated since 2.5
8db5dcb7
MG
1505 */
1506function get_child_categories($parentid) {
1ac1d29b
AA
1507 throw new coding_exception('Function get_child_categories() is deprecated. Use coursecat::get_children() or see phpdocs for
1508 more details.');
8db5dcb7 1509}
e1d54562
MG
1510
1511/**
e1d54562
MG
1512 *
1513 * @deprecated since 2.5
1514 *
1515 * This function is deprecated. Use appropriate functions from class coursecat.
1516 * Examples:
1517 *
1518 * coursecat::get($categoryid)->get_children()
1519 * - returns all children of the specified category as instances of class
0198b4a5
MG
1520 * coursecat, which means on each of them method get_children() can be called again.
1521 * Only categories visible to the current user are returned.
e1d54562 1522 *
0198b4a5
MG
1523 * coursecat::get(0)->get_children()
1524 * - returns all top-level categories visible to the current user.
e1d54562
MG
1525 *
1526 * Sort fields can be specified, see phpdocs to {@link coursecat::get_children()}
1527 *
0198b4a5
MG
1528 * coursecat::make_categories_list()
1529 * - returns an array of all categories id/names in the system.
1530 * Also only returns categories visible to current user and can additionally be
1531 * filetered by capability, see phpdocs to {@link coursecat::make_categories_list()}
1532 *
1533 * make_categories_options()
1534 * - Returns full course categories tree to be used in html_writer::select()
1535 *
e1d54562
MG
1536 * Also see functions {@link coursecat::get_children_count()}, {@link coursecat::count_all()},
1537 * {@link coursecat::get_default()}
e1d54562
MG
1538 */
1539function get_categories($parent='none', $sort=NULL, $shallow=true) {
1ac1d29b 1540 throw new coding_exception('Function get_categories() is deprecated. Please use coursecat::get_children() or see phpdocs for other alternatives');
e1d54562 1541}
a8d683ca
MG
1542
1543/**
a8d683ca
MG
1544* This function is deprecated, please use course renderer:
1545* $renderer = $PAGE->get_renderer('core', 'course');
1546* echo $renderer->course_search_form($value, $format);
1547*
1548* @deprecated since 2.5
a8d683ca
MG
1549*/
1550function print_course_search($value="", $return=false, $format="plain") {
1ac1d29b 1551 throw new coding_exception('Function print_course_search() is deprecated, please use course renderer');
a8d683ca 1552}
09ae7ee0
MG
1553
1554/**
09ae7ee0
MG
1555 * This function is deprecated, please use:
1556 * $renderer = $PAGE->get_renderer('core', 'course');
1557 * echo $renderer->frontpage_my_courses()
1558 *
1559 * @deprecated since 2.5
1560 */
1561function print_my_moodle() {
1ac1d29b 1562 throw new coding_exception('Function print_my_moodle() is deprecated, please use course renderer function frontpage_my_courses()');
09ae7ee0
MG
1563}
1564
1565/**
09ae7ee0
MG
1566 * This function is deprecated, it is replaced with protected function
1567 * {@link core_course_renderer::frontpage_remote_course()}
1568 * It is only used from function {@link core_course_renderer::frontpage_my_courses()}
1569 *
1570 * @deprecated since 2.5
1571 */
1572function print_remote_course($course, $width="100%") {
1ac1d29b 1573 throw new coding_exception('Function print_remote_course() is deprecated, please use course renderer');
09ae7ee0
MG
1574}
1575
1576/**
09ae7ee0
MG
1577 * This function is deprecated, it is replaced with protected function
1578 * {@link core_course_renderer::frontpage_remote_host()}
1579 * It is only used from function {@link core_course_renderer::frontpage_my_courses()}
1580 *
1581 * @deprecated since 2.5
1582 */
1583function print_remote_host($host, $width="100%") {
1ac1d29b 1584 throw new coding_exception('Function print_remote_host() is deprecated, please use course renderer');
09ae7ee0
MG
1585}
1586
1587/**
09ae7ee0
MG
1588 * @deprecated since 2.5
1589 *
1590 * See http://docs.moodle.org/dev/Courses_lists_upgrade_to_2.5
1591 */
1592function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1, $showcourses = true, $categorycourses=NULL) {
1593 global $PAGE;
1ac1d29b 1594 throw new coding_exception('Function print_whole_category_list() is deprecated, please use course renderer');
09ae7ee0
MG
1595}
1596
1597/**
09ae7ee0 1598 * @deprecated since 2.5
09ae7ee0
MG
1599 */
1600function print_category_info($category, $depth = 0, $showcourses = false, array $courses = null) {
1ac1d29b 1601 throw new coding_exception('Function print_category_info() is deprecated, please use course renderer');
09ae7ee0
MG
1602}
1603
1604/**
09ae7ee0
MG
1605 * @deprecated since 2.5
1606 *
1607 * This function is not used any more in moodle core and course renderer does not have render function for it.
1608 * Combo list on the front page is displayed as:
1609 * $renderer = $PAGE->get_renderer('core', 'course');
1610 * echo $renderer->frontpage_combo_list()
1611 *
1612 * The new class {@link coursecat} stores the information about course category tree
1613 * To get children categories use:
1614 * coursecat::get($id)->get_children()
1615 * To get list of courses use:
1616 * coursecat::get($id)->get_courses()
1617 *
1618 * See http://docs.moodle.org/dev/Courses_lists_upgrade_to_2.5
09ae7ee0
MG
1619 */
1620function get_course_category_tree($id = 0, $depth = 0) {
1ac1d29b
AA
1621 throw new coding_exception('Function get_course_category_tree() is deprecated, please use course renderer or coursecat class,
1622 see function phpdocs for more info');
09ae7ee0
MG
1623}
1624
1625/**
09ae7ee0
MG
1626 * @deprecated since 2.5
1627 *
1628 * To print a generic list of courses use:
1629 * $renderer = $PAGE->get_renderer('core', 'course');
1630 * echo $renderer->courses_list($courses);
1631 *
1632 * To print list of all courses:
1633 * $renderer = $PAGE->get_renderer('core', 'course');
1634 * echo $renderer->frontpage_available_courses();
1635 *
1636 * To print list of courses inside category:
1637 * $renderer = $PAGE->get_renderer('core', 'course');
1638 * echo $renderer->course_category($category); // this will also print subcategories
09ae7ee0
MG
1639 */
1640function print_courses($category) {
1ac1d29b 1641 throw new coding_exception('Function print_courses() is deprecated, please use course renderer');
09ae7ee0
MG
1642}
1643
1644/**
09ae7ee0
MG
1645 * @deprecated since 2.5
1646 *
1647 * Please use course renderer to display a course information box.
1648 * $renderer = $PAGE->get_renderer('core', 'course');
1649 * echo $renderer->courses_list($courses); // will print list of courses
1650 * echo $renderer->course_info_box($course); // will print one course wrapped in div.generalbox
09ae7ee0
MG
1651 */
1652function print_course($course, $highlightterms = '') {
1ac1d29b 1653 throw new coding_exception('Function print_course() is deprecated, please use course renderer');
09ae7ee0
MG
1654}
1655
1656/**
09ae7ee0
MG
1657 * @deprecated since 2.5
1658 *
1659 * This function is not used any more in moodle core and course renderer does not have render function for it.
1660 * Combo list on the front page is displayed as:
1661 * $renderer = $PAGE->get_renderer('core', 'course');
1662 * echo $renderer->frontpage_combo_list()
1663 *
1664 * The new class {@link coursecat} stores the information about course category tree
1665 * To get children categories use:
1666 * coursecat::get($id)->get_children()
1667 * To get list of courses use:
1668 * coursecat::get($id)->get_courses()
09ae7ee0
MG
1669 */
1670function get_category_courses_array($categoryid = 0) {
1ac1d29b 1671 throw new coding_exception('Function get_category_courses_array() is deprecated, please use methods of coursecat class');
09ae7ee0
MG
1672}
1673
1674/**
09ae7ee0 1675 * @deprecated since 2.5
09ae7ee0
MG
1676 */
1677function get_category_courses_array_recursively(array &$flattened, $category) {
1ac1d29b 1678 throw new coding_exception('Function get_category_courses_array_recursively() is deprecated, please use methods of coursecat class', DEBUG_DEVELOPER);
09ae7ee0
MG
1679}
1680
7ac18cf9 1681/**
7ac18cf9 1682 * @deprecated since Moodle 2.5 MDL-27814 - please do not use this function any more.
7ac18cf9
AA
1683 */
1684function blog_get_context_url($context=null) {
1ac1d29b 1685 throw new coding_exception('Function blog_get_context_url() is deprecated, getting params from context is not reliable for blogs.');
7ac18cf9
AA
1686}
1687
09ae7ee0 1688/**
09ae7ee0
MG
1689 * @deprecated since 2.5
1690 *
1691 * To get list of all courses with course contacts ('managers') use
1692 * coursecat::get(0)->get_courses(array('recursive' => true, 'coursecontacts' => true));
1693 *
1694 * To get list of courses inside particular category use
1695 * coursecat::get($id)->get_courses(array('coursecontacts' => true));
1696 *
1697 * Additionally you can specify sort order, offset and maximum number of courses,
1698 * see {@link coursecat::get_courses()}
09ae7ee0
MG
1699 */
1700function get_courses_wmanagers($categoryid=0, $sort="c.sortorder ASC", $fields=array()) {
1ac1d29b 1701 throw new coding_exception('Function get_courses_wmanagers() is deprecated, please use coursecat::get_courses()');
09ae7ee0 1702}
c269b9d1
MG
1703
1704/**
c269b9d1 1705 * @deprecated since 2.5
c269b9d1
MG
1706 */
1707function convert_tree_to_html($tree, $row=0) {
1ac1d29b 1708 throw new coding_exception('Function convert_tree_to_html() is deprecated since Moodle 2.5. Consider using class tabtree and core_renderer::render_tabtree()');
c269b9d1
MG
1709}
1710
1711/**
c269b9d1 1712 * @deprecated since 2.5
c269b9d1
MG
1713 */
1714function convert_tabrows_to_tree($tabrows, $selected, $inactive, $activated) {
1ac1d29b 1715 throw new coding_exception('Function convert_tabrows_to_tree() is deprecated since Moodle 2.5. Consider using class tabtree');
c269b9d1 1716}
9052fc44 1717
8ef3a222 1718/**
8ef3a222 1719 * @deprecated since 2.5 - do not use, the textrotate.js will work it out automatically
8ef3a222
DP
1720 */
1721function can_use_rotated_text() {
1ac1d29b 1722 debugging('can_use_rotated_text() is deprecated since Moodle 2.5. JS feature detection is used automatically.');
8ef3a222 1723}
61a0299a 1724
ce2b2150 1725/**
ce2b2150 1726 * @deprecated since Moodle 2.2 MDL-35009 - please do not use this function any more.
ce2b2150 1727 * @see context::instance_by_id($id)
ce2b2150
RT
1728 */
1729function get_context_instance_by_id($id, $strictness = IGNORE_MISSING) {
f9b7be4f 1730 throw new coding_exception('get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.');
ce2b2150 1731}
85b2e46f 1732
492ba9de
AA
1733/**
1734 * Returns system context or null if can not be created yet.
1735 *
1736 * @see context_system::instance()
01546175 1737 * @deprecated since 2.2
492ba9de
AA
1738 * @param bool $cache use caching
1739 * @return context system context (null if context table not created yet)
1740 */
1741function get_system_context($cache = true) {
1742 debugging('get_system_context() is deprecated, please use context_system::instance() instead.', DEBUG_DEVELOPER);
1743 return context_system::instance(0, IGNORE_MISSING, $cache);
1744}
8e8891b7
FM
1745
1746/**
8e8891b7
FM
1747 * @see context::get_parent_context_ids()
1748 * @deprecated since 2.2, use $context->get_parent_context_ids() instead
8e8891b7
FM
1749 */
1750function get_parent_contexts(context $context, $includeself = false) {
1ac1d29b 1751 throw new coding_exception('get_parent_contexts() is deprecated, please use $context->get_parent_context_ids() instead.');
8e8891b7 1752}
766fd0d9
AD
1753
1754/**
7f5b51c4
RT
1755 * @deprecated since Moodle 2.2
1756 * @see context::get_parent_context()
766fd0d9 1757 */
7f5b51c4 1758function get_parent_contextid(context $context) {
1ac1d29b 1759 throw new coding_exception('get_parent_contextid() is deprecated, please use $context->get_parent_context() instead.');
766fd0d9 1760}
f9aa8016
FM
1761
1762/**
f9aa8016
FM
1763 * @see context::get_child_contexts()
1764 * @deprecated since 2.2
f9aa8016
FM
1765 */
1766function get_child_contexts(context $context) {
1ac1d29b 1767 throw new coding_exception('get_child_contexts() is deprecated, please use $context->get_child_contexts() instead.');
f9aa8016 1768}
9fdbf620
FM
1769
1770/**
9fdbf620
FM
1771 * @see context_helper::create_instances()
1772 * @deprecated since 2.2
9fdbf620
FM
1773 */
1774function create_contexts($contextlevel = null, $buildpaths = true) {
1ac1d29b 1775 throw new coding_exception('create_contexts() is deprecated, please use context_helper::create_instances() instead.');
9fdbf620 1776}
84378a57
FM
1777
1778/**
84378a57
FM
1779 * @see context_helper::cleanup_instances()
1780 * @deprecated since 2.2
84378a57
FM
1781 */
1782function cleanup_contexts() {
1ac1d29b 1783 throw new coding_exception('cleanup_contexts() is deprecated, please use context_helper::cleanup_instances() instead.');
84378a57 1784}
79f6b384
FM
1785
1786/**
1787 * Populate context.path and context.depth where missing.
1788 *
79f6b384 1789 * @deprecated since 2.2
79f6b384
FM
1790 */
1791function build_context_path($force = false) {
1ac1d29b 1792 throw new coding_exception('build_context_path() is deprecated, please use context_helper::build_all_paths() instead.');
79f6b384 1793}
cc4de415
FM
1794
1795/**
cc4de415 1796 * @deprecated since 2.2
cc4de415
FM
1797 */
1798function rebuild_contexts(array $fixcontexts) {
1ac1d29b 1799 throw new coding_exception('rebuild_contexts() is deprecated, please use $context->reset_paths(true) instead.');
cc4de415 1800}
8f7d3d12
RT
1801
1802/**
8f7d3d12
RT
1803 * @deprecated since Moodle 2.2
1804 * @see context_helper::preload_course()
8f7d3d12
RT
1805 */
1806function preload_course_contexts($courseid) {
1ac1d29b 1807 throw new coding_exception('preload_course_contexts() is deprecated, please use context_helper::preload_course() instead.');
8f7d3d12 1808}
2c5b0eb7
RT
1809
1810/**
2c5b0eb7
RT
1811 * @deprecated since Moodle 2.2
1812 * @see context::update_moved()
2c5b0eb7
RT
1813 */
1814function context_moved(context $context, context $newparent) {
1ac1d29b 1815 throw new coding_exception('context_moved() is deprecated, please use context::update_moved() instead.');
c5dcd25d
AA
1816}
1817
a439b2f9 1818/**
a439b2f9
FM
1819 * @see context::get_capabilities()
1820 * @deprecated since 2.2
a439b2f9
FM
1821 */
1822function fetch_context_capabilities(context $context) {
1ac1d29b 1823 throw new coding_exception('fetch_context_capabilities() is deprecated, please use $context->get_capabilities() instead.');
a439b2f9
FM
1824}
1825
c5dcd25d 1826/**
c5dcd25d
AA
1827 * @deprecated since 2.2
1828 * @see context_helper::preload_from_record()
c5dcd25d
AA
1829 */
1830function context_instance_preload(stdClass $rec) {
1ac1d29b 1831 throw new coding_exception('context_instance_preload() is deprecated, please use context_helper::preload_from_record() instead.');
c5dcd25d 1832}
b4482dfe
AG
1833
1834/**
1835 * Returns context level name
1836 *
1837 * @deprecated since 2.2
1838 * @see context_helper::get_level_name()
b4482dfe
AG
1839 */
1840function get_contextlevel_name($contextlevel) {
1ac1d29b 1841 throw new coding_exception('get_contextlevel_name() is deprecated, please use context_helper::get_level_name() instead.');
b4482dfe 1842}
329846f1
AG
1843
1844/**
329846f1
AG
1845 * @deprecated since 2.2
1846 * @see context::get_context_name()
329846f1
AG
1847 */
1848function print_context_name(context $context, $withprefix = true, $short = false) {
1ac1d29b 1849 throw new coding_exception('print_context_name() is deprecated, please use $context->get_context_name() instead.');
329846f1 1850}
1de02d62
AG
1851
1852/**
1de02d62
AG
1853 * @deprecated since 2.2, use $context->mark_dirty() instead
1854 * @see context::mark_dirty()
1de02d62
AG
1855 */
1856function mark_context_dirty($path) {
1ac1d29b 1857 throw new coding_exception('mark_context_dirty() is deprecated, please use $context->mark_dirty() instead.');
1de02d62 1858}
c592eea2
RT
1859
1860/**
c592eea2
RT
1861 * @deprecated since Moodle 2.2
1862 * @see context_helper::delete_instance() or context::delete_content()
c592eea2
RT
1863 */
1864function delete_context($contextlevel, $instanceid, $deleterecord = true) {
1865 if ($deleterecord) {
1ac1d29b 1866 throw new coding_exception('delete_context() is deprecated, please use context_helper::delete_instance() instead.');
c592eea2 1867 } else {
1ac1d29b 1868 throw new coding_exception('delete_context() is deprecated, please use $context->delete_content() instead.');
c592eea2 1869 }
c592eea2 1870}
6c89d4e1
MN
1871
1872/**
6c89d4e1
MN
1873 * @deprecated since 2.2
1874 * @see context::get_url()
6c89d4e1
MN
1875 */
1876function get_context_url(context $context) {
1ac1d29b 1877 throw new coding_exception('get_context_url() is deprecated, please use $context->get_url() instead.');
6c89d4e1
MN
1878}
1879
dd33f4af 1880/**
dd33f4af
MN
1881 * @deprecated since 2.2
1882 * @see context::get_course_context()
dd33f4af
MN
1883 */
1884function get_course_context(context $context) {
1ac1d29b 1885 throw new coding_exception('get_course_context() is deprecated, please use $context->get_course_context(true) instead.');
dd33f4af 1886}
6acc54b3
AA
1887
1888/**
6acc54b3
AA
1889 * @deprecated since 2.2
1890 * @see enrol_get_users_courses()
6acc54b3
AA
1891 */
1892function get_user_courses_bycap($userid, $cap, $accessdata_ignored, $doanything_ignored, $sort = 'c.sortorder ASC', $fields = null, $limit_ignored = 0) {
1893
1ac1d29b 1894 throw new coding_exception('get_user_courses_bycap() is deprecated, please use enrol_get_users_courses() instead.');
6acc54b3 1895}
ae38dcb1
RT
1896
1897/**
ae38dcb1 1898 * @deprecated since Moodle 2.2
ae38dcb1
RT
1899 */
1900function get_role_context_caps($roleid, context $context) {
1ac1d29b 1901 throw new coding_exception('get_role_context_caps() is deprecated, it is really slow. Don\'t use it.');
ae38dcb1 1902}
b123a543
FM
1903
1904/**
b123a543
FM
1905 * @see context::get_course_context()
1906 * @deprecated since 2.2
b123a543
FM
1907 */
1908function get_courseid_from_context(context $context) {
1ac1d29b 1909 throw new coding_exception('get_courseid_from_context() is deprecated, please use $context->get_course_context(false) instead.');
6a30b48d 1910}
2e4c0c91
FM
1911
1912/**
2e4c0c91
FM
1913 * If you are using this methid, you should have something like this:
1914 *
1915 * list($ctxselect, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
1916 *
1917 * To prevent the use of this deprecated function, replace the line above with something similar to this:
1918 *
1919 * $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx');
1920 * ^
1921 * $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)";
1922 * ^ ^ ^ ^
1923 * $params = array('contextlevel' => CONTEXT_COURSE);
1924 * ^
1925 * @see context_helper:;get_preload_record_columns_sql()
1926 * @deprecated since 2.2
2e4c0c91
FM
1927 */
1928function context_instance_preload_sql($joinon, $contextlevel, $tablealias) {
1ac1d29b 1929 throw new coding_exception('context_instance_preload_sql() is deprecated, please use context_helper::get_preload_record_columns_sql() instead.');
b123a543 1930}
b6452844
MN
1931
1932/**
b6452844
MN
1933 * @deprecated since 2.2
1934 * @see context::get_parent_context_ids()
b6452844
MN
1935 */
1936function get_related_contexts_string(context $context) {
1ac1d29b 1937 throw new coding_exception('get_related_contexts_string() is deprecated, please use $context->get_parent_context_ids(true) instead.');
b6452844 1938}
0142523d 1939
d0cac8b5 1940/**
d0cac8b5
FM
1941 * @deprecated since 2.6
1942 * @see core_component::get_plugin_list_with_file()
1943 */
1944function get_plugin_list_with_file($plugintype, $file, $include = false) {
1ac1d29b 1945 throw new coding_exception('get_plugin_list_with_file() is deprecated, please use core_component::get_plugin_list_with_file() instead.');
d0cac8b5 1946}
c3d2fbf9
SH
1947
1948/**
c3d2fbf9 1949 * @deprecated since 2.6
c3d2fbf9
SH
1950 */
1951function check_browser_operating_system($brand) {
1ac1d29b 1952 throw new coding_exception('check_browser_operating_system has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1953}
1954
1955/**
c3d2fbf9 1956 * @deprecated since 2.6
c3d2fbf9
SH
1957 */
1958function check_browser_version($brand, $version = null) {
1ac1d29b 1959 throw new coding_exception('check_browser_version has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1960}
1961
1962/**
c3d2fbf9 1963 * @deprecated since 2.6
c3d2fbf9
SH
1964 */
1965function get_device_type() {
1ac1d29b 1966 throw new coding_exception('get_device_type has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1967}
1968
1969/**
c3d2fbf9 1970 * @deprecated since 2.6
c3d2fbf9
SH
1971 */
1972function get_device_type_list($incusertypes = true) {
1ac1d29b 1973 throw new coding_exception('get_device_type_list has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1974}
1975
1976/**
c3d2fbf9 1977 * @deprecated since 2.6
c3d2fbf9
SH
1978 */
1979function get_selected_theme_for_device_type($devicetype = null) {
1ac1d29b 1980 throw new coding_exception('get_selected_theme_for_device_type has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1981}
1982
1983/**
c3d2fbf9 1984 * @deprecated since 2.6
c3d2fbf9
SH
1985 */
1986function get_device_cfg_var_name($devicetype = null) {
1ac1d29b 1987 throw new coding_exception('get_device_cfg_var_name has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1988}
1989
1990/**
c3d2fbf9 1991 * @deprecated since 2.6
c3d2fbf9
SH
1992 */
1993function set_user_device_type($newdevice) {
1ac1d29b 1994 throw new coding_exception('set_user_device_type has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
1995}
1996
1997/**
c3d2fbf9 1998 * @deprecated since 2.6
c3d2fbf9
SH
1999 */
2000function get_user_device_type() {
1ac1d29b 2001 throw new coding_exception('get_user_device_type has been deprecated, please update your code to use core_useragent instead.');
c3d2fbf9
SH
2002}
2003
2004/**
c3d2fbf9 2005 * @deprecated since 2.6
c3d2fbf9
SH
2006 */
2007function get_browser_version_classes() {
1ac1d29b 2008 throw new coding_exception('get_browser_version_classes has been deprecated, please update your code to use core_useragent instead.');
2b503e40
RT
2009}
2010
2011/**
2b503e40
RT
2012 * @deprecated since Moodle 2.6
2013 * @see core_user::get_support_user()
2b503e40
RT
2014 */
2015function generate_email_supportuser() {
1ac1d29b 2016 throw new coding_exception('generate_email_supportuser is deprecated, please use core_user::get_support_user');
853e506a
Y
2017}
2018
2019/**
853e506a 2020 * @deprecated since Moodle 2.6
853e506a
Y
2021 */
2022function badges_get_issued_badge_info($hash) {
1ac1d29b 2023 throw new coding_exception('Function badges_get_issued_badge_info() is deprecated. Please use core_badges_assertion class and methods to generate badge assertion.');
853e506a 2024}
3d27180e
DW
2025
2026/**
3d27180e 2027 * @deprecated since 2.6
3d27180e
DW
2028 */
2029function can_use_html_editor() {
1ac1d29b 2030 throw new coding_exception('can_use_html_editor has been deprecated please update your code to assume it returns true.');
3d27180e 2031}
52dc1de7
AA
2032
2033
2034/**
26e4b0ca 2035 * @deprecated since Moodle 2.7, use {@link user_count_login_failures()} instead.
52dc1de7
AA
2036 */
2037function count_login_failures($mode, $username, $lastlogin) {
26e4b0ca 2038 throw new coding_exception('count_login_failures() can not be used any more, please use user_count_login_failures().');
52dc1de7 2039}
de878a38 2040
6538153b 2041/**
44ab05b3 2042 * @deprecated since 2.7 MDL-33099/MDL-44088 - please do not use this function any more.
6538153b
FM
2043 */
2044function ajaxenabled(array $browsers = null) {
44ab05b3 2045 throw new coding_exception('ajaxenabled() can not be used anymore. Update your code to work with JS at all times.');
6538153b 2046}
8d1f33e1 2047
2048/**
e56e8e3a 2049 * @deprecated Since Moodle 2.7 MDL-44070
8d1f33e1 2050 */
2051function coursemodule_visible_for_user($cm, $userid=0) {
e56e8e3a
AA
2052 throw new coding_exception('coursemodule_visible_for_user() can not be used any more,
2053 please use \core_availability\info_module::is_user_visible()');
8d1f33e1 2054}
80f98467
MG
2055
2056/**
58b5b04d 2057 * @deprecated since Moodle 2.8 MDL-36014, MDL-35618 this functionality is removed
80f98467
MG
2058 */
2059function enrol_cohort_get_cohorts(course_enrolment_manager $manager) {
1ac1d29b
AA
2060 throw new coding_exception('Function enrol_cohort_get_cohorts() is deprecated, use enrol_cohort_search_cohorts() or '.
2061 'cohort_get_available_cohorts() instead');
80f98467
MG
2062}
2063
2064/**
80f98467
MG
2065 * This function is deprecated, use {@link cohort_can_view_cohort()} instead since it also
2066 * takes into account current context
2067 *
2068 * @deprecated since Moodle 2.8 MDL-36014 please use cohort_can_view_cohort()
80f98467
MG
2069 */
2070function enrol_cohort_can_view_cohort($cohortid) {
1ac1d29b 2071 throw new coding_exception('Function enrol_cohort_can_view_cohort() is deprecated, use cohort_can_view_cohort() instead');
80f98467
MG
2072}
2073
2074/**
80f98467
MG
2075 * It is advisable to use {@link cohort_get_available_cohorts()} instead.
2076 *
2077 * @deprecated since Moodle 2.8 MDL-36014 use cohort_get_available_cohorts() instead
80f98467
MG
2078 */
2079function cohort_get_visible_list($course, $onlyenrolled=true) {
1ac1d29b
AA
2080 throw new coding_exception('Function cohort_get_visible_list() is deprecated. Please use function cohort_get_available_cohorts() ".
2081 "that correctly checks capabilities.');
80f98467 2082}
58b5b04d
MG
2083
2084/**
58b5b04d 2085 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
58b5b04d
MG
2086 */
2087function enrol_cohort_enrol_all_users(course_enrolment_manager $manager, $cohortid, $roleid) {
1ac1d29b 2088 throw new coding_exception('enrol_cohort_enrol_all_users() is deprecated. This functionality is moved to enrol_manual.');
58b5b04d
MG
2089}
2090
2091/**
58b5b04d 2092 * @deprecated since Moodle 2.8 MDL-35618 this functionality is removed
58b5b04d
MG
2093 */
2094function enrol_cohort_search_cohorts(course_enrolment_manager $manager, $offset = 0, $limit = 25, $search = '') {
1ac1d29b 2095 throw new coding_exception('enrol_cohort_search_cohorts() is deprecated. This functionality is moved to enrol_manual.');
58b5b04d 2096}
bdc83277 2097
8322ed4a
AA
2098/* === Apis deprecated in since Moodle 2.9 === */
2099
bdc83277
DM
2100/**
2101 * Is $USER one of the supplied users?
2102 *
2103 * $user2 will be null if viewing a user's recent conversations
2104 *
2105 * @deprecated since Moodle 2.9 MDL-49371 - please do not use this function any more.
2106 * @todo MDL-49290 This will be deleted in Moodle 3.1.
2107 * @param stdClass the first user
2108 * @param stdClass the second user or null
2109 * @return bool True if the current user is one of either $user1 or $user2
2110 */
2111function message_current_user_is_involved($user1, $user2) {
2112 global $USER;
2113
2114 debugging('message_current_user_is_involved() is deprecated, please do not use this function.', DEBUG_DEVELOPER);
2115
2116 if (empty($user1->id) || (!empty($user2) && empty($user2->id))) {
2117 throw new coding_exception('Invalid user object detected. Missing id.');
2118 }
2119
2120 if ($user1->id != $USER->id && (empty($user2) || $user2->id != $USER->id)) {
2121 return false;
2122 }
2123 return true;
2124}
b19cc4ef
AA
2125
2126/**
2127 * Print badges on user profile page.
2128 *
2129 * @deprecated since Moodle 2.9 MDL-45898 - please do not use this function any more.
2130 * @param int $userid User ID.
2131 * @param int $courseid Course if we need to filter badges (optional).
2132 */
2133function profile_display_badges($userid, $courseid = 0) {
2134 global $CFG, $PAGE, $USER, $SITE;
2135 require_once($CFG->dirroot . '/badges/renderer.php');
2136
2137 debugging('profile_display_badges() is deprecated.', DEBUG_DEVELOPER);
2138
2139 // Determine context.
2140 if (isloggedin()) {
2141 $context = context_user::instance($USER->id);
2142 } else {
2143 $context = context_system::instance();
2144 }
2145
2146 if ($USER->id == $userid || has_capability('moodle/badges:viewotherbadges', $context)) {
2147 $records = badges_get_user_badges($userid, $courseid, null, null, null, true);
2148 $renderer = new core_badges_renderer($PAGE, '');
2149
2150 // Print local badges.
2151 if ($records) {
2152 $left = get_string('localbadgesp', 'badges', format_string($SITE->fullname));
2153 $right = $renderer->print_badges_list($records, $userid, true);
2154 echo html_writer::tag('dt', $left);
2155 echo html_writer::tag('dd', $right);
2156 }
2157
2158 // Print external badges.
2159 if ($courseid == 0 && !empty($CFG->badges_allowexternalbackpack)) {
2160 $backpack = get_backpack_settings($userid);
2161 if (isset($backpack->totalbadges) && $backpack->totalbadges !== 0) {
2162 $left = get_string('externalbadgesp', 'badges');
2163 $right = $renderer->print_badges_list($backpack->badges, $userid, true, true);
2164 echo html_writer::tag('dt', $left);
2165 echo html_writer::tag('dd', $right);
2166 }
2167 }
2168 }
2169}
efd32edb
AG
2170
2171/**
2172 * Adds user preferences elements to user edit form.
2173 *
2174 * @deprecated since Moodle 2.9 MDL-45774 - Please do not use this function any more.
2175 * @todo MDL-49784 Remove this function in Moodle 3.1
2176 * @param stdClass $user
2177 * @param moodleform $mform
2178 * @param array|null $editoroptions
2179 * @param array|null $filemanageroptions
2180 */
2181function useredit_shared_definition_preferences($user, &$mform, $editoroptions = null, $filemanageroptions = null) {
2182 global $CFG;
2183
2184 debugging('useredit_shared_definition_preferences() is deprecated.', DEBUG_DEVELOPER, backtrace);
2185
2186 $choices = array();
2187 $choices['0'] = get_string('emaildisplayno');
2188 $choices['1'] = get_string('emaildisplayyes');
2189 $choices['2'] = get_string('emaildisplaycourse');
2190 $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
2191 $mform->setDefault('maildisplay', $CFG->defaultpreference_maildisplay);
2192
2193 $choices = array();
2194 $choices['0'] = get_string('textformat');
2195 $choices['1'] = get_string('htmlformat');
2196 $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
2197 $mform->setDefault('mailformat', $CFG->defaultpreference_mailformat);
2198
2199 if (!empty($CFG->allowusermailcharset)) {
2200 $choices = array();
2201 $charsets = get_list_of_charsets();
2202 if (!empty($CFG->sitemailcharset)) {
2203 $choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')';
2204 } else {
2205 $choices['0'] = get_string('site').' (UTF-8)';
2206 }
2207 $choices = array_merge($choices, $charsets);
2208 $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
2209 }
2210
2211 $choices = array();
2212 $choices['0'] = get_string('emaildigestoff');
2213 $choices['1'] = get_string('emaildigestcomplete');
2214 $choices['2'] = get_string('emaildigestsubjects');
2215 $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
2216 $mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
2217 $mform->addHelpButton('maildigest', 'emaildigest');
2218
2219 $choices = array();
2220 $choices['1'] = get_string('autosubscribeyes');
2221 $choices['0'] = get_string('autosubscribeno');
2222 $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
2223 $mform->setDefault('autosubscribe', $CFG->defaultpreference_autosubscribe);
2224
2225 if (!empty($CFG->forum_trackreadposts)) {
2226 $choices = array();
2227 $choices['0'] = get_string('trackforumsno');
2228 $choices['1'] = get_string('trackforumsyes');
2229 $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
2230 $mform->setDefault('trackforums', $CFG->defaultpreference_trackforums);
2231 }
2232
2233 $editors = editors_get_enabled();
2234 if (count($editors) > 1) {
2235 $choices = array('' => get_string('defaulteditor'));
2236 $firsteditor = '';
2237 foreach (array_keys($editors) as $editor) {
2238 if (!$firsteditor) {
2239 $firsteditor = $editor;
2240 }
2241 $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
2242 }
2243 $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
2244 $mform->setDefault('preference_htmleditor', '');
2245 } else {
2246 // Empty string means use the first chosen text editor.
2247 $mform->addElement('hidden', 'preference_htmleditor');
2248 $mform->setDefault('preference_htmleditor', '');
2249 $mform->setType('preference_htmleditor', PARAM_PLUGIN);
2250 }
2251
2252 $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
2253 $mform->setDefault('lang', $CFG->lang);
2254
2255}
8322ed4a
AA
2256
2257
2258/**
2259 * Convert region timezone to php supported timezone
2260 *
2261 * @deprecated since Moodle 2.9
2262 * @param string $tz value from ical file
2263 * @return string $tz php supported timezone
2264 */
2265function calendar_normalize_tz($tz) {
2266 debugging('calendar_normalize_tz() is deprecated, use core_date::normalise_timezone() instead', DEBUG_DEVELOPER);
2267 return core_date::normalise_timezone($tz);
2268}
2269
2270/**
2271 * Returns a float which represents the user's timezone difference from GMT in hours
2272 * Checks various settings and picks the most dominant of those which have a value
2273 * @deprecated since Moodle 2.9
2274 * @param float|int|string $tz timezone user timezone
2275 * @return float
2276 */
2277function get_user_timezone_offset($tz = 99) {
2278 debugging('get_user_timezone_offset() is deprecated, use PHP DateTimeZone instead', DEBUG_DEVELOPER);
2279 $tz = core_date::get_user_timezone($tz);
2280 $date = new DateTime('now', new DateTimeZone($tz));
2281 return ($date->getOffset() - dst_offset_on(time(), $tz)) / (3600.0);
2282}
2283
2284/**
2285 * Returns an int which represents the systems's timezone difference from GMT in seconds
2286 * @deprecated since Moodle 2.9
2287 * @param float|int|string $tz timezone for which offset is required.
2288 * {@link http://docs.moodle.org/dev/Time_API#Timezone}
2289 * @return int|bool if found, false is timezone 99 or error
2290 */
2291function get_timezone_offset($tz) {
2292 debugging('get_timezone_offset() is deprecated, use PHP DateTimeZone instead', DEBUG_DEVELOPER);
2293 $date = new DateTime('now', new DateTimeZone(core_date::normalise_timezone($tz)));
2294 return $date->getOffset() - dst_offset_on(time(), $tz);
2295}
2296
2297/**
2298 * Returns a list of timezones in the current language.
2299 * @deprecated since Moodle 2.9
2300 * @return array
2301 */
2302function get_list_of_timezones() {
2303 debugging('get_list_of_timezones() is deprecated, use core_date::get_list_of_timezones() instead', DEBUG_DEVELOPER);
2304 return core_date::get_list_of_timezones();
2305}
2306
2307/**
2308 * Previous internal API, it was not supposed to be used anywhere.
2309 * @deprecated since Moodle 2.9
2310 * @param array $timezones
2311 */
2312function update_timezone_records($timezones) {
2313 debugging('update_timezone_records() is not available any more, use standard PHP date/time code', DEBUG_DEVELOPER);
2314}
2315
2316/**
2317 * Previous internal API, it was not supposed to be used anywhere.
2318 * @deprecated since Moodle 2.9
2319 * @param int $fromyear
2320 * @param int $toyear
2321 * @param mixed $strtimezone
2322 * @return bool
2323 */
2324function calculate_user_dst_table($fromyear = null, $toyear = null, $strtimezone = null) {
2325 debugging('calculate_user_dst_table() is not available any more, use standard PHP date/time code', DEBUG_DEVELOPER);
2326 return false;
2327}
2328
2329/**
2330 * Previous internal API, it was not supposed to be used anywhere.
2331 * @deprecated since Moodle 2.9
2332 * @param int|string $year
2333 * @param mixed $timezone
2334 * @return null
2335 */
2336function dst_changes_for_year($year, $timezone) {
2337 debugging('dst_changes_for_year() is not available any more, use standard PHP date/time code', DEBUG_DEVELOPER);
2338 return null;
2339}
2340
2341/**
2342 * Previous internal API, it was not supposed to be used anywhere.
2343 * @deprecated since Moodle 2.9
2344 * @param string $timezonename
2345 * @return array
2346 */
2347function get_timezone_record($timezonename) {
2348 debugging('get_timezone_record() is not available any more, use standard PHP date/time code', DEBUG_DEVELOPER);
2349 return array();
2350}
2351
2352/* === Apis deprecated in since Moodle 3.0 === */