|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00031 defined('MOODLE_INTERNAL') || die(); 00032 00038 function sid_ob_rewrite($buffer) { 00039 throw new coding_exception('$CFG->usesid support was removed completely and can not be used.'); 00040 } 00041 00054 function update_log_display_entry($module, $action, $mtable, $field) { 00055 global $DB; 00056 00057 debugging('The update_log_display_entry() is deprecated, please use db/log.php description file instead.'); 00058 } 00059 00071 function filter_text($text, $courseid = NULL) { 00072 global $CFG, $COURSE; 00073 00074 if (!$courseid) { 00075 $courseid = $COURSE->id; 00076 } 00077 00078 if (!$context = get_context_instance(CONTEXT_COURSE, $courseid)) { 00079 return $text; 00080 } 00081 00082 return filter_manager::instance()->filter_text($text, $context); 00083 } 00084 00093 function httpsrequired() { 00094 global $PAGE; 00095 $PAGE->https_required(); 00096 } 00097 00108 function get_file_url($path, $options=null, $type='coursefile') { 00109 global $CFG; 00110 00111 $path = str_replace('//', '/', $path); 00112 $path = trim($path, '/'); // no leading and trailing slashes 00113 00114 // type of file 00115 switch ($type) { 00116 case 'questionfile': 00117 $url = $CFG->wwwroot."/question/exportfile.php"; 00118 break; 00119 case 'rssfile': 00120 $url = $CFG->wwwroot."/rss/file.php"; 00121 break; 00122 case 'httpscoursefile': 00123 $url = $CFG->httpswwwroot."/file.php"; 00124 break; 00125 case 'coursefile': 00126 default: 00127 $url = $CFG->wwwroot."/file.php"; 00128 } 00129 00130 if ($CFG->slasharguments) { 00131 $parts = explode('/', $path); 00132 foreach ($parts as $key => $part) { 00134 $subparts = explode('#', $part); 00135 $subparts = array_map('rawurlencode', $subparts); 00136 $parts[$key] = implode('#', $subparts); 00137 } 00138 $path = implode('/', $parts); 00139 $ffurl = $url.'/'.$path; 00140 $separator = '?'; 00141 } else { 00142 $path = rawurlencode('/'.$path); 00143 $ffurl = $url.'?file='.$path; 00144 $separator = '&'; 00145 } 00146 00147 if ($options) { 00148 foreach ($options as $name=>$value) { 00149 $ffurl = $ffurl.$separator.$name.'='.$value; 00150 $separator = '&'; 00151 } 00152 } 00153 00154 return $ffurl; 00155 } 00156 00162 function print_file_upload_error($filearray = '', $returnerror = false) { 00163 throw new coding_exception('print_file_upload_error() can not be used any more, please use new file API'); 00164 } 00165 00171 function resolve_filename_collisions($destination,$files,$format='%s_%d.%s') { 00172 throw new coding_exception('resolve_filename_collisions() can not be used any more, please use new file API'); 00173 } 00174 00179 function check_potential_filename($destination,$filename,$files) { 00180 throw new coding_exception('check_potential_filename() can not be used any more, please use new file API'); 00181 } 00182 00187 function upload_print_form_fragment($numfiles=1, $names=null, $descriptions=null, $uselabels=false, $labelnames=null, $coursebytes=0, $modbytes=0, $return=false) { 00188 throw new coding_exception('upload_print_form_fragment() can not be used any more, please use new file API'); 00189 } 00190 00197 function auth_get_plugin_title($authtype) { 00198 debugging('Function auth_get_plugin_title() is deprecated, please use standard get_string("pluginname", "auth_'.$authtype.'")!'); 00199 return get_string('pluginname', "auth_{$authtype}"); 00200 } 00201 00202 00203 00208 function enrol_into_course($course, $user, $enrol) { 00209 error('Function enrol_into_course() was removed, please use new enrol plugins instead!'); 00210 } 00211 00219 function get_default_course_role($course) { 00220 debugging('Function get_default_course_role() is deprecated, please use individual enrol plugin settings instead!'); 00221 00222 $student = get_archetype_roles('student'); 00223 $student = reset($student); 00224 00225 return $student; 00226 } 00227 00232 function get_my_courses($userid, $sort='visible DESC,sortorder ASC', $fields=NULL, $doanything=false,$limit=0) { 00233 error('Function get_my_courses() was removed, please use new enrol_get_my_courses() or enrol_get_users_courses()!'); 00234 } 00235 00244 function get_list_of_languages($refreshcache=false, $returnall=false) { 00245 debugging('get_list_of_languages() is deprecated, please use get_string_manager()->get_list_of_translations() instead.'); 00246 if ($refreshcache) { 00247 get_string_manager()->reset_caches(); 00248 } 00249 return get_string_manager()->get_list_of_translations($returnall); 00250 } 00251 00257 function get_list_of_currencies() { 00258 debugging('get_list_of_currencies() is deprecated, please use get_string_manager()->get_list_of_currencies() instead.'); 00259 return get_string_manager()->get_list_of_currencies(); 00260 } 00261 00267 function get_list_of_countries() { 00268 debugging('get_list_of_countries() is deprecated, please use get_string_manager()->get_list_of_countries() instead.'); 00269 return get_string_manager()->get_list_of_countries(false); 00270 } 00271 00275 function isteacher() { 00276 error('Function isteacher() was removed, please use capabilities instead!'); 00277 } 00278 00282 function isteacherinanycourse() { 00283 throw new coding_Exception('Function isteacherinanycourse() was removed, please use capabilities instead!'); 00284 } 00285 00289 function get_guest() { 00290 throw new coding_Exception('Function get_guest() was removed, please use capabilities instead!'); 00291 } 00292 00296 function isguest() { 00297 throw new coding_Exception('Function isguest() was removed, please use capabilities instead!'); 00298 } 00299 00303 function get_teacher() { 00304 throw new coding_Exception('Function get_teacher() was removed, please use capabilities instead!'); 00305 } 00306 00314 function get_course_participants($courseid) { 00315 return get_enrolled_users(get_context_instance(CONTEXT_COURSE, $courseid)); 00316 } 00317 00326 function is_course_participant($userid, $courseid) { 00327 return is_enrolled(get_context_instance(CONTEXT_COURSE, $courseid), $userid); 00328 } 00329 00341 function get_recent_enrolments($courseid, $timestart) { 00342 global $DB; 00343 00344 $context = get_context_instance(CONTEXT_COURSE, $courseid); 00345 00346 $sql = "SELECT u.id, u.firstname, u.lastname, MAX(l.time) 00347 FROM {user} u, {role_assignments} ra, {log} l 00348 WHERE l.time > ? 00349 AND l.course = ? 00350 AND l.module = 'course' 00351 AND l.action = 'enrol' 00352 AND ".$DB->sql_cast_char2int('l.info')." = u.id 00353 AND u.id = ra.userid 00354 AND ra.contextid ".get_related_contexts_string($context)." 00355 GROUP BY u.id, u.firstname, u.lastname 00356 ORDER BY MAX(l.time) ASC"; 00357 $params = array($timestart, $courseid); 00358 return $DB->get_records_sql($sql, $params); 00359 } 00360 00361 00373 function make_context_subobj($rec) { 00374 throw new coding_Exception('make_context_subobj() was removed, use new context preloading'); 00375 } 00376 00389 function is_context_subobj_valid($rec, $contextlevel) { 00390 throw new coding_Exception('is_context_subobj_valid() was removed, use new context preloading'); 00391 } 00392 00406 function ensure_context_subobj_present(&$rec, $contextlevel) { 00407 throw new coding_Exception('ensure_context_subobj_present() was removed, use new context preloading'); 00408 } 00409 00410 ########### FROM weblib.php ########################################################################## 00411 00412 00430 function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) { 00431 $output = ''; 00432 $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true); 00433 $output .= $message; 00434 $output .= print_simple_box_end(true); 00435 00436 if ($return) { 00437 return $output; 00438 } else { 00439 echo $output; 00440 } 00441 } 00442 00443 00444 00459 function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) { 00460 debugging('print_simple_box(_start/_end) is deprecated. Please use $OUTPUT->box(_start/_end) instead', DEBUG_DEVELOPER); 00461 00462 $output = ''; 00463 00464 $divclasses = 'box '.$class.' '.$class.'content'; 00465 $divstyles = ''; 00466 00467 if ($align) { 00468 $divclasses .= ' boxalign'.$align; // Implement alignment using a class 00469 } 00470 if ($width) { // Hopefully we can eliminate these in calls to this function (inline styles are bad) 00471 if (substr($width, -1, 1) == '%') { // Width is a % value 00472 $width = (int) substr($width, 0, -1); // Extract just the number 00473 if ($width < 40) { 00474 $divclasses .= ' boxwidthnarrow'; // Approx 30% depending on theme 00475 } else if ($width > 60) { 00476 $divclasses .= ' boxwidthwide'; // Approx 80% depending on theme 00477 } else { 00478 $divclasses .= ' boxwidthnormal'; // Approx 50% depending on theme 00479 } 00480 } else { 00481 $divstyles .= ' width:'.$width.';'; // Last resort 00482 } 00483 } 00484 if ($color) { // Hopefully we can eliminate these in calls to this function (inline styles are bad) 00485 $divstyles .= ' background:'.$color.';'; 00486 } 00487 if ($divstyles) { 00488 $divstyles = ' style="'.$divstyles.'"'; 00489 } 00490 00491 if ($id) { 00492 $id = ' id="'.$id.'"'; 00493 } 00494 00495 $output .= '<div'.$id.$divstyles.' class="'.$divclasses.'">'; 00496 00497 if ($return) { 00498 return $output; 00499 } else { 00500 echo $output; 00501 } 00502 } 00503 00504 00512 function print_simple_box_end($return=false) { 00513 $output = '</div>'; 00514 if ($return) { 00515 return $output; 00516 } else { 00517 echo $output; 00518 } 00519 } 00520 00528 function convert_urls_into_links($text) { 00529 debugging('convert_urls_into_links() has been deprecated and replaced by a new filter'); 00530 } 00531 00538 function get_emoticons_list_for_help_file() { 00539 debugging('get_emoticons_list_for_help_file() has been deprecated, see the new emoticon_manager API'); 00540 return ''; 00541 } 00542 00548 function replace_smilies(&$text) { 00549 debugging('replace_smilies() has been deprecated and replaced with the new filter_emoticon'); 00550 } 00551 00562 function detect_munged_arguments($string, $allowdots=1) { 00563 if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references 00564 return true; 00565 } 00566 if (preg_match('/[\|\`]/', $string)) { // check for other bad characters 00567 return true; 00568 } 00569 if (empty($string) or $string == '/') { 00570 return true; 00571 } 00572 00573 return false; 00574 } 00575 00576 00588 function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) { 00589 global $CFG; 00590 00591 //Extract everything from zipfile 00592 $path_parts = pathinfo(cleardoubleslashes($zipfile)); 00593 $zippath = $path_parts["dirname"]; //The path of the zip file 00594 $zipfilename = $path_parts["basename"]; //The name of the zip file 00595 $extension = $path_parts["extension"]; //The extension of the file 00596 00597 //If no file, error 00598 if (empty($zipfilename)) { 00599 return false; 00600 } 00601 00602 //If no extension, error 00603 if (empty($extension)) { 00604 return false; 00605 } 00606 00607 //Clear $zipfile 00608 $zipfile = cleardoubleslashes($zipfile); 00609 00610 //Check zipfile exists 00611 if (!file_exists($zipfile)) { 00612 return false; 00613 } 00614 00615 //If no destination, passed let's go with the same directory 00616 if (empty($destination)) { 00617 $destination = $zippath; 00618 } 00619 00620 //Clear $destination 00621 $destpath = rtrim(cleardoubleslashes($destination), "/"); 00622 00623 //Check destination path exists 00624 if (!is_dir($destpath)) { 00625 return false; 00626 } 00627 00628 $packer = get_file_packer('application/zip'); 00629 00630 $result = $packer->extract_to_pathname($zipfile, $destpath); 00631 00632 if ($result === false) { 00633 return false; 00634 } 00635 00636 foreach ($result as $status) { 00637 if ($status !== true) { 00638 return false; 00639 } 00640 } 00641 00642 return true; 00643 } 00644 00654 function zip_files ($originalfiles, $destination) { 00655 global $CFG; 00656 00657 //Extract everything from destination 00658 $path_parts = pathinfo(cleardoubleslashes($destination)); 00659 $destpath = $path_parts["dirname"]; //The path of the zip file 00660 $destfilename = $path_parts["basename"]; //The name of the zip file 00661 $extension = $path_parts["extension"]; //The extension of the file 00662 00663 //If no file, error 00664 if (empty($destfilename)) { 00665 return false; 00666 } 00667 00668 //If no extension, add it 00669 if (empty($extension)) { 00670 $extension = 'zip'; 00671 $destfilename = $destfilename.'.'.$extension; 00672 } 00673 00674 //Check destination path exists 00675 if (!is_dir($destpath)) { 00676 return false; 00677 } 00678 00679 //Check destination path is writable. TODO!! 00680 00681 //Clean destination filename 00682 $destfilename = clean_filename($destfilename); 00683 00684 //Now check and prepare every file 00685 $files = array(); 00686 $origpath = NULL; 00687 00688 foreach ($originalfiles as $file) { //Iterate over each file 00689 //Check for every file 00690 $tempfile = cleardoubleslashes($file); // no doubleslashes! 00691 //Calculate the base path for all files if it isn't set 00692 if ($origpath === NULL) { 00693 $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/"); 00694 } 00695 //See if the file is readable 00696 if (!is_readable($tempfile)) { //Is readable 00697 continue; 00698 } 00699 //See if the file/dir is in the same directory than the rest 00700 if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) { 00701 continue; 00702 } 00703 //Add the file to the array 00704 $files[] = $tempfile; 00705 } 00706 00707 $zipfiles = array(); 00708 $start = strlen($origpath)+1; 00709 foreach($files as $file) { 00710 $zipfiles[substr($file, $start)] = $file; 00711 } 00712 00713 $packer = get_file_packer('application/zip'); 00714 00715 return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename); 00716 } 00717 00721 00722 00734 function mygroupid($courseid) { 00735 global $USER; 00736 if ($groups = groups_get_all_groups($courseid, $USER->id)) { 00737 return array_keys($groups); 00738 } else { 00739 return false; 00740 } 00741 } 00742 00743 00753 function groupmode($course, $cm=null) { 00754 00755 if (isset($cm->groupmode) && empty($course->groupmodeforce)) { 00756 return $cm->groupmode; 00757 } 00758 return $course->groupmode; 00759 } 00760 00773 function set_current_group($courseid, $groupid) { 00774 global $SESSION; 00775 return $SESSION->currentgroup[$courseid] = $groupid; 00776 } 00777 00778 00789 function get_current_group($courseid, $full = false) { 00790 global $SESSION; 00791 00792 if (isset($SESSION->currentgroup[$courseid])) { 00793 if ($full) { 00794 return groups_get_group($SESSION->currentgroup[$courseid]); 00795 } else { 00796 return $SESSION->currentgroup[$courseid]; 00797 } 00798 } 00799 00800 $mygroupid = mygroupid($courseid); 00801 if (is_array($mygroupid)) { 00802 $mygroupid = array_shift($mygroupid); 00803 set_current_group($courseid, $mygroupid); 00804 if ($full) { 00805 return groups_get_group($mygroupid); 00806 } else { 00807 return $mygroupid; 00808 } 00809 } 00810 00811 if ($full) { 00812 return false; 00813 } else { 00814 return 0; 00815 } 00816 } 00817 00818 00830 function error($message, $link='') { 00831 throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a deprecated function, please call print_error() instead of error()'); 00832 } 00833 00834 00836 00842 function table_exists($table) { 00843 global $DB; 00844 debugging('Deprecated ddllib function used!'); 00845 return $DB->get_manager()->table_exists($table); 00846 } 00847 00855 function field_exists($table, $field) { 00856 global $DB; 00857 debugging('Deprecated ddllib function used!'); 00858 return $DB->get_manager()->field_exists($table, $field); 00859 } 00860 00868 function find_index_name($table, $index) { 00869 global $DB; 00870 debugging('Deprecated ddllib function used!'); 00871 return $DB->get_manager()->find_index_name($table, $index); 00872 } 00873 00881 function index_exists($table, $index) { 00882 global $DB; 00883 debugging('Deprecated ddllib function used!'); 00884 return $DB->get_manager()->index_exists($table, $index); 00885 } 00886 00894 function find_check_constraint_name($table, $field) { 00895 global $DB; 00896 debugging('Deprecated ddllib function used!'); 00897 return $DB->get_manager()->find_check_constraint_name($table, $field); 00898 } 00899 00904 function check_constraint_exists($table, $field) { 00905 global $DB; 00906 debugging('Deprecated ddllib function used!'); 00907 return $DB->get_manager()->check_constraint_exists($table, $field); 00908 } 00909 00917 function find_key_name($table, $xmldb_key) { 00918 global $DB; 00919 debugging('Deprecated ddllib function used!'); 00920 return $DB->get_manager()->find_key_name($table, $xmldb_key); 00921 } 00922 00929 function drop_table($table) { 00930 global $DB; 00931 debugging('Deprecated ddllib function used!'); 00932 $DB->get_manager()->drop_table($table); 00933 return true; 00934 } 00935 00942 function install_from_xmldb_file($file) { 00943 global $DB; 00944 debugging('Deprecated ddllib function used!'); 00945 $DB->get_manager()->install_from_xmldb_file($file); 00946 return true; 00947 } 00948 00955 function create_table($table) { 00956 global $DB; 00957 debugging('Deprecated ddllib function used!'); 00958 $DB->get_manager()->create_table($table); 00959 return true; 00960 } 00961 00968 function create_temp_table($table) { 00969 global $DB; 00970 debugging('Deprecated ddllib function used!'); 00971 $DB->get_manager()->create_temp_table($table); 00972 return true; 00973 } 00974 00982 function rename_table($table, $newname) { 00983 global $DB; 00984 debugging('Deprecated ddllib function used!'); 00985 $DB->get_manager()->rename_table($table, $newname); 00986 return true; 00987 } 00988 00996 function add_field($table, $field) { 00997 global $DB; 00998 debugging('Deprecated ddllib function used!'); 00999 $DB->get_manager()->add_field($table, $field); 01000 return true; 01001 } 01002 01010 function drop_field($table, $field) { 01011 global $DB; 01012 debugging('Deprecated ddllib function used!'); 01013 $DB->get_manager()->drop_field($table, $field); 01014 return true; 01015 } 01016 01024 function change_field_type($table, $field) { 01025 global $DB; 01026 debugging('Deprecated ddllib function used!'); 01027 $DB->get_manager()->change_field_type($table, $field); 01028 return true; 01029 } 01030 01038 function change_field_precision($table, $field) { 01039 global $DB; 01040 debugging('Deprecated ddllib function used!'); 01041 $DB->get_manager()->change_field_precision($table, $field); 01042 return true; 01043 } 01044 01052 function change_field_unsigned($table, $field) { 01053 global $DB; 01054 debugging('Deprecated ddllib function used!'); 01055 $DB->get_manager()->change_field_unsigned($table, $field); 01056 return true; 01057 } 01058 01066 function change_field_notnull($table, $field) { 01067 global $DB; 01068 debugging('Deprecated ddllib function used!'); 01069 $DB->get_manager()->change_field_notnull($table, $field); 01070 return true; 01071 } 01072 01080 function change_field_enum($table, $field) { 01081 global $DB; 01082 debugging('Deprecated ddllib function used! Only dropping of enums is allowed.'); 01083 $DB->get_manager()->drop_enum_from_field($table, $field); 01084 return true; 01085 } 01086 01094 function change_field_default($table, $field) { 01095 global $DB; 01096 debugging('Deprecated ddllib function used!'); 01097 $DB->get_manager()->change_field_default($table, $field); 01098 return true; 01099 } 01100 01109 function rename_field($table, $field, $newname) { 01110 global $DB; 01111 debugging('Deprecated ddllib function used!'); 01112 $DB->get_manager()->rename_field($table, $field, $newname); 01113 return true; 01114 } 01115 01123 function add_key($table, $key) { 01124 global $DB; 01125 debugging('Deprecated ddllib function used!'); 01126 $DB->get_manager()->add_key($table, $key); 01127 return true; 01128 } 01129 01137 function drop_key($table, $key) { 01138 global $DB; 01139 debugging('Deprecated ddllib function used!'); 01140 $DB->get_manager()->drop_key($table, $key); 01141 return true; 01142 } 01143 01152 function rename_key($table, $key, $newname) { 01153 global $DB; 01154 debugging('Deprecated ddllib function used!'); 01155 $DB->get_manager()->rename_key($table, $key, $newname); 01156 return true; 01157 } 01158 01166 function add_index($table, $index) { 01167 global $DB; 01168 debugging('Deprecated ddllib function used!'); 01169 $DB->get_manager()->add_index($table, $index); 01170 return true; 01171 } 01172 01180 function drop_index($table, $index) { 01181 global $DB; 01182 debugging('Deprecated ddllib function used!'); 01183 $DB->get_manager()->drop_index($table, $index); 01184 return true; 01185 } 01186 01195 function rename_index($table, $index, $newname) { 01196 global $DB; 01197 debugging('Deprecated ddllib function used!'); 01198 $DB->get_manager()->rename_index($table, $index, $newname); 01199 return true; 01200 } 01201 01202 01206 01212 function stripslashes_safe($mixed) { 01213 error('stripslashes_safe() not available anymore'); 01214 } 01220 function stripslashes_recursive($var) { 01221 error('stripslashes_recursive() not available anymore'); 01222 } 01228 function addslashes_object($dataobject) { 01229 error('addslashes_object() not available anymore'); 01230 } 01236 function addslashes_recursive($var) { 01237 error('addslashes_recursive() not available anymore'); 01238 } 01245 function execute_sql($command, $feedback=true) { 01246 error('execute_sql() not available anymore'); 01247 } 01255 function record_exists_select($table, $select='') { 01256 error('record_exists_select() not available anymore'); 01257 } 01264 function record_exists_sql($sql) { 01265 error('record_exists_sql() not available anymore'); 01266 } 01275 function count_records_select($table, $select='', $countitem='COUNT(*)') { 01276 error('count_records_select() not available anymore'); 01277 } 01284 function count_records_sql($sql) { 01285 error('count_records_sql() not available anymore'); 01286 } 01295 function get_record_sql($sql, $expectmultiple=false, $nolimit=false) { 01296 error('get_record_sql() not available anymore'); 01297 } 01306 function get_record_select($table, $select='', $fields='*') { 01307 error('get_record_select() not available anymore'); 01308 } 01321 function get_recordset($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01322 error('get_recordset() not available anymore'); 01323 } 01332 function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) { 01333 error('get_recordset_sql() not available anymore'); 01334 } 01340 function rs_fetch_record(&$rs) { 01341 error('rs_fetch_record() not available anymore'); 01342 } 01348 function rs_next_record(&$rs) { 01349 error('rs_next_record() not available anymore'); 01350 } 01356 function rs_fetch_next_record(&$rs) { 01357 error('rs_fetch_next_record() not available anymore'); 01358 } 01364 function rs_EOF($rs) { 01365 error('rs_EOF() not available anymore'); 01366 } 01372 function rs_close(&$rs) { 01373 error('rs_close() not available anymore'); 01374 } 01386 function get_records_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01387 error('get_records_select() not available anymore'); 01388 } 01397 function get_field_select($table, $return, $select) { 01398 error('get_field_select() not available anymore'); 01399 } 01406 function get_field_sql($sql) { 01407 error('get_field_sql() not available anymore'); 01408 } 01416 function delete_records_select($table, $select='') { 01417 error('get_field_sql() not available anymore'); 01418 } 01423 function configure_dbconnection() { 01424 error('configure_dbconnection() removed'); 01425 } 01431 function sql_max($field) { 01432 error('sql_max() removed - use normal sql MAX() instead'); 01433 } 01438 function sql_as() { 01439 error('sql_as() removed - do not use AS for tables at all'); 01440 } 01447 function sql_paging_limit($page, $recordsperpage) { 01448 error('Function sql_paging_limit() is deprecated. Replace it with the correct use of limitfrom, limitnum parameters'); 01449 } 01454 function db_uppercase() { 01455 error('upper() removed - use normal sql UPPER()'); 01456 } 01461 function db_lowercase() { 01462 error('upper() removed - use normal sql LOWER()'); 01463 } 01470 function modify_database($sqlfile='', $sqlstring='') { 01471 error('modify_database() removed - use new XMLDB functions'); 01472 } 01483 function where_clause($field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { 01484 error('where_clause() removed - use new functions with $conditions parameter'); 01485 } 01493 function execute_sql_arr($sqlarr, $continue=true, $feedback=true) { 01494 error('execute_sql_arr() removed'); 01495 } 01508 function get_records_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01509 error('get_records_list() removed'); 01510 } 01523 function get_recordset_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01524 error('get_recordset_list() removed'); 01525 } 01538 function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01539 error('get_records_menu() removed'); 01540 } 01552 function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01553 error('get_records_select_menu() removed'); 01554 } 01563 function get_records_sql_menu($sql, $limitfrom='', $limitnum='') { 01564 error('get_records_sql_menu() removed'); 01565 } 01572 function column_type($table, $column) { 01573 error('column_type() removed'); 01574 } 01580 function recordset_to_menu($rs) { 01581 error('recordset_to_menu() removed'); 01582 } 01590 function records_to_menu($records, $field1, $field2) { 01591 error('records_to_menu() removed'); 01592 } 01603 function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) { 01604 error('set_field_select() removed'); 01605 } 01614 function get_fieldset_select($table, $return, $select) { 01615 error('get_fieldset_select() removed'); 01616 } 01623 function get_fieldset_sql($sql) { 01624 error('get_fieldset_sql() removed'); 01625 } 01631 function sql_ilike() { 01632 error('sql_ilike() not available anymore'); 01633 } 01640 function sql_fullname($first='firstname', $last='lastname') { 01641 error('sql_fullname() not available anymore'); 01642 } 01647 function sql_concat() { 01648 error('sql_concat() not available anymore'); 01649 } 01654 function sql_empty() { 01655 error('sql_empty() not available anymore'); 01656 } 01661 function sql_substr() { 01662 error('sql_substr() not available anymore'); 01663 } 01670 function sql_bitand($int1, $int2) { 01671 error('sql_bitand() not available anymore'); 01672 } 01678 function sql_bitnot($int1) { 01679 error('sql_bitnot() not available anymore'); 01680 } 01687 function sql_bitor($int1, $int2) { 01688 error('sql_bitor() not available anymore'); 01689 } 01696 function sql_bitxor($int1, $int2) { 01697 error('sql_bitxor() not available anymore'); 01698 } 01705 function sql_cast_char2int($fieldname, $text=false) { 01706 error('sql_cast_char2int() not available anymore'); 01707 } 01714 function sql_compare_text($fieldname, $numchars=32) { 01715 error('sql_compare_text() not available anymore'); 01716 } 01723 function sql_order_by_text($fieldname, $numchars=32) { 01724 error('sql_order_by_text() not available anymore'); 01725 } 01731 function sql_length($fieldname) { 01732 error('sql_length() not available anymore'); 01733 } 01740 function sql_concat_join($separator="' '", $elements=array()) { 01741 error('sql_concat_join() not available anymore'); 01742 } 01751 function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) { 01752 error('sql_isempty() not available anymore'); 01753 } 01762 function sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield) { 01763 error('sql_isnotempty() not available anymore'); 01764 } 01769 function begin_sql() { 01770 error('begin_sql() not available anymore'); 01771 } 01776 function commit_sql() { 01777 error('commit_sql() not available anymore'); 01778 } 01783 function rollback_sql() { 01784 error('rollback_sql() not available anymore'); 01785 } 01795 function insert_record($table, $dataobject, $returnid=true, $primarykey='id') { 01796 error('insert_record() not available anymore'); 01797 } 01805 function update_record($table, $dataobject) { 01806 error('update_record() not available anymore'); 01807 } 01821 function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { 01822 error('get_records() not available anymore'); 01823 } 01837 function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') { 01838 error('get_record() not available anymore'); 01839 } 01854 function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $value2='', $field3='', $value3='') { 01855 error('set_field() not available anymore'); 01856 } 01869 function count_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { 01870 error('count_records() not available anymore'); 01871 } 01884 function record_exists($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { 01885 error('record_exists() not available anymore'); 01886 } 01899 function delete_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { 01900 error('delete_records() not available anymore'); 01901 } 01915 function get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='') { 01916 error('get_field() not available anymore'); 01917 } 01931 function table_column($table, $oldfield, $field, $type='integer', $size='10', 01932 $signed='unsigned', $default='0', $null='not null', $after='') { 01933 error('table_column() was removed, please use new ddl functions'); 01934 } 01942 function use_html_editor($name='', $editorhidebuttons='', $id='') { 01943 error('use_html_editor() not available anymore'); 01944 } 01945 01957 function require_js($lib) { 01958 global $CFG, $PAGE; 01959 // Add the lib to the list of libs to be loaded, if it isn't already 01960 // in the list. 01961 if (is_array($lib)) { 01962 foreach($lib as $singlelib) { 01963 require_js($singlelib); 01964 } 01965 return; 01966 } 01967 01968 debugging('Call to deprecated function require_js. Please use $PAGE->requires->js_module() instead.', DEBUG_DEVELOPER); 01969 01970 if (strpos($lib, 'yui_') === 0) { 01971 $PAGE->requires->yui2_lib(substr($lib, 4)); 01972 } else { 01973 if ($PAGE->requires->is_head_done()) { 01974 echo html_writer::script('', $lib); 01975 } else { 01976 $PAGE->requires->js(new moodle_url($lib)); 01977 } 01978 } 01979 } 01980 01990 function make_mod_upload_directory($courseid) { 01991 throw new coding_exception('make_mod_upload_directory has been deprecated by the file API changes in Moodle 2.0.'); 01992 } 01993 02008 function theme_setup($theme = '', $params=NULL) { 02009 throw new coding_exception('The function theme_setup is no longer required, and should no longer be used. ' . 02010 'The current theme gets initialised automatically before it is first used.'); 02011 } 02012 02017 function current_theme() { 02018 global $PAGE; 02019 // TODO, uncomment this once we have eliminated all references to current_theme in core code. 02020 // debugging('current_theme is deprecated, use $PAGE->theme->name instead', DEBUG_DEVELOPER); 02021 return $PAGE->theme->name; 02022 } 02023 02031 function page_id_and_class(&$getid, &$getclass) { 02032 global $PAGE; 02033 debugging('Call to deprecated function page_id_and_class. Please use $PAGE->pagetype instead.', DEBUG_DEVELOPER); 02034 $getid = $PAGE->pagetype; 02035 $getclass = $PAGE->legacyclass; 02036 } 02037 02044 function formerr($error) { 02045 debugging('formerr() has been deprecated. Please change your code to use $OUTPUT->error_text($string).'); 02046 global $OUTPUT; 02047 echo $OUTPUT->error_text($error); 02048 } 02049 02059 function skip_main_destination() { 02060 global $OUTPUT; 02061 return $OUTPUT->skip_link_target(); 02062 } 02063 02073 function print_headline($text, $size=2, $return=false) { 02074 global $OUTPUT; 02075 debugging('print_headline() has been deprecated. Please change your code to use $OUTPUT->heading().'); 02076 $output = $OUTPUT->heading($text, $size); 02077 if ($return) { 02078 return $output; 02079 } else { 02080 echo $output; 02081 } 02082 } 02083 02096 function print_heading($text, $deprecated = '', $size = 2, $class = 'main', $return = false, $id = '') { 02097 global $OUTPUT; 02098 debugging('print_heading() has been deprecated. Please change your code to use $OUTPUT->heading().'); 02099 if (!empty($deprecated)) { 02100 debugging('Use of deprecated align attribute of print_heading. ' . 02101 'Please do not specify styling in PHP code like that.', DEBUG_DEVELOPER); 02102 } 02103 $output = $OUTPUT->heading($text, $size, $class, $id); 02104 if ($return) { 02105 return $output; 02106 } else { 02107 echo $output; 02108 } 02109 } 02110 02120 function print_heading_block($heading, $class='', $return=false) { 02121 global $OUTPUT; 02122 debugging('print_heading_with_block() has been deprecated. Please change your code to use $OUTPUT->heading().'); 02123 $output = $OUTPUT->heading($heading, 2, 'headingblock header ' . renderer_base::prepare_classes($class)); 02124 if ($return) { 02125 return $output; 02126 } else { 02127 echo $output; 02128 } 02129 } 02130 02142 function print_box($message, $classes='generalbox', $ids='', $return=false) { 02143 global $OUTPUT; 02144 debugging('print_box() has been deprecated. Please change your code to use $OUTPUT->box().'); 02145 $output = $OUTPUT->box($message, $classes, $ids); 02146 if ($return) { 02147 return $output; 02148 } else { 02149 echo $output; 02150 } 02151 } 02152 02163 function print_box_start($classes='generalbox', $ids='', $return=false) { 02164 global $OUTPUT; 02165 debugging('print_box_start() has been deprecated. Please change your code to use $OUTPUT->box_start().'); 02166 $output = $OUTPUT->box_start($classes, $ids); 02167 if ($return) { 02168 return $output; 02169 } else { 02170 echo $output; 02171 } 02172 } 02173 02182 function print_box_end($return=false) { 02183 global $OUTPUT; 02184 debugging('print_box_end() has been deprecated. Please change your code to use $OUTPUT->box_end().'); 02185 $output = $OUTPUT->box_end(); 02186 if ($return) { 02187 return $output; 02188 } else { 02189 echo $output; 02190 } 02191 } 02192 02204 function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) { 02205 global $OUTPUT; 02206 if ($clearfix) { 02207 $classes .= ' clearfix'; 02208 } 02209 $output = $OUTPUT->container($message, $classes, $idbase); 02210 if ($return) { 02211 return $output; 02212 } else { 02213 echo $output; 02214 } 02215 } 02216 02227 function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) { 02228 global $OUTPUT; 02229 if ($clearfix) { 02230 $classes .= ' clearfix'; 02231 } 02232 $output = $OUTPUT->container_start($classes, $idbase); 02233 if ($return) { 02234 return $output; 02235 } else { 02236 echo $output; 02237 } 02238 } 02239 02243 function check_theme_arrows() { 02244 debugging('check_theme_arrows() has been deprecated, do not use it anymore, it is now automatic.'); 02245 } 02246 02254 function print_container_end($return=false) { 02255 global $OUTPUT; 02256 $output = $OUTPUT->container_end(); 02257 if ($return) { 02258 return $output; 02259 } else { 02260 echo $output; 02261 } 02262 } 02263 02274 function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) { 02275 global $OUTPUT; 02276 02277 if ($classes == 'green') { 02278 debugging('Use of deprecated class name "green" in notify. Please change to "notifysuccess".', DEBUG_DEVELOPER); 02279 $classes = 'notifysuccess'; // Backward compatible with old color system 02280 } 02281 02282 $output = $OUTPUT->notification($message, $classes); 02283 if ($return) { 02284 return $output; 02285 } else { 02286 echo $output; 02287 } 02288 } 02289 02299 function print_continue($link, $return = false) { 02300 global $CFG, $OUTPUT; 02301 02302 if ($link == '') { 02303 if (!empty($_SERVER['HTTP_REFERER'])) { 02304 $link = $_SERVER['HTTP_REFERER']; 02305 $link = str_replace('&', '&', $link); // make it valid XHTML 02306 } else { 02307 $link = $CFG->wwwroot .'/'; 02308 } 02309 } 02310 02311 $output = $OUTPUT->continue_button($link); 02312 if ($return) { 02313 return $output; 02314 } else { 02315 echo $output; 02316 } 02317 } 02318 02335 function print_header($title='', $heading='', $navigation='', $focus='', 02336 $meta='', $cache=true, $button=' ', $menu=null, 02337 $usexml=false, $bodytags='', $return=false) { 02338 global $PAGE, $OUTPUT; 02339 02340 $PAGE->set_title($title); 02341 $PAGE->set_heading($heading); 02342 $PAGE->set_cacheable($cache); 02343 if ($button == '') { 02344 $button = ' '; 02345 } 02346 $PAGE->set_button($button); 02347 $PAGE->set_headingmenu($menu); 02348 02349 // TODO $menu 02350 02351 if ($meta) { 02352 throw new coding_exception('The $meta parameter to print_header is no longer supported. '. 02353 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.'); 02354 } 02355 if ($usexml) { 02356 throw new coding_exception('The $usexml parameter to print_header is no longer supported.'); 02357 } 02358 if ($bodytags) { 02359 throw new coding_exception('The $bodytags parameter to print_header is no longer supported.'); 02360 } 02361 02362 $output = $OUTPUT->header(); 02363 02364 if ($return) { 02365 return $output; 02366 } else { 02367 echo $output; 02368 } 02369 } 02370 02390 function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='', 02391 $cache=true, $button=' ', $menu='', $usexml=false, $bodytags='', $return=false) { 02392 02393 global $COURSE, $CFG, $PAGE, $OUTPUT; 02394 02395 if ($meta) { 02396 throw new coding_exception('The $meta parameter to print_header is no longer supported. '. 02397 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.'); 02398 } 02399 if ($usexml) { 02400 throw new coding_exception('The $usexml parameter to print_header is no longer supported.'); 02401 } 02402 if ($bodytags) { 02403 throw new coding_exception('The $bodytags parameter to print_header is no longer supported.'); 02404 } 02405 02406 $PAGE->set_title($title); 02407 $PAGE->set_heading($heading); 02408 $PAGE->set_cacheable(true); 02409 $PAGE->set_button($button); 02410 02411 $output = $OUTPUT->header(); 02412 02413 if ($return) { 02414 return $output; 02415 } else { 02416 echo $output; 02417 } 02418 } 02419 02420 function print_footer($course = NULL, $usercourse = NULL, $return = false) { 02421 global $PAGE, $OUTPUT; 02422 debugging('print_footer() has been deprecated. Please change your code to use $OUTPUT->footer().'); 02423 // TODO check arguments. 02424 if (is_string($course)) { 02425 debugging("Magic values like 'home', 'empty' passed to print_footer no longer have any effect. " . 02426 'To achieve a similar effect, call $PAGE->set_pagelayout before you call print_header.', DEBUG_DEVELOPER); 02427 } else if (!empty($course->id) && $course->id != $PAGE->course->id) { 02428 throw new coding_exception('The $course object you passed to print_footer does not match $PAGE->course.'); 02429 } 02430 if (!is_null($usercourse)) { 02431 debugging('The second parameter ($usercourse) to print_footer is no longer supported. ' . 02432 '(I did not think it was being used anywhere.)', DEBUG_DEVELOPER); 02433 } 02434 $output = $OUTPUT->footer(); 02435 if ($return) { 02436 return $output; 02437 } else { 02438 echo $output; 02439 } 02440 } 02441 02454 function user_login_string($course='ignored', $user='ignored') { 02455 debugging('user_login_info() has been deprecated. User login info is now handled via themes layouts.'); 02456 return ''; 02457 } 02458 02479 function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') { 02480 global $OUTPUT; 02481 02482 // We don't use $heading, becuse it often contains HTML that we don't want. 02483 // However, sometimes $title is not set, but $heading is. 02484 if (empty($title)) { 02485 $title = strip_tags($heading); 02486 } 02487 02488 // Render list contents to HTML if required. 02489 if (empty($content) && $list) { 02490 $content = $OUTPUT->list_block_contents($icons, $list); 02491 } 02492 02493 $bc = new block_contents(); 02494 $bc->content = $content; 02495 $bc->footer = $footer; 02496 $bc->title = $title; 02497 02498 if (isset($attributes['id'])) { 02499 $bc->id = $attributes['id']; 02500 unset($attributes['id']); 02501 } 02502 $bc->attributes = $attributes; 02503 02504 echo $OUTPUT->block($bc, BLOCK_POS_LEFT); // POS LEFT may be wrong, but no way to get a better guess here. 02505 } 02506 02520 function print_side_block_start($heading='', $attributes = array()) { 02521 throw new coding_exception('print_side_block_start has been deprecated. Please change your code to use $OUTPUT->block().'); 02522 } 02523 02533 function print_side_block_end($attributes = array(), $title='') { 02534 throw new coding_exception('print_side_block_end has been deprecated. Please change your code to use $OUTPUT->block().'); 02535 } 02536 02550 function blocks_have_content(&$blockmanager, $region) { 02551 debugging('The function blocks_have_content should no longer be used. Blocks are now printed by the theme.'); 02552 return false; 02553 } 02554 02567 function blocks_print_group($page, $blockmanager, $region) { 02568 debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.'); 02569 } 02570 02581 function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE) { 02582 debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.'); 02583 return array(BLOCK_POS_LEFT => array(), BLOCK_POS_RIGHT => array()); 02584 } 02585 02594 function blocks_preferred_width($instances) { 02595 debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.'); 02596 $width = 210; 02597 } 02598 02609 function blocks_execute_action($page, &$blockmanager, $blockaction, $instanceorid, $pinned=false, $redirect=true) { 02610 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.'); 02611 } 02612 02622 function blocks_execute_url_action(&$PAGE, &$blockmanager,$pinned=false) { 02623 throw new coding_exception('blocks_execute_url_action is no longer used. It has been replaced by methods of block_manager.'); 02624 } 02625 02637 function blocks_execute_repositioning(&$instance, $newpos, $newweight, $pinned=false) { 02638 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.'); 02639 } 02640 02641 02657 function blocks_move_block($page, &$instance, $destpos, $destweight=NULL, $pinned=false) { 02658 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.'); 02659 } 02660 02668 function print_table($table, $return=false) { 02669 global $OUTPUT; 02670 // TODO MDL-19755 turn debugging on once we migrate the current core code to use the new API 02671 debugging('print_table() has been deprecated. Please change your code to use html_writer::table().'); 02672 $newtable = new html_table(); 02673 foreach ($table as $property => $value) { 02674 if (property_exists($newtable, $property)) { 02675 $newtable->{$property} = $value; 02676 } 02677 } 02678 if (isset($table->class)) { 02679 $newtable->attributes['class'] = $table->class; 02680 } 02681 if (isset($table->rowclass) && is_array($table->rowclass)) { 02682 debugging('rowclass[] has been deprecated for html_table and should be replaced by rowclasses[]. please fix the code.'); 02683 $newtable->rowclasses = $table->rowclass; 02684 } 02685 $output = html_writer::table($newtable); 02686 if ($return) { 02687 return $output; 02688 } else { 02689 echo $output; 02690 return true; 02691 } 02692 } 02693 02712 function link_to_popup_window ($url, $name=null, $linkname=null, $height=400, $width=500, $title=null, $options=null, $return=false) { 02713 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'); 02714 02715 return html_writer::link($url, $name); 02716 } 02717 02736 function button_to_popup_window ($url, $name=null, $linkname=null, 02737 $height=400, $width=500, $title=null, $options=null, $return=false, 02738 $id=null, $class=null) { 02739 global $OUTPUT; 02740 02741 debugging('button_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->single_button().'); 02742 02743 if ($options == 'none') { 02744 $options = null; 02745 } 02746 02747 if (empty($linkname)) { 02748 throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->action_link() for usage.'); 02749 } 02750 02751 // Create a single_button object 02752 $form = new single_button($url, $linkname, 'post'); 02753 $form->button->title = $title; 02754 $form->button->id = $id; 02755 02756 // Parse the $options string 02757 $popupparams = array(); 02758 if (!empty($options)) { 02759 $optionsarray = explode(',', $options); 02760 foreach ($optionsarray as $option) { 02761 if (strstr($option, '=')) { 02762 $parts = explode('=', $option); 02763 if ($parts[1] == '0') { 02764 $popupparams[$parts[0]] = false; 02765 } else { 02766 $popupparams[$parts[0]] = $parts[1]; 02767 } 02768 } else { 02769 $popupparams[$option] = true; 02770 } 02771 } 02772 } 02773 02774 if (!empty($height)) { 02775 $popupparams['height'] = $height; 02776 } 02777 if (!empty($width)) { 02778 $popupparams['width'] = $width; 02779 } 02780 02781 $form->button->add_action(new popup_action('click', $url, $name, $popupparams)); 02782 $output = $OUTPUT->render($form); 02783 02784 if ($return) { 02785 return $output; 02786 } else { 02787 echo $output; 02788 } 02789 } 02790 02808 function print_single_button($link, $options, $label='OK', $method='get', $notusedanymore='', 02809 $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $formid = '') { 02810 global $OUTPUT; 02811 02812 debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->single_button().'); 02813 02814 // Cast $options to array 02815 $options = (array) $options; 02816 02817 $button = new single_button(new moodle_url($link, $options), $label, $method, array('disabled'=>$disabled, 'title'=>$tooltip, 'id'=>$formid)); 02818 02819 if ($jsconfirmmessage) { 02820 $button->button->add_confirm_action($jsconfirmmessage); 02821 } 02822 02823 $output = $OUTPUT->render($button); 02824 02825 if ($return) { 02826 return $output; 02827 } else { 02828 echo $output; 02829 } 02830 } 02831 02842 function print_spacer($height=1, $width=1, $br=true, $return=false) { 02843 global $CFG, $OUTPUT; 02844 02845 debugging('print_spacer() has been deprecated. Please change your code to use $OUTPUT->spacer().'); 02846 02847 $output = $OUTPUT->spacer(array('height'=>$height, 'width'=>$width, 'br'=>$br)); 02848 02849 if ($return) { 02850 return $output; 02851 } else { 02852 echo $output; 02853 } 02854 } 02855 02862 function print_file_picture($path, $courseid=0, $height='', $width='', $link='', $return=false) { 02863 throw new coding_exception('print_file_picture() has been deprecated since Moodle 2.0. Please use $OUTPUT->action_icon() instead.'); 02864 } 02865 02886 function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true) { 02887 global $OUTPUT; 02888 02889 debugging('print_user_picture() has been deprecated. Please change your code to use $OUTPUT->user_picture($user, array(\'courseid\'=>$courseid).'); 02890 02891 if (!is_object($user)) { 02892 $userid = $user; 02893 $user = new stdClass(); 02894 $user->id = $userid; 02895 } 02896 02897 if (empty($user->picture) and $picture) { 02898 $user->picture = $picture; 02899 } 02900 02901 $options = array('size'=>$size, 'link'=>$link, 'alttext'=>$alttext, 'courseid'=>$courseid, 'popup'=>!empty($target)); 02902 02903 $output = $OUTPUT->user_picture($user, $options); 02904 02905 if ($return) { 02906 return $output; 02907 } else { 02908 echo $output; 02909 } 02910 } 02911 02918 function print_png() { 02919 throw new coding_exception('print_png() has been deprecated since Moodle 2.0. Please use $OUTPUT->pix_icon() instead.'); 02920 } 02921 02922 02943 function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') { 02946 02947 // Disabling because there is not yet a viable $OUTPUT option for cases when mforms can't be used 02948 // debugging('print_textarea() has been deprecated. You should be using mforms and the editor element.'); 02949 02950 global $CFG; 02951 02952 $mincols = 65; 02953 $minrows = 10; 02954 $str = ''; 02955 02956 if ($id === '') { 02957 $id = 'edit-'.$name; 02958 } 02959 02960 if ($usehtmleditor) { 02961 if ($height && ($rows < $minrows)) { 02962 $rows = $minrows; 02963 } 02964 if ($width && ($cols < $mincols)) { 02965 $cols = $mincols; 02966 } 02967 } 02968 02969 if ($usehtmleditor) { 02970 editors_head_setup(); 02971 $editor = editors_get_preferred_editor(FORMAT_HTML); 02972 $editor->use_editor($id, array('legacy'=>true)); 02973 } else { 02974 $editorclass = ''; 02975 } 02976 02977 $str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n"; 02978 if ($usehtmleditor) { 02979 $str .= htmlspecialchars($value); // needed for editing of cleaned text! 02980 } else { 02981 $str .= s($value); 02982 } 02983 $str .= '</textarea>'."\n"; 02984 02985 if ($return) { 02986 return $str; 02987 } 02988 echo $str; 02989 } 02990 02991 03009 function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false, $imagetext='') { 03010 debugging('helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_icon().'); 03011 03012 global $OUTPUT; 03013 03014 $output = $OUTPUT->old_help_icon($page, $title, $module, $linktext); 03015 03016 // hide image with CSS if needed 03017 03018 if ($return) { 03019 return $output; 03020 } else { 03021 echo $output; 03022 } 03023 } 03024 03039 function emoticonhelpbutton($form, $field, $return = false) { 03041 03042 debugging('emoticonhelpbutton() was removed, new text editors will implement this feature'); 03043 } 03044 03055 function editorhelpbutton(){ 03056 return ''; 03057 03059 } 03060 03070 function editorshortcutshelpbutton() { 03072 03073 global $CFG; 03074 //TODO: detect current editor and print correct info 03075 /* $imagetext = '<img src="' . $CFG->httpswwwroot . '/lib/editor/htmlarea/images/kbhelp.gif" alt="'. 03076 get_string('editorshortcutkeys').'" class="iconkbhelp" />'; 03077 03078 return helpbutton('editorshortcuts', get_string('editorshortcutkeys'), 'moodle', true, false, '', true, $imagetext);*/ 03079 return ''; 03080 } 03081 03082 03099 function print_arrow($direction='up', $strsort=null, $return=false) { 03100 // debugging('print_arrow() has been deprecated. Please change your code to use $OUTPUT->arrow().'); 03101 03102 global $OUTPUT; 03103 03104 if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) { 03105 return null; 03106 } 03107 03108 $return = null; 03109 03110 switch ($direction) { 03111 case 'up': 03112 $sortdir = 'asc'; 03113 break; 03114 case 'down': 03115 $sortdir = 'desc'; 03116 break; 03117 case 'move': 03118 $sortdir = 'asc'; 03119 break; 03120 default: 03121 $sortdir = null; 03122 break; 03123 } 03124 03125 // Prepare language string 03126 $strsort = ''; 03127 if (empty($strsort) && !empty($sortdir)) { 03128 $strsort = get_string('sort' . $sortdir, 'grades'); 03129 } 03130 03131 $return = ' <img src="'.$OUTPUT->pix_url('t/' . $direction) . '" alt="'.$strsort.'" /> '; 03132 03133 if ($return) { 03134 return $return; 03135 } else { 03136 echo $return; 03137 } 03138 } 03139 03152 function doc_link($path='', $text='', $iconpath='ignored') { 03153 global $CFG, $OUTPUT; 03154 03155 debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->doc_link().'); 03156 03157 if (empty($CFG->docroot)) { 03158 return ''; 03159 } 03160 03161 return $OUTPUT->doc_link($path, $text); 03162 } 03163 03179 function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page',$nocurr=false, $return=false) { 03180 global $OUTPUT; 03181 03182 debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->render($pagingbar).'); 03183 03184 if (empty($nocurr)) { 03185 debugging('the feature of parameter $nocurr has been removed from the paging_bar'); 03186 } 03187 03188 $pagingbar = new paging_bar($totalcount, $page, $perpage, $baseurl); 03189 $pagingbar->pagevar = $pagevar; 03190 $output = $OUTPUT->render($pagingbar); 03191 03192 if ($return) { 03193 return $output; 03194 } 03195 03196 echo $output; 03197 return true; 03198 } 03199 03215 function notice_yesno($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno=NULL, $methodyes='post', $methodno='post') { 03216 03217 debugging('notice_yesno() has been deprecated. Please change your code to use $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel).'); 03218 03219 global $OUTPUT; 03220 03221 $buttoncontinue = new single_button(new moodle_url($linkyes, $optionsyes), get_string('yes'), $methodyes); 03222 $buttoncancel = new single_button(new moodle_url($linkno, $optionsno), get_string('no'), $methodno); 03223 03224 echo $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel); 03225 } 03226 03231 function print_scale_menu() { 03232 throw new coding_exception('print_scale_menu() has been deprecated since the Jurassic period. Get with the times!.'); 03233 } 03234 03265 function choose_from_menu ($options, $name, $selected='', $nothing='choose', $script='', 03266 $nothingvalue='0', $return=false, $disabled=false, $tabindex=0, 03267 $id='', $listbox=false, $multiple=false, $class='') { 03268 03269 global $OUTPUT; 03270 debugging('choose_from_menu() has been deprecated. Please change your code to use html_writer::select().'); 03271 03272 if ($script) { 03273 debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER); 03274 } 03275 $attributes = array(); 03276 $attributes['disabled'] = $disabled ? 'disabled' : null; 03277 $attributes['tabindex'] = $tabindex ? $tabindex : null; 03278 $attributes['multiple'] = $multiple ? $multiple : null; 03279 $attributes['class'] = $class ? $class : null; 03280 $attributes['id'] = $id ? $id : null; 03281 03282 $output = html_writer::select($options, $name, $selected, array($nothingvalue=>$nothing), $attributes); 03283 03284 if ($return) { 03285 return $output; 03286 } else { 03287 echo $output; 03288 } 03289 } 03290 03308 function choose_from_menu_yesno($name, $selected, $script = '', $return = false, $disabled = false, $tabindex = 0) { 03309 debugging('choose_from_menu_yesno() has been deprecated. Please change your code to use html_writer.'); 03310 global $OUTPUT; 03311 03312 if ($script) { 03313 debugging('The $script parameter has been deprecated. You must use component_actions instead', DEBUG_DEVELOPER); 03314 } 03315 03316 $output = html_writer::select_yes_no($name, $selected, array('disabled'=>($disabled ? 'disabled' : null), 'tabindex'=>$tabindex)); 03317 03318 if ($return) { 03319 return $output; 03320 } else { 03321 echo $output; 03322 } 03323 } 03324 03350 function choose_from_menu_nested($options,$name,$selected='',$nothing='choose',$script = '', 03351 $nothingvalue=0,$return=false,$disabled=false,$tabindex=0) { 03352 03353 debugging('choose_from_menu_nested() has been removed. Please change your code to use html_writer::select().'); 03354 global $OUTPUT; 03355 } 03356 03368 function print_scale_menu_helpbutton($courseid, $scale, $return=false) { 03369 // debugging('print_scale_menu_helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_scale($courseid, $scale).'); 03370 global $OUTPUT; 03371 03372 $output = $OUTPUT->help_icon_scale($courseid, $scale); 03373 03374 if ($return) { 03375 return $output; 03376 } else { 03377 echo $output; 03378 } 03379 } 03380 03381 03397 function print_timer_selector($timelimit = 0, $unit = '', $name = 'timelimit', $return=false) { 03398 throw new coding_exception('print_timer_selector is completely removed. Please use html_writer instead'); 03399 } 03400 03413 function print_time_selector($hour, $minute, $currenttime=0, $step=5, $return=false) { 03414 debugging('print_time_selector() has been deprecated. Please change your code to use html_writer.'); 03415 03416 $hourselector = html_writer::select_time('hours', $hour, $currenttime); 03417 $minuteselector = html_writer::select_time('minutes', $minute, $currenttime, $step); 03418 03419 $output = $hourselector . $$minuteselector; 03420 03421 if ($return) { 03422 return $output; 03423 } else { 03424 echo $output; 03425 } 03426 } 03427 03440 function print_date_selector($day, $month, $year, $currenttime=0, $return=false) { 03441 debugging('print_date_selector() has been deprecated. Please change your code to use html_writer.'); 03442 03443 $dayselector = html_writer::select_time('days', $day, $currenttime); 03444 $monthselector = html_writer::select_time('months', $month, $currenttime); 03445 $yearselector = html_writer::select_time('years', $year, $currenttime); 03446 03447 $output = $dayselector . $monthselector . $yearselector; 03448 03449 if ($return) { 03450 return $output; 03451 } else { 03452 echo $output; 03453 } 03454 } 03455 03484 function popup_form($baseurl, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false, 03485 $targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false, $showbutton=false) { 03486 global $OUTPUT, $CFG; 03487 03488 debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->single_select() or $OUTPUT->url_select().'); 03489 03490 if (empty($options)) { 03491 return ''; 03492 } 03493 03494 $urls = array(); 03495 03496 foreach ($options as $value=>$label) { 03497 $url = $baseurl.$value; 03498 $url = str_replace($CFG->wwwroot, '', $url); 03499 $url = str_replace('&', '&', $url); 03500 $urls[$url] = $label; 03501 if ($selected == $value) { 03502 $active = $url; 03503 } 03504 } 03505 03506 $nothing = $nothing ? array(''=>$nothing) : null; 03507 03508 $select = new url_select($urls, $active, $nothing, $formid); 03509 $select->disabled = $disabled; 03510 03511 $select->set_label($selectlabel); 03512 $select->set_old_help_icon($help, $helptext); 03513 03514 $output = $OUTPUT->render($select); 03515 03516 if ($return) { 03517 return $output; 03518 } else { 03519 echo $output; 03520 } 03521 } 03522 03535 function close_window_button($name='closewindow', $return=false, $reloadopener = false) { 03536 global $OUTPUT; 03537 03538 debugging('close_window_button() has been deprecated. Please change your code to use $OUTPUT->close_window_button().'); 03539 $output = $OUTPUT->close_window_button(get_string($name)); 03540 03541 if ($return) { 03542 return $output; 03543 } else { 03544 echo $output; 03545 } 03546 } 03547 03561 function choose_from_radio ($options, $name, $checked='', $return=false) { 03562 debugging('choose_from_radio() has been removed. Please change your code to use html_writer.'); 03563 } 03564 03582 function print_checkbox($name, $value, $checked = true, $label = '', $alt = '', $script='', $return=false) { 03583 03584 // debugging('print_checkbox() has been deprecated. Please change your code to use html_writer::checkbox().'); 03585 global $OUTPUT; 03586 03587 if (!empty($script)) { 03588 debugging('The use of the $script param in print_checkbox has not been migrated into html_writer::checkbox().', DEBUG_DEVELOPER); 03589 } 03590 03591 $output = html_writer::checkbox($name, $value, $checked, $label); 03592 03593 if (empty($return)) { 03594 echo $output; 03595 } else { 03596 return $output; 03597 } 03598 03599 } 03600 03601 03616 function print_textfield($name, $value, $alt = '', $size=50, $maxlength=0, $return=false) { 03617 debugging('print_textfield() has been deprecated. Please use mforms or html_writer.'); 03618 03619 if ($alt === '') { 03620 $alt = null; 03621 } 03622 03623 $style = "width: {$size}px;"; 03624 $attributes = array('type'=>'text', 'name'=>$name, 'alt'=>$alt, 'style'=>$style, 'value'=>$value); 03625 if ($maxlength) { 03626 $attributes['maxlength'] = $maxlength; 03627 } 03628 03629 $output = html_writer::empty_tag('input', $attributes); 03630 03631 if (empty($return)) { 03632 echo $output; 03633 } else { 03634 return $output; 03635 } 03636 } 03637 03638 03652 function print_heading_with_help($text, $helppage, $module='moodle', $icon=false, $return=false) { 03653 03654 debugging('print_heading_with_help() has been deprecated. Please change your code to use $OUTPUT->heading().'); 03655 03656 global $OUTPUT; 03657 03658 // Extract the src from $icon if it exists 03659 if (preg_match('/src="([^"]*)"/', $icon, $matches)) { 03660 $icon = $matches[1]; 03661 $icon = new moodle_url($icon); 03662 } else { 03663 $icon = ''; 03664 } 03665 03666 $output = $OUTPUT->heading_with_help($text, $helppage, $module, $icon); 03667 03668 if ($return) { 03669 return $output; 03670 } else { 03671 echo $output; 03672 } 03673 } 03674 03680 function update_mymoodle_icon() { 03681 throw new coding_exception('update_mymoodle_icon() has been completely deprecated.'); 03682 } 03683 03690 function update_tag_button($tagid) { 03691 global $OUTPUT; 03692 debugging('update_tag_button() has been deprecated. Please change your code to use $OUTPUT->edit_button(moodle_url).'); 03693 return $OUTPUT->edit_button(new moodle_url('/tag/index.php', array('id' => $tagid))); 03694 } 03695 03696 03707 function update_module_button($cmid, $ignored, $string) { 03708 global $CFG, $OUTPUT; 03709 03710 // debugging('update_module_button() has been deprecated. Please change your code to use $OUTPUT->update_module_button().'); 03711 03712 //NOTE: DO NOT call new output method because it needs the module name we do not have here! 03713 03714 if (has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_MODULE, $cmid))) { 03715 $string = get_string('updatethis', '', $string); 03716 03717 $url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $cmid, 'return' => true, 'sesskey' => sesskey())); 03718 return $OUTPUT->single_button($url, $string); 03719 } else { 03720 return ''; 03721 } 03722 } 03723 03729 function update_categories_search_button($search,$page,$perpage) { 03730 throw new coding_exception('update_categories_search_button() has been completely deprecated.'); 03731 } 03732 03737 function print_user($user, $course, $messageselect=false, $return=false) { 03738 throw new coding_exception('print_user() has been completely deprecated. See user/index.php for new usage.'); 03739 } 03740 03752 function update_course_icon($courseid) { 03753 global $CFG, $OUTPUT; 03754 03755 debugging('update_course_button() has been deprecated. Please change your code to use $OUTPUT->edit_button(moodle_url).'); 03756 03757 return $OUTPUT->edit_button(new moodle_url('/course/view.php', array('id' => $courseid))); 03758 } 03759 03776 function print_navigation ($navigation, $separator=0, $return=false) { 03777 global $OUTPUT,$PAGE; 03778 03779 # debugging('print_navigation has been deprecated please update your theme to use $OUTPUT->navbar() instead', DEBUG_DEVELOPER); 03780 03781 $output = $OUTPUT->navbar(); 03782 03783 if ($return) { 03784 return $output; 03785 } else { 03786 echo $output; 03787 } 03788 } 03789 03832 function build_navigation($extranavlinks, $cm = null) { 03833 global $CFG, $COURSE, $DB, $SITE, $PAGE; 03834 03835 if (is_array($extranavlinks) && count($extranavlinks)>0) { 03836 # debugging('build_navigation() has been deprecated, please replace with $PAGE->navbar methods', DEBUG_DEVELOPER); 03837 foreach ($extranavlinks as $nav) { 03838 if (array_key_exists('name', $nav)) { 03839 if (array_key_exists('link', $nav) && !empty($nav['link'])) { 03840 $link = $nav['link']; 03841 } else { 03842 $link = null; 03843 } 03844 $PAGE->navbar->add($nav['name'],$link); 03845 } 03846 } 03847 } 03848 03849 return(array('newnav' => true, 'navlinks' => array())); 03850 } 03851 03871 function navmenu($course, $cm=NULL, $targetwindow='self') { 03872 // This function has been deprecated with the creation of the global nav in 03873 // moodle 2.0 03874 03875 return ''; 03876 } 03877 03885 function switchroles_form($courseid) { 03886 debugging('switchroles_form() has been deprecated and replaced by an item in the global settings block'); 03887 return ''; 03888 } 03889 03895 function admin_externalpage_print_header($focus='') { 03896 global $OUTPUT; 03897 03898 debugging('admin_externalpage_print_header is deprecated. Please $OUTPUT->header() instead.', DEBUG_DEVELOPER); 03899 03900 echo $OUTPUT->header(); 03901 } 03902 03906 function admin_externalpage_print_footer() { 03907 // TODO Still 103 referernces in core code. Don't do debugging output yet. 03908 debugging('admin_externalpage_print_footer is deprecated. Please $OUTPUT->footer() instead.', DEBUG_DEVELOPER); 03909 global $OUTPUT; 03910 echo $OUTPUT->footer(); 03911 } 03912 03914 03915 03938 function add_event($event) { 03939 global $CFG; 03940 require_once($CFG->dirroot.'/calendar/lib.php'); 03941 $event = calendar_event::create($event); 03942 if ($event !== false) { 03943 return $event->id; 03944 } 03945 return false; 03946 } 03947 03955 function update_event($event) { 03956 global $CFG; 03957 require_once($CFG->dirroot.'/calendar/lib.php'); 03958 $event = (object)$event; 03959 $calendarevent = calendar_event::load($event->id); 03960 return $calendarevent->update($event); 03961 } 03962 03969 function delete_event($id) { 03970 global $CFG; 03971 require_once($CFG->dirroot.'/calendar/lib.php'); 03972 $event = calendar_event::load($id); 03973 return $event->delete(); 03974 } 03975 03983 function hide_event($event) { 03984 global $CFG; 03985 require_once($CFG->dirroot.'/calendar/lib.php'); 03986 $event = new calendar_event($event); 03987 return $event->toggle_visibility(false); 03988 } 03989 03997 function show_event($event) { 03998 global $CFG; 03999 require_once($CFG->dirroot.'/calendar/lib.php'); 04000 $event = new calendar_event($event); 04001 return $event->toggle_visibility(true); 04002 }