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