c861fe2f |
1 | <?php |
2 | |
3 | // This file is part of Moodle - http://moodle.org/ |
4 | // |
5 | // Moodle is free software: you can redistribute it and/or modify |
6 | // it under the terms of the GNU General Public License as published by |
7 | // the Free Software Foundation, either version 3 of the License, or |
8 | // (at your option) any later version. |
9 | // |
10 | // Moodle is distributed in the hope that it will be useful, |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // GNU General Public License for more details. |
14 | // |
15 | // You should have received a copy of the GNU General Public License |
16 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
c4d0753b |
17 | |
18 | /** |
19 | * deprecatedlib.php - Old functions retained only for backward compatibility |
20 | * |
21 | * Old functions retained only for backward compatibility. New code should not |
22 | * use any of these functions. |
23 | * |
c4d0753b |
24 | * @package moodlecore |
c861fe2f |
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 |
c4d0753b |
29 | */ |
30 | |
c4d0753b |
31 | /** |
32 | * Determines if a user is a teacher (or better) |
33 | * |
c861fe2f |
34 | * @global object |
35 | * @uses CONTEXT_COURSE |
36 | * @uses CONTEXT_SYSTEM |
c4d0753b |
37 | * @param int $courseid The id of the course that is being viewed, if any |
38 | * @param int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. |
39 | * @param bool $obsolete_includeadmin Not used any more |
40 | * @return bool |
41 | */ |
c4d0753b |
42 | function isteacher($courseid=0, $userid=0, $obsolete_includeadmin=true) { |
43 | /// Is the user able to access this course as a teacher? |
c2da0757 |
44 | global $CFG; |
c4d0753b |
45 | |
c4d0753b |
46 | if ($courseid) { |
47 | $context = get_context_instance(CONTEXT_COURSE, $courseid); |
48 | } else { |
12d06877 |
49 | $context = get_context_instance(CONTEXT_SYSTEM); |
c4d0753b |
50 | } |
51 | |
c2da0757 |
52 | return (has_capability('moodle/legacy:teacher', $context, $userid, false) |
53 | or has_capability('moodle/legacy:editingteacher', $context, $userid, false) |
54 | or has_capability('moodle/legacy:admin', $context, $userid, false)); |
c4d0753b |
55 | } |
56 | |
57 | /** |
58 | * Determines if a user is a teacher in any course, or an admin |
59 | * |
c861fe2f |
60 | * @global object |
61 | * @global object |
62 | * @global object |
63 | * @uses CAP_ALLOW |
64 | * @uses CONTEXT_SYSTEM |
c4d0753b |
65 | * @param int $userid The id of the user that is being tested against. Set this to 0 if you would just like to test against the currently logged in user. |
c2da0757 |
66 | * @param bool $includeadmin Include anyone wo is an admin as well |
c4d0753b |
67 | * @return bool |
68 | */ |
c2da0757 |
69 | function isteacherinanycourse($userid=0, $includeadmin=true) { |
79eaec48 |
70 | global $USER, $CFG, $DB; |
c4d0753b |
71 | |
c4d0753b |
72 | if (!$userid) { |
73 | if (empty($USER->id)) { |
74 | return false; |
75 | } |
76 | $userid = $USER->id; |
77 | } |
78 | |
79eaec48 |
79 | if (!$DB->record_exists('role_assignments', array('userid'=>$userid))) { // Has no roles anywhere |
c4d0753b |
80 | return false; |
81 | } |
82 | |
83 | /// If this user is assigned as an editing teacher anywhere then return true |
84 | if ($roles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) { |
85 | foreach ($roles as $role) { |
79eaec48 |
86 | if ($DB->record_exists('role_assignments', array('roleid'=>$role->id, 'userid'=>$userid))) { |
c4d0753b |
87 | return true; |
88 | } |
89 | } |
90 | } |
91 | |
92 | /// If this user is assigned as a non-editing teacher anywhere then return true |
93 | if ($roles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) { |
94 | foreach ($roles as $role) { |
79eaec48 |
95 | if ($DB->record_exists('role_assignments', array('roleid'=>$role->id, 'userid'=>$userid))) { |
c4d0753b |
96 | return true; |
97 | } |
98 | } |
99 | } |
100 | |
c2da0757 |
101 | /// Include admins if required |
102 | if ($includeadmin) { |
12d06877 |
103 | $context = get_context_instance(CONTEXT_SYSTEM); |
c2da0757 |
104 | if (has_capability('moodle/legacy:admin', $context, $userid, false)) { |
105 | return true; |
106 | } |
107 | } |
c4d0753b |
108 | |
109 | return false; |
110 | } |
111 | |
c4d0753b |
112 | |
113 | /** |
114 | * Determines if the specified user is logged in as guest. |
115 | * |
c861fe2f |
116 | * @global object |
117 | * @uses CONTEXT_SYSTEM |
c4d0753b |
118 | * @param int $userid The user being tested. You can set this to 0 or leave it blank to test the currently logged in user. |
119 | * @return bool |
120 | */ |
121 | function isguest($userid=0) { |
c2da0757 |
122 | global $CFG; |
c4d0753b |
123 | |
364fffda |
124 | $context = get_context_instance(CONTEXT_SYSTEM); |
c4d0753b |
125 | |
c2da0757 |
126 | return has_capability('moodle/legacy:guest', $context, $userid, false); |
c4d0753b |
127 | } |
128 | |
613bbd7c |
129 | |
130 | /** |
131 | * Get the guest user information from the database |
132 | * |
c861fe2f |
133 | * @todo Is object(user) a correct return type? Or is array the proper return type with a |
134 | * note that the contents include all details for a user. |
135 | * |
613bbd7c |
136 | * @return object(user) An associative array with the details of the guest user account. |
613bbd7c |
137 | */ |
138 | function get_guest() { |
139 | return get_complete_user_data('username', 'guest'); |
140 | } |
141 | |
613bbd7c |
142 | /** |
143 | * Returns $user object of the main teacher for a course |
144 | * |
c861fe2f |
145 | * @global object |
146 | * @uses CONTEXT_COURSE |
613bbd7c |
147 | * @param int $courseid The course in question. |
148 | * @return user|false A {@link $USER} record of the main teacher for the specified course or false if error. |
613bbd7c |
149 | */ |
150 | function get_teacher($courseid) { |
151 | |
152 | global $CFG; |
153 | |
888fb649 |
154 | $context = get_context_instance(CONTEXT_COURSE, $courseid); |
155 | |
1113f800 |
156 | // Pass $view=true to filter hidden caps if the user cannot see them |
157 | if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC', |
158 | '', '', '', '', false, true)) { |
b1469317 |
159 | $users = sort_by_roleassignment_authority($users, $context); |
1113f800 |
160 | return array_shift($users); |
613bbd7c |
161 | } |
888fb649 |
162 | |
163 | return false; |
613bbd7c |
164 | } |
165 | |
166 | /** |
167 | * Searches logs to find all enrolments since a certain date |
168 | * |
169 | * used to print recent activity |
170 | * |
c861fe2f |
171 | * @global object |
172 | * @uses CONTEXT_COURSE |
613bbd7c |
173 | * @param int $courseid The course in question. |
c861fe2f |
174 | * @param int $timestart The date to check forward of |
613bbd7c |
175 | * @return object|false {@link $USER} records or false if error. |
613bbd7c |
176 | */ |
177 | function get_recent_enrolments($courseid, $timestart) { |
10df888a |
178 | global $DB; |
364fffda |
179 | |
71dea306 |
180 | $context = get_context_instance(CONTEXT_COURSE, $courseid); |
613bbd7c |
181 | |
10df888a |
182 | $sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, l.time |
183 | FROM {user} u, {role_assignments} ra, {log} l |
184 | WHERE l.time > ? |
185 | AND l.course = ? |
186 | AND l.module = 'course' |
187 | AND l.action = 'enrol' |
9f43d70d |
188 | AND ".$DB->sql_cast_char2int('l.info')." = u.id |
10df888a |
189 | AND u.id = ra.userid |
190 | AND ra.contextid ".get_related_contexts_string($context)." |
191 | ORDER BY l.time ASC"; |
192 | $params = array($timestart, $courseid); |
193 | return $DB->get_records_sql($sql, $params); |
613bbd7c |
194 | } |
195 | |
2123b644 |
196 | ########### FROM weblib.php ########################################################################## |
197 | |
198 | |
199 | /** |
200 | * Print a message in a standard themed box. |
364fffda |
201 | * This old function used to implement boxes using tables. Now it uses a DIV, but the old |
2123b644 |
202 | * parameters remain. If possible, $align, $width and $color should not be defined at all. |
203 | * Preferably just use print_box() in weblib.php |
204 | * |
c861fe2f |
205 | * @param string $message The message to display |
206 | * @param string $align alignment of the box, not the text (default center, left, right). |
207 | * @param string $width width of the box, including units %, for example '100%'. |
208 | * @param string $color background colour of the box, for example '#eee'. |
209 | * @param int $padding padding in pixels, specified without units. |
210 | * @param string $class space-separated class names. |
211 | * @param string $id space-separated id names. |
212 | * @param boolean $return return as string or just print it |
213 | * @return string|void Depending on $return |
2123b644 |
214 | */ |
215 | function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) { |
216 | $output = ''; |
217 | $output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true); |
294ce987 |
218 | $output .= $message; |
2123b644 |
219 | $output .= print_simple_box_end(true); |
220 | |
221 | if ($return) { |
222 | return $output; |
223 | } else { |
224 | echo $output; |
225 | } |
226 | } |
227 | |
228 | |
229 | |
230 | /** |
364fffda |
231 | * This old function used to implement boxes using tables. Now it uses a DIV, but the old |
2123b644 |
232 | * parameters remain. If possible, $align, $width and $color should not be defined at all. |
233 | * Even better, please use print_box_start() in weblib.php |
234 | * |
c861fe2f |
235 | * @param string $align alignment of the box, not the text (default center, left, right). DEPRECATED |
236 | * @param string $width width of the box, including % units, for example '100%'. DEPRECATED |
237 | * @param string $color background colour of the box, for example '#eee'. DEPRECATED |
238 | * @param int $padding padding in pixels, specified without units. OBSOLETE |
239 | * @param string $class space-separated class names. |
240 | * @param string $id space-separated id names. |
241 | * @param boolean $return return as string or just print it |
242 | * @return string|void Depending on $return |
2123b644 |
243 | */ |
244 | function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) { |
245 | |
246 | $output = ''; |
247 | |
8f36e33e |
248 | $divclasses = 'box '.$class.' '.$class.'content'; |
2123b644 |
249 | $divstyles = ''; |
250 | |
251 | if ($align) { |
252 | $divclasses .= ' boxalign'.$align; // Implement alignment using a class |
253 | } |
254 | if ($width) { // Hopefully we can eliminate these in calls to this function (inline styles are bad) |
8f36e33e |
255 | if (substr($width, -1, 1) == '%') { // Width is a % value |
256 | $width = (int) substr($width, 0, -1); // Extract just the number |
257 | if ($width < 40) { |
258 | $divclasses .= ' boxwidthnarrow'; // Approx 30% depending on theme |
259 | } else if ($width > 60) { |
260 | $divclasses .= ' boxwidthwide'; // Approx 80% depending on theme |
261 | } else { |
262 | $divclasses .= ' boxwidthnormal'; // Approx 50% depending on theme |
263 | } |
264 | } else { |
265 | $divstyles .= ' width:'.$width.';'; // Last resort |
266 | } |
2123b644 |
267 | } |
268 | if ($color) { // Hopefully we can eliminate these in calls to this function (inline styles are bad) |
269 | $divstyles .= ' background:'.$color.';'; |
270 | } |
271 | if ($divstyles) { |
272 | $divstyles = ' style="'.$divstyles.'"'; |
273 | } |
274 | |
275 | if ($id) { |
276 | $id = ' id="'.$id.'"'; |
277 | } |
278 | |
279 | $output .= '<div'.$id.$divstyles.' class="'.$divclasses.'">'; |
280 | |
281 | if ($return) { |
282 | return $output; |
283 | } else { |
284 | echo $output; |
285 | } |
286 | } |
287 | |
288 | |
289 | /** |
290 | * Print the end portion of a standard themed box. |
291 | * Preferably just use print_box_end() in weblib.php |
c861fe2f |
292 | * |
293 | * @param boolean $return return as string or just print it |
294 | * @return string|void Depending on $return |
2123b644 |
295 | */ |
296 | function print_simple_box_end($return=false) { |
297 | $output = '</div>'; |
298 | if ($return) { |
299 | return $output; |
300 | } else { |
301 | echo $output; |
302 | } |
303 | } |
304 | |
ed5dd29f |
305 | /** |
306 | * deprecated - use clean_param($string, PARAM_FILE); instead |
307 | * Check for bad characters ? |
308 | * |
c861fe2f |
309 | * @todo Finish documenting this function - more detail needed in description as well as details on arguments |
310 | * |
ed5dd29f |
311 | * @param string $string ? |
312 | * @param int $allowdots ? |
c861fe2f |
313 | * @return bool |
ed5dd29f |
314 | */ |
315 | function detect_munged_arguments($string, $allowdots=1) { |
316 | if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references |
317 | return true; |
318 | } |
319 | if (ereg('[\|\`]', $string)) { // check for other bad characters |
320 | return true; |
321 | } |
322 | if (empty($string) or $string == '/') { |
323 | return true; |
324 | } |
325 | |
326 | return false; |
327 | } |
328 | |
9152fc99 |
329 | |
0c6d2dd4 |
330 | /** |
331 | * Unzip one zip file to a destination dir |
332 | * Both parameters must be FULL paths |
333 | * If destination isn't specified, it will be the |
334 | * SAME directory where the zip file resides. |
c861fe2f |
335 | * |
336 | * @global object |
337 | * @param string $zipfile The zip file to unzip |
338 | * @param string $destination The location to unzip to |
339 | * @param bool $showstatus_ignored Unused |
0c6d2dd4 |
340 | */ |
341 | function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) { |
342 | global $CFG; |
343 | |
344 | //Extract everything from zipfile |
345 | $path_parts = pathinfo(cleardoubleslashes($zipfile)); |
346 | $zippath = $path_parts["dirname"]; //The path of the zip file |
347 | $zipfilename = $path_parts["basename"]; //The name of the zip file |
348 | $extension = $path_parts["extension"]; //The extension of the file |
349 | |
350 | //If no file, error |
351 | if (empty($zipfilename)) { |
352 | return false; |
353 | } |
354 | |
355 | //If no extension, error |
356 | if (empty($extension)) { |
357 | return false; |
358 | } |
359 | |
360 | //Clear $zipfile |
361 | $zipfile = cleardoubleslashes($zipfile); |
362 | |
363 | //Check zipfile exists |
364 | if (!file_exists($zipfile)) { |
365 | return false; |
366 | } |
367 | |
368 | //If no destination, passed let's go with the same directory |
369 | if (empty($destination)) { |
370 | $destination = $zippath; |
371 | } |
372 | |
373 | //Clear $destination |
374 | $destpath = rtrim(cleardoubleslashes($destination), "/"); |
375 | |
376 | //Check destination path exists |
377 | if (!is_dir($destpath)) { |
378 | return false; |
379 | } |
380 | |
0b0bfa93 |
381 | $packer = get_file_packer('application/zip'); |
382 | |
383 | $result = $packer->extract_to_pathname($zipfile, $destpath); |
0c6d2dd4 |
384 | |
385 | if ($result === false) { |
386 | return false; |
387 | } |
388 | |
389 | foreach ($result as $status) { |
390 | if ($status !== true) { |
391 | return false; |
392 | } |
393 | } |
394 | |
395 | return true; |
396 | } |
397 | |
ed94cb66 |
398 | /** |
399 | * Zip an array of files/dirs to a destination zip file |
400 | * Both parameters must be FULL paths to the files/dirs |
c861fe2f |
401 | * |
402 | * @global object |
403 | * @param array $originalfiles Files to zip |
404 | * @param string $destination The destination path |
405 | * @return bool Outcome |
ed94cb66 |
406 | */ |
407 | function zip_files ($originalfiles, $destination) { |
408 | global $CFG; |
409 | |
410 | //Extract everything from destination |
411 | $path_parts = pathinfo(cleardoubleslashes($destination)); |
412 | $destpath = $path_parts["dirname"]; //The path of the zip file |
413 | $destfilename = $path_parts["basename"]; //The name of the zip file |
414 | $extension = $path_parts["extension"]; //The extension of the file |
415 | |
416 | //If no file, error |
417 | if (empty($destfilename)) { |
418 | return false; |
419 | } |
420 | |
421 | //If no extension, add it |
422 | if (empty($extension)) { |
423 | $extension = 'zip'; |
424 | $destfilename = $destfilename.'.'.$extension; |
425 | } |
426 | |
427 | //Check destination path exists |
428 | if (!is_dir($destpath)) { |
429 | return false; |
430 | } |
431 | |
432 | //Check destination path is writable. TODO!! |
433 | |
434 | //Clean destination filename |
435 | $destfilename = clean_filename($destfilename); |
436 | |
437 | //Now check and prepare every file |
438 | $files = array(); |
439 | $origpath = NULL; |
440 | |
441 | foreach ($originalfiles as $file) { //Iterate over each file |
442 | //Check for every file |
443 | $tempfile = cleardoubleslashes($file); // no doubleslashes! |
444 | //Calculate the base path for all files if it isn't set |
445 | if ($origpath === NULL) { |
446 | $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/"); |
447 | } |
448 | //See if the file is readable |
449 | if (!is_readable($tempfile)) { //Is readable |
450 | continue; |
451 | } |
452 | //See if the file/dir is in the same directory than the rest |
453 | if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) { |
454 | continue; |
455 | } |
456 | //Add the file to the array |
457 | $files[] = $tempfile; |
458 | } |
459 | |
460 | $zipfiles = array(); |
461 | $start = strlen($origpath)+1; |
462 | foreach($files as $file) { |
463 | $zipfiles[substr($file, $start)] = $file; |
464 | } |
465 | |
0b0bfa93 |
466 | $packer = get_file_packer('application/zip'); |
ed94cb66 |
467 | |
3ed22f1a |
468 | return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename); |
ed94cb66 |
469 | } |
470 | |
ed5dd29f |
471 | ///////////////////////////////////////////////////////////// |
472 | /// Old functions not used anymore - candidates for removal |
473 | ///////////////////////////////////////////////////////////// |
474 | |
ed5dd29f |
475 | |
1d684195 |
476 | /** various deprecated groups function **/ |
477 | |
478 | |
5bf243d1 |
479 | /** |
480 | * Get the IDs for the user's groups in the given course. |
481 | * |
c861fe2f |
482 | * @global object |
5bf243d1 |
483 | * @param int $courseid The course being examined - the 'course' table id field. |
c861fe2f |
484 | * @return array|bool An _array_ of groupids, or false |
5bf243d1 |
485 | * (Was return $groupids[0] - consequences!) |
486 | */ |
487 | function mygroupid($courseid) { |
488 | global $USER; |
489 | if ($groups = groups_get_all_groups($courseid, $USER->id)) { |
490 | return array_keys($groups); |
491 | } else { |
492 | return false; |
493 | } |
494 | } |
495 | |
5bf243d1 |
496 | |
5bf243d1 |
497 | /** |
498 | * Returns the current group mode for a given course or activity module |
364fffda |
499 | * |
5bf243d1 |
500 | * Could be false, SEPARATEGROUPS or VISIBLEGROUPS (<-- Martin) |
c861fe2f |
501 | * |
502 | * @param object $course Course Object |
503 | * @param object $cm Course Manager Object |
504 | * @return mixed $course->groupmode |
5bf243d1 |
505 | */ |
506 | function groupmode($course, $cm=null) { |
507 | |
508 | if (isset($cm->groupmode) && empty($course->groupmodeforce)) { |
509 | return $cm->groupmode; |
510 | } |
511 | return $course->groupmode; |
512 | } |
513 | |
c584346c |
514 | /** |
515 | * Sets the current group in the session variable |
516 | * When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups. |
517 | * Sets currentgroup[$courseid] in the session variable appropriately. |
518 | * Does not do any permission checking. |
c861fe2f |
519 | * |
520 | * @global object |
c584346c |
521 | * @param int $courseid The course being examined - relates to id field in |
522 | * 'course' table. |
523 | * @param int $groupid The group being examined. |
524 | * @return int Current group id which was set by this function |
525 | */ |
526 | function set_current_group($courseid, $groupid) { |
527 | global $SESSION; |
528 | return $SESSION->currentgroup[$courseid] = $groupid; |
529 | } |
530 | |
5bf243d1 |
531 | |
5bf243d1 |
532 | /** |
364fffda |
533 | * Gets the current group - either from the session variable or from the database. |
5bf243d1 |
534 | * |
c861fe2f |
535 | * @global object |
364fffda |
536 | * @param int $courseid The course being examined - relates to id field in |
5bf243d1 |
537 | * 'course' table. |
364fffda |
538 | * @param bool $full If true, the return value is a full record object. |
5bf243d1 |
539 | * If false, just the id of the record. |
c861fe2f |
540 | * @return int|bool |
5bf243d1 |
541 | */ |
542 | function get_current_group($courseid, $full = false) { |
543 | global $SESSION; |
544 | |
545 | if (isset($SESSION->currentgroup[$courseid])) { |
546 | if ($full) { |
547 | return groups_get_group($SESSION->currentgroup[$courseid]); |
548 | } else { |
549 | return $SESSION->currentgroup[$courseid]; |
550 | } |
551 | } |
552 | |
553 | $mygroupid = mygroupid($courseid); |
554 | if (is_array($mygroupid)) { |
555 | $mygroupid = array_shift($mygroupid); |
556 | set_current_group($courseid, $mygroupid); |
557 | if ($full) { |
558 | return groups_get_group($mygroupid); |
559 | } else { |
560 | return $mygroupid; |
561 | } |
562 | } |
563 | |
564 | if ($full) { |
565 | return false; |
566 | } else { |
567 | return 0; |
568 | } |
569 | } |
570 | |
571 | |
8ec50604 |
572 | /** |
573 | * Print an error page displaying an error message. |
574 | * Old method, don't call directly in new code - use print_error instead. |
575 | * |
c861fe2f |
576 | * @global object |
8ec50604 |
577 | * @param string $message The message to display to the user about the error. |
578 | * @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. |
c861fe2f |
579 | * @return void Terminates script, does not return! |
8ec50604 |
580 | */ |
245ac557 |
581 | function error($message, $link='') { |
251387d0 |
582 | global $UNITTEST; |
8ec50604 |
583 | |
251387d0 |
584 | // If unittest running, throw exception instead |
a230012c |
585 | if (!empty($UNITTEST->running)) { |
73f7ad71 |
586 | // Errors in unit test become exceptions, so you can unit test |
587 | // code that might call error(). |
251387d0 |
588 | throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message); |
8ec50604 |
589 | } |
590 | |
5ca18631 |
591 | _print_normal_error('notlocalisederrormessage', 'error', $message, $link, debug_backtrace(), null, true); // show debug warning |
251387d0 |
592 | } |
8ec50604 |
593 | |
8ec50604 |
594 | |
b1f93b15 |
595 | /// Deprecated DDL functions, to be removed soon /// |
c861fe2f |
596 | /** |
597 | * @deprecated |
598 | * @global object |
599 | * @param string $table |
600 | * @return bool |
601 | */ |
b1f93b15 |
602 | function table_exists($table) { |
603 | global $DB; |
604 | debugging('Deprecated ddllib function used!'); |
605 | return $DB->get_manager()->table_exists($table); |
606 | } |
607 | |
c861fe2f |
608 | /** |
609 | * @deprecated |
610 | * @global object |
611 | * @param string $table |
612 | * @param string $field |
613 | * @return bool |
614 | */ |
b1f93b15 |
615 | function field_exists($table, $field) { |
616 | global $DB; |
617 | debugging('Deprecated ddllib function used!'); |
618 | return $DB->get_manager()->field_exists($table, $field); |
619 | } |
620 | |
c861fe2f |
621 | /** |
622 | * @deprecated |
623 | * @global object |
624 | * @param string $table |
625 | * @param string $index |
626 | * @return bool |
627 | */ |
b1f93b15 |
628 | function find_index_name($table, $index) { |
629 | global $DB; |
630 | debugging('Deprecated ddllib function used!'); |
631 | return $DB->get_manager()->find_index_name($table, $index); |
632 | } |
633 | |
c861fe2f |
634 | /** |
635 | * @deprecated |
636 | * @global object |
637 | * @param string $table |
638 | * @param string $index |
639 | * @return bool |
640 | */ |
b1f93b15 |
641 | function index_exists($table, $index) { |
642 | global $DB; |
643 | debugging('Deprecated ddllib function used!'); |
644 | return $DB->get_manager()->index_exists($table, $index); |
645 | } |
646 | |
c861fe2f |
647 | /** |
648 | * @deprecated |
649 | * @global object |
650 | * @param string $table |
651 | * @param string $field |
652 | * @return bool |
653 | */ |
b1f93b15 |
654 | function find_check_constraint_name($table, $field) { |
655 | global $DB; |
656 | debugging('Deprecated ddllib function used!'); |
657 | return $DB->get_manager()->find_check_constraint_name($table, $field); |
658 | } |
659 | |
c861fe2f |
660 | /** |
661 | * @deprecated |
662 | * @global object |
663 | */ |
b1f93b15 |
664 | function check_constraint_exists($table, $field) { |
665 | global $DB; |
666 | debugging('Deprecated ddllib function used!'); |
667 | return $DB->get_manager()->check_constraint_exists($table, $field); |
668 | } |
669 | |
c861fe2f |
670 | /** |
671 | * @deprecated |
672 | * @global object |
673 | * @param string $table |
674 | * @param string $xmldb_key |
675 | * @return bool |
676 | */ |
b1f93b15 |
677 | function find_key_name($table, $xmldb_key) { |
678 | global $DB; |
679 | debugging('Deprecated ddllib function used!'); |
680 | return $DB->get_manager()->find_key_name($table, $xmldb_key); |
681 | } |
682 | |
c861fe2f |
683 | /** |
684 | * @deprecated |
685 | * @global object |
686 | * @param string $table |
687 | * @return bool |
688 | */ |
b1f93b15 |
689 | function find_sequence_name($table) { |
690 | global $DB; |
691 | debugging('Deprecated ddllib function used!'); |
692 | return $DB->get_manager()->find_sequence_name($table); |
693 | } |
694 | |
c861fe2f |
695 | /** |
696 | * @deprecated |
697 | * @global object |
698 | * @param string $table |
699 | * @return bool |
700 | */ |
eee5d9bb |
701 | function drop_table($table) { |
b1f93b15 |
702 | global $DB; |
703 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
704 | $DB->get_manager()->drop_table($table); |
705 | return true; |
b1f93b15 |
706 | } |
707 | |
c861fe2f |
708 | /** |
709 | * @deprecated |
710 | * @global object |
711 | * @param string $file |
712 | * @return bool |
713 | */ |
b1f93b15 |
714 | function install_from_xmldb_file($file) { |
715 | global $DB; |
716 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
717 | $DB->get_manager()->install_from_xmldb_file($file); |
718 | return true; |
b1f93b15 |
719 | } |
720 | |
c861fe2f |
721 | /** |
722 | * @deprecated |
723 | * @global object |
724 | * @param string $table |
725 | * @return bool |
726 | */ |
eee5d9bb |
727 | function create_table($table) { |
b1f93b15 |
728 | global $DB; |
729 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
730 | $DB->get_manager()->create_table($table); |
731 | return true; |
b1f93b15 |
732 | } |
733 | |
c861fe2f |
734 | /** |
735 | * @deprecated |
736 | * @global object |
737 | * @param string $table |
738 | * @return bool |
739 | */ |
eee5d9bb |
740 | function create_temp_table($table) { |
b1f93b15 |
741 | global $DB; |
742 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
743 | $DB->get_manager()->create_temp_table($table); |
744 | return true; |
b1f93b15 |
745 | } |
746 | |
c861fe2f |
747 | /** |
748 | * @deprecated |
749 | * @global object |
750 | * @param string $table |
751 | * @param string $newname |
752 | * @return bool |
753 | */ |
eee5d9bb |
754 | function rename_table($table, $newname) { |
b1f93b15 |
755 | global $DB; |
756 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
757 | $DB->get_manager()->rename_table($table, $newname); |
758 | return true; |
b1f93b15 |
759 | } |
760 | |
c861fe2f |
761 | /** |
762 | * @deprecated |
763 | * @global object |
764 | * @param string $table |
765 | * @param string $field |
766 | * @return bool |
767 | */ |
eee5d9bb |
768 | function add_field($table, $field) { |
b1f93b15 |
769 | global $DB; |
770 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
771 | $DB->get_manager()->add_field($table, $field); |
772 | return true; |
b1f93b15 |
773 | } |
774 | |
c861fe2f |
775 | /** |
776 | * @deprecated |
777 | * @global object |
778 | * @param string $table |
779 | * @param string $field |
780 | * @return bool |
781 | */ |
eee5d9bb |
782 | function drop_field($table, $field) { |
b1f93b15 |
783 | global $DB; |
784 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
785 | $DB->get_manager()->drop_field($table, $field); |
786 | return true; |
b1f93b15 |
787 | } |
788 | |
c861fe2f |
789 | /** |
790 | * @deprecated |
791 | * @global object |
792 | * @param string $table |
793 | * @param string $field |
794 | * @return bool |
795 | */ |
eee5d9bb |
796 | function change_field_type($table, $field) { |
b1f93b15 |
797 | global $DB; |
798 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
799 | $DB->get_manager()->change_field_type($table, $field); |
800 | return true; |
b1f93b15 |
801 | } |
802 | |
c861fe2f |
803 | /** |
804 | * @deprecated |
805 | * @global object |
806 | * @param string $table |
807 | * @param string $field |
808 | * @return bool |
809 | */ |
eee5d9bb |
810 | function change_field_precision($table, $field) { |
b1f93b15 |
811 | global $DB; |
812 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
813 | $DB->get_manager()->change_field_precision($table, $field); |
814 | return true; |
b1f93b15 |
815 | } |
816 | |
c861fe2f |
817 | /** |
818 | * @deprecated |
819 | * @global object |
820 | * @param string $table |
821 | * @param string $field |
822 | * @return bool |
823 | */ |
eee5d9bb |
824 | function change_field_unsigned($table, $field) { |
b1f93b15 |
825 | global $DB; |
826 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
827 | $DB->get_manager()->change_field_unsigned($table, $field); |
828 | return true; |
b1f93b15 |
829 | } |
830 | |
c861fe2f |
831 | /** |
832 | * @deprecated |
833 | * @global object |
834 | * @param string $table |
835 | * @param string $field |
836 | * @return bool |
837 | */ |
eee5d9bb |
838 | function change_field_notnull($table, $field) { |
b1f93b15 |
839 | global $DB; |
840 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
841 | $DB->get_manager()->change_field_notnull($table, $field); |
842 | return true; |
b1f93b15 |
843 | } |
844 | |
c861fe2f |
845 | /** |
846 | * @deprecated |
847 | * @global object |
848 | * @param string $table |
849 | * @param string $field |
850 | * @return bool |
851 | */ |
eee5d9bb |
852 | function change_field_enum($table, $field) { |
b1f93b15 |
853 | global $DB; |
526fe7d8 |
854 | debugging('Deprecated ddllib function used! Only dropping of enums is allowed.'); |
855 | $DB->get_manager()->drop_enum_from_field($table, $field); |
eee5d9bb |
856 | return true; |
b1f93b15 |
857 | } |
858 | |
c861fe2f |
859 | /** |
860 | * @deprecated |
861 | * @global object |
862 | * @param string $table |
863 | * @param string $field |
864 | * @return bool |
865 | */ |
eee5d9bb |
866 | function change_field_default($table, $field) { |
b1f93b15 |
867 | global $DB; |
868 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
869 | $DB->get_manager()->change_field_default($table, $field); |
870 | return true; |
b1f93b15 |
871 | } |
872 | |
c861fe2f |
873 | /** |
874 | * @deprecated |
875 | * @global object |
876 | * @param string $table |
877 | * @param string $field |
878 | * @param string $newname |
879 | * @return bool |
880 | */ |
eee5d9bb |
881 | function rename_field($table, $field, $newname) { |
b1f93b15 |
882 | global $DB; |
883 | debugging('Deprecated ddllib function used!'); |
fe772c2a |
884 | $DB->get_manager()->rename_field($table, $field, $newname); |
eee5d9bb |
885 | return true; |
b1f93b15 |
886 | } |
887 | |
c861fe2f |
888 | /** |
889 | * @deprecated |
890 | * @global object |
891 | * @param string $table |
892 | * @param string $key |
893 | * @return bool |
894 | */ |
eee5d9bb |
895 | function add_key($table, $key) { |
b1f93b15 |
896 | global $DB; |
897 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
898 | $DB->get_manager()->add_key($table, $key); |
899 | return true; |
b1f93b15 |
900 | } |
901 | |
c861fe2f |
902 | /** |
903 | * @deprecated |
904 | * @global object |
905 | * @param string $table |
906 | * @param string $key |
907 | * @return bool |
908 | */ |
eee5d9bb |
909 | function drop_key($table, $key) { |
b1f93b15 |
910 | global $DB; |
911 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
912 | $DB->get_manager()->drop_key($table, $key); |
913 | return true; |
b1f93b15 |
914 | } |
915 | |
c861fe2f |
916 | /** |
917 | * @deprecated |
918 | * @global object |
919 | * @param string $table |
920 | * @param string $key |
921 | * @param string $newname |
922 | * @return bool |
923 | */ |
eee5d9bb |
924 | function rename_key($table, $key, $newname) { |
b1f93b15 |
925 | global $DB; |
926 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
927 | $DB->get_manager()->rename_key($table, $key, $newname); |
928 | return true; |
b1f93b15 |
929 | } |
930 | |
c861fe2f |
931 | /** |
932 | * @deprecated |
933 | * @global object |
934 | * @param string $table |
935 | * @param string $index |
936 | * @return bool |
937 | */ |
eee5d9bb |
938 | function add_index($table, $index) { |
b1f93b15 |
939 | global $DB; |
940 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
941 | $DB->get_manager()->add_index($table, $index); |
942 | return true; |
b1f93b15 |
943 | } |
944 | |
c861fe2f |
945 | /** |
946 | * @deprecated |
947 | * @global object |
948 | * @param string $table |
949 | * @param string $index |
950 | * @return bool |
951 | */ |
eee5d9bb |
952 | function drop_index($table, $index) { |
b1f93b15 |
953 | global $DB; |
954 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
955 | $DB->get_manager()->drop_index($table, $index); |
956 | return true; |
b1f93b15 |
957 | } |
958 | |
c861fe2f |
959 | /** |
960 | * @deprecated |
961 | * @global object |
962 | * @param string $table |
963 | * @param string $index |
964 | * @param string $newname |
965 | * @return bool |
966 | */ |
eee5d9bb |
967 | function rename_index($table, $index, $newname) { |
b1f93b15 |
968 | global $DB; |
969 | debugging('Deprecated ddllib function used!'); |
eee5d9bb |
970 | $DB->get_manager()->rename_index($table, $index, $newname); |
971 | return true; |
b1f93b15 |
972 | } |
973 | |
8ec50604 |
974 | |
251387d0 |
975 | ////////////////////////// |
976 | /// removed functions //// |
977 | ////////////////////////// |
294ce987 |
978 | |
c861fe2f |
979 | /** |
980 | * @deprecated |
981 | * @param mixed $mixed |
982 | * @return void Throws an error and does nothing |
983 | */ |
2fd0e9fe |
984 | function stripslashes_safe($mixed) { |
985 | error('stripslashes_safe() not available anymore'); |
986 | } |
c861fe2f |
987 | /** |
988 | * @deprecated |
989 | * @param mixed $var |
990 | * @return void Throws an error and does nothing |
991 | */ |
2fd0e9fe |
992 | function stripslashes_recursive($var) { |
993 | error('stripslashes_recursive() not available anymore'); |
994 | } |
c861fe2f |
995 | /** |
996 | * @deprecated |
997 | * @param mixed $dataobject |
998 | * @return void Throws an error and does nothing |
999 | */ |
245ac557 |
1000 | function addslashes_object($dataobject) { |
6795800d |
1001 | error('addslashes_object() not available anymore'); |
294ce987 |
1002 | } |
c861fe2f |
1003 | /** |
1004 | * @deprecated |
1005 | * @param mixed $var |
1006 | * @return void Throws an error and does nothing |
1007 | */ |
294ce987 |
1008 | function addslashes_recursive($var) { |
1009 | error('addslashes_recursive() not available anymore'); |
1010 | } |
c861fe2f |
1011 | /** |
1012 | * @deprecated |
1013 | * @param mixed $command |
1014 | * @param bool $feedback |
1015 | * @return void Throws an error and does nothing |
1016 | */ |
245ac557 |
1017 | function execute_sql($command, $feedback=true) { |
1018 | error('execute_sql() not available anymore'); |
1019 | } |
c861fe2f |
1020 | /** |
1021 | * @deprecated |
1022 | * @param mixed $table |
1023 | * @param mixed $select |
1024 | * @return void Throws an error and does nothing |
1025 | */ |
245ac557 |
1026 | function record_exists_select($table, $select='') { |
1027 | error('record_exists_select() not available anymore'); |
1028 | } |
c861fe2f |
1029 | /** |
1030 | * @deprecated |
1031 | * @param mixed $sql |
1032 | * @return void Throws an error and does nothing |
1033 | */ |
245ac557 |
1034 | function record_exists_sql($sql) { |
1035 | error('record_exists_sql() not available anymore'); |
1036 | } |
c861fe2f |
1037 | /** |
1038 | * @deprecated |
1039 | * @param mixed $table |
1040 | * @param mixed $select |
1041 | * @param mixed $countitem |
1042 | * @return void Throws an error and does nothing |
1043 | */ |
245ac557 |
1044 | function count_records_select($table, $select='', $countitem='COUNT(*)') { |
1045 | error('count_records_select() not available anymore'); |
1046 | } |
c861fe2f |
1047 | /** |
1048 | * @deprecated |
1049 | * @param mixed $sql |
1050 | * @return void Throws an error and does nothing |
1051 | */ |
245ac557 |
1052 | function count_records_sql($sql) { |
1053 | error('count_records_sql() not available anymore'); |
1054 | } |
c861fe2f |
1055 | /** |
1056 | * @deprecated |
1057 | * @param mixed $sql |
1058 | * @param bool $expectmultiple |
1059 | * @param bool $nolimit |
1060 | * @return void Throws an error and does nothing |
1061 | */ |
245ac557 |
1062 | function get_record_sql($sql, $expectmultiple=false, $nolimit=false) { |
1063 | error('get_record_sql() not available anymore'); |
1064 | } |
c861fe2f |
1065 | /** |
1066 | * @deprecated |
1067 | * @param mixed $table |
1068 | * @param mixed $select |
1069 | * @param mixed $fields |
1070 | * @return void Throws an error and does nothing |
1071 | */ |
245ac557 |
1072 | function get_record_select($table, $select='', $fields='*') { |
1073 | error('get_record_select() not available anymore'); |
1074 | } |
c861fe2f |
1075 | /** |
1076 | * @deprecated |
1077 | * @param mixed $table |
1078 | * @param mixed $field |
1079 | * @param mixed $value |
1080 | * @param mixed $sort |
1081 | * @param mixed $fields |
1082 | * @param mixed $limitfrom |
1083 | * @param mixed $limitnum |
1084 | * @return void Throws an error and does nothing |
1085 | */ |
245ac557 |
1086 | function get_recordset($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1087 | error('get_recordset() not available anymore'); |
1088 | } |
c861fe2f |
1089 | /** |
1090 | * @deprecated |
1091 | * @param mixed $sql |
1092 | * @param mixed $limitfrom |
1093 | * @param mixed $limitnum |
1094 | * @return void Throws an error and does nothing |
1095 | */ |
245ac557 |
1096 | function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) { |
1097 | error('get_recordset_sql() not available anymore'); |
1098 | } |
c861fe2f |
1099 | /** |
1100 | * @deprecated |
1101 | * @param mixed $rs |
1102 | * @return void Throws an error and does nothing |
1103 | */ |
245ac557 |
1104 | function rs_fetch_record(&$rs) { |
1105 | error('rs_fetch_record() not available anymore'); |
1106 | } |
c861fe2f |
1107 | /** |
1108 | * @deprecated |
1109 | * @param mixed $rs |
1110 | * @return void Throws an error and does nothing |
1111 | */ |
245ac557 |
1112 | function rs_next_record(&$rs) { |
1113 | error('rs_next_record() not available anymore'); |
1114 | } |
c861fe2f |
1115 | /** |
1116 | * @deprecated |
1117 | * @param mixed $rs |
1118 | * @return void Throws an error and does nothing |
1119 | */ |
245ac557 |
1120 | function rs_fetch_next_record(&$rs) { |
1121 | error('rs_fetch_next_record() not available anymore'); |
1122 | } |
c861fe2f |
1123 | /** |
1124 | * @deprecated |
1125 | * @param mixed $rs |
1126 | * @return void Throws an error and does nothing |
1127 | */ |
245ac557 |
1128 | function rs_EOF($rs) { |
1129 | error('rs_EOF() not available anymore'); |
1130 | } |
c861fe2f |
1131 | /** |
1132 | * @deprecated |
1133 | * @param mixed $rs |
1134 | * @return void Throws an error and does nothing |
1135 | */ |
245ac557 |
1136 | function rs_close(&$rs) { |
1137 | error('rs_close() not available anymore'); |
1138 | } |
c861fe2f |
1139 | /** |
1140 | * @deprecated |
1141 | * @param mixed $table |
1142 | * @param mixed $select |
1143 | * @param mixed $sort |
1144 | * @param mixed $fields |
1145 | * @param mixed $limitfrom |
1146 | * @param mixed $limitnum |
1147 | * @return void Throws an error and does nothing |
1148 | */ |
245ac557 |
1149 | function get_records_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1150 | error('get_records_select() not available anymore'); |
1151 | } |
c861fe2f |
1152 | /** |
1153 | * @deprecated |
1154 | * @param mixed $table |
1155 | * @param mixed $return |
1156 | * @param mixed $select |
1157 | * @return void Throws an error and does nothing |
1158 | */ |
245ac557 |
1159 | function get_field_select($table, $return, $select) { |
1160 | error('get_field_select() not available anymore'); |
1161 | } |
c861fe2f |
1162 | /** |
1163 | * @deprecated |
1164 | * @param mixed $sql |
1165 | * @return void Throws an error and does nothing |
1166 | */ |
245ac557 |
1167 | function get_field_sql($sql) { |
1168 | error('get_field_sql() not available anymore'); |
1169 | } |
c861fe2f |
1170 | /** |
1171 | * @deprecated |
1172 | * @param mixed $sql |
1173 | * @param mixed $select |
1174 | * @return void Throws an error and does nothing |
1175 | */ |
245ac557 |
1176 | function delete_records_select($table, $select='') { |
165a2c9e |
1177 | error('get_field_sql() not available anymore'); |
245ac557 |
1178 | } |
c861fe2f |
1179 | /** |
1180 | * @deprecated |
1181 | * @return void Throws an error and does nothing |
1182 | */ |
245ac557 |
1183 | function configure_dbconnection() { |
1184 | error('configure_dbconnection() removed'); |
1185 | } |
c861fe2f |
1186 | /** |
1187 | * @deprecated |
1188 | * @param mixed $field |
1189 | * @return void Throws an error and does nothing |
1190 | */ |
245ac557 |
1191 | function sql_max($field) { |
1192 | error('sql_max() removed - use normal sql MAX() instead'); |
1193 | } |
c861fe2f |
1194 | /** |
1195 | * @deprecated |
1196 | * @return void Throws an error and does nothing |
1197 | */ |
245ac557 |
1198 | function sql_as() { |
1199 | error('sql_as() removed - do not use AS for tables at all'); |
1200 | } |
c861fe2f |
1201 | /** |
1202 | * @deprecated |
1203 | * @param mixed $page |
1204 | * @param mixed $recordsperpage |
1205 | * @return void Throws an error and does nothing |
1206 | */ |
245ac557 |
1207 | function sql_paging_limit($page, $recordsperpage) { |
1208 | error('Function sql_paging_limit() is deprecated. Replace it with the correct use of limitfrom, limitnum parameters'); |
1209 | } |
c861fe2f |
1210 | /** |
1211 | * @deprecated |
1212 | * @return void Throws an error and does nothing |
1213 | */ |
245ac557 |
1214 | function db_uppercase() { |
1215 | error('upper() removed - use normal sql UPPER()'); |
1216 | } |
c861fe2f |
1217 | /** |
1218 | * @deprecated |
1219 | * @return void Throws an error and does nothing |
1220 | */ |
245ac557 |
1221 | function db_lowercase() { |
1222 | error('upper() removed - use normal sql LOWER()'); |
1223 | } |
c861fe2f |
1224 | /** |
1225 | * @deprecated |
1226 | * @param mixed $sqlfile |
1227 | * @param mixed $sqlstring |
1228 | * @return void Throws an error and does nothing |
1229 | */ |
245ac557 |
1230 | function modify_database($sqlfile='', $sqlstring='') { |
1231 | error('modify_database() removed - use new XMLDB functions'); |
1232 | } |
c861fe2f |
1233 | /** |
1234 | * @deprecated |
1235 | * @param mixed $field1 |
1236 | * @param mixed $value1 |
1237 | * @param mixed $field2 |
1238 | * @param mixed $value2 |
1239 | * @param mixed $field3 |
1240 | * @param mixed $value3 |
1241 | * @return void Throws an error and does nothing |
1242 | */ |
245ac557 |
1243 | function where_clause($field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { |
1244 | error('where_clause() removed - use new functions with $conditions parameter'); |
1245 | } |
c861fe2f |
1246 | /** |
1247 | * @deprecated |
1248 | * @param mixed $sqlarr |
1249 | * @param mixed $continue |
1250 | * @param mixed $feedback |
1251 | * @return void Throws an error and does nothing |
1252 | */ |
245ac557 |
1253 | function execute_sql_arr($sqlarr, $continue=true, $feedback=true) { |
1254 | error('execute_sql_arr() removed'); |
1255 | } |
c861fe2f |
1256 | /** |
1257 | * @deprecated |
1258 | * @param mixed $table |
1259 | * @param mixed $field |
1260 | * @param mixed $values |
1261 | * @param mixed $sort |
1262 | * @param mixed $fields |
1263 | * @param mixed $limitfrom |
1264 | * @param mixed $limitnum |
1265 | * @return void Throws an error and does nothing |
1266 | */ |
245ac557 |
1267 | function get_records_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1268 | error('get_records_list() removed'); |
1269 | } |
c861fe2f |
1270 | /** |
1271 | * @deprecated |
1272 | * @param mixed $table |
1273 | * @param mixed $field |
1274 | * @param mixed $values |
1275 | * @param mixed $sort |
1276 | * @param mixed $fields |
1277 | * @param mixed $limitfrom |
1278 | * @param mixed $limitnum |
1279 | * @return void Throws an error and does nothing |
1280 | */ |
245ac557 |
1281 | function get_recordset_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1282 | error('get_recordset_list() removed'); |
1283 | } |
c861fe2f |
1284 | /** |
1285 | * @deprecated |
1286 | * @param mixed $table |
1287 | * @param mixed $field |
1288 | * @param mixed $value |
1289 | * @param mixed $sort |
1290 | * @param mixed $fields |
1291 | * @param mixed $limitfrom |
1292 | * @param mixed $limitnum |
1293 | * @return void Throws an error and does nothing |
1294 | */ |
245ac557 |
1295 | function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1296 | error('get_records_menu() removed'); |
1297 | } |
c861fe2f |
1298 | /** |
1299 | * @deprecated |
1300 | * @param mixed $table |
1301 | * @param mixed $select |
1302 | * @param mixed $sort |
1303 | * @param mixed $fields |
1304 | * @param mixed $limitfrom |
1305 | * @param mixed $limitnum |
1306 | * @return void Throws an error and does nothing |
1307 | */ |
245ac557 |
1308 | function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1309 | error('get_records_select_menu() removed'); |
1310 | } |
c861fe2f |
1311 | /** |
1312 | * @deprecated |
1313 | * @param mixed $sql |
1314 | * @param mixed $limitfrom |
1315 | * @param mixed $limitnum |
1316 | * @return void Throws an error and does nothing |
1317 | */ |
245ac557 |
1318 | function get_records_sql_menu($sql, $limitfrom='', $limitnum='') { |
1319 | error('get_records_sql_menu() removed'); |
1320 | } |
c861fe2f |
1321 | /** |
1322 | * @deprecated |
1323 | * @param mixed $table |
1324 | * @param mixed $column |
1325 | * @return void Throws an error and does nothing |
1326 | */ |
245ac557 |
1327 | function column_type($table, $column) { |
1328 | error('column_type() removed'); |
1329 | } |
c861fe2f |
1330 | /** |
1331 | * @deprecated |
1332 | * @param mixed $rs |
1333 | * @return void Throws an error and does nothing |
1334 | */ |
245ac557 |
1335 | function recordset_to_menu($rs) { |
1336 | error('recordset_to_menu() removed'); |
1337 | } |
c861fe2f |
1338 | /** |
1339 | * @deprecated |
1340 | * @param mixed $records |
1341 | * @param mixed $field1 |
1342 | * @param mixed $field2 |
1343 | * @return void Throws an error and does nothing |
1344 | */ |
245ac557 |
1345 | function records_to_menu($records, $field1, $field2) { |
1346 | error('records_to_menu() removed'); |
1347 | } |
c861fe2f |
1348 | /** |
1349 | * @deprecated |
1350 | * @param mixed $table |
1351 | * @param mixed $newfield |
1352 | * @param mixed $newvalue |
1353 | * @param mixed $select |
1354 | * @param mixed $localcall |
1355 | * @return void Throws an error and does nothing |
1356 | */ |
245ac557 |
1357 | function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) { |
1358 | error('set_field_select() removed'); |
1359 | } |
c861fe2f |
1360 | /** |
1361 | * @deprecated |
1362 | * @param mixed $table |
1363 | * @param mixed $return |
1364 | * @param mixed $select |
1365 | * @return void Throws an error and does nothing |
1366 | */ |
245ac557 |
1367 | function get_fieldset_select($table, $return, $select) { |
1368 | error('get_fieldset_select() removed'); |
1369 | } |
c861fe2f |
1370 | /** |
1371 | * @deprecated |
1372 | * @param mixed $sql |
1373 | * @return void Throws an error and does nothing |
1374 | */ |
245ac557 |
1375 | function get_fieldset_sql($sql) { |
1376 | error('get_fieldset_sql() removed'); |
1377 | } |
c861fe2f |
1378 | /** |
1379 | * @deprecated |
1380 | * @return void Throws an error and does nothing |
1381 | */ |
245ac557 |
1382 | function sql_ilike() { |
1383 | error('sql_ilike() not available anymore'); |
1384 | } |
c861fe2f |
1385 | /** |
1386 | * @deprecated |
1387 | * @param mixed $first |
1388 | * @param mixed $last |
1389 | * @return void Throws an error and does nothing |
1390 | */ |
245ac557 |
1391 | function sql_fullname($first='firstname', $last='lastname') { |
1392 | error('sql_fullname() not available anymore'); |
1393 | } |
c861fe2f |
1394 | /** |
1395 | * @deprecated |
1396 | * @return void Throws an error and does nothing |
1397 | */ |
245ac557 |
1398 | function sql_concat() { |
1399 | error('sql_concat() not available anymore'); |
1400 | } |
c861fe2f |
1401 | /** |
1402 | * @deprecated |
1403 | * @return void Throws an error and does nothing |
1404 | */ |
245ac557 |
1405 | function sql_empty() { |
1406 | error('sql_empty() not available anymore'); |
1407 | } |
c861fe2f |
1408 | /** |
1409 | * @deprecated |
1410 | * @return void Throws an error and does nothing |
1411 | */ |
245ac557 |
1412 | function sql_substr() { |
1413 | error('sql_substr() not available anymore'); |
1414 | } |
c861fe2f |
1415 | /** |
1416 | * @deprecated |
1417 | * @param mixed $int1 |
1418 | * @param mixed $int2 |
1419 | * @return void Throws an error and does nothing |
1420 | */ |
245ac557 |
1421 | function sql_bitand($int1, $int2) { |
1422 | error('sql_bitand() not available anymore'); |
1423 | } |
c861fe2f |
1424 | /** |
1425 | * @deprecated |
1426 | * @param mixed $int1 |
1427 | * @return void Throws an error and does nothing |
1428 | */ |
245ac557 |
1429 | function sql_bitnot($int1) { |
1430 | error('sql_bitnot() not available anymore'); |
1431 | } |
c861fe2f |
1432 | /** |
1433 | * @deprecated |
1434 | * @param mixed $int1 |
1435 | * @param mixed $int2 |
1436 | * @return void Throws an error and does nothing |
1437 | */ |
245ac557 |
1438 | function sql_bitor($int1, $int2) { |
1439 | error('sql_bitor() not available anymore'); |
1440 | } |
c861fe2f |
1441 | /** |
1442 | * @deprecated |
1443 | * @param mixed $int1 |
1444 | * @param mixed $int2 |
1445 | * @return void Throws an error and does nothing |
1446 | */ |
245ac557 |
1447 | function sql_bitxor($int1, $int2) { |
1448 | error('sql_bitxor() not available anymore'); |
1449 | } |
c861fe2f |
1450 | /** |
1451 | * @deprecated |
1452 | * @param mixed $fieldname |
1453 | * @param mixed $text |
1454 | * @return void Throws an error and does nothing |
1455 | */ |
245ac557 |
1456 | function sql_cast_char2int($fieldname, $text=false) { |
1457 | error('sql_cast_char2int() not available anymore'); |
1458 | } |
c861fe2f |
1459 | /** |
1460 | * @deprecated |
1461 | * @param mixed $fieldname |
1462 | * @param mixed $numchars |
1463 | * @return void Throws an error and does nothing |
1464 | */ |
245ac557 |
1465 | function sql_compare_text($fieldname, $numchars=32) { |
1466 | error('sql_compare_text() not available anymore'); |
1467 | } |
c861fe2f |
1468 | /** |
1469 | * @deprecated |
1470 | * @param mixed $fieldname |
1471 | * @param mixed $numchars |
1472 | * @return void Throws an error and does nothing |
1473 | */ |
245ac557 |
1474 | function sql_order_by_text($fieldname, $numchars=32) { |
1475 | error('sql_order_by_text() not available anymore'); |
1476 | } |
c861fe2f |
1477 | /** |
1478 | * @deprecated |
1479 | * @param mixed $fieldname |
1480 | * @return void Throws an error and does nothing |
1481 | */ |
7b837bc3 |
1482 | function sql_length($fieldname) { |
1483 | error('sql_length() not available anymore'); |
1484 | } |
c861fe2f |
1485 | /** |
1486 | * @deprecated |
1487 | * @param mixed $separator |
1488 | * @param mixed $elements |
1489 | * @return void Throws an error and does nothing |
1490 | */ |
245ac557 |
1491 | function sql_concat_join($separator="' '", $elements=array()) { |
1492 | error('sql_concat_join() not available anymore'); |
1493 | } |
c861fe2f |
1494 | /** |
1495 | * @deprecated |
1496 | * @param mixed $tablename |
1497 | * @param mixed $fieldname |
1498 | * @param mixed $nullablefield |
1499 | * @param mixed $textfield |
1500 | * @return void Throws an error and does nothing |
1501 | */ |
245ac557 |
1502 | function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) { |
1503 | error('sql_isempty() not available anymore'); |
1504 | } |
c861fe2f |
1505 | /** |
1506 | * @deprecated |
1507 | * @param mixed $tablename |
1508 | * @param mixed $fieldname |
1509 | * @param mixed $nullablefield |
1510 | * @param mixed $textfield |
1511 | * @return void Throws an error and does nothing |
1512 | */ |
245ac557 |
1513 | function sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield) { |
1514 | error('sql_isnotempty() not available anymore'); |
1515 | } |
c861fe2f |
1516 | /** |
1517 | * @deprecated |
1518 | * @return void Throws an error and does nothing |
1519 | */ |
245ac557 |
1520 | function begin_sql() { |
1521 | error('begin_sql() not available anymore'); |
1522 | } |
c861fe2f |
1523 | /** |
1524 | * @deprecated |
1525 | * @return void Throws an error and does nothing |
1526 | */ |
245ac557 |
1527 | function commit_sql() { |
1528 | error('commit_sql() not available anymore'); |
1529 | } |
c861fe2f |
1530 | /** |
1531 | * @deprecated |
1532 | * @return void Throws an error and does nothing |
1533 | */ |
245ac557 |
1534 | function rollback_sql() { |
1535 | error('rollback_sql() not available anymore'); |
1536 | } |
c861fe2f |
1537 | /** |
1538 | * @deprecated |
1539 | * @param mixed $table |
1540 | * @param mixed $dataobject |
1541 | * @param mixed $returnid |
1542 | * @param mixed $primarykey |
1543 | * @return void Throws an error and does nothing |
1544 | */ |
245ac557 |
1545 | function insert_record($table, $dataobject, $returnid=true, $primarykey='id') { |
1546 | error('insert_record() not available anymore'); |
1547 | } |
c861fe2f |
1548 | /** |
1549 | * @deprecated |
1550 | * @param mixed $table |
1551 | * @param mixed $dataobject |
1552 | * @return void Throws an error and does nothing |
1553 | */ |
245ac557 |
1554 | function update_record($table, $dataobject) { |
1555 | error('update_record() not available anymore'); |
1556 | } |
c861fe2f |
1557 | /** |
1558 | * @deprecated |
1559 | * @param mixed $table |
1560 | * @param mixed $field |
1561 | * @param mixed $value |
1562 | * @param mixed $sort |
1563 | * @param mixed $fields |
1564 | * @param mixed $limitfrom |
1565 | * @param mixed $limitnum |
1566 | |
1567 | * @return void Throws an error and does nothing |
1568 | */ |
245ac557 |
1569 | function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { |
1570 | error('get_records() not available anymore'); |
1571 | } |
c861fe2f |
1572 | /** |
1573 | * @deprecated |
1574 | * @param mixed $table |
1575 | * @param mixed $field1 |
1576 | * @param mixed $value1 |
1577 | * @param mixed $field2 |
1578 | * @param mixed $value2 |
1579 | * @param mixed $field3 |
1580 | * @param mixed $value3 |
1581 | * @param mixed $fields |
1582 | * @return void Throws an error and does nothing |
1583 | */ |
245ac557 |
1584 | function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') { |
1585 | error('get_record() not available anymore'); |
1586 | } |
c861fe2f |
1587 | /** |
1588 | * @deprecated |
1589 | * @param mixed $table |
1590 | * @param mixed $newfield |
1591 | * @param mixed $newvalue |
1592 | * @param mixed $field1 |
1593 | * @param mixed $value1 |
1594 | * @param mixed $field2 |
1595 | * @param mixed $value2 |
1596 | * @param mixed $field3 |
1597 | * @param mixed $value3 |
1598 | * @return void Throws an error and does nothing |
1599 | */ |
245ac557 |
1600 | function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $value2='', $field3='', $value3='') { |
1601 | error('set_field() not available anymore'); |
1602 | } |
c861fe2f |
1603 | /** |
1604 | * @deprecated |
1605 | * @param mixed $table |
1606 | * @param mixed $field1 |
1607 | * @param mixed $value1 |
1608 | * @param mixed $field2 |
1609 | * @param mixed $value2 |
1610 | * @param mixed $field3 |
1611 | * @param mixed $value3 |
1612 | * @return void Throws an error and does nothing |
1613 | */ |
245ac557 |
1614 | function count_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { |
1615 | error('count_records() not available anymore'); |
1616 | } |
c861fe2f |
1617 | /** |
1618 | * @deprecated |
1619 | * @param mixed $table |
1620 | * @param mixed $field1 |
1621 | * @param mixed $value1 |
1622 | * @param mixed $field2 |
1623 | * @param mixed $value2 |
1624 | * @param mixed $field3 |
1625 | * @param mixed $value3 |
1626 | * @return void Throws an error and does nothing |
1627 | */ |
245ac557 |
1628 | function record_exists($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { |
1629 | error('record_exists() not available anymore'); |
1630 | } |
c861fe2f |
1631 | /** |
1632 | * @deprecated |
1633 | * @param mixed $table |
1634 | * @param mixed $field1 |
1635 | * @param mixed $value1 |
1636 | * @param mixed $field2 |
1637 | * @param mixed $value2 |
1638 | * @param mixed $field3 |
1639 | * @param mixed $value3 |
1640 | * @return void Throws an error and does nothing |
1641 | */ |
245ac557 |
1642 | function delete_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') { |
1643 | error('delete_records() not available anymore'); |
1644 | } |
c861fe2f |
1645 | /** |
1646 | * @deprecated |
1647 | * @param mixed $table |
1648 | * @param mixed $return |
1649 | * @param mixed $field1 |
1650 | * @param mixed $value1 |
1651 | * @param mixed $field2 |
1652 | * @param mixed $value2 |
1653 | * @param mixed $field3 |
1654 | * @param mixed $value3 |
1655 | * @return void Throws an error and does nothing |
1656 | */ |
245ac557 |
1657 | function get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='') { |
1658 | error('get_field() not available anymore'); |
1659 | } |
c861fe2f |
1660 | /** |
1661 | * @deprecated |
1662 | * @param mixed $table |
1663 | * @param mixed $oldfield |
1664 | * @param mixed $field |
1665 | * @param mixed $type |
1666 | * @param mixed $size |
1667 | * @param mixed $signed |
1668 | * @param mixed $default |
1669 | * @param mixed $null |
1670 | * @param mixed $after |
1671 | * @return void Throws an error and does nothing |
1672 | */ |
e6b4f00e |
1673 | function table_column($table, $oldfield, $field, $type='integer', $size='10', |
1674 | $signed='unsigned', $default='0', $null='not null', $after='') { |
1675 | error('table_column() was removed, please use new ddl functions'); |
1676 | } |
c861fe2f |
1677 | /** |
1678 | * @deprecated |
1679 | * @param mixed $name |
1680 | * @param mixed $editorhidebuttons |
1681 | * @param mixed $id |
1682 | * @return void Throws an error and does nothing |
1683 | */ |
88c8d161 |
1684 | function use_html_editor($name='', $editorhidebuttons='', $id='') { |
1685 | error('use_html_editor() not available anymore'); |
1686 | } |
cf615522 |
1687 | |
1688 | /** |
1689 | * The old method that was used to include JavaScript libraries. |
1690 | * Please use $PAGE->requires->js() or $PAGE->requires->yui_lib() instead. |
1691 | * |
1692 | * @param mixed $lib The library or libraries to load (a string or array of strings) |
1693 | * There are three way to specify the library: |
1694 | * 1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui_lib('yahoo')->asap(); |
1695 | * 2. the path to the library relative to wwwroot, for example 'lib/javascript-static.js' |
1696 | * 3. (legacy) a full URL like $CFG->wwwroot . '/lib/javascript-static.js'. |
1697 | * 2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js'). |
1698 | */ |
1699 | function require_js($lib) { |
1700 | global $CFG, $PAGE; |
1701 | // Add the lib to the list of libs to be loaded, if it isn't already |
1702 | // in the list. |
1703 | if (is_array($lib)) { |
1704 | foreach($lib as $singlelib) { |
1705 | require_js($singlelib); |
1706 | } |
1707 | return; |
1708 | } |
1709 | |
1710 | // TODO uncomment this once we have eliminated the remaining calls to require_js from core. |
1711 | //debugging('Call to deprecated function require_js. Please use $PAGE->requires->js() ' . |
1712 | // 'or $PAGE->requires->yui_lib() instead.', DEBUG_DEVELOPER); |
1713 | |
1714 | if (strpos($lib, 'yui_') === 0) { |
1715 | echo $PAGE->requires->yui_lib(substr($lib, 4))->asap(); |
1716 | } else if (preg_match('/^https?:/', $lib)) { |
1717 | echo $PAGE->requires->js(str_replace($CFG->wwwroot, '', $lib))->asap(); |
1718 | } else { |
1719 | echo $PAGE->requires->js($lib)->asap(); |
1720 | } |
1721 | } |
5af6ec1b |
1722 | |
1723 | /** |
1724 | * Makes an upload directory for a particular module. |
1725 | * |
1726 | * This funciton has been deprecated by the file API changes in Moodle 2.0. |
1727 | * |
1728 | * @deprecated |
1729 | * @param int $courseid The id of the course in question - maps to id field of 'course' table. |
1730 | * @return string|false Returns full path to directory if successful, false if not |
1731 | */ |
1732 | function make_mod_upload_directory($courseid) { |
1733 | global $CFG; |
1734 | debugging('make_mod_upload_directory has been deprecated by the file API changes in Moodle 2.0.', DEBUG_DEVELOPER); |
1735 | return make_upload_directory($courseid .'/'. $CFG->moddata); |
1736 | } |
1737 | |
8954245a |
1738 | /** |
1739 | * Prints some red text using echo |
1740 | * |
1741 | * @deprecated |
1742 | * @param string $error The text to be displayed in red |
1743 | */ |
1744 | function formerr($error) { |
1745 | global $OUTPUT; |
1746 | echo $OUTPUT->error_text($error); |
1747 | } |
1748 | |