MDL-35537 - Right align registration text on login page, when in RTL mode
[moodle.git] / lib / deprecatedlib.php
blob5b3c9ca860b70988317ddeb03dc3e0f70f3af2ca
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
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/>.
18 /**
19 * deprecatedlib.php - Old functions retained only for backward compatibility
21 * Old functions retained only for backward compatibility. New code should not
22 * use any of these functions.
24 * @package core
25 * @subpackage deprecated
26 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 * @deprecated
31 defined('MOODLE_INTERNAL') || die();
33 /**
34 * Unsupported session id rewriting.
35 * @deprecated
36 * @param string $buffer
38 function sid_ob_rewrite($buffer) {
39 throw new coding_exception('$CFG->usesid support was removed completely and can not be used.');
42 /**
43 * Insert or update log display entry. Entry may already exist.
44 * $module, $action must be unique
45 * @deprecated
47 * @param string $module
48 * @param string $action
49 * @param string $mtable
50 * @param string $field
51 * @return void
54 function update_log_display_entry($module, $action, $mtable, $field) {
55 global $DB;
57 debugging('The update_log_display_entry() is deprecated, please use db/log.php description file instead.');
60 /**
61 * Given some text in HTML format, this function will pass it
62 * through any filters that have been configured for this context.
64 * @deprecated use the text formatting in a standard way instead,
65 * this was abused mostly for embedding of attachments
67 * @param string $text The text to be passed through format filters
68 * @param int $courseid The current course.
69 * @return string the filtered string.
71 function filter_text($text, $courseid = NULL) {
72 global $CFG, $COURSE;
74 if (!$courseid) {
75 $courseid = $COURSE->id;
78 if (!$context = get_context_instance(CONTEXT_COURSE, $courseid)) {
79 return $text;
82 return filter_manager::instance()->filter_text($text, $context);
85 /**
86 * This function indicates that current page requires the https
87 * when $CFG->loginhttps enabled.
89 * By using this function properly, we can ensure 100% https-ized pages
90 * at our entire discretion (login, forgot_password, change_password)
91 * @deprecated use $PAGE->https_required() instead
93 function httpsrequired() {
94 global $PAGE;
95 $PAGE->https_required();
98 /**
99 * Given a physical path to a file, returns the URL through which it can be reached in Moodle.
101 * @deprecated use moodle_url factory methods instead
103 * @param string $path Physical path to a file
104 * @param array $options associative array of GET variables to append to the URL
105 * @param string $type (questionfile|rssfile|httpscoursefile|coursefile)
106 * @return string URL to file
108 function get_file_url($path, $options=null, $type='coursefile') {
109 global $CFG;
111 $path = str_replace('//', '/', $path);
112 $path = trim($path, '/'); // no leading and trailing slashes
114 // type of file
115 switch ($type) {
116 case 'questionfile':
117 $url = $CFG->wwwroot."/question/exportfile.php";
118 break;
119 case 'rssfile':
120 $url = $CFG->wwwroot."/rss/file.php";
121 break;
122 case 'httpscoursefile':
123 $url = $CFG->httpswwwroot."/file.php";
124 break;
125 case 'coursefile':
126 default:
127 $url = $CFG->wwwroot."/file.php";
130 if ($CFG->slasharguments) {
131 $parts = explode('/', $path);
132 foreach ($parts as $key => $part) {
133 /// anchor dash character should not be encoded
134 $subparts = explode('#', $part);
135 $subparts = array_map('rawurlencode', $subparts);
136 $parts[$key] = implode('#', $subparts);
138 $path = implode('/', $parts);
139 $ffurl = $url.'/'.$path;
140 $separator = '?';
141 } else {
142 $path = rawurlencode('/'.$path);
143 $ffurl = $url.'?file='.$path;
144 $separator = '&amp;';
147 if ($options) {
148 foreach ($options as $name=>$value) {
149 $ffurl = $ffurl.$separator.$name.'='.$value;
150 $separator = '&amp;';
154 return $ffurl;
158 * If there has been an error uploading a file, print the appropriate error message
159 * Numerical constants used as constant definitions not added until PHP version 4.2.0
160 * @deprecated removed - use new file api
162 function print_file_upload_error($filearray = '', $returnerror = false) {
163 throw new coding_exception('print_file_upload_error() can not be used any more, please use new file API');
167 * Handy function for resolving file conflicts
168 * @deprecated removed - use new file api
171 function resolve_filename_collisions($destination,$files,$format='%s_%d.%s') {
172 throw new coding_exception('resolve_filename_collisions() can not be used any more, please use new file API');
176 * Checks a file name for any conflicts
177 * @deprecated removed - use new file api
179 function check_potential_filename($destination,$filename,$files) {
180 throw new coding_exception('check_potential_filename() can not be used any more, please use new file API');
184 * This function prints out a number of upload form elements.
185 * @deprecated removed - use new file api
187 function upload_print_form_fragment($numfiles=1, $names=null, $descriptions=null, $uselabels=false, $labelnames=null, $coursebytes=0, $modbytes=0, $return=false) {
188 throw new coding_exception('upload_print_form_fragment() can not be used any more, please use new file API');
192 * Return the authentication plugin title
194 * @param string $authtype plugin type
195 * @return string
197 function auth_get_plugin_title($authtype) {
198 debugging('Function auth_get_plugin_title() is deprecated, please use standard get_string("pluginname", "auth_'.$authtype.'")!');
199 return get_string('pluginname', "auth_{$authtype}");
205 * Enrol someone without using the default role in a course
206 * @deprecated
208 function enrol_into_course($course, $user, $enrol) {
209 error('Function enrol_into_course() was removed, please use new enrol plugins instead!');
213 * Returns a role object that is the default role for new enrolments in a given course
215 * @deprecated
216 * @param object $course
217 * @return object returns a role or NULL if none set
219 function get_default_course_role($course) {
220 debugging('Function get_default_course_role() is deprecated, please use individual enrol plugin settings instead!');
222 $student = get_archetype_roles('student');
223 $student = reset($student);
225 return $student;
229 * Extremely slow enrolled courses query.
230 * @deprecated
232 function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NULL, $doanything=false,$limit=0) {
233 error('Function get_my_courses() was removed, please use new enrol_get_my_courses() or enrol_get_users_courses()!');
237 * Was returning list of translations, use new string_manager instead
239 * @deprecated
240 * @param bool $refreshcache force refreshing of lang cache
241 * @param bool $returnall ignore langlist, return all languages available
242 * @return array An associative array with contents in the form of LanguageCode => LanguageName
244 function get_list_of_languages($refreshcache=false, $returnall=false) {
245 debugging('get_list_of_languages() is deprecated, please use get_string_manager()->get_list_of_translations() instead.');
246 if ($refreshcache) {
247 get_string_manager()->reset_caches();
249 return get_string_manager()->get_list_of_translations($returnall);
253 * Returns a list of currencies in the current language
254 * @deprecated
255 * @return array
257 function get_list_of_currencies() {
258 debugging('get_list_of_currencies() is deprecated, please use get_string_manager()->get_list_of_currencies() instead.');
259 return get_string_manager()->get_list_of_currencies();
263 * Returns a list of all enabled country names in the current translation
264 * @deprecated
265 * @return array two-letter country code => translated name.
267 function get_list_of_countries() {
268 debugging('get_list_of_countries() is deprecated, please use get_string_manager()->get_list_of_countries() instead.');
269 return get_string_manager()->get_list_of_countries(false);
273 * @deprecated
275 function isteacher() {
276 error('Function isteacher() was removed, please use capabilities instead!');
280 * @deprecated
282 function isteacherinanycourse() {
283 throw new coding_Exception('Function isteacherinanycourse() was removed, please use capabilities instead!');
287 * @deprecated
289 function get_guest() {
290 throw new coding_Exception('Function get_guest() was removed, please use capabilities instead!');
294 * @deprecated
296 function isguest() {
297 throw new coding_Exception('Function isguest() was removed, please use capabilities instead!');
301 * @deprecated
303 function get_teacher() {
304 throw new coding_Exception('Function get_teacher() was removed, please use capabilities instead!');
308 * Return all course participant for a given course
310 * @deprecated
311 * @param integer $courseid
312 * @return array of user
314 function get_course_participants($courseid) {
315 return get_enrolled_users(get_context_instance(CONTEXT_COURSE, $courseid));
319 * Return true if the user is a participant for a given course
321 * @deprecated
322 * @param integer $userid
323 * @param integer $courseid
324 * @return boolean
326 function is_course_participant($userid, $courseid) {
327 return is_enrolled(get_context_instance(CONTEXT_COURSE, $courseid), $userid);
331 * Searches logs to find all enrolments since a certain date
333 * used to print recent activity
335 * @global object
336 * @uses CONTEXT_COURSE
337 * @param int $courseid The course in question.
338 * @param int $timestart The date to check forward of
339 * @return object|false {@link $USER} records or false if error.
341 function get_recent_enrolments($courseid, $timestart) {
342 global $DB;
344 $context = get_context_instance(CONTEXT_COURSE, $courseid);
346 $sql = "SELECT u.id, u.firstname, u.lastname, MAX(l.time)
347 FROM {user} u, {role_assignments} ra, {log} l
348 WHERE l.time > ?
349 AND l.course = ?
350 AND l.module = 'course'
351 AND l.action = 'enrol'
352 AND ".$DB->sql_cast_char2int('l.info')." = u.id
353 AND u.id = ra.userid
354 AND ra.contextid ".get_related_contexts_string($context)."
355 GROUP BY u.id, u.firstname, u.lastname
356 ORDER BY MAX(l.time) ASC";
357 $params = array($timestart, $courseid);
358 return $DB->get_records_sql($sql, $params);
363 * Turn the ctx* fields in an objectlike record into a context subobject
364 * This allows us to SELECT from major tables JOINing with
365 * context at no cost, saving a ton of context lookups...
367 * Use context_instance_preload() instead.
369 * @deprecated since 2.0
370 * @param object $rec
371 * @return object
373 function make_context_subobj($rec) {
374 throw new coding_Exception('make_context_subobj() was removed, use new context preloading');
378 * Do some basic, quick checks to see whether $rec->context looks like a valid context object.
380 * Use context_instance_preload() instead.
382 * @deprecated since 2.0
383 * @param object $rec a think that has a context, for example a course,
384 * course category, course modules, etc.
385 * @param int $contextlevel the type of thing $rec is, one of the CONTEXT_... constants.
386 * @return bool whether $rec->context looks like the correct context object
387 * for this thing.
389 function is_context_subobj_valid($rec, $contextlevel) {
390 throw new coding_Exception('is_context_subobj_valid() was removed, use new context preloading');
394 * Ensure that $rec->context is present and correct before you continue
396 * When you have a record (for example a $category, $course, $user or $cm that may,
397 * or may not, have come from a place that does make_context_subobj, you can use
398 * this method to ensure that $rec->context is present and correct before you continue.
400 * Use context_instance_preload() instead.
402 * @deprecated since 2.0
403 * @param object $rec a thing that has an associated context.
404 * @param integer $contextlevel the type of thing $rec is, one of the CONTEXT_... constants.
406 function ensure_context_subobj_present(&$rec, $contextlevel) {
407 throw new coding_Exception('ensure_context_subobj_present() was removed, use new context preloading');
410 ########### FROM weblib.php ##########################################################################
414 * Print a message in a standard themed box.
415 * This old function used to implement boxes using tables. Now it uses a DIV, but the old
416 * parameters remain. If possible, $align, $width and $color should not be defined at all.
417 * Preferably just use print_box() in weblib.php
419 * @deprecated
420 * @param string $message The message to display
421 * @param string $align alignment of the box, not the text (default center, left, right).
422 * @param string $width width of the box, including units %, for example '100%'.
423 * @param string $color background colour of the box, for example '#eee'.
424 * @param int $padding padding in pixels, specified without units.
425 * @param string $class space-separated class names.
426 * @param string $id space-separated id names.
427 * @param boolean $return return as string or just print it
428 * @return string|void Depending on $return
430 function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
431 $output = '';
432 $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true);
433 $output .= $message;
434 $output .= print_simple_box_end(true);
436 if ($return) {
437 return $output;
438 } else {
439 echo $output;
446 * This old function used to implement boxes using tables. Now it uses a DIV, but the old
447 * parameters remain. If possible, $align, $width and $color should not be defined at all.
448 * Even better, please use print_box_start() in weblib.php
450 * @param string $align alignment of the box, not the text (default center, left, right). DEPRECATED
451 * @param string $width width of the box, including % units, for example '100%'. DEPRECATED
452 * @param string $color background colour of the box, for example '#eee'. DEPRECATED
453 * @param int $padding padding in pixels, specified without units. OBSOLETE
454 * @param string $class space-separated class names.
455 * @param string $id space-separated id names.
456 * @param boolean $return return as string or just print it
457 * @return string|void Depending on $return
459 function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
460 debugging('print_simple_box(_start/_end) is deprecated. Please use $OUTPUT->box(_start/_end) instead', DEBUG_DEVELOPER);
462 $output = '';
464 $divclasses = 'box '.$class.' '.$class.'content';
465 $divstyles = '';
467 if ($align) {
468 $divclasses .= ' boxalign'.$align; // Implement alignment using a class
470 if ($width) { // Hopefully we can eliminate these in calls to this function (inline styles are bad)
471 if (substr($width, -1, 1) == '%') { // Width is a % value
472 $width = (int) substr($width, 0, -1); // Extract just the number
473 if ($width < 40) {
474 $divclasses .= ' boxwidthnarrow'; // Approx 30% depending on theme
475 } else if ($width > 60) {
476 $divclasses .= ' boxwidthwide'; // Approx 80% depending on theme
477 } else {
478 $divclasses .= ' boxwidthnormal'; // Approx 50% depending on theme
480 } else {
481 $divstyles .= ' width:'.$width.';'; // Last resort
484 if ($color) { // Hopefully we can eliminate these in calls to this function (inline styles are bad)
485 $divstyles .= ' background:'.$color.';';
487 if ($divstyles) {
488 $divstyles = ' style="'.$divstyles.'"';
491 if ($id) {
492 $id = ' id="'.$id.'"';
495 $output .= '<div'.$id.$divstyles.' class="'.$divclasses.'">';
497 if ($return) {
498 return $output;
499 } else {
500 echo $output;
506 * Print the end portion of a standard themed box.
507 * Preferably just use print_box_end() in weblib.php
509 * @param boolean $return return as string or just print it
510 * @return string|void Depending on $return
512 function print_simple_box_end($return=false) {
513 $output = '</div>';
514 if ($return) {
515 return $output;
516 } else {
517 echo $output;
522 * Given some text this function converted any URLs it found into HTML links
524 * This core function has been replaced with filter_urltolink since Moodle 2.0
526 * @param string $text Passed in by reference. The string to be searched for urls.
528 function convert_urls_into_links($text) {
529 debugging('convert_urls_into_links() has been deprecated and replaced by a new filter');
533 * Used to be called from help.php to inject a list of smilies into the
534 * emoticons help file.
536 * @return string HTML
538 function get_emoticons_list_for_help_file() {
539 debugging('get_emoticons_list_for_help_file() has been deprecated, see the new emoticon_manager API');
540 return '';
544 * Was used to replace all known smileys in the text with image equivalents
546 * This core function has been replaced with filter_emoticon since Moodle 2.0
548 function replace_smilies(&$text) {
549 debugging('replace_smilies() has been deprecated and replaced with the new filter_emoticon');
553 * deprecated - use clean_param($string, PARAM_FILE); instead
554 * Check for bad characters ?
556 * @todo Finish documenting this function - more detail needed in description as well as details on arguments
558 * @param string $string ?
559 * @param int $allowdots ?
560 * @return bool
562 function detect_munged_arguments($string, $allowdots=1) {
563 if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references
564 return true;
566 if (preg_match('/[\|\`]/', $string)) { // check for other bad characters
567 return true;
569 if (empty($string) or $string == '/') {
570 return true;
573 return false;
578 * Unzip one zip file to a destination dir
579 * Both parameters must be FULL paths
580 * If destination isn't specified, it will be the
581 * SAME directory where the zip file resides.
583 * @global object
584 * @param string $zipfile The zip file to unzip
585 * @param string $destination The location to unzip to
586 * @param bool $showstatus_ignored Unused
588 function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
589 global $CFG;
591 //Extract everything from zipfile
592 $path_parts = pathinfo(cleardoubleslashes($zipfile));
593 $zippath = $path_parts["dirname"]; //The path of the zip file
594 $zipfilename = $path_parts["basename"]; //The name of the zip file
595 $extension = $path_parts["extension"]; //The extension of the file
597 //If no file, error
598 if (empty($zipfilename)) {
599 return false;
602 //If no extension, error
603 if (empty($extension)) {
604 return false;
607 //Clear $zipfile
608 $zipfile = cleardoubleslashes($zipfile);
610 //Check zipfile exists
611 if (!file_exists($zipfile)) {
612 return false;
615 //If no destination, passed let's go with the same directory
616 if (empty($destination)) {
617 $destination = $zippath;
620 //Clear $destination
621 $destpath = rtrim(cleardoubleslashes($destination), "/");
623 //Check destination path exists
624 if (!is_dir($destpath)) {
625 return false;
628 $packer = get_file_packer('application/zip');
630 $result = $packer->extract_to_pathname($zipfile, $destpath);
632 if ($result === false) {
633 return false;
636 foreach ($result as $status) {
637 if ($status !== true) {
638 return false;
642 return true;
646 * Zip an array of files/dirs to a destination zip file
647 * Both parameters must be FULL paths to the files/dirs
649 * @global object
650 * @param array $originalfiles Files to zip
651 * @param string $destination The destination path
652 * @return bool Outcome
654 function zip_files ($originalfiles, $destination) {
655 global $CFG;
657 //Extract everything from destination
658 $path_parts = pathinfo(cleardoubleslashes($destination));
659 $destpath = $path_parts["dirname"]; //The path of the zip file
660 $destfilename = $path_parts["basename"]; //The name of the zip file
661 $extension = $path_parts["extension"]; //The extension of the file
663 //If no file, error
664 if (empty($destfilename)) {
665 return false;
668 //If no extension, add it
669 if (empty($extension)) {
670 $extension = 'zip';
671 $destfilename = $destfilename.'.'.$extension;
674 //Check destination path exists
675 if (!is_dir($destpath)) {
676 return false;
679 //Check destination path is writable. TODO!!
681 //Clean destination filename
682 $destfilename = clean_filename($destfilename);
684 //Now check and prepare every file
685 $files = array();
686 $origpath = NULL;
688 foreach ($originalfiles as $file) { //Iterate over each file
689 //Check for every file
690 $tempfile = cleardoubleslashes($file); // no doubleslashes!
691 //Calculate the base path for all files if it isn't set
692 if ($origpath === NULL) {
693 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
695 //See if the file is readable
696 if (!is_readable($tempfile)) { //Is readable
697 continue;
699 //See if the file/dir is in the same directory than the rest
700 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
701 continue;
703 //Add the file to the array
704 $files[] = $tempfile;
707 $zipfiles = array();
708 $start = strlen($origpath)+1;
709 foreach($files as $file) {
710 $zipfiles[substr($file, $start)] = $file;
713 $packer = get_file_packer('application/zip');
715 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
718 /////////////////////////////////////////////////////////////
719 /// Old functions not used anymore - candidates for removal
720 /////////////////////////////////////////////////////////////
723 /** various deprecated groups function **/
727 * Get the IDs for the user's groups in the given course.
729 * @global object
730 * @param int $courseid The course being examined - the 'course' table id field.
731 * @return array|bool An _array_ of groupids, or false
732 * (Was return $groupids[0] - consequences!)
734 function mygroupid($courseid) {
735 global $USER;
736 if ($groups = groups_get_all_groups($courseid, $USER->id)) {
737 return array_keys($groups);
738 } else {
739 return false;
745 * Returns the current group mode for a given course or activity module
747 * Could be false, SEPARATEGROUPS or VISIBLEGROUPS (<-- Martin)
749 * @param object $course Course Object
750 * @param object $cm Course Manager Object
751 * @return mixed $course->groupmode
753 function groupmode($course, $cm=null) {
755 if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
756 return $cm->groupmode;
758 return $course->groupmode;
762 * Sets the current group in the session variable
763 * When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups.
764 * Sets currentgroup[$courseid] in the session variable appropriately.
765 * Does not do any permission checking.
767 * @global object
768 * @param int $courseid The course being examined - relates to id field in
769 * 'course' table.
770 * @param int $groupid The group being examined.
771 * @return int Current group id which was set by this function
773 function set_current_group($courseid, $groupid) {
774 global $SESSION;
775 return $SESSION->currentgroup[$courseid] = $groupid;
780 * Gets the current group - either from the session variable or from the database.
782 * @global object
783 * @param int $courseid The course being examined - relates to id field in
784 * 'course' table.
785 * @param bool $full If true, the return value is a full record object.
786 * If false, just the id of the record.
787 * @return int|bool
789 function get_current_group($courseid, $full = false) {
790 global $SESSION;
792 if (isset($SESSION->currentgroup[$courseid])) {
793 if ($full) {
794 return groups_get_group($SESSION->currentgroup[$courseid]);
795 } else {
796 return $SESSION->currentgroup[$courseid];
800 $mygroupid = mygroupid($courseid);
801 if (is_array($mygroupid)) {
802 $mygroupid = array_shift($mygroupid);
803 set_current_group($courseid, $mygroupid);
804 if ($full) {
805 return groups_get_group($mygroupid);
806 } else {
807 return $mygroupid;
811 if ($full) {
812 return false;
813 } else {
814 return 0;
820 * Inndicates fatal error. This function was originally printing the
821 * error message directly, since 2.0 it is throwing exception instead.
822 * The error printing is handled in default exception handler.
824 * Old method, don't call directly in new code - use print_error instead.
826 * @param string $message The message to display to the user about the error.
827 * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
828 * @return void, always throws moodle_exception
830 function error($message, $link='') {
831 throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a deprecated function, please call print_error() instead of error()');
835 /// Deprecated DDL functions, to be removed soon ///
837 * @deprecated
838 * @global object
839 * @param string $table
840 * @return bool
842 function table_exists($table) {
843 global $DB;
844 debugging('Deprecated ddllib function used!');
845 return $DB->get_manager()->table_exists($table);
849 * @deprecated
850 * @global object
851 * @param string $table
852 * @param string $field
853 * @return bool
855 function field_exists($table, $field) {
856 global $DB;
857 debugging('Deprecated ddllib function used!');
858 return $DB->get_manager()->field_exists($table, $field);
862 * @deprecated
863 * @global object
864 * @param string $table
865 * @param string $index
866 * @return bool
868 function find_index_name($table, $index) {
869 global $DB;
870 debugging('Deprecated ddllib function used!');
871 return $DB->get_manager()->find_index_name($table, $index);
875 * @deprecated
876 * @global object
877 * @param string $table
878 * @param string $index
879 * @return bool
881 function index_exists($table, $index) {
882 global $DB;
883 debugging('Deprecated ddllib function used!');
884 return $DB->get_manager()->index_exists($table, $index);
888 * @deprecated
889 * @global object
890 * @param string $table
891 * @param string $field
892 * @return bool
894 function find_check_constraint_name($table, $field) {
895 global $DB;
896 debugging('Deprecated ddllib function used!');
897 return $DB->get_manager()->find_check_constraint_name($table, $field);
901 * @deprecated
902 * @global object
904 function check_constraint_exists($table, $field) {
905 global $DB;
906 debugging('Deprecated ddllib function used!');
907 return $DB->get_manager()->check_constraint_exists($table, $field);
911 * @deprecated
912 * @global object
913 * @param string $table
914 * @param string $xmldb_key
915 * @return bool
917 function find_key_name($table, $xmldb_key) {
918 global $DB;
919 debugging('Deprecated ddllib function used!');
920 return $DB->get_manager()->find_key_name($table, $xmldb_key);
924 * @deprecated
925 * @global object
926 * @param string $table
927 * @return bool
929 function drop_table($table) {
930 global $DB;
931 debugging('Deprecated ddllib function used!');
932 $DB->get_manager()->drop_table($table);
933 return true;
937 * @deprecated
938 * @global object
939 * @param string $file
940 * @return bool
942 function install_from_xmldb_file($file) {
943 global $DB;
944 debugging('Deprecated ddllib function used!');
945 $DB->get_manager()->install_from_xmldb_file($file);
946 return true;
950 * @deprecated
951 * @global object
952 * @param string $table
953 * @return bool
955 function create_table($table) {
956 global $DB;
957 debugging('Deprecated ddllib function used!');
958 $DB->get_manager()->create_table($table);
959 return true;
963 * @deprecated
964 * @global object
965 * @param string $table
966 * @return bool
968 function create_temp_table($table) {
969 global $DB;
970 debugging('Deprecated ddllib function used!');
971 $DB->get_manager()->create_temp_table($table);
972 return true;
976 * @deprecated
977 * @global object
978 * @param string $table
979 * @param string $newname
980 * @return bool
982 function rename_table($table, $newname) {
983 global $DB;
984 debugging('Deprecated ddllib function used!');
985 $DB->get_manager()->rename_table($table, $newname);
986 return true;
990 * @deprecated
991 * @global object
992 * @param string $table
993 * @param string $field
994 * @return bool
996 function add_field($table, $field) {
997 global $DB;
998 debugging('Deprecated ddllib function used!');
999 $DB->get_manager()->add_field($table, $field);
1000 return true;
1004 * @deprecated
1005 * @global object
1006 * @param string $table
1007 * @param string $field
1008 * @return bool
1010 function drop_field($table, $field) {
1011 global $DB;
1012 debugging('Deprecated ddllib function used!');
1013 $DB->get_manager()->drop_field($table, $field);
1014 return true;
1018 * @deprecated
1019 * @global object
1020 * @param string $table
1021 * @param string $field
1022 * @return bool
1024 function change_field_type($table, $field) {
1025 global $DB;
1026 debugging('Deprecated ddllib function used!');
1027 $DB->get_manager()->change_field_type($table, $field);
1028 return true;
1032 * @deprecated
1033 * @global object
1034 * @param string $table
1035 * @param string $field
1036 * @return bool
1038 function change_field_precision($table, $field) {
1039 global $DB;
1040 debugging('Deprecated ddllib function used!');
1041 $DB->get_manager()->change_field_precision($table, $field);
1042 return true;
1046 * @deprecated
1047 * @global object
1048 * @param string $table
1049 * @param string $field
1050 * @return bool
1052 function change_field_unsigned($table, $field) {
1053 global $DB;
1054 debugging('Deprecated ddllib function used!');
1055 $DB->get_manager()->change_field_unsigned($table, $field);
1056 return true;
1060 * @deprecated
1061 * @global object
1062 * @param string $table
1063 * @param string $field
1064 * @return bool
1066 function change_field_notnull($table, $field) {
1067 global $DB;
1068 debugging('Deprecated ddllib function used!');
1069 $DB->get_manager()->change_field_notnull($table, $field);
1070 return true;
1074 * @deprecated
1075 * @global object
1076 * @param string $table
1077 * @param string $field
1078 * @return bool
1080 function change_field_enum($table, $field) {
1081 global $DB;
1082 debugging('Deprecated ddllib function used! Only dropping of enums is allowed.');
1083 $DB->get_manager()->drop_enum_from_field($table, $field);
1084 return true;
1088 * @deprecated
1089 * @global object
1090 * @param string $table
1091 * @param string $field
1092 * @return bool
1094 function change_field_default($table, $field) {
1095 global $DB;
1096 debugging('Deprecated ddllib function used!');
1097 $DB->get_manager()->change_field_default($table, $field);
1098 return true;
1102 * @deprecated
1103 * @global object
1104 * @param string $table
1105 * @param string $field
1106 * @param string $newname
1107 * @return bool
1109 function rename_field($table, $field, $newname) {
1110 global $DB;
1111 debugging('Deprecated ddllib function used!');
1112 $DB->get_manager()->rename_field($table, $field, $newname);
1113 return true;
1117 * @deprecated
1118 * @global object
1119 * @param string $table
1120 * @param string $key
1121 * @return bool
1123 function add_key($table, $key) {
1124 global $DB;
1125 debugging('Deprecated ddllib function used!');
1126 $DB->get_manager()->add_key($table, $key);
1127 return true;
1131 * @deprecated
1132 * @global object
1133 * @param string $table
1134 * @param string $key
1135 * @return bool
1137 function drop_key($table, $key) {
1138 global $DB;
1139 debugging('Deprecated ddllib function used!');
1140 $DB->get_manager()->drop_key($table, $key);
1141 return true;
1145 * @deprecated
1146 * @global object
1147 * @param string $table
1148 * @param string $key
1149 * @param string $newname
1150 * @return bool
1152 function rename_key($table, $key, $newname) {
1153 global $DB;
1154 debugging('Deprecated ddllib function used!');
1155 $DB->get_manager()->rename_key($table, $key, $newname);
1156 return true;
1160 * @deprecated
1161 * @global object
1162 * @param string $table
1163 * @param string $index
1164 * @return bool
1166 function add_index($table, $index) {
1167 global $DB;
1168 debugging('Deprecated ddllib function used!');
1169 $DB->get_manager()->add_index($table, $index);
1170 return true;
1174 * @deprecated
1175 * @global object
1176 * @param string $table
1177 * @param string $index
1178 * @return bool
1180 function drop_index($table, $index) {
1181 global $DB;
1182 debugging('Deprecated ddllib function used!');
1183 $DB->get_manager()->drop_index($table, $index);
1184 return true;
1188 * @deprecated
1189 * @global object
1190 * @param string $table
1191 * @param string $index
1192 * @param string $newname
1193 * @return bool
1195 function rename_index($table, $index, $newname) {
1196 global $DB;
1197 debugging('Deprecated ddllib function used!');
1198 $DB->get_manager()->rename_index($table, $index, $newname);
1199 return true;
1203 //////////////////////////
1204 /// removed functions ////
1205 //////////////////////////
1208 * @deprecated
1209 * @param mixed $mixed
1210 * @return void Throws an error and does nothing
1212 function stripslashes_safe($mixed) {
1213 error('stripslashes_safe() not available anymore');
1216 * @deprecated
1217 * @param mixed $var
1218 * @return void Throws an error and does nothing
1220 function stripslashes_recursive($var) {
1221 error('stripslashes_recursive() not available anymore');
1224 * @deprecated
1225 * @param mixed $dataobject
1226 * @return void Throws an error and does nothing
1228 function addslashes_object($dataobject) {
1229 error('addslashes_object() not available anymore');
1232 * @deprecated
1233 * @param mixed $var
1234 * @return void Throws an error and does nothing
1236 function addslashes_recursive($var) {
1237 error('addslashes_recursive() not available anymore');
1240 * @deprecated
1241 * @param mixed $command
1242 * @param bool $feedback
1243 * @return void Throws an error and does nothing
1245 function execute_sql($command, $feedback=true) {
1246 error('execute_sql() not available anymore');
1249 * @deprecated use $DB->record_exists_select() instead
1250 * @see moodle_database::record_exists_select()
1251 * @param mixed $table
1252 * @param mixed $select
1253 * @return void Throws an error and does nothing
1255 function record_exists_select($table, $select='') {
1256 error('record_exists_select() not available anymore');
1259 * @deprecated use $DB->record_exists_sql() instead
1260 * @see moodle_database::record_exists_sql()
1261 * @param mixed $sql
1262 * @return void Throws an error and does nothing
1264 function record_exists_sql($sql) {
1265 error('record_exists_sql() not available anymore');
1268 * @deprecated use $DB->count_records_select() instead
1269 * @see moodle_database::count_records_select()
1270 * @param mixed $table
1271 * @param mixed $select
1272 * @param mixed $countitem
1273 * @return void Throws an error and does nothing
1275 function count_records_select($table, $select='', $countitem='COUNT(*)') {
1276 error('count_records_select() not available anymore');
1279 * @deprecated use $DB->count_records_sql() instead
1280 * @see moodle_database::count_records_sql()
1281 * @param mixed $sql
1282 * @return void Throws an error and does nothing
1284 function count_records_sql($sql) {
1285 error('count_records_sql() not available anymore');
1288 * @deprecated use $DB->get_record_sql() instead
1289 * @see moodle_database::get_record_sql()
1290 * @param mixed $sql
1291 * @param bool $expectmultiple
1292 * @param bool $nolimit
1293 * @return void Throws an error and does nothing
1295 function get_record_sql($sql, $expectmultiple=false, $nolimit=false) {
1296 error('get_record_sql() not available anymore');
1299 * @deprecated use $DB->get_record_select() instead
1300 * @see moodle_database::get_record_select()
1301 * @param mixed $table
1302 * @param mixed $select
1303 * @param mixed $fields
1304 * @return void Throws an error and does nothing
1306 function get_record_select($table, $select='', $fields='*') {
1307 error('get_record_select() not available anymore');
1310 * @deprecated use $DB->get_recordset() instead
1311 * @see moodle_database::get_recordset()
1312 * @param mixed $table
1313 * @param mixed $field
1314 * @param mixed $value
1315 * @param mixed $sort
1316 * @param mixed $fields
1317 * @param mixed $limitfrom
1318 * @param mixed $limitnum
1319 * @return void Throws an error and does nothing
1321 function get_recordset($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1322 error('get_recordset() not available anymore');
1325 * @deprecated use $DB->get_recordset_sql() instead
1326 * @see moodle_database::get_recordset_sql()
1327 * @param mixed $sql
1328 * @param mixed $limitfrom
1329 * @param mixed $limitnum
1330 * @return void Throws an error and does nothing
1332 function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
1333 error('get_recordset_sql() not available anymore');
1336 * @deprecated
1337 * @param mixed $rs
1338 * @return void Throws an error and does nothing
1340 function rs_fetch_record(&$rs) {
1341 error('rs_fetch_record() not available anymore');
1344 * @deprecated
1345 * @param mixed $rs
1346 * @return void Throws an error and does nothing
1348 function rs_next_record(&$rs) {
1349 error('rs_next_record() not available anymore');
1352 * @deprecated
1353 * @param mixed $rs
1354 * @return void Throws an error and does nothing
1356 function rs_fetch_next_record(&$rs) {
1357 error('rs_fetch_next_record() not available anymore');
1360 * @deprecated
1361 * @param mixed $rs
1362 * @return void Throws an error and does nothing
1364 function rs_EOF($rs) {
1365 error('rs_EOF() not available anymore');
1368 * @deprecated
1369 * @param mixed $rs
1370 * @return void Throws an error and does nothing
1372 function rs_close(&$rs) {
1373 error('rs_close() not available anymore');
1376 * @deprecated use $DB->get_records_select() instead
1377 * @see moodle_database::get_records_select()
1378 * @param mixed $table
1379 * @param mixed $select
1380 * @param mixed $sort
1381 * @param mixed $fields
1382 * @param mixed $limitfrom
1383 * @param mixed $limitnum
1384 * @return void Throws an error and does nothing
1386 function get_records_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1387 error('get_records_select() not available anymore');
1390 * @deprecated use $DB->get_field_select() instead
1391 * @see moodle_database::get_field_select()
1392 * @param mixed $table
1393 * @param mixed $return
1394 * @param mixed $select
1395 * @return void Throws an error and does nothing
1397 function get_field_select($table, $return, $select) {
1398 error('get_field_select() not available anymore');
1401 * @deprecated use $DB->get_field_sql() instead
1402 * @see moodle_database::get_field_sql()
1403 * @param mixed $sql
1404 * @return void Throws an error and does nothing
1406 function get_field_sql($sql) {
1407 error('get_field_sql() not available anymore');
1410 * @deprecated use $DB->delete_records_select() instead
1411 * @see moodle_database::delete_records_select()
1412 * @param mixed $sql
1413 * @param mixed $select
1414 * @return void Throws an error and does nothing
1416 function delete_records_select($table, $select='') {
1417 error('get_field_sql() not available anymore');
1420 * @deprecated
1421 * @return void Throws an error and does nothing
1423 function configure_dbconnection() {
1424 error('configure_dbconnection() removed');
1427 * @deprecated
1428 * @param mixed $field
1429 * @return void Throws an error and does nothing
1431 function sql_max($field) {
1432 error('sql_max() removed - use normal sql MAX() instead');
1435 * @deprecated
1436 * @return void Throws an error and does nothing
1438 function sql_as() {
1439 error('sql_as() removed - do not use AS for tables at all');
1442 * @deprecated
1443 * @param mixed $page
1444 * @param mixed $recordsperpage
1445 * @return void Throws an error and does nothing
1447 function sql_paging_limit($page, $recordsperpage) {
1448 error('Function sql_paging_limit() is deprecated. Replace it with the correct use of limitfrom, limitnum parameters');
1451 * @deprecated
1452 * @return void Throws an error and does nothing
1454 function db_uppercase() {
1455 error('upper() removed - use normal sql UPPER()');
1458 * @deprecated
1459 * @return void Throws an error and does nothing
1461 function db_lowercase() {
1462 error('upper() removed - use normal sql LOWER()');
1465 * @deprecated
1466 * @param mixed $sqlfile
1467 * @param mixed $sqlstring
1468 * @return void Throws an error and does nothing
1470 function modify_database($sqlfile='', $sqlstring='') {
1471 error('modify_database() removed - use new XMLDB functions');
1474 * @deprecated
1475 * @param mixed $field1
1476 * @param mixed $value1
1477 * @param mixed $field2
1478 * @param mixed $value2
1479 * @param mixed $field3
1480 * @param mixed $value3
1481 * @return void Throws an error and does nothing
1483 function where_clause($field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
1484 error('where_clause() removed - use new functions with $conditions parameter');
1487 * @deprecated
1488 * @param mixed $sqlarr
1489 * @param mixed $continue
1490 * @param mixed $feedback
1491 * @return void Throws an error and does nothing
1493 function execute_sql_arr($sqlarr, $continue=true, $feedback=true) {
1494 error('execute_sql_arr() removed');
1497 * @deprecated use $DB->get_records_list() instead
1498 * @see moodle_database::get_records_list()
1499 * @param mixed $table
1500 * @param mixed $field
1501 * @param mixed $values
1502 * @param mixed $sort
1503 * @param mixed $fields
1504 * @param mixed $limitfrom
1505 * @param mixed $limitnum
1506 * @return void Throws an error and does nothing
1508 function get_records_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1509 error('get_records_list() removed');
1512 * @deprecated use $DB->get_recordset_list() instead
1513 * @see moodle_database::get_recordset_list()
1514 * @param mixed $table
1515 * @param mixed $field
1516 * @param mixed $values
1517 * @param mixed $sort
1518 * @param mixed $fields
1519 * @param mixed $limitfrom
1520 * @param mixed $limitnum
1521 * @return void Throws an error and does nothing
1523 function get_recordset_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1524 error('get_recordset_list() removed');
1527 * @deprecated use $DB->get_records_menu() instead
1528 * @see moodle_database::get_records_menu()
1529 * @param mixed $table
1530 * @param mixed $field
1531 * @param mixed $value
1532 * @param mixed $sort
1533 * @param mixed $fields
1534 * @param mixed $limitfrom
1535 * @param mixed $limitnum
1536 * @return void Throws an error and does nothing
1538 function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1539 error('get_records_menu() removed');
1542 * @deprecated use $DB->get_records_select_menu() instead
1543 * @see moodle_database::get_records_select_menu()
1544 * @param mixed $table
1545 * @param mixed $select
1546 * @param mixed $sort
1547 * @param mixed $fields
1548 * @param mixed $limitfrom
1549 * @param mixed $limitnum
1550 * @return void Throws an error and does nothing
1552 function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1553 error('get_records_select_menu() removed');
1556 * @deprecated use $DB->get_records_sql_menu() instead
1557 * @see moodle_database::get_records_sql_menu()
1558 * @param mixed $sql
1559 * @param mixed $limitfrom
1560 * @param mixed $limitnum
1561 * @return void Throws an error and does nothing
1563 function get_records_sql_menu($sql, $limitfrom='', $limitnum='') {
1564 error('get_records_sql_menu() removed');
1567 * @deprecated
1568 * @param mixed $table
1569 * @param mixed $column
1570 * @return void Throws an error and does nothing
1572 function column_type($table, $column) {
1573 error('column_type() removed');
1576 * @deprecated
1577 * @param mixed $rs
1578 * @return void Throws an error and does nothing
1580 function recordset_to_menu($rs) {
1581 error('recordset_to_menu() removed');
1584 * @deprecated
1585 * @param mixed $records
1586 * @param mixed $field1
1587 * @param mixed $field2
1588 * @return void Throws an error and does nothing
1590 function records_to_menu($records, $field1, $field2) {
1591 error('records_to_menu() removed');
1594 * @deprecated use $DB->set_field_select() instead
1595 * @see moodle_database::set_field_select()
1596 * @param mixed $table
1597 * @param mixed $newfield
1598 * @param mixed $newvalue
1599 * @param mixed $select
1600 * @param mixed $localcall
1601 * @return void Throws an error and does nothing
1603 function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) {
1604 error('set_field_select() removed');
1607 * @deprecated use $DB->get_fieldset_select() instead
1608 * @see moodle_database::get_fieldset_select()
1609 * @param mixed $table
1610 * @param mixed $return
1611 * @param mixed $select
1612 * @return void Throws an error and does nothing
1614 function get_fieldset_select($table, $return, $select) {
1615 error('get_fieldset_select() removed');
1618 * @deprecated use $DB->get_fieldset_sql() instead
1619 * @see moodle_database::get_fieldset_sql()
1620 * @param mixed $sql
1621 * @return void Throws an error and does nothing
1623 function get_fieldset_sql($sql) {
1624 error('get_fieldset_sql() removed');
1627 * @deprecated use $DB->sql_like() instead
1628 * @see moodle_database::sql_like()
1629 * @return void Throws an error and does nothing
1631 function sql_ilike() {
1632 error('sql_ilike() not available anymore');
1635 * @deprecated
1636 * @param mixed $first
1637 * @param mixed $last
1638 * @return void Throws an error and does nothing
1640 function sql_fullname($first='firstname', $last='lastname') {
1641 error('sql_fullname() not available anymore');
1644 * @deprecated
1645 * @return void Throws an error and does nothing
1647 function sql_concat() {
1648 error('sql_concat() not available anymore');
1651 * @deprecated
1652 * @return void Throws an error and does nothing
1654 function sql_empty() {
1655 error('sql_empty() not available anymore');
1658 * @deprecated
1659 * @return void Throws an error and does nothing
1661 function sql_substr() {
1662 error('sql_substr() not available anymore');
1665 * @deprecated
1666 * @param mixed $int1
1667 * @param mixed $int2
1668 * @return void Throws an error and does nothing
1670 function sql_bitand($int1, $int2) {
1671 error('sql_bitand() not available anymore');
1674 * @deprecated
1675 * @param mixed $int1
1676 * @return void Throws an error and does nothing
1678 function sql_bitnot($int1) {
1679 error('sql_bitnot() not available anymore');
1682 * @deprecated
1683 * @param mixed $int1
1684 * @param mixed $int2
1685 * @return void Throws an error and does nothing
1687 function sql_bitor($int1, $int2) {
1688 error('sql_bitor() not available anymore');
1691 * @deprecated
1692 * @param mixed $int1
1693 * @param mixed $int2
1694 * @return void Throws an error and does nothing
1696 function sql_bitxor($int1, $int2) {
1697 error('sql_bitxor() not available anymore');
1700 * @deprecated
1701 * @param mixed $fieldname
1702 * @param mixed $text
1703 * @return void Throws an error and does nothing
1705 function sql_cast_char2int($fieldname, $text=false) {
1706 error('sql_cast_char2int() not available anymore');
1709 * @deprecated
1710 * @param mixed $fieldname
1711 * @param mixed $numchars
1712 * @return void Throws an error and does nothing
1714 function sql_compare_text($fieldname, $numchars=32) {
1715 error('sql_compare_text() not available anymore');
1718 * @deprecated
1719 * @param mixed $fieldname
1720 * @param mixed $numchars
1721 * @return void Throws an error and does nothing
1723 function sql_order_by_text($fieldname, $numchars=32) {
1724 error('sql_order_by_text() not available anymore');
1727 * @deprecated
1728 * @param mixed $fieldname
1729 * @return void Throws an error and does nothing
1731 function sql_length($fieldname) {
1732 error('sql_length() not available anymore');
1735 * @deprecated
1736 * @param mixed $separator
1737 * @param mixed $elements
1738 * @return void Throws an error and does nothing
1740 function sql_concat_join($separator="' '", $elements=array()) {
1741 error('sql_concat_join() not available anymore');
1744 * @deprecated
1745 * @param mixed $tablename
1746 * @param mixed $fieldname
1747 * @param mixed $nullablefield
1748 * @param mixed $textfield
1749 * @return void Throws an error and does nothing
1751 function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) {
1752 error('sql_isempty() not available anymore');
1755 * @deprecated
1756 * @param mixed $tablename
1757 * @param mixed $fieldname
1758 * @param mixed $nullablefield
1759 * @param mixed $textfield
1760 * @return void Throws an error and does nothing
1762 function sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield) {
1763 error('sql_isnotempty() not available anymore');
1766 * @deprecated
1767 * @return void Throws an error and does nothing
1769 function begin_sql() {
1770 error('begin_sql() not available anymore');
1773 * @deprecated
1774 * @return void Throws an error and does nothing
1776 function commit_sql() {
1777 error('commit_sql() not available anymore');
1780 * @deprecated
1781 * @return void Throws an error and does nothing
1783 function rollback_sql() {
1784 error('rollback_sql() not available anymore');
1787 * @deprecated use $DB->insert_record() instead
1788 * @see moodle_database::insert_record()
1789 * @param mixed $table
1790 * @param mixed $dataobject
1791 * @param mixed $returnid
1792 * @param mixed $primarykey
1793 * @return void Throws an error and does nothing
1795 function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
1796 error('insert_record() not available anymore');
1799 * @deprecated use $DB->update_record() instead
1800 * @see moodle_database::update_record()
1801 * @param mixed $table
1802 * @param mixed $dataobject
1803 * @return void Throws an error and does nothing
1805 function update_record($table, $dataobject) {
1806 error('update_record() not available anymore');
1809 * @deprecated use $DB->get_records() instead
1810 * @see moodle_database::get_records()
1811 * @param mixed $table
1812 * @param mixed $field
1813 * @param mixed $value
1814 * @param mixed $sort
1815 * @param mixed $fields
1816 * @param mixed $limitfrom
1817 * @param mixed $limitnum
1819 * @return void Throws an error and does nothing
1821 function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
1822 error('get_records() not available anymore');
1825 * @deprecated use $DB->get_record() instead
1826 * @see moodle_database::get_record()
1827 * @param mixed $table
1828 * @param mixed $field1
1829 * @param mixed $value1
1830 * @param mixed $field2
1831 * @param mixed $value2
1832 * @param mixed $field3
1833 * @param mixed $value3
1834 * @param mixed $fields
1835 * @return void Throws an error and does nothing
1837 function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') {
1838 error('get_record() not available anymore');
1841 * @deprecated use $DB->set_field() instead
1842 * @see moodle_database::set_field()
1843 * @param mixed $table
1844 * @param mixed $newfield
1845 * @param mixed $newvalue
1846 * @param mixed $field1
1847 * @param mixed $value1
1848 * @param mixed $field2
1849 * @param mixed $value2
1850 * @param mixed $field3
1851 * @param mixed $value3
1852 * @return void Throws an error and does nothing
1854 function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
1855 error('set_field() not available anymore');
1858 * @deprecated use $DB->count_records() instead
1859 * @see moodle_database::count_records()
1860 * @param mixed $table
1861 * @param mixed $field1
1862 * @param mixed $value1
1863 * @param mixed $field2
1864 * @param mixed $value2
1865 * @param mixed $field3
1866 * @param mixed $value3
1867 * @return void Throws an error and does nothing
1869 function count_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
1870 error('count_records() not available anymore');
1873 * @deprecated use $DB->record_exists() instead
1874 * @see moodle_database::record_exists()
1875 * @param mixed $table
1876 * @param mixed $field1
1877 * @param mixed $value1
1878 * @param mixed $field2
1879 * @param mixed $value2
1880 * @param mixed $field3
1881 * @param mixed $value3
1882 * @return void Throws an error and does nothing
1884 function record_exists($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
1885 error('record_exists() not available anymore');
1888 * @deprecated use $DB->delete_records() instead
1889 * @see moodle_database::delete_records()
1890 * @param mixed $table
1891 * @param mixed $field1
1892 * @param mixed $value1
1893 * @param mixed $field2
1894 * @param mixed $value2
1895 * @param mixed $field3
1896 * @param mixed $value3
1897 * @return void Throws an error and does nothing
1899 function delete_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
1900 error('delete_records() not available anymore');
1903 * @deprecated use $DB->get_field() instead
1904 * @see moodle_database::get_field()
1905 * @param mixed $table
1906 * @param mixed $return
1907 * @param mixed $field1
1908 * @param mixed $value1
1909 * @param mixed $field2
1910 * @param mixed $value2
1911 * @param mixed $field3
1912 * @param mixed $value3
1913 * @return void Throws an error and does nothing
1915 function get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
1916 error('get_field() not available anymore');
1919 * @deprecated
1920 * @param mixed $table
1921 * @param mixed $oldfield
1922 * @param mixed $field
1923 * @param mixed $type
1924 * @param mixed $size
1925 * @param mixed $signed
1926 * @param mixed $default
1927 * @param mixed $null
1928 * @param mixed $after
1929 * @return void Throws an error and does nothing
1931 function table_column($table, $oldfield, $field, $type='integer', $size='10',
1932 $signed='unsigned', $default='0', $null='not null', $after='') {
1933 error('table_column() was removed, please use new ddl functions');
1936 * @deprecated
1937 * @param mixed $name
1938 * @param mixed $editorhidebuttons
1939 * @param mixed $id
1940 * @return void Throws an error and does nothing
1942 function use_html_editor($name='', $editorhidebuttons='', $id='') {
1943 error('use_html_editor() not available anymore');
1947 * The old method that was used to include JavaScript libraries.
1948 * Please use $PAGE->requires->js_module() instead.
1950 * @param mixed $lib The library or libraries to load (a string or array of strings)
1951 * There are three way to specify the library:
1952 * 1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui2_lib('yahoo');
1953 * 2. the path to the library relative to wwwroot, for example 'lib/javascript-static.js'
1954 * 3. (legacy) a full URL like $CFG->wwwroot . '/lib/javascript-static.js'.
1955 * 2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js').
1957 function require_js($lib) {
1958 global $CFG, $PAGE;
1959 // Add the lib to the list of libs to be loaded, if it isn't already
1960 // in the list.
1961 if (is_array($lib)) {
1962 foreach($lib as $singlelib) {
1963 require_js($singlelib);
1965 return;
1968 debugging('Call to deprecated function require_js. Please use $PAGE->requires->js_module() instead.', DEBUG_DEVELOPER);
1970 if (strpos($lib, 'yui_') === 0) {
1971 $PAGE->requires->yui2_lib(substr($lib, 4));
1972 } else {
1973 if ($PAGE->requires->is_head_done()) {
1974 echo html_writer::script('', $lib);
1975 } else {
1976 $PAGE->requires->js(new moodle_url($lib));
1982 * Makes an upload directory for a particular module.
1984 * This function has been deprecated by the file API changes in Moodle 2.0.
1986 * @deprecated
1987 * @param int $courseid The id of the course in question - maps to id field of 'course' table.
1988 * @return string|false Returns full path to directory if successful, false if not
1990 function make_mod_upload_directory($courseid) {
1991 throw new coding_exception('make_mod_upload_directory has been deprecated by the file API changes in Moodle 2.0.');
1995 * Used to be used for setting up the theme. No longer used by core code, and
1996 * should not have been used elsewhere.
1998 * The theme is now automatically initialised before it is first used. If you really need
1999 * to force this to happen, just reference $PAGE->theme.
2001 * To force a particular theme on a particular page, you can use $PAGE->force_theme(...).
2002 * However, I can't think of any valid reason to do that outside the theme selector UI.
2004 * @deprecated
2005 * @param string $theme The theme to use defaults to current theme
2006 * @param array $params An array of parameters to use
2008 function theme_setup($theme = '', $params=NULL) {
2009 throw new coding_exception('The function theme_setup is no longer required, and should no longer be used. ' .
2010 'The current theme gets initialised automatically before it is first used.');
2014 * @deprecated use $PAGE->theme->name instead.
2015 * @return string the name of the current theme.
2017 function current_theme() {
2018 global $PAGE;
2019 // TODO, uncomment this once we have eliminated all references to current_theme in core code.
2020 // debugging('current_theme is deprecated, use $PAGE->theme->name instead', DEBUG_DEVELOPER);
2021 return $PAGE->theme->name;
2025 * @todo Remove this deprecated function when no longer used
2026 * @deprecated since Moodle 2.0 - use $PAGE->pagetype instead of the .
2028 * @param string $getid used to return $PAGE->pagetype.
2029 * @param string $getclass used to return $PAGE->legacyclass.
2031 function page_id_and_class(&$getid, &$getclass) {
2032 global $PAGE;
2033 debugging('Call to deprecated function page_id_and_class. Please use $PAGE->pagetype instead.', DEBUG_DEVELOPER);
2034 $getid = $PAGE->pagetype;
2035 $getclass = $PAGE->legacyclass;
2039 * Prints some red text using echo
2041 * @deprecated
2042 * @param string $error The text to be displayed in red
2044 function formerr($error) {
2045 debugging('formerr() has been deprecated. Please change your code to use $OUTPUT->error_text($string).');
2046 global $OUTPUT;
2047 echo $OUTPUT->error_text($error);
2051 * Return the markup for the destination of the 'Skip to main content' links.
2052 * Accessibility improvement for keyboard-only users.
2054 * Used in course formats, /index.php and /course/index.php
2056 * @deprecated use $OUTPUT->skip_link_target() in instead.
2057 * @return string HTML element.
2059 function skip_main_destination() {
2060 global $OUTPUT;
2061 return $OUTPUT->skip_link_target();
2065 * Prints a string in a specified size (retained for backward compatibility)
2067 * @deprecated
2068 * @param string $text The text to be displayed
2069 * @param int $size The size to set the font for text display.
2070 * @param bool $return If set to true output is returned rather than echoed Default false
2071 * @return string|void String if return is true
2073 function print_headline($text, $size=2, $return=false) {
2074 global $OUTPUT;
2075 debugging('print_headline() has been deprecated. Please change your code to use $OUTPUT->heading().');
2076 $output = $OUTPUT->heading($text, $size);
2077 if ($return) {
2078 return $output;
2079 } else {
2080 echo $output;
2085 * Prints text in a format for use in headings.
2087 * @deprecated
2088 * @param string $text The text to be displayed
2089 * @param string $deprecated No longer used. (Use to do alignment.)
2090 * @param int $size The size to set the font for text display.
2091 * @param string $class
2092 * @param bool $return If set to true output is returned rather than echoed, default false
2093 * @param string $id The id to use in the element
2094 * @return string|void String if return=true nothing otherwise
2096 function print_heading($text, $deprecated = '', $size = 2, $class = 'main', $return = false, $id = '') {
2097 global $OUTPUT;
2098 debugging('print_heading() has been deprecated. Please change your code to use $OUTPUT->heading().');
2099 if (!empty($deprecated)) {
2100 debugging('Use of deprecated align attribute of print_heading. ' .
2101 'Please do not specify styling in PHP code like that.', DEBUG_DEVELOPER);
2103 $output = $OUTPUT->heading($text, $size, $class, $id);
2104 if ($return) {
2105 return $output;
2106 } else {
2107 echo $output;
2112 * Output a standard heading block
2114 * @deprecated
2115 * @param string $heading The text to write into the heading
2116 * @param string $class An additional Class Attr to use for the heading
2117 * @param bool $return If set to true output is returned rather than echoed, default false
2118 * @return string|void HTML String if return=true nothing otherwise
2120 function print_heading_block($heading, $class='', $return=false) {
2121 global $OUTPUT;
2122 debugging('print_heading_with_block() has been deprecated. Please change your code to use $OUTPUT->heading().');
2123 $output = $OUTPUT->heading($heading, 2, 'headingblock header ' . renderer_base::prepare_classes($class));
2124 if ($return) {
2125 return $output;
2126 } else {
2127 echo $output;
2132 * Print a message in a standard themed box.
2133 * Replaces print_simple_box (see deprecatedlib.php)
2135 * @deprecated
2136 * @param string $message, the content of the box
2137 * @param string $classes, space-separated class names.
2138 * @param string $ids
2139 * @param boolean $return, return as string or just print it
2140 * @return string|void mixed string or void
2142 function print_box($message, $classes='generalbox', $ids='', $return=false) {
2143 global $OUTPUT;
2144 debugging('print_box() has been deprecated. Please change your code to use $OUTPUT->box().');
2145 $output = $OUTPUT->box($message, $classes, $ids);
2146 if ($return) {
2147 return $output;
2148 } else {
2149 echo $output;
2154 * Starts a box using divs
2155 * Replaces print_simple_box_start (see deprecatedlib.php)
2157 * @deprecated
2158 * @param string $classes, space-separated class names.
2159 * @param string $ids
2160 * @param boolean $return, return as string or just print it
2161 * @return string|void string or void
2163 function print_box_start($classes='generalbox', $ids='', $return=false) {
2164 global $OUTPUT;
2165 debugging('print_box_start() has been deprecated. Please change your code to use $OUTPUT->box_start().');
2166 $output = $OUTPUT->box_start($classes, $ids);
2167 if ($return) {
2168 return $output;
2169 } else {
2170 echo $output;
2175 * Simple function to end a box (see above)
2176 * Replaces print_simple_box_end (see deprecatedlib.php)
2178 * @deprecated
2179 * @param boolean $return, return as string or just print it
2180 * @return string|void Depending on value of return
2182 function print_box_end($return=false) {
2183 global $OUTPUT;
2184 debugging('print_box_end() has been deprecated. Please change your code to use $OUTPUT->box_end().');
2185 $output = $OUTPUT->box_end();
2186 if ($return) {
2187 return $output;
2188 } else {
2189 echo $output;
2194 * Print a message in a standard themed container.
2196 * @deprecated
2197 * @param string $message, the content of the container
2198 * @param boolean $clearfix clear both sides
2199 * @param string $classes, space-separated class names.
2200 * @param string $idbase
2201 * @param boolean $return, return as string or just print it
2202 * @return string|void Depending on value of $return
2204 function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) {
2205 global $OUTPUT;
2206 if ($clearfix) {
2207 $classes .= ' clearfix';
2209 $output = $OUTPUT->container($message, $classes, $idbase);
2210 if ($return) {
2211 return $output;
2212 } else {
2213 echo $output;
2218 * Starts a container using divs
2220 * @deprecated
2221 * @param boolean $clearfix clear both sides
2222 * @param string $classes, space-separated class names.
2223 * @param string $idbase
2224 * @param boolean $return, return as string or just print it
2225 * @return string|void Based on value of $return
2227 function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) {
2228 global $OUTPUT;
2229 if ($clearfix) {
2230 $classes .= ' clearfix';
2232 $output = $OUTPUT->container_start($classes, $idbase);
2233 if ($return) {
2234 return $output;
2235 } else {
2236 echo $output;
2241 * Deprecated, now handled automatically in themes
2243 function check_theme_arrows() {
2244 debugging('check_theme_arrows() has been deprecated, do not use it anymore, it is now automatic.');
2248 * Simple function to end a container (see above)
2250 * @deprecated
2251 * @param boolean $return, return as string or just print it
2252 * @return string|void Based on $return
2254 function print_container_end($return=false) {
2255 global $OUTPUT;
2256 $output = $OUTPUT->container_end();
2257 if ($return) {
2258 return $output;
2259 } else {
2260 echo $output;
2265 * Print a bold message in an optional color.
2267 * @deprecated use $OUTPUT->notification instead.
2268 * @param string $message The message to print out
2269 * @param string $style Optional style to display message text in
2270 * @param string $align Alignment option
2271 * @param bool $return whether to return an output string or echo now
2272 * @return string|bool Depending on $result
2274 function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) {
2275 global $OUTPUT;
2277 if ($classes == 'green') {
2278 debugging('Use of deprecated class name "green" in notify. Please change to "notifysuccess".', DEBUG_DEVELOPER);
2279 $classes = 'notifysuccess'; // Backward compatible with old color system
2282 $output = $OUTPUT->notification($message, $classes);
2283 if ($return) {
2284 return $output;
2285 } else {
2286 echo $output;
2291 * Print a continue button that goes to a particular URL.
2293 * @deprecated since Moodle 2.0
2295 * @param string $link The url to create a link to.
2296 * @param bool $return If set to true output is returned rather than echoed, default false
2297 * @return string|void HTML String if return=true nothing otherwise
2299 function print_continue($link, $return = false) {
2300 global $CFG, $OUTPUT;
2302 if ($link == '') {
2303 if (!empty($_SERVER['HTTP_REFERER'])) {
2304 $link = $_SERVER['HTTP_REFERER'];
2305 $link = str_replace('&', '&amp;', $link); // make it valid XHTML
2306 } else {
2307 $link = $CFG->wwwroot .'/';
2311 $output = $OUTPUT->continue_button($link);
2312 if ($return) {
2313 return $output;
2314 } else {
2315 echo $output;
2320 * Print a standard header
2322 * @param string $title Appears at the top of the window
2323 * @param string $heading Appears at the top of the page
2324 * @param string $navigation Array of $navlinks arrays (keys: name, link, type) for use as breadcrumbs links
2325 * @param string $focus Indicates form element to get cursor focus on load eg inputform.password
2326 * @param string $meta Meta tags to be added to the header
2327 * @param boolean $cache Should this page be cacheable?
2328 * @param string $button HTML code for a button (usually for module editing)
2329 * @param string $menu HTML code for a popup menu
2330 * @param boolean $usexml use XML for this page
2331 * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
2332 * @param bool $return If true, return the visible elements of the header instead of echoing them.
2333 * @return string|void If return=true then string else void
2335 function print_header($title='', $heading='', $navigation='', $focus='',
2336 $meta='', $cache=true, $button='&nbsp;', $menu=null,
2337 $usexml=false, $bodytags='', $return=false) {
2338 global $PAGE, $OUTPUT;
2340 $PAGE->set_title($title);
2341 $PAGE->set_heading($heading);
2342 $PAGE->set_cacheable($cache);
2343 if ($button == '') {
2344 $button = '&nbsp;';
2346 $PAGE->set_button($button);
2347 $PAGE->set_headingmenu($menu);
2349 // TODO $menu
2351 if ($meta) {
2352 throw new coding_exception('The $meta parameter to print_header is no longer supported. '.
2353 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.');
2355 if ($usexml) {
2356 throw new coding_exception('The $usexml parameter to print_header is no longer supported.');
2358 if ($bodytags) {
2359 throw new coding_exception('The $bodytags parameter to print_header is no longer supported.');
2362 $output = $OUTPUT->header();
2364 if ($return) {
2365 return $output;
2366 } else {
2367 echo $output;
2372 * This version of print_header is simpler because the course name does not have to be
2373 * provided explicitly in the strings. It can be used on the site page as in courses
2374 * Eventually all print_header could be replaced by print_header_simple
2376 * @deprecated since Moodle 2.0
2377 * @param string $title Appears at the top of the window
2378 * @param string $heading Appears at the top of the page
2379 * @param string $navigation Premade navigation string (for use as breadcrumbs links)
2380 * @param string $focus Indicates form element to get cursor focus on load eg inputform.password
2381 * @param string $meta Meta tags to be added to the header
2382 * @param boolean $cache Should this page be cacheable?
2383 * @param string $button HTML code for a button (usually for module editing)
2384 * @param string $menu HTML code for a popup menu
2385 * @param boolean $usexml use XML for this page
2386 * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
2387 * @param bool $return If true, return the visible elements of the header instead of echoing them.
2388 * @return string|void If $return=true the return string else nothing
2390 function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
2391 $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='', $return=false) {
2393 global $COURSE, $CFG, $PAGE, $OUTPUT;
2395 if ($meta) {
2396 throw new coding_exception('The $meta parameter to print_header is no longer supported. '.
2397 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.');
2399 if ($usexml) {
2400 throw new coding_exception('The $usexml parameter to print_header is no longer supported.');
2402 if ($bodytags) {
2403 throw new coding_exception('The $bodytags parameter to print_header is no longer supported.');
2406 $PAGE->set_title($title);
2407 $PAGE->set_heading($heading);
2408 $PAGE->set_cacheable(true);
2409 $PAGE->set_button($button);
2411 $output = $OUTPUT->header();
2413 if ($return) {
2414 return $output;
2415 } else {
2416 echo $output;
2420 function print_footer($course = NULL, $usercourse = NULL, $return = false) {
2421 global $PAGE, $OUTPUT;
2422 debugging('print_footer() has been deprecated. Please change your code to use $OUTPUT->footer().');
2423 // TODO check arguments.
2424 if (is_string($course)) {
2425 debugging("Magic values like 'home', 'empty' passed to print_footer no longer have any effect. " .
2426 'To achieve a similar effect, call $PAGE->set_pagelayout before you call print_header.', DEBUG_DEVELOPER);
2427 } else if (!empty($course->id) && $course->id != $PAGE->course->id) {
2428 throw new coding_exception('The $course object you passed to print_footer does not match $PAGE->course.');
2430 if (!is_null($usercourse)) {
2431 debugging('The second parameter ($usercourse) to print_footer is no longer supported. ' .
2432 '(I did not think it was being used anywhere.)', DEBUG_DEVELOPER);
2434 $output = $OUTPUT->footer();
2435 if ($return) {
2436 return $output;
2437 } else {
2438 echo $output;
2443 * Returns text to be displayed to the user which reflects their login status
2445 * @global object
2446 * @global object
2447 * @global object
2448 * @global object
2449 * @uses CONTEXT_COURSE
2450 * @param course $course {@link $COURSE} object containing course information
2451 * @param user $user {@link $USER} object containing user information
2452 * @return string HTML
2454 function user_login_string($course='ignored', $user='ignored') {
2455 debugging('user_login_info() has been deprecated. User login info is now handled via themes layouts.');
2456 return '';
2460 * Prints a nice side block with an optional header. The content can either
2461 * be a block of HTML or a list of text with optional icons.
2463 * @todo Finish documenting this function. Show example of various attributes, etc.
2465 * @static int $block_id Increments for each call to the function
2466 * @param string $heading HTML for the heading. Can include full HTML or just
2467 * plain text - plain text will automatically be enclosed in the appropriate
2468 * heading tags.
2469 * @param string $content HTML for the content
2470 * @param array $list an alternative to $content, it you want a list of things with optional icons.
2471 * @param array $icons optional icons for the things in $list.
2472 * @param string $footer Extra HTML content that gets output at the end, inside a &lt;div class="footer">
2473 * @param array $attributes an array of attribute => value pairs that are put on the
2474 * outer div of this block. If there is a class attribute ' block' gets appended to it. If there isn't
2475 * already a class, class='block' is used.
2476 * @param string $title Plain text title, as embedded in the $heading.
2477 * @deprecated
2479 function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
2480 global $OUTPUT;
2482 // We don't use $heading, becuse it often contains HTML that we don't want.
2483 // However, sometimes $title is not set, but $heading is.
2484 if (empty($title)) {
2485 $title = strip_tags($heading);
2488 // Render list contents to HTML if required.
2489 if (empty($content) && $list) {
2490 $content = $OUTPUT->list_block_contents($icons, $list);
2493 $bc = new block_contents();
2494 $bc->content = $content;
2495 $bc->footer = $footer;
2496 $bc->title = $title;
2498 if (isset($attributes['id'])) {
2499 $bc->id = $attributes['id'];
2500 unset($attributes['id']);
2502 $bc->attributes = $attributes;
2504 echo $OUTPUT->block($bc, BLOCK_POS_LEFT); // POS LEFT may be wrong, but no way to get a better guess here.
2508 * Starts a nice side block with an optional header.
2510 * @todo Finish documenting this function
2512 * @global object
2513 * @global object
2514 * @param string $heading HTML for the heading. Can include full HTML or just
2515 * plain text - plain text will automatically be enclosed in the appropriate
2516 * heading tags.
2517 * @param array $attributes HTML attributes to apply if possible
2518 * @deprecated
2520 function print_side_block_start($heading='', $attributes = array()) {
2521 throw new coding_exception('print_side_block_start has been deprecated. Please change your code to use $OUTPUT->block().');
2525 * Print table ending tags for a side block box.
2527 * @global object
2528 * @global object
2529 * @param array $attributes HTML attributes to apply if possible [id]
2530 * @param string $title
2531 * @deprecated
2533 function print_side_block_end($attributes = array(), $title='') {
2534 throw new coding_exception('print_side_block_end has been deprecated. Please change your code to use $OUTPUT->block().');
2538 * This was used by old code to see whether a block region had anything in it,
2539 * and hence wether that region should be printed.
2541 * We don't ever want old code to print blocks, so we now always return false.
2542 * The function only exists to avoid fatal errors in old code.
2544 * @deprecated since Moodle 2.0. always returns false.
2546 * @param object $blockmanager
2547 * @param string $region
2548 * @return bool
2550 function blocks_have_content(&$blockmanager, $region) {
2551 debugging('The function blocks_have_content should no longer be used. Blocks are now printed by the theme.');
2552 return false;
2556 * This was used by old code to print the blocks in a region.
2558 * We don't ever want old code to print blocks, so this is now a no-op.
2559 * The function only exists to avoid fatal errors in old code.
2561 * @deprecated since Moodle 2.0. does nothing.
2563 * @param object $page
2564 * @param object $blockmanager
2565 * @param string $region
2567 function blocks_print_group($page, $blockmanager, $region) {
2568 debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
2572 * This used to be the old entry point for anyone that wants to use blocks.
2573 * Since we don't want people people dealing with blocks this way any more,
2574 * just return a suitable empty array.
2576 * @deprecated since Moodle 2.0.
2578 * @param object $page
2579 * @return array
2581 function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE) {
2582 debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
2583 return array(BLOCK_POS_LEFT => array(), BLOCK_POS_RIGHT => array());
2587 * This iterates over an array of blocks and calculates the preferred width
2588 * Parameter passed by reference for speed; it's not modified.
2590 * @deprecated since Moodle 2.0. Layout is now controlled by the theme.
2592 * @param mixed $instances
2594 function blocks_preferred_width($instances) {
2595 debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
2596 $width = 210;
2600 * @deprecated since Moodle 2.0. See the replacements in blocklib.php.
2602 * @param object $page The page object
2603 * @param object $blockmanager The block manager object
2604 * @param string $blockaction One of [config, add, delete]
2605 * @param int|object $instanceorid The instance id or a block_instance object
2606 * @param bool $pinned
2607 * @param bool $redirect To redirect or not to that is the question but you should stick with true
2609 function blocks_execute_action($page, &$blockmanager, $blockaction, $instanceorid, $pinned=false, $redirect=true) {
2610 throw new coding_exception('blocks_execute_action is no longer used. The way blocks work has been changed. See the new code in blocklib.php.');
2614 * You can use this to get the blocks to respond to URL actions without much hassle
2616 * @deprecated since Moodle 2.0. Blocks have been changed. {@link block_manager::process_url_actions} is the closest replacement.
2618 * @param object $PAGE
2619 * @param object $blockmanager
2620 * @param bool $pinned
2622 function blocks_execute_url_action(&$PAGE, &$blockmanager,$pinned=false) {
2623 throw new coding_exception('blocks_execute_url_action is no longer used. It has been replaced by methods of block_manager.');
2627 * This shouldn't be used externally at all, it's here for use by blocks_execute_action()
2628 * in order to reduce code repetition.
2630 * @deprecated since Moodle 2.0. See the replacements in blocklib.php.
2632 * @param $instance
2633 * @param $newpos
2634 * @param string|int $newweight
2635 * @param bool $pinned
2637 function blocks_execute_repositioning(&$instance, $newpos, $newweight, $pinned=false) {
2638 throw new coding_exception('blocks_execute_repositioning is no longer used. The way blocks work has been changed. See the new code in blocklib.php.');
2643 * Moves a block to the new position (column) and weight (sort order).
2645 * @deprecated since Moodle 2.0. See the replacements in blocklib.php.
2647 * @param object $instance The block instance to be moved.
2648 * @param string $destpos BLOCK_POS_LEFT or BLOCK_POS_RIGHT. The destination column.
2649 * @param string $destweight The destination sort order. If NULL, we add to the end
2650 * of the destination column.
2651 * @param bool $pinned Are we moving pinned blocks? We can only move pinned blocks
2652 * to a new position withing the pinned list. Likewise, we
2653 * can only moved non-pinned blocks to a new position within
2654 * the non-pinned list.
2655 * @return boolean success or failure
2657 function blocks_move_block($page, &$instance, $destpos, $destweight=NULL, $pinned=false) {
2658 throw new coding_exception('blocks_move_block is no longer used. The way blocks work has been changed. See the new code in blocklib.php.');
2662 * Print a nicely formatted table.
2664 * @deprecated since Moodle 2.0
2666 * @param array $table is an object with several properties.
2668 function print_table($table, $return=false) {
2669 global $OUTPUT;
2670 // TODO MDL-19755 turn debugging on once we migrate the current core code to use the new API
2671 debugging('print_table() has been deprecated. Please change your code to use html_writer::table().');
2672 $newtable = new html_table();
2673 foreach ($table as $property => $value) {
2674 if (property_exists($newtable, $property)) {
2675 $newtable->{$property} = $value;
2678 if (isset($table->class)) {
2679 $newtable->attributes['class'] = $table->class;
2681 if (isset($table->rowclass) && is_array($table->rowclass)) {
2682 debugging('rowclass[] has been deprecated for html_table and should be replaced by rowclasses[]. please fix the code.');
2683 $newtable->rowclasses = $table->rowclass;
2685 $output = html_writer::table($newtable);
2686 if ($return) {
2687 return $output;
2688 } else {
2689 echo $output;
2690 return true;
2695 * Creates and displays (or returns) a link to a popup window
2697 * @deprecated since Moodle 2.0
2699 * @param string $url Web link. Either relative to $CFG->wwwroot, or a full URL.
2700 * @param string $name Name to be assigned to the popup window (this is used by
2701 * client-side scripts to "talk" to the popup window)
2702 * @param string $linkname Text to be displayed as web link
2703 * @param int $height Height to assign to popup window
2704 * @param int $width Height to assign to popup window
2705 * @param string $title Text to be displayed as popup page title
2706 * @param string $options List of additional options for popup window
2707 * @param bool $return If true, return as a string, otherwise print
2708 * @param string $id id added to the element
2709 * @param string $class class added to the element
2710 * @return string html code to display a link to a popup window.
2712 function link_to_popup_window ($url, $name=null, $linkname=null, $height=400, $width=500, $title=null, $options=null, $return=false) {
2713 debugging('link_to_popup_window() has been removed. Please change your code to use $OUTPUT->action_link(). Please note popups are discouraged for accessibility reasons');
2715 return html_writer::link($url, $name);
2719 * Creates and displays (or returns) a buttons to a popup window.
2721 * @deprecated since Moodle 2.0
2723 * @param string $url Web link. Either relative to $CFG->wwwroot, or a full URL.
2724 * @param string $name Name to be assigned to the popup window (this is used by
2725 * client-side scripts to "talk" to the popup window)
2726 * @param string $linkname Text to be displayed as web link
2727 * @param int $height Height to assign to popup window
2728 * @param int $width Height to assign to popup window
2729 * @param string $title Text to be displayed as popup page title
2730 * @param string $options List of additional options for popup window
2731 * @param bool $return If true, return as a string, otherwise print
2732 * @param string $id id added to the element
2733 * @param string $class class added to the element
2734 * @return string html code to display a link to a popup window.
2736 function button_to_popup_window ($url, $name=null, $linkname=null,
2737 $height=400, $width=500, $title=null, $options=null, $return=false,
2738 $id=null, $class=null) {
2739 global $OUTPUT;
2741 debugging('button_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->single_button().');
2743 if ($options == 'none') {
2744 $options = null;
2747 if (empty($linkname)) {
2748 throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->action_link() for usage.');
2751 // Create a single_button object
2752 $form = new single_button($url, $linkname, 'post');
2753 $form->button->title = $title;
2754 $form->button->id = $id;
2756 // Parse the $options string
2757 $popupparams = array();
2758 if (!empty($options)) {
2759 $optionsarray = explode(',', $options);
2760 foreach ($optionsarray as $option) {
2761 if (strstr($option, '=')) {
2762 $parts = explode('=', $option);
2763 if ($parts[1] == '0') {
2764 $popupparams[$parts[0]] = false;
2765 } else {
2766 $popupparams[$parts[0]] = $parts[1];
2768 } else {
2769 $popupparams[$option] = true;
2774 if (!empty($height)) {
2775 $popupparams['height'] = $height;
2777 if (!empty($width)) {
2778 $popupparams['width'] = $width;
2781 $form->button->add_action(new popup_action('click', $url, $name, $popupparams));
2782 $output = $OUTPUT->render($form);
2784 if ($return) {
2785 return $output;
2786 } else {
2787 echo $output;
2792 * Print a self contained form with a single submit button.
2794 * @deprecated since Moodle 2.0
2796 * @param string $link used as the action attribute on the form, so the URL that will be hit if the button is clicked.
2797 * @param array $options these become hidden form fields, so these options get passed to the script at $link.
2798 * @param string $label the caption that appears on the button.
2799 * @param string $method HTTP method used on the request of the button is clicked. 'get' or 'post'.
2800 * @param string $notusedanymore no longer used.
2801 * @param boolean $return if false, output the form directly, otherwise return the HTML as a string.
2802 * @param string $tooltip a tooltip to add to the button as a title attribute.
2803 * @param boolean $disabled if true, the button will be disabled.
2804 * @param string $jsconfirmmessage if not empty then display a confirm dialogue with this string as the question.
2805 * @param string $formid The id attribute to use for the form
2806 * @return string|void Depending on the $return paramter.
2808 function print_single_button($link, $options, $label='OK', $method='get', $notusedanymore='',
2809 $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $formid = '') {
2810 global $OUTPUT;
2812 debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->single_button().');
2814 // Cast $options to array
2815 $options = (array) $options;
2817 $button = new single_button(new moodle_url($link, $options), $label, $method, array('disabled'=>$disabled, 'title'=>$tooltip, 'id'=>$formid));
2819 if ($jsconfirmmessage) {
2820 $button->button->add_confirm_action($jsconfirmmessage);
2823 $output = $OUTPUT->render($button);
2825 if ($return) {
2826 return $output;
2827 } else {
2828 echo $output;
2833 * Print a spacer image with the option of including a line break.
2835 * @deprecated since Moodle 2.0
2837 * @global object
2838 * @param int $height The height in pixels to make the spacer
2839 * @param int $width The width in pixels to make the spacer
2840 * @param boolean $br If set to true a BR is written after the spacer
2842 function print_spacer($height=1, $width=1, $br=true, $return=false) {
2843 global $CFG, $OUTPUT;
2845 debugging('print_spacer() has been deprecated. Please change your code to use $OUTPUT->spacer().');
2847 $output = $OUTPUT->spacer(array('height'=>$height, 'width'=>$width, 'br'=>$br));
2849 if ($return) {
2850 return $output;
2851 } else {
2852 echo $output;
2857 * Given the path to a picture file in a course, or a URL,
2858 * this function includes the picture in the page.
2860 * @deprecated since Moodle 2.0
2862 function print_file_picture($path, $courseid=0, $height='', $width='', $link='', $return=false) {
2863 throw new coding_exception('print_file_picture() has been deprecated since Moodle 2.0. Please use $OUTPUT->action_icon() instead.');
2867 * Print the specified user's avatar.
2869 * @deprecated since Moodle 2.0
2871 * @global object
2872 * @global object
2873 * @param mixed $user Should be a $user object with at least fields id, picture, imagealt, firstname, lastname, email
2874 * If any of these are missing, or if a userid is passed, the the database is queried. Avoid this
2875 * if at all possible, particularly for reports. It is very bad for performance.
2876 * @param int $courseid The course id. Used when constructing the link to the user's profile.
2877 * @param boolean $picture The picture to print. By default (or if NULL is passed) $user->picture is used.
2878 * @param int $size Size in pixels. Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatibility
2879 * @param boolean $return If false print picture to current page, otherwise return the output as string
2880 * @param boolean $link enclose printed image in a link the user's profile (default true).
2881 * @param string $target link target attribute. Makes the profile open in a popup window.
2882 * @param boolean $alttext add non-blank alt-text to the image. (Default true, set to false for purely
2883 * decorative images, or where the username will be printed anyway.)
2884 * @return string|void String or nothing, depending on $return.
2886 function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true) {
2887 global $OUTPUT;
2889 debugging('print_user_picture() has been deprecated. Please change your code to use $OUTPUT->user_picture($user, array(\'courseid\'=>$courseid).');
2891 if (!is_object($user)) {
2892 $userid = $user;
2893 $user = new stdClass();
2894 $user->id = $userid;
2897 if (empty($user->picture) and $picture) {
2898 $user->picture = $picture;
2901 $options = array('size'=>$size, 'link'=>$link, 'alttext'=>$alttext, 'courseid'=>$courseid, 'popup'=>!empty($target));
2903 $output = $OUTPUT->user_picture($user, $options);
2905 if ($return) {
2906 return $output;
2907 } else {
2908 echo $output;
2913 * Print a png image.
2915 * @deprecated since Moodle 2.0: no replacement
2918 function print_png() {
2919 throw new coding_exception('print_png() has been deprecated since Moodle 2.0. Please use $OUTPUT->pix_icon() instead.');
2924 * Prints a basic textarea field.
2926 * @deprecated since Moodle 2.0
2928 * When using this function, you should
2930 * @global object
2931 * @param bool $usehtmleditor Enables the use of the htmleditor for this field.
2932 * @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
2933 * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
2934 * @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.
2935 * @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.
2936 * @param string $name Name to use for the textarea element.
2937 * @param string $value Initial content to display in the textarea.
2938 * @param int $obsolete deprecated
2939 * @param bool $return If false, will output string. If true, will return string value.
2940 * @param string $id CSS ID to add to the textarea element.
2941 * @return string|void depending on the value of $return
2943 function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
2944 /// $width and height are legacy fields and no longer used as pixels like they used to be.
2945 /// However, you can set them to zero to override the mincols and minrows values below.
2947 // Disabling because there is not yet a viable $OUTPUT option for cases when mforms can't be used
2948 // debugging('print_textarea() has been deprecated. You should be using mforms and the editor element.');
2950 global $CFG;
2952 $mincols = 65;
2953 $minrows = 10;
2954 $str = '';
2956 if ($id === '') {
2957 $id = 'edit-'.$name;
2960 if ($usehtmleditor) {
2961 if ($height && ($rows < $minrows)) {
2962 $rows = $minrows;
2964 if ($width && ($cols < $mincols)) {
2965 $cols = $mincols;
2969 if ($usehtmleditor) {
2970 editors_head_setup();
2971 $editor = editors_get_preferred_editor(FORMAT_HTML);
2972 $editor->use_editor($id, array('legacy'=>true));
2973 } else {
2974 $editorclass = '';
2977 $str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
2978 if ($usehtmleditor) {
2979 $str .= htmlspecialchars($value); // needed for editing of cleaned text!
2980 } else {
2981 $str .= s($value);
2983 $str .= '</textarea>'."\n";
2985 if ($return) {
2986 return $str;
2988 echo $str;
2993 * Print a help button.
2995 * @deprecated since Moodle 2.0
2997 * @param string $page The keyword that defines a help page
2998 * @param string $title The title of links, rollover tips, alt tags etc
2999 * 'Help with' (or the language equivalent) will be prefixed and '...' will be stripped.
3000 * @param string $module Which module is the page defined in
3001 * @param mixed $image Use a help image for the link? (true/false/"both")
3002 * @param boolean $linktext If true, display the title next to the help icon.
3003 * @param string $text If defined then this text is used in the page, and
3004 * the $page variable is ignored. DEPRECATED!
3005 * @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
3006 * @param string $imagetext The full text for the helpbutton icon. If empty use default help.gif
3007 * @return string|void Depending on value of $return
3009 function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false, $imagetext='') {
3010 debugging('helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_icon().');
3012 global $OUTPUT;
3014 $output = $OUTPUT->old_help_icon($page, $title, $module, $linktext);
3016 // hide image with CSS if needed
3018 if ($return) {
3019 return $output;
3020 } else {
3021 echo $output;
3026 * Print a help button.
3028 * Prints a special help button that is a link to the "live" emoticon popup
3030 * @todo Finish documenting this function
3032 * @global object
3033 * @global object
3034 * @param string $form ?
3035 * @param string $field ?
3036 * @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
3037 * @return string|void Depending on value of $return
3039 function emoticonhelpbutton($form, $field, $return = false) {
3040 /// TODO: MDL-21215
3042 debugging('emoticonhelpbutton() was removed, new text editors will implement this feature');
3046 * Returns a string of html with an image of a help icon linked to a help page on a number of help topics.
3047 * Should be used only with htmleditor or textarea.
3049 * @global object
3050 * @global object
3051 * @param mixed $helptopics variable amount of params accepted. Each param may be a string or an array of arguments for
3052 * helpbutton.
3053 * @return string Link to help button
3055 function editorhelpbutton(){
3056 return '';
3058 /// TODO: MDL-21215
3062 * Print a help button.
3064 * Prints a special help button for html editors (htmlarea in this case)
3066 * @todo Write code into this function! detect current editor and print correct info
3067 * @global object
3068 * @return string Only returns an empty string at the moment
3070 function editorshortcutshelpbutton() {
3071 /// TODO: MDL-21215
3073 global $CFG;
3074 //TODO: detect current editor and print correct info
3075 /* $imagetext = '<img src="' . $CFG->httpswwwroot . '/lib/editor/htmlarea/images/kbhelp.gif" alt="'.
3076 get_string('editorshortcutkeys').'" class="iconkbhelp" />';
3078 return helpbutton('editorshortcuts', get_string('editorshortcutkeys'), 'moodle', true, false, '', true, $imagetext);*/
3079 return '';
3084 * Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
3085 * provide this function with the language strings for sortasc and sortdesc.
3087 * @deprecated since Moodle 2.0
3089 * TODO migrate to outputlib
3090 * If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
3092 * @global object
3093 * @param string $direction 'up' or 'down'
3094 * @param string $strsort The language string used for the alt attribute of this image
3095 * @param bool $return Whether to print directly or return the html string
3096 * @return string|void depending on $return
3099 function print_arrow($direction='up', $strsort=null, $return=false) {
3100 // debugging('print_arrow() has been deprecated. Please change your code to use $OUTPUT->arrow().');
3102 global $OUTPUT;
3104 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
3105 return null;
3108 $return = null;
3110 switch ($direction) {
3111 case 'up':
3112 $sortdir = 'asc';
3113 break;
3114 case 'down':
3115 $sortdir = 'desc';
3116 break;
3117 case 'move':
3118 $sortdir = 'asc';
3119 break;
3120 default:
3121 $sortdir = null;
3122 break;
3125 // Prepare language string
3126 $strsort = '';
3127 if (empty($strsort) && !empty($sortdir)) {
3128 $strsort = get_string('sort' . $sortdir, 'grades');
3131 $return = ' <img src="'.$OUTPUT->pix_url('t/' . $direction) . '" alt="'.$strsort.'" /> ';
3133 if ($return) {
3134 return $return;
3135 } else {
3136 echo $return;
3141 * Returns a string containing a link to the user documentation.
3142 * Also contains an icon by default. Shown to teachers and admin only.
3144 * @deprecated since Moodle 2.0
3146 * @global object
3147 * @param string $path The page link after doc root and language, no leading slash.
3148 * @param string $text The text to be displayed for the link
3149 * @param string $iconpath The path to the icon to be displayed
3150 * @return string Either the link or an empty string
3152 function doc_link($path='', $text='', $iconpath='ignored') {
3153 global $CFG, $OUTPUT;
3155 debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->doc_link().');
3157 if (empty($CFG->docroot)) {
3158 return '';
3161 return $OUTPUT->doc_link($path, $text);
3165 * Prints a single paging bar to provide access to other pages (usually in a search)
3167 * @deprecated since Moodle 2.0
3169 * @param int $totalcount Thetotal number of entries available to be paged through
3170 * @param int $page The page you are currently viewing
3171 * @param int $perpage The number of entries that should be shown per page
3172 * @param mixed $baseurl If this is a string then it is the url which will be appended with $pagevar, an equals sign and the page number.
3173 * If this is a moodle_url object then the pagevar param will be replaced by the page no, for each page.
3174 * @param string $pagevar This is the variable name that you use for the page number in your code (ie. 'tablepage', 'blogpage', etc)
3175 * @param bool $nocurr do not display the current page as a link (dropped, link is never displayed for the current page)
3176 * @param bool $return whether to return an output string or echo now
3177 * @return bool|string depending on $result
3179 function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page',$nocurr=false, $return=false) {
3180 global $OUTPUT;
3182 debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->render($pagingbar).');
3184 if (empty($nocurr)) {
3185 debugging('the feature of parameter $nocurr has been removed from the paging_bar');
3188 $pagingbar = new paging_bar($totalcount, $page, $perpage, $baseurl);
3189 $pagingbar->pagevar = $pagevar;
3190 $output = $OUTPUT->render($pagingbar);
3192 if ($return) {
3193 return $output;
3196 echo $output;
3197 return true;
3201 * Print a message along with "Yes" and "No" links for the user to continue.
3203 * @deprecated since Moodle 2.0
3205 * @global object
3206 * @param string $message The text to display
3207 * @param string $linkyes The link to take the user to if they choose "Yes"
3208 * @param string $linkno The link to take the user to if they choose "No"
3209 * @param string $optionyes The yes option to show on the notice
3210 * @param string $optionsno The no option to show
3211 * @param string $methodyes Form action method to use if yes [post, get]
3212 * @param string $methodno Form action method to use if no [post, get]
3213 * @return void Output is echo'd
3215 function notice_yesno($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno=NULL, $methodyes='post', $methodno='post') {
3217 debugging('notice_yesno() has been deprecated. Please change your code to use $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel).');
3219 global $OUTPUT;
3221 $buttoncontinue = new single_button(new moodle_url($linkyes, $optionsyes), get_string('yes'), $methodyes);
3222 $buttoncancel = new single_button(new moodle_url($linkno, $optionsno), get_string('no'), $methodno);
3224 echo $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel);
3228 * Prints a scale menu (as part of an existing form) including help button
3229 * @deprecated since Moodle 2.0
3231 function print_scale_menu() {
3232 throw new coding_exception('print_scale_menu() has been deprecated since the Jurassic period. Get with the times!.');
3236 * Given an array of values, output the HTML for a select element with those options.
3238 * @deprecated since Moodle 2.0
3240 * Normally, you only need to use the first few parameters.
3242 * @param array $options The options to offer. An array of the form
3243 * $options[{value}] = {text displayed for that option};
3244 * @param string $name the name of this form control, as in &lt;select name="..." ...
3245 * @param string $selected the option to select initially, default none.
3246 * @param string $nothing The label for the 'nothing is selected' option. Defaults to get_string('choose').
3247 * Set this to '' if you don't want a 'nothing is selected' option.
3248 * @param string $script if not '', then this is added to the &lt;select> element as an onchange handler.
3249 * @param string $nothingvalue The value corresponding to the $nothing option. Defaults to 0.
3250 * @param boolean $return if false (the default) the the output is printed directly, If true, the
3251 * generated HTML is returned as a string.
3252 * @param boolean $disabled if true, the select is generated in a disabled state. Default, false.
3253 * @param int $tabindex if give, sets the tabindex attribute on the &lt;select> element. Default none.
3254 * @param string $id value to use for the id attribute of the &lt;select> element. If none is given,
3255 * then a suitable one is constructed.
3256 * @param mixed $listbox if false, display as a dropdown menu. If true, display as a list box.
3257 * By default, the list box will have a number of rows equal to min(10, count($options)), but if
3258 * $listbox is an integer, that number is used for size instead.
3259 * @param boolean $multiple if true, enable multiple selections, else only 1 item can be selected. Used
3260 * when $listbox display is enabled
3261 * @param string $class value to use for the class attribute of the &lt;select> element. If none is given,
3262 * then a suitable one is constructed.
3263 * @return string|void If $return=true returns string, else echo's and returns void
3265 function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='',
3266 $nothingvalue='0', $return=false, $disabled=false, $tabindex=0,
3267 $id='', $listbox=false, $multiple=false, $class='') {
3269 global $OUTPUT;
3270 debugging('choose_from_menu() has been deprecated. Please change your code to use html_writer::select().');
3272 if ($script) {
3273 debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
3275 $attributes = array();
3276 $attributes['disabled'] = $disabled ? 'disabled' : null;
3277 $attributes['tabindex'] = $tabindex ? $tabindex : null;
3278 $attributes['multiple'] = $multiple ? $multiple : null;
3279 $attributes['class'] = $class ? $class : null;
3280 $attributes['id'] = $id ? $id : null;
3282 $output = html_writer::select($options, $name, $selected, array($nothingvalue=>$nothing), $attributes);
3284 if ($return) {
3285 return $output;
3286 } else {
3287 echo $output;
3292 * Choose value 0 or 1 from a menu with options 'No' and 'Yes'.
3293 * Other options like choose_from_menu.
3295 * @deprecated since Moodle 2.0
3297 * Calls {@link choose_from_menu()} with preset arguments
3298 * @see choose_from_menu()
3300 * @param string $name the name of this form control, as in &lt;select name="..." ...
3301 * @param string $selected the option to select initially, default none.
3302 * @param string $script if not '', then this is added to the &lt;select> element as an onchange handler.
3303 * @param boolean $return Whether this function should return a string or output it (defaults to false)
3304 * @param boolean $disabled (defaults to false)
3305 * @param int $tabindex
3306 * @return string|void If $return=true returns string, else echo's and returns void
3308 function choose_from_menu_yesno($name, $selected, $script = '', $return = false, $disabled = false, $tabindex = 0) {
3309 debugging('choose_from_menu_yesno() has been deprecated. Please change your code to use html_writer.');
3310 global $OUTPUT;
3312 if ($script) {
3313 debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER);
3316 $output = html_writer::select_yes_no($name, $selected, array('disabled'=>($disabled ? 'disabled' : null), 'tabindex'=>$tabindex));
3318 if ($return) {
3319 return $output;
3320 } else {
3321 echo $output;
3326 * Just like choose_from_menu, but takes a nested array (2 levels) and makes a dropdown menu
3327 * including option headings with the first level.
3329 * @deprecated since Moodle 2.0
3331 * This function is very similar to {@link choose_from_menu_yesno()}
3332 * and {@link choose_from_menu()}
3334 * @todo Add datatype handling to make sure $options is an array
3336 * @param array $options An array of objects to choose from
3337 * @param string $name The XHTML field name
3338 * @param string $selected The value to select by default
3339 * @param string $nothing The label for the 'nothing is selected' option.
3340 * Defaults to get_string('choose').
3341 * @param string $script If not '', then this is added to the &lt;select> element
3342 * as an onchange handler.
3343 * @param string $nothingvalue The value for the first `nothing` option if $nothing is set
3344 * @param bool $return Whether this function should return a string or output
3345 * it (defaults to false)
3346 * @param bool $disabled Is the field disabled by default
3347 * @param int|string $tabindex Override the tabindex attribute [numeric]
3348 * @return string|void If $return=true returns string, else echo's and returns void
3350 function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$script = '',
3351 $nothingvalue=0,$return=false,$disabled=false,$tabindex=0) {
3353 debugging('choose_from_menu_nested() has been removed. Please change your code to use html_writer::select().');
3354 global $OUTPUT;
3358 * Prints a help button about a scale
3360 * @deprecated since Moodle 2.0
3362 * @global object
3363 * @param id $courseid
3364 * @param object $scale
3365 * @param boolean $return If set to true returns rather than echo's
3366 * @return string|bool Depending on value of $return
3368 function print_scale_menu_helpbutton($courseid, $scale, $return=false) {
3369 // debugging('print_scale_menu_helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_scale($courseid, $scale).');
3370 global $OUTPUT;
3372 $output = $OUTPUT->help_icon_scale($courseid, $scale);
3374 if ($return) {
3375 return $output;
3376 } else {
3377 echo $output;
3383 * Prints time limit value selector
3385 * @deprecated since Moodle 2.0
3387 * Uses {@link choose_from_menu()} to generate HTML
3388 * @see choose_from_menu()
3390 * @global object
3391 * @param int $timelimit default
3392 * @param string $unit
3393 * @param string $name
3394 * @param boolean $return If set to true returns rather than echo's
3395 * @return string|bool Depending on value of $return
3397 function print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit', $return=false) {
3398 throw new coding_exception('print_timer_selector is completely removed. Please use html_writer instead');
3402 * Prints form items with the names $hour and $minute
3404 * @deprecated since Moodle 2.0
3406 * @param string $hour fieldname
3407 * @param string $minute fieldname
3408 * @param int $currenttime A default timestamp in GMT
3409 * @param int $step minute spacing
3410 * @param boolean $return If set to true returns rather than echo's
3411 * @return string|bool Depending on value of $return
3413 function print_time_selector($hour, $minute, $currenttime=0, $step=5, $return=false) {
3414 debugging('print_time_selector() has been deprecated. Please change your code to use html_writer.');
3416 $hourselector = html_writer::select_time('hours', $hour, $currenttime);
3417 $minuteselector = html_writer::select_time('minutes', $minute, $currenttime, $step);
3419 $output = $hourselector . $$minuteselector;
3421 if ($return) {
3422 return $output;
3423 } else {
3424 echo $output;
3429 * Prints form items with the names $day, $month and $year
3431 * @deprecated since Moodle 2.0
3433 * @param string $day fieldname
3434 * @param string $month fieldname
3435 * @param string $year fieldname
3436 * @param int $currenttime A default timestamp in GMT
3437 * @param boolean $return If set to true returns rather than echo's
3438 * @return string|bool Depending on value of $return
3440 function print_date_selector($day, $month, $year, $currenttime=0, $return=false) {
3441 debugging('print_date_selector() has been deprecated. Please change your code to use html_writer.');
3443 $dayselector = html_writer::select_time('days', $day, $currenttime);
3444 $monthselector = html_writer::select_time('months', $month, $currenttime);
3445 $yearselector = html_writer::select_time('years', $year, $currenttime);
3447 $output = $dayselector . $monthselector . $yearselector;
3449 if ($return) {
3450 return $output;
3451 } else {
3452 echo $output;
3457 * Implements a complete little form with a dropdown menu.
3459 * @deprecated since Moodle 2.0
3461 * When JavaScript is on selecting an option from the dropdown automatically
3462 * submits the form (while avoiding the usual acessibility problems with this appoach).
3463 * With JavaScript off, a 'Go' button is printed.
3465 * @global object
3466 * @global object
3467 * @param string $baseurl The target URL up to the point of the variable that changes
3468 * @param array $options A list of value-label pairs for the popup list
3469 * @param string $formid id for the control. Must be unique on the page. Used in the HTML.
3470 * @param string $selected The option that is initially selected
3471 * @param string $nothing The label for the "no choice" option
3472 * @param string $help The name of a help page if help is required
3473 * @param string $helptext The name of the label for the help button
3474 * @param boolean $return Indicates whether the function should return the HTML
3475 * as a string or echo it directly to the page being rendered
3476 * @param string $targetwindow The name of the target page to open the linked page in.
3477 * @param string $selectlabel Text to place in a [label] element - preferred for accessibility.
3478 * @param array $optionsextra an array with the same keys as $options. The values are added within the corresponding <option ...> tag.
3479 * @param string $submitvalue Optional label for the 'Go' button. Defaults to get_string('go').
3480 * @param boolean $disabled If true, the menu will be displayed disabled.
3481 * @param boolean $showbutton If true, the button will always be shown even if JavaScript is available
3482 * @return string|void If $return=true returns string, else echo's and returns void
3484 function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false,
3485 $targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) {
3486 global $OUTPUT, $CFG;
3488 debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->single_select() or $OUTPUT->url_select().');
3490 if (empty($options)) {
3491 return '';
3494 $urls = array();
3496 foreach ($options as $value=>$label) {
3497 $url = $baseurl.$value;
3498 $url = str_replace($CFG->wwwroot, '', $url);
3499 $url = str_replace('&amp;', '&', $url);
3500 $urls[$url] = $label;
3501 if ($selected == $value) {
3502 $active = $url;
3506 $nothing = $nothing ? array(''=>$nothing) : null;
3508 $select = new url_select($urls, $active, $nothing, $formid);
3509 $select->disabled = $disabled;
3511 $select->set_label($selectlabel);
3512 $select->set_old_help_icon($help, $helptext);
3514 $output = $OUTPUT->render($select);
3516 if ($return) {
3517 return $output;
3518 } else {
3519 echo $output;
3524 * Prints a simple button to close a window
3526 * @deprecated since Moodle 2.0
3528 * @global object
3529 * @param string $name Name of the window to close
3530 * @param boolean $return whether this function should return a string or output it.
3531 * @param boolean $reloadopener if true, clicking the button will also reload
3532 * the page that opend this popup window.
3533 * @return string|void if $return is true, void otherwise
3535 function close_window_button($name='closewindow', $return=false, $reloadopener = false) {
3536 global $OUTPUT;
3538 debugging('close_window_button() has been deprecated. Please change your code to use $OUTPUT->close_window_button().');
3539 $output = $OUTPUT->close_window_button(get_string($name));
3541 if ($return) {
3542 return $output;
3543 } else {
3544 echo $output;
3549 * Given an array of values, creates a group of radio buttons to be part of a form
3551 * @deprecated since Moodle 2.0
3553 * @staticvar int $idcounter
3554 * @param array $options An array of value-label pairs for the radio group (values as keys)
3555 * @param string $name Name of the radiogroup (unique in the form)
3556 * @param string $checked The value that is already checked
3557 * @param bool $return Whether this function should return a string or output
3558 * it (defaults to false)
3559 * @return string|void If $return=true returns string, else echo's and returns void
3561 function choose_from_radio ($options, $name, $checked='', $return=false) {
3562 debugging('choose_from_radio() has been removed. Please change your code to use html_writer.');
3566 * Display an standard html checkbox with an optional label
3568 * @deprecated since Moodle 2.0
3570 * @staticvar int $idcounter
3571 * @param string $name The name of the checkbox
3572 * @param string $value The valus that the checkbox will pass when checked
3573 * @param bool $checked The flag to tell the checkbox initial state
3574 * @param string $label The label to be showed near the checkbox
3575 * @param string $alt The info to be inserted in the alt tag
3576 * @param string $script If not '', then this is added to the checkbox element
3577 * as an onchange handler.
3578 * @param bool $return Whether this function should return a string or output
3579 * it (defaults to false)
3580 * @return string|void If $return=true returns string, else echo's and returns void
3582 function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) {
3584 // debugging('print_checkbox() has been deprecated. Please change your code to use html_writer::checkbox().');
3585 global $OUTPUT;
3587 if (!empty($script)) {
3588 debugging('The use of the $script param in print_checkbox has not been migrated into html_writer::checkbox().', DEBUG_DEVELOPER);
3591 $output = html_writer::checkbox($name, $value, $checked, $label);
3593 if (empty($return)) {
3594 echo $output;
3595 } else {
3596 return $output;
3603 * Display an standard html text field with an optional label
3605 * @deprecated since Moodle 2.0
3607 * @param string $name The name of the text field
3608 * @param string $value The value of the text field
3609 * @param string $alt The info to be inserted in the alt tag
3610 * @param int $size Sets the size attribute of the field. Defaults to 50
3611 * @param int $maxlength Sets the maxlength attribute of the field. Not set by default
3612 * @param bool $return Whether this function should return a string or output
3613 * it (defaults to false)
3614 * @return string|void If $return=true returns string, else echo's and returns void
3616 function print_textfield($name, $value, $alt = '', $size=50, $maxlength=0, $return=false) {
3617 debugging('print_textfield() has been deprecated. Please use mforms or html_writer.');
3619 if ($alt === '') {
3620 $alt = null;
3623 $style = "width: {$size}px;";
3624 $attributes = array('type'=>'text', 'name'=>$name, 'alt'=>$alt, 'style'=>$style, 'value'=>$value);
3625 if ($maxlength) {
3626 $attributes['maxlength'] = $maxlength;
3629 $output = html_writer::empty_tag('input', $attributes);
3631 if (empty($return)) {
3632 echo $output;
3633 } else {
3634 return $output;
3640 * Centered heading with attached help button (same title text)
3641 * and optional icon attached
3643 * @deprecated since Moodle 2.0
3645 * @param string $text The text to be displayed
3646 * @param string $helppage The help page to link to
3647 * @param string $module The module whose help should be linked to
3648 * @param string $icon Image to display if needed
3649 * @param bool $return If set to true output is returned rather than echoed, default false
3650 * @return string|void String if return=true nothing otherwise
3652 function print_heading_with_help($text, $helppage, $module='moodle', $icon=false, $return=false) {
3654 debugging('print_heading_with_help() has been deprecated. Please change your code to use $OUTPUT->heading().');
3656 global $OUTPUT;
3658 // Extract the src from $icon if it exists
3659 if (preg_match('/src="([^"]*)"/', $icon, $matches)) {
3660 $icon = $matches[1];
3661 $icon = new moodle_url($icon);
3662 } else {
3663 $icon = '';
3666 $output = $OUTPUT->heading_with_help($text, $helppage, $module, $icon);
3668 if ($return) {
3669 return $output;
3670 } else {
3671 echo $output;
3676 * Returns a turn edit on/off button for course in a self contained form.
3677 * Used to be an icon, but it's now a simple form button
3678 * @deprecated since Moodle 2.0
3680 function update_mymoodle_icon() {
3681 throw new coding_exception('update_mymoodle_icon() has been completely deprecated.');
3685 * Returns a turn edit on/off button for tag in a self contained form.
3686 * @deprecated since Moodle 2.0
3687 * @param string $tagid The ID attribute
3688 * @return string
3690 function update_tag_button($tagid) {
3691 global $OUTPUT;
3692 debugging('update_tag_button() has been deprecated. Please change your code to use $OUTPUT->edit_button(moodle_url).');
3693 return $OUTPUT->edit_button(new moodle_url('/tag/index.php', array('id' => $tagid)));
3698 * Prints the 'update this xxx' button that appears on module pages.
3700 * @deprecated since Moodle 2.0
3702 * @param string $cmid the course_module id.
3703 * @param string $ignored not used any more. (Used to be courseid.)
3704 * @param string $string the module name - get_string('modulename', 'xxx')
3705 * @return string the HTML for the button, if this user has permission to edit it, else an empty string.
3707 function update_module_button($cmid, $ignored, $string) {
3708 global $CFG, $OUTPUT;
3710 // debugging('update_module_button() has been deprecated. Please change your code to use $OUTPUT->update_module_button().');
3712 //NOTE: DO NOT call new output method because it needs the module name we do not have here!
3714 if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $cmid))) {
3715 $string = get_string('updatethis', '', $string);
3717 $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey()));
3718 return $OUTPUT->single_button($url, $string);
3719 } else {
3720 return '';
3725 * Prints the editing button on search results listing
3726 * For bulk move courses to another category
3727 * @deprecated since Moodle 2.0
3729 function update_categories_search_button($search,$page,$perpage) {
3730 throw new coding_exception('update_categories_search_button() has been completely deprecated.');
3734 * Prints a summary of a user in a nice little box.
3735 * @deprecated since Moodle 2.0
3737 function print_user($user, $course, $messageselect=false, $return=false) {
3738 throw new coding_exception('print_user() has been completely deprecated. See user/index.php for new usage.');
3742 * Returns a turn edit on/off button for course in a self contained form.
3743 * Used to be an icon, but it's now a simple form button
3745 * Note that the caller is responsible for capchecks.
3747 * @global object
3748 * @global object
3749 * @param int $courseid The course to update by id as found in 'course' table
3750 * @return string
3752 function update_course_icon($courseid) {
3753 global $CFG, $OUTPUT;
3755 debugging('update_course_button() has been deprecated. Please change your code to use $OUTPUT->edit_button(moodle_url).');
3757 return $OUTPUT->edit_button(new moodle_url('/course/view.php', array('id' => $courseid)));
3761 * Prints breadcrumb trail of links, called in theme/-/header.html
3763 * This function has now been deprecated please use output's navbar method instead
3764 * as shown below
3766 * <code php>
3767 * echo $OUTPUT->navbar();
3768 * </code>
3770 * @deprecated since 2.0
3771 * @param mixed $navigation deprecated
3772 * @param string $separator OBSOLETE, and now deprecated
3773 * @param boolean $return False to echo the breadcrumb string (default), true to return it.
3774 * @return string|void String or null, depending on $return.
3776 function print_navigation ($navigation, $separator=0, $return=false) {
3777 global $OUTPUT,$PAGE;
3779 # debugging('print_navigation has been deprecated please update your theme to use $OUTPUT->navbar() instead', DEBUG_DEVELOPER);
3781 $output = $OUTPUT->navbar();
3783 if ($return) {
3784 return $output;
3785 } else {
3786 echo $output;
3791 * This function will build the navigation string to be used by print_header
3792 * and others.
3794 * It automatically generates the site and course level (if appropriate) links.
3796 * If you pass in a $cm object, the method will also generate the activity (e.g. 'Forums')
3797 * and activityinstances (e.g. 'General Developer Forum') navigation levels.
3799 * If you want to add any further navigation links after the ones this function generates,
3800 * the pass an array of extra link arrays like this:
3801 * array(
3802 * array('name' => $linktext1, 'link' => $url1, 'type' => $linktype1),
3803 * array('name' => $linktext2, 'link' => $url2, 'type' => $linktype2)
3805 * The normal case is to just add one further link, for example 'Editing forum' after
3806 * 'General Developer Forum', with no link.
3807 * To do that, you need to pass
3808 * array(array('name' => $linktext, 'link' => '', 'type' => 'title'))
3809 * However, becuase this is a very common case, you can use a shortcut syntax, and just
3810 * pass the string 'Editing forum', instead of an array as $extranavlinks.
3812 * At the moment, the link types only have limited significance. Type 'activity' is
3813 * recognised in order to implement the $CFG->hideactivitytypenavlink feature. Types
3814 * that are known to appear are 'home', 'course', 'activity', 'activityinstance' and 'title'.
3815 * This really needs to be documented better. In the mean time, try to be consistent, it will
3816 * enable people to customise the navigation more in future.
3818 * When passing a $cm object, the fields used are $cm->modname, $cm->name and $cm->course.
3819 * If you get the $cm object using the function get_coursemodule_from_instance or
3820 * get_coursemodule_from_id (as recommended) then this will be done for you automatically.
3821 * If you don't have $cm->modname or $cm->name, this fuction will attempt to find them using
3822 * the $cm->module and $cm->instance fields, but this takes extra database queries, so a
3823 * warning is printed in developer debug mode.
3825 * @deprecated since 2.0
3826 * @param mixed $extranavlinks - Normally an array of arrays, keys: name, link, type. If you
3827 * only want one extra item with no link, you can pass a string instead. If you don't want
3828 * any extra links, pass an empty string.
3829 * @param mixed $cm deprecated
3830 * @return array Navigation array
3832 function build_navigation($extranavlinks, $cm = null) {
3833 global $CFG, $COURSE, $DB, $SITE, $PAGE;
3835 if (is_array($extranavlinks) && count($extranavlinks)>0) {
3836 # debugging('build_navigation() has been deprecated, please replace with $PAGE->navbar methods', DEBUG_DEVELOPER);
3837 foreach ($extranavlinks as $nav) {
3838 if (array_key_exists('name', $nav)) {
3839 if (array_key_exists('link', $nav) && !empty($nav['link'])) {
3840 $link = $nav['link'];
3841 } else {
3842 $link = null;
3844 $PAGE->navbar->add($nav['name'],$link);
3849 return(array('newnav' => true, 'navlinks' => array()));
3853 * Returns a small popup menu of course activity modules
3855 * Given a course and a (current) coursemodule
3856 * his function returns a small popup menu with all the
3857 * course activity modules in it, as a navigation menu
3858 * The data is taken from the serialised array stored in
3859 * the course record
3861 * @global object
3862 * @global object
3863 * @global object
3864 * @global object
3865 * @uses CONTEXT_COURSE
3866 * @param object $course A {@link $COURSE} object.
3867 * @param object $cm A {@link $COURSE} object.
3868 * @param string $targetwindow The target window attribute to us
3869 * @return string
3871 function navmenu($course, $cm=NULL, $targetwindow='self') {
3872 // This function has been deprecated with the creation of the global nav in
3873 // moodle 2.0
3875 return '';
3879 * Returns a little popup menu for switching roles
3881 * @deprecated in Moodle 2.0
3882 * @param int $courseid The course to update by id as found in 'course' table
3883 * @return string
3885 function switchroles_form($courseid) {
3886 debugging('switchroles_form() has been deprecated and replaced by an item in the global settings block');
3887 return '';
3891 * Print header for admin page
3892 * @deprecated since Moodle 20. Please use normal $OUTPUT->header() instead
3893 * @param string $focus focus element
3895 function admin_externalpage_print_header($focus='') {
3896 global $OUTPUT;
3898 debugging('admin_externalpage_print_header is deprecated. Please $OUTPUT->header() instead.', DEBUG_DEVELOPER);
3900 echo $OUTPUT->header();
3904 * @deprecated since Moodle 1.9. Please use normal $OUTPUT->footer() instead
3906 function admin_externalpage_print_footer() {
3907 // TODO Still 103 referernces in core code. Don't do debugging output yet.
3908 debugging('admin_externalpage_print_footer is deprecated. Please $OUTPUT->footer() instead.', DEBUG_DEVELOPER);
3909 global $OUTPUT;
3910 echo $OUTPUT->footer();
3913 /// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
3917 * Call this function to add an event to the calendar table and to call any calendar plugins
3919 * @param object $event An object representing an event from the calendar table.
3920 * The event will be identified by the id field. The object event should include the following:
3921 * <ul>
3922 * <li><b>$event->name</b> - Name for the event
3923 * <li><b>$event->description</b> - Description of the event (defaults to '')
3924 * <li><b>$event->format</b> - Format for the description (using formatting types defined at the top of weblib.php)
3925 * <li><b>$event->courseid</b> - The id of the course this event belongs to (0 = all courses)
3926 * <li><b>$event->groupid</b> - The id of the group this event belongs to (0 = no group)
3927 * <li><b>$event->userid</b> - The id of the user this event belongs to (0 = no user)
3928 * <li><b>$event->modulename</b> - Name of the module that creates this event
3929 * <li><b>$event->instance</b> - Instance of the module that owns this event
3930 * <li><b>$event->eventtype</b> - The type info together with the module info could
3931 * be used by calendar plugins to decide how to display event
3932 * <li><b>$event->timestart</b>- Timestamp for start of event
3933 * <li><b>$event->timeduration</b> - Duration (defaults to zero)
3934 * <li><b>$event->visible</b> - 0 if the event should be hidden (e.g. because the activity that created it is hidden)
3935 * </ul>
3936 * @return int|false The id number of the resulting record or false if failed
3938 function add_event($event) {
3939 global $CFG;
3940 require_once($CFG->dirroot.'/calendar/lib.php');
3941 $event = calendar_event::create($event);
3942 if ($event !== false) {
3943 return $event->id;
3945 return false;
3949 * Call this function to update an event in the calendar table
3950 * the event will be identified by the id field of the $event object.
3952 * @param object $event An object representing an event from the calendar table. The event will be identified by the id field.
3953 * @return bool Success
3955 function update_event($event) {
3956 global $CFG;
3957 require_once($CFG->dirroot.'/calendar/lib.php');
3958 $event = (object)$event;
3959 $calendarevent = calendar_event::load($event->id);
3960 return $calendarevent->update($event);
3964 * Call this function to delete the event with id $id from calendar table.
3966 * @param int $id The id of an event from the 'event' table.
3967 * @return bool
3969 function delete_event($id) {
3970 global $CFG;
3971 require_once($CFG->dirroot.'/calendar/lib.php');
3972 $event = calendar_event::load($id);
3973 return $event->delete();
3977 * Call this function to hide an event in the calendar table
3978 * the event will be identified by the id field of the $event object.
3980 * @param object $event An object representing an event from the calendar table. The event will be identified by the id field.
3981 * @return true
3983 function hide_event($event) {
3984 global $CFG;
3985 require_once($CFG->dirroot.'/calendar/lib.php');
3986 $event = new calendar_event($event);
3987 return $event->toggle_visibility(false);
3991 * Call this function to unhide an event in the calendar table
3992 * the event will be identified by the id field of the $event object.
3994 * @param object $event An object representing an event from the calendar table. The event will be identified by the id field.
3995 * @return true
3997 function show_event($event) {
3998 global $CFG;
3999 require_once($CFG->dirroot.'/calendar/lib.php');
4000 $event = new calendar_event($event);
4001 return $event->toggle_visibility(true);