2009-05-22 09:10:53 +00:00
|
|
|
<?php
|
|
|
|
|
2009-06-29 08:17:31 +00:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
2009-05-22 09:10:53 +00:00
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2009-06-29 08:17:31 +00:00
|
|
|
//
|
2009-05-22 09:10:53 +00:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
2006-09-03 08:10:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* deprecatedlib.php - Old functions retained only for backward compatibility
|
|
|
|
*
|
|
|
|
* Old functions retained only for backward compatibility. New code should not
|
|
|
|
* use any of these functions.
|
|
|
|
*
|
|
|
|
* @package moodlecore
|
2009-05-22 09:10:53 +00:00
|
|
|
* @subpackage deprecated
|
|
|
|
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @deprecated
|
2006-09-03 08:10:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if a user is a teacher (or better)
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
|
|
|
* @uses CONTEXT_COURSE
|
|
|
|
* @uses CONTEXT_SYSTEM
|
2006-09-03 08:10:10 +00:00
|
|
|
* @param int $courseid The id of the course that is being viewed, if any
|
|
|
|
* @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.
|
|
|
|
* @param bool $obsolete_includeadmin Not used any more
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function isteacher($courseid=0, $userid=0, $obsolete_includeadmin=true) {
|
|
|
|
/// Is the user able to access this course as a teacher?
|
2006-09-04 08:31:07 +00:00
|
|
|
global $CFG;
|
2006-09-03 08:10:10 +00:00
|
|
|
|
|
|
|
if ($courseid) {
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
|
|
|
} else {
|
2008-05-01 06:07:24 +00:00
|
|
|
$context = get_context_instance(CONTEXT_SYSTEM);
|
2006-09-03 08:10:10 +00:00
|
|
|
}
|
|
|
|
|
2006-09-04 08:31:07 +00:00
|
|
|
return (has_capability('moodle/legacy:teacher', $context, $userid, false)
|
|
|
|
or has_capability('moodle/legacy:editingteacher', $context, $userid, false)
|
|
|
|
or has_capability('moodle/legacy:admin', $context, $userid, false));
|
2006-09-03 08:10:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if a user is a teacher in any course, or an admin
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
|
|
|
* @global object
|
|
|
|
* @global object
|
|
|
|
* @uses CAP_ALLOW
|
|
|
|
* @uses CONTEXT_SYSTEM
|
2006-09-03 08:10:10 +00:00
|
|
|
* @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.
|
2006-09-04 08:31:07 +00:00
|
|
|
* @param bool $includeadmin Include anyone wo is an admin as well
|
2006-09-03 08:10:10 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2006-09-04 08:31:07 +00:00
|
|
|
function isteacherinanycourse($userid=0, $includeadmin=true) {
|
2008-05-25 11:18:12 +00:00
|
|
|
global $USER, $CFG, $DB;
|
2006-09-03 08:10:10 +00:00
|
|
|
|
|
|
|
if (!$userid) {
|
|
|
|
if (empty($USER->id)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$userid = $USER->id;
|
|
|
|
}
|
|
|
|
|
2008-05-25 11:18:12 +00:00
|
|
|
if (!$DB->record_exists('role_assignments', array('userid'=>$userid))) { // Has no roles anywhere
|
2006-09-03 08:10:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// If this user is assigned as an editing teacher anywhere then return true
|
|
|
|
if ($roles = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW)) {
|
|
|
|
foreach ($roles as $role) {
|
2008-05-25 11:18:12 +00:00
|
|
|
if ($DB->record_exists('role_assignments', array('roleid'=>$role->id, 'userid'=>$userid))) {
|
2006-09-03 08:10:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// If this user is assigned as a non-editing teacher anywhere then return true
|
|
|
|
if ($roles = get_roles_with_capability('moodle/legacy:teacher', CAP_ALLOW)) {
|
|
|
|
foreach ($roles as $role) {
|
2008-05-25 11:18:12 +00:00
|
|
|
if ($DB->record_exists('role_assignments', array('roleid'=>$role->id, 'userid'=>$userid))) {
|
2006-09-03 08:10:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-04 08:31:07 +00:00
|
|
|
/// Include admins if required
|
|
|
|
if ($includeadmin) {
|
2008-05-01 06:07:24 +00:00
|
|
|
$context = get_context_instance(CONTEXT_SYSTEM);
|
2006-09-04 08:31:07 +00:00
|
|
|
if (has_capability('moodle/legacy:admin', $context, $userid, false)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2006-09-03 08:10:10 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines if the specified user is logged in as guest.
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
|
|
|
* @uses CONTEXT_SYSTEM
|
2006-09-03 08:10:10 +00:00
|
|
|
* @param int $userid The user being tested. You can set this to 0 or leave it blank to test the currently logged in user.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function isguest($userid=0) {
|
2006-09-04 08:31:07 +00:00
|
|
|
global $CFG;
|
2006-09-03 08:10:10 +00:00
|
|
|
|
2007-08-24 04:22:30 +00:00
|
|
|
$context = get_context_instance(CONTEXT_SYSTEM);
|
2006-09-03 08:10:10 +00:00
|
|
|
|
2006-09-04 08:31:07 +00:00
|
|
|
return has_capability('moodle/legacy:guest', $context, $userid, false);
|
2006-09-03 08:10:10 +00:00
|
|
|
}
|
|
|
|
|
2006-09-10 07:07:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the guest user information from the database
|
|
|
|
*
|
2009-06-29 08:17:31 +00:00
|
|
|
* @todo Is object(user) a correct return type? Or is array the proper return type with a
|
2009-05-22 09:10:53 +00:00
|
|
|
* note that the contents include all details for a user.
|
|
|
|
*
|
2006-09-10 07:07:52 +00:00
|
|
|
* @return object(user) An associative array with the details of the guest user account.
|
|
|
|
*/
|
|
|
|
function get_guest() {
|
|
|
|
return get_complete_user_data('username', 'guest');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns $user object of the main teacher for a course
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
|
|
|
* @uses CONTEXT_COURSE
|
2006-09-10 07:07:52 +00:00
|
|
|
* @param int $courseid The course in question.
|
|
|
|
* @return user|false A {@link $USER} record of the main teacher for the specified course or false if error.
|
|
|
|
*/
|
|
|
|
function get_teacher($courseid) {
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
2006-09-16 13:55:30 +00:00
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
|
|
|
|
2008-01-06 23:25:26 +00:00
|
|
|
// Pass $view=true to filter hidden caps if the user cannot see them
|
|
|
|
if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',
|
|
|
|
'', '', '', '', false, true)) {
|
2008-01-06 23:25:51 +00:00
|
|
|
$users = sort_by_roleassignment_authority($users, $context);
|
2008-01-06 23:25:26 +00:00
|
|
|
return array_shift($users);
|
2006-09-10 07:07:52 +00:00
|
|
|
}
|
2006-09-16 13:55:30 +00:00
|
|
|
|
|
|
|
return false;
|
2006-09-10 07:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Searches logs to find all enrolments since a certain date
|
|
|
|
*
|
|
|
|
* used to print recent activity
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
|
|
|
* @uses CONTEXT_COURSE
|
2006-09-10 07:07:52 +00:00
|
|
|
* @param int $courseid The course in question.
|
2009-05-22 09:10:53 +00:00
|
|
|
* @param int $timestart The date to check forward of
|
2006-09-10 07:07:52 +00:00
|
|
|
* @return object|false {@link $USER} records or false if error.
|
|
|
|
*/
|
|
|
|
function get_recent_enrolments($courseid, $timestart) {
|
2008-05-25 14:33:33 +00:00
|
|
|
global $DB;
|
2007-08-24 04:22:30 +00:00
|
|
|
|
2006-09-15 09:08:48 +00:00
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
2006-09-10 07:07:52 +00:00
|
|
|
|
2008-05-25 14:33:33 +00:00
|
|
|
$sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, l.time
|
|
|
|
FROM {user} u, {role_assignments} ra, {log} l
|
|
|
|
WHERE l.time > ?
|
|
|
|
AND l.course = ?
|
|
|
|
AND l.module = 'course'
|
|
|
|
AND l.action = 'enrol'
|
2008-06-01 13:20:02 +00:00
|
|
|
AND ".$DB->sql_cast_char2int('l.info')." = u.id
|
2008-05-25 14:33:33 +00:00
|
|
|
AND u.id = ra.userid
|
|
|
|
AND ra.contextid ".get_related_contexts_string($context)."
|
|
|
|
ORDER BY l.time ASC";
|
|
|
|
$params = array($timestart, $courseid);
|
|
|
|
return $DB->get_records_sql($sql, $params);
|
2006-09-10 07:07:52 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 03:06:32 +00:00
|
|
|
########### FROM weblib.php ##########################################################################
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a message in a standard themed box.
|
2007-08-24 04:22:30 +00:00
|
|
|
* This old function used to implement boxes using tables. Now it uses a DIV, but the old
|
2007-01-08 03:06:32 +00:00
|
|
|
* parameters remain. If possible, $align, $width and $color should not be defined at all.
|
|
|
|
* Preferably just use print_box() in weblib.php
|
|
|
|
*
|
2009-06-26 09:06:16 +00:00
|
|
|
* @deprecated
|
2009-05-22 09:10:53 +00:00
|
|
|
* @param string $message The message to display
|
|
|
|
* @param string $align alignment of the box, not the text (default center, left, right).
|
|
|
|
* @param string $width width of the box, including units %, for example '100%'.
|
|
|
|
* @param string $color background colour of the box, for example '#eee'.
|
|
|
|
* @param int $padding padding in pixels, specified without units.
|
|
|
|
* @param string $class space-separated class names.
|
|
|
|
* @param string $id space-separated id names.
|
|
|
|
* @param boolean $return return as string or just print it
|
|
|
|
* @return string|void Depending on $return
|
2007-01-08 03:06:32 +00:00
|
|
|
*/
|
|
|
|
function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
|
|
|
|
$output = '';
|
|
|
|
$output .= print_simple_box_start($align, $width, $color, $padding, $class, $id, true);
|
2008-06-09 16:53:30 +00:00
|
|
|
$output .= $message;
|
2007-01-08 03:06:32 +00:00
|
|
|
$output .= print_simple_box_end(true);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-08-24 04:22:30 +00:00
|
|
|
* This old function used to implement boxes using tables. Now it uses a DIV, but the old
|
2007-01-08 03:06:32 +00:00
|
|
|
* parameters remain. If possible, $align, $width and $color should not be defined at all.
|
|
|
|
* Even better, please use print_box_start() in weblib.php
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @param string $align alignment of the box, not the text (default center, left, right). DEPRECATED
|
|
|
|
* @param string $width width of the box, including % units, for example '100%'. DEPRECATED
|
|
|
|
* @param string $color background colour of the box, for example '#eee'. DEPRECATED
|
|
|
|
* @param int $padding padding in pixels, specified without units. OBSOLETE
|
|
|
|
* @param string $class space-separated class names.
|
|
|
|
* @param string $id space-separated id names.
|
|
|
|
* @param boolean $return return as string or just print it
|
|
|
|
* @return string|void Depending on $return
|
2007-01-08 03:06:32 +00:00
|
|
|
*/
|
|
|
|
function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
|
2009-07-03 04:08:52 +00:00
|
|
|
debugging('print_simple_box(_start/_end) is deprecated. Please use $OUTPUT->box(_start/_end) instead', DEBUG_DEVELOPER);
|
2007-01-08 03:06:32 +00:00
|
|
|
|
|
|
|
$output = '';
|
|
|
|
|
2007-01-23 05:37:26 +00:00
|
|
|
$divclasses = 'box '.$class.' '.$class.'content';
|
2007-01-08 03:06:32 +00:00
|
|
|
$divstyles = '';
|
|
|
|
|
|
|
|
if ($align) {
|
|
|
|
$divclasses .= ' boxalign'.$align; // Implement alignment using a class
|
|
|
|
}
|
|
|
|
if ($width) { // Hopefully we can eliminate these in calls to this function (inline styles are bad)
|
2007-01-23 05:37:26 +00:00
|
|
|
if (substr($width, -1, 1) == '%') { // Width is a % value
|
|
|
|
$width = (int) substr($width, 0, -1); // Extract just the number
|
|
|
|
if ($width < 40) {
|
|
|
|
$divclasses .= ' boxwidthnarrow'; // Approx 30% depending on theme
|
|
|
|
} else if ($width > 60) {
|
|
|
|
$divclasses .= ' boxwidthwide'; // Approx 80% depending on theme
|
|
|
|
} else {
|
|
|
|
$divclasses .= ' boxwidthnormal'; // Approx 50% depending on theme
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$divstyles .= ' width:'.$width.';'; // Last resort
|
|
|
|
}
|
2007-01-08 03:06:32 +00:00
|
|
|
}
|
|
|
|
if ($color) { // Hopefully we can eliminate these in calls to this function (inline styles are bad)
|
|
|
|
$divstyles .= ' background:'.$color.';';
|
|
|
|
}
|
|
|
|
if ($divstyles) {
|
|
|
|
$divstyles = ' style="'.$divstyles.'"';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($id) {
|
|
|
|
$id = ' id="'.$id.'"';
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= '<div'.$id.$divstyles.' class="'.$divclasses.'">';
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print the end portion of a standard themed box.
|
|
|
|
* Preferably just use print_box_end() in weblib.php
|
2009-05-22 09:10:53 +00:00
|
|
|
*
|
|
|
|
* @param boolean $return return as string or just print it
|
|
|
|
* @return string|void Depending on $return
|
2007-01-08 03:06:32 +00:00
|
|
|
*/
|
|
|
|
function print_simple_box_end($return=false) {
|
|
|
|
$output = '</div>';
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-20 13:32:15 +00:00
|
|
|
/**
|
|
|
|
* deprecated - use clean_param($string, PARAM_FILE); instead
|
|
|
|
* Check for bad characters ?
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @todo Finish documenting this function - more detail needed in description as well as details on arguments
|
|
|
|
*
|
2007-01-20 13:32:15 +00:00
|
|
|
* @param string $string ?
|
|
|
|
* @param int $allowdots ?
|
2009-05-22 09:10:53 +00:00
|
|
|
* @return bool
|
2007-01-20 13:32:15 +00:00
|
|
|
*/
|
|
|
|
function detect_munged_arguments($string, $allowdots=1) {
|
|
|
|
if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (ereg('[\|\`]', $string)) { // check for other bad characters
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (empty($string) or $string == '/') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-28 21:18:08 +00:00
|
|
|
|
2008-08-02 18:59:00 +00:00
|
|
|
/**
|
|
|
|
* Unzip one zip file to a destination dir
|
|
|
|
* Both parameters must be FULL paths
|
|
|
|
* If destination isn't specified, it will be the
|
|
|
|
* SAME directory where the zip file resides.
|
2009-05-22 09:10:53 +00:00
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param string $zipfile The zip file to unzip
|
|
|
|
* @param string $destination The location to unzip to
|
|
|
|
* @param bool $showstatus_ignored Unused
|
2008-08-02 18:59:00 +00:00
|
|
|
*/
|
|
|
|
function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
//Extract everything from zipfile
|
|
|
|
$path_parts = pathinfo(cleardoubleslashes($zipfile));
|
|
|
|
$zippath = $path_parts["dirname"]; //The path of the zip file
|
|
|
|
$zipfilename = $path_parts["basename"]; //The name of the zip file
|
|
|
|
$extension = $path_parts["extension"]; //The extension of the file
|
|
|
|
|
|
|
|
//If no file, error
|
|
|
|
if (empty($zipfilename)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//If no extension, error
|
|
|
|
if (empty($extension)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Clear $zipfile
|
|
|
|
$zipfile = cleardoubleslashes($zipfile);
|
|
|
|
|
|
|
|
//Check zipfile exists
|
|
|
|
if (!file_exists($zipfile)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//If no destination, passed let's go with the same directory
|
|
|
|
if (empty($destination)) {
|
|
|
|
$destination = $zippath;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Clear $destination
|
|
|
|
$destpath = rtrim(cleardoubleslashes($destination), "/");
|
|
|
|
|
|
|
|
//Check destination path exists
|
|
|
|
if (!is_dir($destpath)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-08 10:22:59 +00:00
|
|
|
$packer = get_file_packer('application/zip');
|
|
|
|
|
|
|
|
$result = $packer->extract_to_pathname($zipfile, $destpath);
|
2008-08-02 18:59:00 +00:00
|
|
|
|
|
|
|
if ($result === false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($result as $status) {
|
|
|
|
if ($status !== true) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-04 16:45:08 +00:00
|
|
|
/**
|
|
|
|
* Zip an array of files/dirs to a destination zip file
|
|
|
|
* Both parameters must be FULL paths to the files/dirs
|
2009-05-22 09:10:53 +00:00
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param array $originalfiles Files to zip
|
|
|
|
* @param string $destination The destination path
|
|
|
|
* @return bool Outcome
|
2008-08-04 16:45:08 +00:00
|
|
|
*/
|
|
|
|
function zip_files ($originalfiles, $destination) {
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
//Extract everything from destination
|
|
|
|
$path_parts = pathinfo(cleardoubleslashes($destination));
|
|
|
|
$destpath = $path_parts["dirname"]; //The path of the zip file
|
|
|
|
$destfilename = $path_parts["basename"]; //The name of the zip file
|
|
|
|
$extension = $path_parts["extension"]; //The extension of the file
|
|
|
|
|
|
|
|
//If no file, error
|
|
|
|
if (empty($destfilename)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//If no extension, add it
|
|
|
|
if (empty($extension)) {
|
|
|
|
$extension = 'zip';
|
|
|
|
$destfilename = $destfilename.'.'.$extension;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check destination path exists
|
|
|
|
if (!is_dir($destpath)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Check destination path is writable. TODO!!
|
|
|
|
|
|
|
|
//Clean destination filename
|
|
|
|
$destfilename = clean_filename($destfilename);
|
|
|
|
|
|
|
|
//Now check and prepare every file
|
|
|
|
$files = array();
|
|
|
|
$origpath = NULL;
|
|
|
|
|
|
|
|
foreach ($originalfiles as $file) { //Iterate over each file
|
|
|
|
//Check for every file
|
|
|
|
$tempfile = cleardoubleslashes($file); // no doubleslashes!
|
|
|
|
//Calculate the base path for all files if it isn't set
|
|
|
|
if ($origpath === NULL) {
|
|
|
|
$origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
|
|
|
|
}
|
|
|
|
//See if the file is readable
|
|
|
|
if (!is_readable($tempfile)) { //Is readable
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//See if the file/dir is in the same directory than the rest
|
|
|
|
if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//Add the file to the array
|
|
|
|
$files[] = $tempfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
$zipfiles = array();
|
|
|
|
$start = strlen($origpath)+1;
|
|
|
|
foreach($files as $file) {
|
|
|
|
$zipfiles[substr($file, $start)] = $file;
|
|
|
|
}
|
|
|
|
|
2008-08-08 10:22:59 +00:00
|
|
|
$packer = get_file_packer('application/zip');
|
2008-08-04 16:45:08 +00:00
|
|
|
|
2008-10-16 17:50:13 +00:00
|
|
|
return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
|
2008-08-04 16:45:08 +00:00
|
|
|
}
|
|
|
|
|
2007-01-20 13:32:15 +00:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
/// Old functions not used anymore - candidates for removal
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2007-08-15 19:28:11 +00:00
|
|
|
/** various deprecated groups function **/
|
|
|
|
|
|
|
|
|
2007-08-16 11:06:48 +00:00
|
|
|
/**
|
|
|
|
* Get the IDs for the user's groups in the given course.
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
2007-08-16 11:06:48 +00:00
|
|
|
* @param int $courseid The course being examined - the 'course' table id field.
|
2009-05-22 09:10:53 +00:00
|
|
|
* @return array|bool An _array_ of groupids, or false
|
2007-08-16 11:06:48 +00:00
|
|
|
* (Was return $groupids[0] - consequences!)
|
|
|
|
*/
|
|
|
|
function mygroupid($courseid) {
|
|
|
|
global $USER;
|
|
|
|
if ($groups = groups_get_all_groups($courseid, $USER->id)) {
|
|
|
|
return array_keys($groups);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current group mode for a given course or activity module
|
2007-08-24 04:22:30 +00:00
|
|
|
*
|
2007-08-16 11:06:48 +00:00
|
|
|
* Could be false, SEPARATEGROUPS or VISIBLEGROUPS (<-- Martin)
|
2009-05-22 09:10:53 +00:00
|
|
|
*
|
|
|
|
* @param object $course Course Object
|
|
|
|
* @param object $cm Course Manager Object
|
|
|
|
* @return mixed $course->groupmode
|
2007-08-16 11:06:48 +00:00
|
|
|
*/
|
|
|
|
function groupmode($course, $cm=null) {
|
|
|
|
|
|
|
|
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
|
|
|
return $cm->groupmode;
|
|
|
|
}
|
|
|
|
return $course->groupmode;
|
|
|
|
}
|
|
|
|
|
2008-05-01 22:32:15 +00:00
|
|
|
/**
|
|
|
|
* Sets the current group in the session variable
|
|
|
|
* When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups.
|
|
|
|
* Sets currentgroup[$courseid] in the session variable appropriately.
|
|
|
|
* Does not do any permission checking.
|
2009-05-22 09:10:53 +00:00
|
|
|
*
|
|
|
|
* @global object
|
2008-05-01 22:32:15 +00:00
|
|
|
* @param int $courseid The course being examined - relates to id field in
|
|
|
|
* 'course' table.
|
|
|
|
* @param int $groupid The group being examined.
|
|
|
|
* @return int Current group id which was set by this function
|
|
|
|
*/
|
|
|
|
function set_current_group($courseid, $groupid) {
|
|
|
|
global $SESSION;
|
|
|
|
return $SESSION->currentgroup[$courseid] = $groupid;
|
|
|
|
}
|
|
|
|
|
2007-08-16 11:06:48 +00:00
|
|
|
|
|
|
|
/**
|
2007-08-24 04:22:30 +00:00
|
|
|
* Gets the current group - either from the session variable or from the database.
|
2007-08-16 11:06:48 +00:00
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
2007-08-24 04:22:30 +00:00
|
|
|
* @param int $courseid The course being examined - relates to id field in
|
2007-08-16 11:06:48 +00:00
|
|
|
* 'course' table.
|
2007-08-24 04:22:30 +00:00
|
|
|
* @param bool $full If true, the return value is a full record object.
|
2007-08-16 11:06:48 +00:00
|
|
|
* If false, just the id of the record.
|
2009-05-22 09:10:53 +00:00
|
|
|
* @return int|bool
|
2007-08-16 11:06:48 +00:00
|
|
|
*/
|
|
|
|
function get_current_group($courseid, $full = false) {
|
|
|
|
global $SESSION;
|
|
|
|
|
|
|
|
if (isset($SESSION->currentgroup[$courseid])) {
|
|
|
|
if ($full) {
|
|
|
|
return groups_get_group($SESSION->currentgroup[$courseid]);
|
|
|
|
} else {
|
|
|
|
return $SESSION->currentgroup[$courseid];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$mygroupid = mygroupid($courseid);
|
|
|
|
if (is_array($mygroupid)) {
|
|
|
|
$mygroupid = array_shift($mygroupid);
|
|
|
|
set_current_group($courseid, $mygroupid);
|
|
|
|
if ($full) {
|
|
|
|
return groups_get_group($mygroupid);
|
|
|
|
} else {
|
|
|
|
return $mygroupid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($full) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-01 04:15:13 +00:00
|
|
|
/**
|
|
|
|
* Print an error page displaying an error message.
|
|
|
|
* Old method, don't call directly in new code - use print_error instead.
|
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @global object
|
2008-04-01 04:15:13 +00:00
|
|
|
* @param string $message The message to display to the user about the error.
|
|
|
|
* @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.
|
2009-05-22 09:10:53 +00:00
|
|
|
* @return void Terminates script, does not return!
|
2008-04-01 04:15:13 +00:00
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function error($message, $link='') {
|
2009-06-29 00:34:49 +00:00
|
|
|
global $UNITTEST, $OUTPUT;
|
2008-04-01 04:15:13 +00:00
|
|
|
|
2008-06-13 17:51:34 +00:00
|
|
|
// If unittest running, throw exception instead
|
2008-06-13 08:35:29 +00:00
|
|
|
if (!empty($UNITTEST->running)) {
|
2008-05-21 14:59:33 +00:00
|
|
|
// Errors in unit test become exceptions, so you can unit test
|
|
|
|
// code that might call error().
|
2008-06-13 17:51:34 +00:00
|
|
|
throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message);
|
2008-04-01 04:15:13 +00:00
|
|
|
}
|
|
|
|
|
2009-06-29 00:34:49 +00:00
|
|
|
list($message, $moreinfourl, $link) = prepare_error_message('notlocalisederrormessage', 'error', $link, $message);
|
|
|
|
$OUTPUT->fatal_error($message, $moreinfourl, $link, debug_backtrace(), null, true); // show debug warning
|
|
|
|
die;
|
2008-06-13 17:51:34 +00:00
|
|
|
}
|
2008-04-01 04:15:13 +00:00
|
|
|
|
|
|
|
|
2008-06-15 10:32:50 +00:00
|
|
|
/// Deprecated DDL functions, to be removed soon ///
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function table_exists($table) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->table_exists($table);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function field_exists($table, $field) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->field_exists($table, $field);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $index
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function find_index_name($table, $index) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->find_index_name($table, $index);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $index
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function index_exists($table, $index) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->index_exists($table, $index);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function find_check_constraint_name($table, $field) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->find_check_constraint_name($table, $field);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function check_constraint_exists($table, $field) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->check_constraint_exists($table, $field);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $xmldb_key
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function find_key_name($table, $xmldb_key) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->find_key_name($table, $xmldb_key);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function find_sequence_name($table) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
|
|
|
return $DB->get_manager()->find_sequence_name($table);
|
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function drop_table($table) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->drop_table($table);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $file
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-15 10:32:50 +00:00
|
|
|
function install_from_xmldb_file($file) {
|
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->install_from_xmldb_file($file);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function create_table($table) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->create_table($table);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function create_temp_table($table) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->create_temp_table($table);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $newname
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function rename_table($table, $newname) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->rename_table($table, $newname);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function add_field($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->add_field($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function drop_field($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->drop_field($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function change_field_type($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->change_field_type($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function change_field_precision($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->change_field_precision($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function change_field_unsigned($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->change_field_unsigned($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function change_field_notnull($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->change_field_notnull($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function change_field_enum($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
2009-05-02 00:22:20 +00:00
|
|
|
debugging('Deprecated ddllib function used! Only dropping of enums is allowed.');
|
|
|
|
$DB->get_manager()->drop_enum_from_field($table, $field);
|
2008-06-22 16:51:55 +00:00
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function change_field_default($table, $field) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->change_field_default($table, $field);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $field
|
|
|
|
* @param string $newname
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function rename_field($table, $field, $newname) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2009-03-26 20:53:03 +00:00
|
|
|
$DB->get_manager()->rename_field($table, $field, $newname);
|
2008-06-22 16:51:55 +00:00
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $key
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function add_key($table, $key) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->add_key($table, $key);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $key
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function drop_key($table, $key) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->drop_key($table, $key);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $key
|
|
|
|
* @param string $newname
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function rename_key($table, $key, $newname) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->rename_key($table, $key, $newname);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $index
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function add_index($table, $index) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->add_index($table, $index);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $index
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function drop_index($table, $index) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->drop_index($table, $index);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @global object
|
|
|
|
* @param string $table
|
|
|
|
* @param string $index
|
|
|
|
* @param string $newname
|
|
|
|
* @return bool
|
|
|
|
*/
|
2008-06-22 16:51:55 +00:00
|
|
|
function rename_index($table, $index, $newname) {
|
2008-06-15 10:32:50 +00:00
|
|
|
global $DB;
|
|
|
|
debugging('Deprecated ddllib function used!');
|
2008-06-22 16:51:55 +00:00
|
|
|
$DB->get_manager()->rename_index($table, $index, $newname);
|
|
|
|
return true;
|
2008-06-15 10:32:50 +00:00
|
|
|
}
|
|
|
|
|
2008-04-01 04:15:13 +00:00
|
|
|
|
2008-06-13 17:51:34 +00:00
|
|
|
//////////////////////////
|
|
|
|
/// removed functions ////
|
|
|
|
//////////////////////////
|
2008-06-09 16:53:30 +00:00
|
|
|
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $mixed
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-09-23 21:09:46 +00:00
|
|
|
function stripslashes_safe($mixed) {
|
|
|
|
error('stripslashes_safe() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $var
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-09-23 21:09:46 +00:00
|
|
|
function stripslashes_recursive($var) {
|
|
|
|
error('stripslashes_recursive() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $dataobject
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function addslashes_object($dataobject) {
|
2008-12-01 20:05:00 +00:00
|
|
|
error('addslashes_object() not available anymore');
|
2008-06-09 16:53:30 +00:00
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $var
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 16:53:30 +00:00
|
|
|
function addslashes_recursive($var) {
|
|
|
|
error('addslashes_recursive() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $command
|
|
|
|
* @param bool $feedback
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function execute_sql($command, $feedback=true) {
|
|
|
|
error('execute_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $select
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function record_exists_select($table, $select='') {
|
|
|
|
error('record_exists_select() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function record_exists_sql($sql) {
|
|
|
|
error('record_exists_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $select
|
|
|
|
* @param mixed $countitem
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function count_records_select($table, $select='', $countitem='COUNT(*)') {
|
|
|
|
error('count_records_select() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function count_records_sql($sql) {
|
|
|
|
error('count_records_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @param bool $expectmultiple
|
|
|
|
* @param bool $nolimit
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_record_sql($sql, $expectmultiple=false, $nolimit=false) {
|
|
|
|
error('get_record_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $select
|
|
|
|
* @param mixed $fields
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_record_select($table, $select='', $fields='*') {
|
|
|
|
error('get_record_select() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field
|
|
|
|
* @param mixed $value
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_recordset($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_recordset() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
|
|
|
|
error('get_recordset_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $rs
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function rs_fetch_record(&$rs) {
|
|
|
|
error('rs_fetch_record() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $rs
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function rs_next_record(&$rs) {
|
|
|
|
error('rs_next_record() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $rs
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function rs_fetch_next_record(&$rs) {
|
|
|
|
error('rs_fetch_next_record() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $rs
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function rs_EOF($rs) {
|
|
|
|
error('rs_EOF() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $rs
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function rs_close(&$rs) {
|
|
|
|
error('rs_close() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $select
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_records_select($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_records_select() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $return
|
|
|
|
* @param mixed $select
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_field_select($table, $return, $select) {
|
|
|
|
error('get_field_select() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_field_sql($sql) {
|
|
|
|
error('get_field_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @param mixed $select
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function delete_records_select($table, $select='') {
|
2008-09-24 21:04:53 +00:00
|
|
|
error('get_field_sql() not available anymore');
|
2008-06-09 19:48:24 +00:00
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function configure_dbconnection() {
|
|
|
|
error('configure_dbconnection() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $field
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_max($field) {
|
|
|
|
error('sql_max() removed - use normal sql MAX() instead');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_as() {
|
|
|
|
error('sql_as() removed - do not use AS for tables at all');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $page
|
|
|
|
* @param mixed $recordsperpage
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_paging_limit($page, $recordsperpage) {
|
|
|
|
error('Function sql_paging_limit() is deprecated. Replace it with the correct use of limitfrom, limitnum parameters');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function db_uppercase() {
|
|
|
|
error('upper() removed - use normal sql UPPER()');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function db_lowercase() {
|
|
|
|
error('upper() removed - use normal sql LOWER()');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sqlfile
|
|
|
|
* @param mixed $sqlstring
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function modify_database($sqlfile='', $sqlstring='') {
|
|
|
|
error('modify_database() removed - use new XMLDB functions');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function where_clause($field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
|
|
|
|
error('where_clause() removed - use new functions with $conditions parameter');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sqlarr
|
|
|
|
* @param mixed $continue
|
|
|
|
* @param mixed $feedback
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function execute_sql_arr($sqlarr, $continue=true, $feedback=true) {
|
|
|
|
error('execute_sql_arr() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field
|
|
|
|
* @param mixed $values
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_records_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_records_list() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field
|
|
|
|
* @param mixed $values
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_recordset_list($table, $field='', $values='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_recordset_list() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field
|
|
|
|
* @param mixed $value
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_records_menu() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $select
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_records_select_menu() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_records_sql_menu($sql, $limitfrom='', $limitnum='') {
|
|
|
|
error('get_records_sql_menu() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $column
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function column_type($table, $column) {
|
|
|
|
error('column_type() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $rs
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function recordset_to_menu($rs) {
|
|
|
|
error('recordset_to_menu() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $records
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function records_to_menu($records, $field1, $field2) {
|
|
|
|
error('records_to_menu() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $newfield
|
|
|
|
* @param mixed $newvalue
|
|
|
|
* @param mixed $select
|
|
|
|
* @param mixed $localcall
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function set_field_select($table, $newfield, $newvalue, $select, $localcall = false) {
|
|
|
|
error('set_field_select() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $return
|
|
|
|
* @param mixed $select
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_fieldset_select($table, $return, $select) {
|
|
|
|
error('get_fieldset_select() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $sql
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_fieldset_sql($sql) {
|
|
|
|
error('get_fieldset_sql() removed');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_ilike() {
|
|
|
|
error('sql_ilike() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $first
|
|
|
|
* @param mixed $last
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_fullname($first='firstname', $last='lastname') {
|
|
|
|
error('sql_fullname() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_concat() {
|
|
|
|
error('sql_concat() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_empty() {
|
|
|
|
error('sql_empty() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_substr() {
|
|
|
|
error('sql_substr() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $int1
|
|
|
|
* @param mixed $int2
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_bitand($int1, $int2) {
|
|
|
|
error('sql_bitand() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $int1
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_bitnot($int1) {
|
|
|
|
error('sql_bitnot() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $int1
|
|
|
|
* @param mixed $int2
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_bitor($int1, $int2) {
|
|
|
|
error('sql_bitor() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $int1
|
|
|
|
* @param mixed $int2
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_bitxor($int1, $int2) {
|
|
|
|
error('sql_bitxor() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $fieldname
|
|
|
|
* @param mixed $text
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_cast_char2int($fieldname, $text=false) {
|
|
|
|
error('sql_cast_char2int() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $fieldname
|
|
|
|
* @param mixed $numchars
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_compare_text($fieldname, $numchars=32) {
|
|
|
|
error('sql_compare_text() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $fieldname
|
|
|
|
* @param mixed $numchars
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_order_by_text($fieldname, $numchars=32) {
|
|
|
|
error('sql_order_by_text() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $fieldname
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2009-02-15 23:18:49 +00:00
|
|
|
function sql_length($fieldname) {
|
|
|
|
error('sql_length() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $separator
|
|
|
|
* @param mixed $elements
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_concat_join($separator="' '", $elements=array()) {
|
|
|
|
error('sql_concat_join() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $tablename
|
|
|
|
* @param mixed $fieldname
|
|
|
|
* @param mixed $nullablefield
|
|
|
|
* @param mixed $textfield
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) {
|
|
|
|
error('sql_isempty() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $tablename
|
|
|
|
* @param mixed $fieldname
|
|
|
|
* @param mixed $nullablefield
|
|
|
|
* @param mixed $textfield
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield) {
|
|
|
|
error('sql_isnotempty() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function begin_sql() {
|
|
|
|
error('begin_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function commit_sql() {
|
|
|
|
error('commit_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function rollback_sql() {
|
|
|
|
error('rollback_sql() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $dataobject
|
|
|
|
* @param mixed $returnid
|
|
|
|
* @param mixed $primarykey
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
|
|
|
|
error('insert_record() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $dataobject
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function update_record($table, $dataobject) {
|
|
|
|
error('update_record() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field
|
|
|
|
* @param mixed $value
|
|
|
|
* @param mixed $sort
|
|
|
|
* @param mixed $fields
|
|
|
|
* @param mixed $limitfrom
|
|
|
|
* @param mixed $limitnum
|
2009-06-29 08:17:31 +00:00
|
|
|
*
|
2009-05-22 09:10:53 +00:00
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
|
|
|
|
error('get_records() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @param mixed $fields
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_record($table, $field1, $value1, $field2='', $value2='', $field3='', $value3='', $fields='*') {
|
|
|
|
error('get_record() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $newfield
|
|
|
|
* @param mixed $newvalue
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function set_field($table, $newfield, $newvalue, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
|
|
|
|
error('set_field() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function count_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
|
|
|
|
error('count_records() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function record_exists($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
|
|
|
|
error('record_exists() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function delete_records($table, $field1='', $value1='', $field2='', $value2='', $field3='', $value3='') {
|
|
|
|
error('delete_records() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $return
|
|
|
|
* @param mixed $field1
|
|
|
|
* @param mixed $value1
|
|
|
|
* @param mixed $field2
|
|
|
|
* @param mixed $value2
|
|
|
|
* @param mixed $field3
|
|
|
|
* @param mixed $value3
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-09 19:48:24 +00:00
|
|
|
function get_field($table, $return, $field1, $value1, $field2='', $value2='', $field3='', $value3='') {
|
|
|
|
error('get_field() not available anymore');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $table
|
|
|
|
* @param mixed $oldfield
|
|
|
|
* @param mixed $field
|
|
|
|
* @param mixed $type
|
|
|
|
* @param mixed $size
|
|
|
|
* @param mixed $signed
|
|
|
|
* @param mixed $default
|
|
|
|
* @param mixed $null
|
|
|
|
* @param mixed $after
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-06-10 19:54:27 +00:00
|
|
|
function table_column($table, $oldfield, $field, $type='integer', $size='10',
|
|
|
|
$signed='unsigned', $default='0', $null='not null', $after='') {
|
|
|
|
error('table_column() was removed, please use new ddl functions');
|
|
|
|
}
|
2009-05-22 09:10:53 +00:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
* @param mixed $name
|
|
|
|
* @param mixed $editorhidebuttons
|
|
|
|
* @param mixed $id
|
|
|
|
* @return void Throws an error and does nothing
|
|
|
|
*/
|
2008-08-29 09:54:44 +00:00
|
|
|
function use_html_editor($name='', $editorhidebuttons='', $id='') {
|
|
|
|
error('use_html_editor() not available anymore');
|
|
|
|
}
|
ajaxlib/require_js: MDL-16693 $PAGE->requires->... deprecates require_js etc.
There is a new implementation of require_js in lib/deprecatedlib.php,
based on $PAGE->requires.
There were a few other recently introduced functions in lib/weblib.php,
namely print_js_call, print_delayed_js_call, print_js_config and
standard_js_config. These have been removed, since they were never in
a stable branch, and all the places that used them have been changed
to use the newer $PAGE->requires->... methods.
get_require_js_code is also gone, and the evil places that were calling
it, even though it is an internal function, have been fixed.
Also, I made some minor improvements to the code I committed yesterday
for MDL-16695.
All that remains is to update all the places in core code that are
still using require_js.
(This commit also fixes the problem where the admin tree would not
start with the right categories expanded.)
2009-06-12 12:13:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The old method that was used to include JavaScript libraries.
|
|
|
|
* Please use $PAGE->requires->js() or $PAGE->requires->yui_lib() instead.
|
|
|
|
*
|
|
|
|
* @param mixed $lib The library or libraries to load (a string or array of strings)
|
|
|
|
* There are three way to specify the library:
|
|
|
|
* 1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui_lib('yahoo')->asap();
|
|
|
|
* 2. the path to the library relative to wwwroot, for example 'lib/javascript-static.js'
|
|
|
|
* 3. (legacy) a full URL like $CFG->wwwroot . '/lib/javascript-static.js'.
|
|
|
|
* 2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js').
|
|
|
|
*/
|
|
|
|
function require_js($lib) {
|
|
|
|
global $CFG, $PAGE;
|
|
|
|
// Add the lib to the list of libs to be loaded, if it isn't already
|
|
|
|
// in the list.
|
|
|
|
if (is_array($lib)) {
|
|
|
|
foreach($lib as $singlelib) {
|
|
|
|
require_js($singlelib);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO uncomment this once we have eliminated the remaining calls to require_js from core.
|
|
|
|
//debugging('Call to deprecated function require_js. Please use $PAGE->requires->js() ' .
|
|
|
|
// 'or $PAGE->requires->yui_lib() instead.', DEBUG_DEVELOPER);
|
|
|
|
|
|
|
|
if (strpos($lib, 'yui_') === 0) {
|
|
|
|
echo $PAGE->requires->yui_lib(substr($lib, 4))->asap();
|
|
|
|
} else if (preg_match('/^https?:/', $lib)) {
|
|
|
|
echo $PAGE->requires->js(str_replace($CFG->wwwroot, '', $lib))->asap();
|
|
|
|
} else {
|
|
|
|
echo $PAGE->requires->js($lib)->asap();
|
|
|
|
}
|
|
|
|
}
|
2009-06-23 04:39:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Makes an upload directory for a particular module.
|
|
|
|
*
|
2009-06-29 08:17:31 +00:00
|
|
|
* This function has been deprecated by the file API changes in Moodle 2.0.
|
2009-06-23 04:39:11 +00:00
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param int $courseid The id of the course in question - maps to id field of 'course' table.
|
|
|
|
* @return string|false Returns full path to directory if successful, false if not
|
|
|
|
*/
|
|
|
|
function make_mod_upload_directory($courseid) {
|
|
|
|
global $CFG;
|
|
|
|
debugging('make_mod_upload_directory has been deprecated by the file API changes in Moodle 2.0.', DEBUG_DEVELOPER);
|
|
|
|
return make_upload_directory($courseid .'/'. $CFG->moddata);
|
|
|
|
}
|
|
|
|
|
2009-06-29 08:17:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a slight variatoin on the standard_renderer_factory that uses
|
|
|
|
* custom_corners_core_renderer instead of moodle_core_renderer.
|
|
|
|
*
|
|
|
|
* This generates the slightly different HTML that the custom_corners theme expects.
|
|
|
|
*
|
|
|
|
* @copyright 2009 Tim Hunt
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
* @deprecated Required to make the old $THEME->customcorners setting work.
|
|
|
|
*/
|
|
|
|
class custom_corners_renderer_factory extends standard_renderer_factory {
|
2009-07-02 07:06:25 +00:00
|
|
|
public function __construct($theme) {
|
|
|
|
parent::__construct($theme);
|
2009-06-29 08:17:31 +00:00
|
|
|
global $CFG;
|
2009-06-29 17:11:34 +00:00
|
|
|
require_once($CFG->themedir . '/custom_corners/renderers.php');
|
2009-07-02 07:06:25 +00:00
|
|
|
}
|
|
|
|
/* Implement the subclass method. */
|
2009-07-08 09:37:06 +00:00
|
|
|
public function get_renderer($module, $page, $subtype=null) {
|
2009-07-02 07:06:25 +00:00
|
|
|
if ($module == 'core') {
|
|
|
|
return new custom_corners_core_renderer($page);
|
|
|
|
}
|
2009-07-08 09:37:06 +00:00
|
|
|
return parent::get_renderer($module, $page, $subtype);
|
2009-06-29 08:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
/**
|
|
|
|
* Used to be used for setting up the theme. No longer used by core code, and
|
|
|
|
* should not have been used elsewhere.
|
|
|
|
*
|
|
|
|
* The theme is now automatically initialised before it is first used. If you really need
|
|
|
|
* to force this to happen, just reference $PAGE->theme.
|
|
|
|
*
|
|
|
|
* To force a particular theme on a particular page, you can use $PAGE->force_theme(...).
|
|
|
|
* However, I can't think of any valid reason to do that outside the theme selector UI.
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $theme The theme to use defaults to current theme
|
|
|
|
* @param array $params An array of parameters to use
|
|
|
|
*/
|
|
|
|
function theme_setup($theme = '', $params=NULL) {
|
|
|
|
throw new coding_exception('The function theme_setup is no longer required, and should no longer be used. ' .
|
|
|
|
'The current theme gets initialised automatically before it is first used.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated use $PAGE->theme->name instead.
|
|
|
|
* @return string the name of the current theme.
|
|
|
|
*/
|
|
|
|
function current_theme() {
|
|
|
|
global $PAGE;
|
|
|
|
// TODO, uncomment this once we have eliminated all references to current_theme in core code.
|
|
|
|
// debugging('current_theme is deprecated, use $PAGE->theme->name instead', DEBUG_DEVELOPER);
|
|
|
|
return $PAGE->theme->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This used to be the thing that theme styles.php files used to do all the work.
|
|
|
|
* This is now handled differently. You should copy theme/standard/styes.php
|
|
|
|
* into your theme.
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param int $lastmodified Always gets set to now
|
|
|
|
* @param int $lifetime The max-age header setting (seconds) defaults to 300
|
|
|
|
* @param string $themename The name of the theme to use (optional) defaults to current theme
|
|
|
|
* @param string $forceconfig Force a particular theme config (optional)
|
|
|
|
* @param string $lang Load styles for the specified language (optional)
|
|
|
|
*/
|
|
|
|
function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='', $forceconfig='', $lang='') {
|
|
|
|
global $CFG, $PAGE, $THEME, $showdeprecatedstylesheetsetupwarning;
|
|
|
|
$showdeprecatedstylesheetsetupwarning = true;
|
|
|
|
include($CFG->dirroot . '/theme/styles.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2009-07-06 05:32:29 +00:00
|
|
|
/**
|
|
|
|
* @todo Remove this deprecated function when no longer used
|
|
|
|
* @deprecated since Moodle 2.0 - use $PAGE->pagetype instead of the .
|
|
|
|
*
|
|
|
|
* @param string $getid used to return $PAGE->pagetype.
|
|
|
|
* @param string $getclass used to return $PAGE->legacyclass.
|
|
|
|
*/
|
|
|
|
function page_id_and_class(&$getid, &$getclass) {
|
|
|
|
global $PAGE;
|
|
|
|
debugging('Call to deprecated function page_id_and_class. Please use $PAGE->pagetype instead.', DEBUG_DEVELOPER);
|
|
|
|
$getid = $PAGE->pagetype;
|
|
|
|
$getclass = $PAGE->legacyclass;
|
|
|
|
}
|
|
|
|
|
2009-06-23 10:41:22 +00:00
|
|
|
/**
|
|
|
|
* Prints some red text using echo
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $error The text to be displayed in red
|
|
|
|
*/
|
|
|
|
function formerr($error) {
|
|
|
|
global $OUTPUT;
|
|
|
|
echo $OUTPUT->error_text($error);
|
|
|
|
}
|
|
|
|
|
2009-06-26 09:06:16 +00:00
|
|
|
/**
|
|
|
|
* Return the markup for the destination of the 'Skip to main content' links.
|
|
|
|
* Accessibility improvement for keyboard-only users.
|
|
|
|
*
|
|
|
|
* Used in course formats, /index.php and /course/index.php
|
|
|
|
*
|
|
|
|
* @deprecated use $OUTPUT->skip_link_target() in instead.
|
|
|
|
* @return string HTML element.
|
|
|
|
*/
|
|
|
|
function skip_main_destination() {
|
|
|
|
global $OUTPUT;
|
|
|
|
return $OUTPUT->skip_link_target();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a string in a specified size (retained for backward compatibility)
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $text The text to be displayed
|
|
|
|
* @param int $size The size to set the font for text display.
|
|
|
|
* @param bool $return If set to true output is returned rather than echoed Default false
|
|
|
|
* @return string|void String if return is true
|
|
|
|
*/
|
|
|
|
function print_headline($text, $size=2, $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
$output = $OUTPUT->heading($text, $size);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints text in a format for use in headings.
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $text The text to be displayed
|
|
|
|
* @param string $deprecated No longer used. (Use to do alignment.)
|
|
|
|
* @param int $size The size to set the font for text display.
|
|
|
|
* @param string $class
|
|
|
|
* @param bool $return If set to true output is returned rather than echoed, default false
|
|
|
|
* @param string $id The id to use in the element
|
|
|
|
* @return string|void String if return=true nothing otherwise
|
|
|
|
*/
|
|
|
|
function print_heading($text, $deprecated = '', $size = 2, $class = 'main', $return = false, $id = '') {
|
|
|
|
global $OUTPUT;
|
|
|
|
if (!empty($deprecated)) {
|
|
|
|
debugging('Use of deprecated align attribute of print_heading. ' .
|
|
|
|
'Please do not specify styling in PHP code like that.', DEBUG_DEVELOPER);
|
|
|
|
}
|
|
|
|
$output = $OUTPUT->heading($text, $size, $class, $id);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output a standard heading block
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $heading The text to write into the heading
|
|
|
|
* @param string $class An additional Class Attr to use for the heading
|
|
|
|
* @param bool $return If set to true output is returned rather than echoed, default false
|
|
|
|
* @return string|void HTML String if return=true nothing otherwise
|
|
|
|
*/
|
|
|
|
function print_heading_block($heading, $class='', $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
$output = $OUTPUT->heading($heading, 2, 'headingblock header ' . moodle_renderer_base::prepare_classes($class));
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a message in a standard themed box.
|
|
|
|
* Replaces print_simple_box (see deprecatedlib.php)
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $message, the content of the box
|
|
|
|
* @param string $classes, space-separated class names.
|
|
|
|
* @param string $ids
|
|
|
|
* @param boolean $return, return as string or just print it
|
|
|
|
* @return string|void mixed string or void
|
|
|
|
*/
|
|
|
|
function print_box($message, $classes='generalbox', $ids='', $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
$output = $OUTPUT->box($message, $classes, $ids);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts a box using divs
|
|
|
|
* Replaces print_simple_box_start (see deprecatedlib.php)
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $classes, space-separated class names.
|
|
|
|
* @param string $ids
|
|
|
|
* @param boolean $return, return as string or just print it
|
|
|
|
* @return string|void string or void
|
|
|
|
*/
|
|
|
|
function print_box_start($classes='generalbox', $ids='', $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
$output = $OUTPUT->box_start($classes, $ids);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple function to end a box (see above)
|
|
|
|
* Replaces print_simple_box_end (see deprecatedlib.php)
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param boolean $return, return as string or just print it
|
|
|
|
* @return string|void Depending on value of return
|
|
|
|
*/
|
|
|
|
function print_box_end($return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
$output = $OUTPUT->box_end();
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a message in a standard themed container.
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param string $message, the content of the container
|
|
|
|
* @param boolean $clearfix clear both sides
|
|
|
|
* @param string $classes, space-separated class names.
|
|
|
|
* @param string $idbase
|
|
|
|
* @param boolean $return, return as string or just print it
|
|
|
|
* @return string|void Depending on value of $return
|
|
|
|
*/
|
|
|
|
function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
if ($clearfix) {
|
|
|
|
$classes .= ' clearfix';
|
|
|
|
}
|
|
|
|
$output = $OUTPUT->container($message, $classes, $idbase);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts a container using divs
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param boolean $clearfix clear both sides
|
|
|
|
* @param string $classes, space-separated class names.
|
|
|
|
* @param string $idbase
|
|
|
|
* @param boolean $return, return as string or just print it
|
|
|
|
* @return string|void Based on value of $return
|
|
|
|
*/
|
|
|
|
function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
if ($clearfix) {
|
|
|
|
$classes .= ' clearfix';
|
|
|
|
}
|
|
|
|
$output = $OUTPUT->container_start($classes, $idbase);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple function to end a container (see above)
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
* @param boolean $return, return as string or just print it
|
|
|
|
* @return string|void Based on $return
|
|
|
|
*/
|
|
|
|
function print_container_end($return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
$output = $OUTPUT->container_end();
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a bold message in an optional color.
|
|
|
|
*
|
|
|
|
* @deprecated use $OUTPUT->notification instead.
|
|
|
|
* @param string $message The message to print out
|
|
|
|
* @param string $style Optional style to display message text in
|
|
|
|
* @param string $align Alignment option
|
|
|
|
* @param bool $return whether to return an output string or echo now
|
2009-06-29 08:17:31 +00:00
|
|
|
* @return string|bool Depending on $result
|
2009-06-26 09:06:16 +00:00
|
|
|
*/
|
|
|
|
function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
if ($classes == 'green') {
|
|
|
|
debugging('Use of deprecated class name "green" in notify. Please change to "notifysuccess".', DEBUG_DEVELOPER);
|
|
|
|
$classes = 'notifysuccess'; // Backward compatible with old color system
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = $OUTPUT->notification($message, $classes);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a continue button that goes to a particular URL.
|
|
|
|
*
|
|
|
|
* @param string $link The url to create a link to.
|
|
|
|
* @param bool $return If set to true output is returned rather than echoed, default false
|
|
|
|
* @return string|void HTML String if return=true nothing otherwise
|
|
|
|
*/
|
|
|
|
function print_continue($link, $return = false) {
|
|
|
|
global $CFG, $OUTPUT;
|
|
|
|
|
|
|
|
if ($link == '') {
|
|
|
|
if (!empty($_SERVER['HTTP_REFERER'])) {
|
|
|
|
$link = $_SERVER['HTTP_REFERER'];
|
|
|
|
$link = str_replace('&', '&', $link); // make it valid XHTML
|
|
|
|
} else {
|
|
|
|
$link = $CFG->wwwroot .'/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = $OUTPUT->continue_button($link);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string containing a link to the user documentation for the current
|
|
|
|
* page. Also contains an icon by default. Shown to teachers and admin only.
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @global object
|
|
|
|
* @param string $text The text to be displayed for the link
|
|
|
|
* @param string $iconpath The path to the icon to be displayed
|
|
|
|
* @return string The link to user documentation for this current page
|
|
|
|
*/
|
|
|
|
function page_doc_link($text='', $iconpath='') {
|
|
|
|
global $CFG, $PAGE;
|
|
|
|
|
|
|
|
if (empty($CFG->docroot) || during_initial_install()) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if (!has_capability('moodle/site:doclinks', $PAGE->context)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$path = $PAGE->docspath;
|
|
|
|
if (!$path) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return doc_link($path, $text, $iconpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a standard header
|
|
|
|
*
|
|
|
|
* @param string $title Appears at the top of the window
|
|
|
|
* @param string $heading Appears at the top of the page
|
|
|
|
* @param string $navigation Array of $navlinks arrays (keys: name, link, type) for use as breadcrumbs links
|
|
|
|
* @param string $focus Indicates form element to get cursor focus on load eg inputform.password
|
|
|
|
* @param string $meta Meta tags to be added to the header
|
|
|
|
* @param boolean $cache Should this page be cacheable?
|
|
|
|
* @param string $button HTML code for a button (usually for module editing)
|
|
|
|
* @param string $menu HTML code for a popup menu
|
|
|
|
* @param boolean $usexml use XML for this page
|
|
|
|
* @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
|
|
|
|
* @param bool $return If true, return the visible elements of the header instead of echoing them.
|
|
|
|
* @return string|void If return=true then string else void
|
|
|
|
*/
|
|
|
|
function print_header($title='', $heading='', $navigation='', $focus='',
|
|
|
|
$meta='', $cache=true, $button=' ', $menu='',
|
|
|
|
$usexml=false, $bodytags='', $return=false) {
|
|
|
|
global $PAGE, $OUTPUT;
|
|
|
|
|
|
|
|
$PAGE->set_title($title);
|
|
|
|
$PAGE->set_heading($heading);
|
|
|
|
$PAGE->set_cacheable($cache);
|
|
|
|
$PAGE->set_focuscontrol($focus);
|
|
|
|
if ($button == '') {
|
|
|
|
$button = ' ';
|
|
|
|
}
|
|
|
|
$PAGE->set_button($button);
|
|
|
|
|
|
|
|
if ($navigation == 'home') {
|
|
|
|
$navigation = '';
|
|
|
|
}
|
|
|
|
if (gettype($navigation) == 'string' && strlen($navigation) != 0 && $navigation != 'home') {
|
|
|
|
debugging("print_header() was sent a string as 3rd ($navigation) parameter. "
|
|
|
|
. "This is deprecated in favour of an array built by build_navigation(). Please upgrade your code.", DEBUG_DEVELOPER);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO $navigation
|
|
|
|
// TODO $menu
|
|
|
|
|
|
|
|
if ($meta) {
|
|
|
|
throw new coding_exception('The $meta parameter to print_header is no longer supported. '.
|
2009-06-26 09:38:14 +00:00
|
|
|
'You should be able to do everything you want with $PAGE->requires and other such mechanisms.');
|
2009-06-26 09:06:16 +00:00
|
|
|
}
|
|
|
|
if ($usexml) {
|
|
|
|
throw new coding_exception('The $usexml parameter to print_header is no longer supported.');
|
|
|
|
}
|
|
|
|
if ($bodytags) {
|
|
|
|
throw new coding_exception('The $bodytags parameter to print_header is no longer supported.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = $OUTPUT->header($navigation, $menu);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function print_footer($course = NULL, $usercourse = NULL, $return = false) {
|
|
|
|
global $PAGE, $OUTPUT;
|
|
|
|
// TODO check arguments.
|
|
|
|
if (is_string($course)) {
|
|
|
|
debugging("Magic values like 'home', 'empty' passed to print_footer no longer have any effect. " .
|
|
|
|
'To achieve a similar effect, call $PAGE->set_generaltype before you call print_header.', DEBUG_DEVELOPER);
|
|
|
|
} else if (!empty($course->id) && $course->id != $PAGE->course->id) {
|
|
|
|
throw new coding_exception('The $course object you passed to print_footer does not match $PAGE->course.');
|
|
|
|
}
|
|
|
|
if (!is_null($usercourse)) {
|
|
|
|
debugging('The second parameter ($usercourse) to print_footer is no longer supported. ' .
|
|
|
|
'(I did not think it was being used anywhere.)', DEBUG_DEVELOPER);
|
|
|
|
}
|
|
|
|
$output = $OUTPUT->footer();
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
2009-06-29 08:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a nice side block with an optional header. The content can either
|
|
|
|
* be a block of HTML or a list of text with optional icons.
|
|
|
|
*
|
|
|
|
* @todo Finish documenting this function. Show example of various attributes, etc.
|
|
|
|
*
|
|
|
|
* @static int $block_id Increments for each call to the function
|
|
|
|
* @param string $heading HTML for the heading. Can include full HTML or just
|
|
|
|
* plain text - plain text will automatically be enclosed in the appropriate
|
|
|
|
* heading tags.
|
|
|
|
* @param string $content HTML for the content
|
|
|
|
* @param array $list an alternative to $content, it you want a list of things with optional icons.
|
|
|
|
* @param array $icons optional icons for the things in $list.
|
|
|
|
* @param string $footer Extra HTML content that gets output at the end, inside a <div class="footer">
|
|
|
|
* @param array $attributes an array of attribute => value pairs that are put on the
|
|
|
|
* outer div of this block. If there is a class attribute ' sideblock' gets appended to it. If there isn't
|
|
|
|
* already a class, class='sideblock' is used.
|
|
|
|
* @param string $title Plain text title, as embedded in the $heading.
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
|
|
|
|
global $OUTPUT;
|
2009-07-09 07:35:03 +00:00
|
|
|
|
|
|
|
// We don't use $heading, becuse it often contains HTML that we don't want.
|
|
|
|
// However, sometimes $title is not set, but $heading is.
|
|
|
|
if (empty($title)) {
|
|
|
|
$title = strip_tags($heading);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Render list contents to HTML if required.
|
|
|
|
if (empty($content) && $list) {
|
|
|
|
$content = $OUTPUT->list_block_contents($icons, $list);
|
|
|
|
}
|
|
|
|
|
2009-06-29 08:17:31 +00:00
|
|
|
$bc = new block_contents();
|
|
|
|
$bc->content = $content;
|
|
|
|
$bc->footer = $footer;
|
|
|
|
$bc->title = $title;
|
|
|
|
|
|
|
|
if (isset($attributes['id'])) {
|
|
|
|
$bc->id = $attributes['id'];
|
|
|
|
unset($attributes['id']);
|
|
|
|
}
|
|
|
|
if (isset($attributes['class'])) {
|
|
|
|
$bc->set_classes($attributes['class']);
|
|
|
|
unset($attributes['class']);
|
|
|
|
}
|
|
|
|
$bc->attributes = $attributes;
|
|
|
|
|
2009-07-22 07:13:43 +00:00
|
|
|
echo $OUTPUT->block($bc, BLOCK_POS_LEFT); // POS LEFT may be wrong, but no way to get a better guess here.
|
2009-06-29 08:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts a nice side block with an optional header.
|
|
|
|
*
|
|
|
|
* @todo Finish documenting this function
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @global object
|
|
|
|
* @param string $heading HTML for the heading. Can include full HTML or just
|
|
|
|
* plain text - plain text will automatically be enclosed in the appropriate
|
|
|
|
* heading tags.
|
|
|
|
* @param array $attributes HTML attributes to apply if possible
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
function print_side_block_start($heading='', $attributes = array()) {
|
2009-07-22 07:13:43 +00:00
|
|
|
throw new coding_exception('print_side_block_start has been deprecated. Please change your code to use $OUTPUT->block().');
|
2009-06-29 08:17:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print table ending tags for a side block box.
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @global object
|
|
|
|
* @param array $attributes HTML attributes to apply if possible [id]
|
|
|
|
* @param string $title
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
function print_side_block_end($attributes = array(), $title='') {
|
2009-07-22 07:13:43 +00:00
|
|
|
throw new coding_exception('print_side_block_end has been deprecated. Please change your code to use $OUTPUT->block().');
|
2009-06-29 08:17:31 +00:00
|
|
|
}
|
2009-07-09 07:35:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This was used by old code to see whether a block region had anything in it,
|
|
|
|
* and hence wether that region should be printed.
|
|
|
|
*
|
|
|
|
* We don't ever want old code to print blocks, so we now always return false.
|
|
|
|
* The function only exists to avoid fatal errors in old code.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0. always returns false.
|
|
|
|
*
|
|
|
|
* @param object $blockmanager
|
|
|
|
* @param string $region
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function blocks_have_content(&$blockmanager, $region) {
|
|
|
|
debugging('The function blocks_have_content should no longer be used. Blocks are now printed by the theme.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This was used by old code to print the blocks in a region.
|
|
|
|
*
|
|
|
|
* We don't ever want old code to print blocks, so this is now a no-op.
|
|
|
|
* The function only exists to avoid fatal errors in old code.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0. does nothing.
|
|
|
|
*
|
|
|
|
* @param object $page
|
|
|
|
* @param object $blockmanager
|
|
|
|
* @param string $region
|
|
|
|
*/
|
|
|
|
function blocks_print_group($page, $blockmanager, $region) {
|
|
|
|
debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This used to be the old entry point for anyone that wants to use blocks.
|
|
|
|
* Since we don't want people people dealing with blocks this way any more,
|
|
|
|
* just return a suitable empty array.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0.
|
|
|
|
*
|
|
|
|
* @param object $page
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE) {
|
|
|
|
debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
|
|
|
|
return array(BLOCK_POS_LEFT => array(), BLOCK_POS_RIGHT => array());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This iterates over an array of blocks and calculates the preferred width
|
|
|
|
* Parameter passed by reference for speed; it's not modified.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0. Layout is now controlled by the theme.
|
|
|
|
*
|
|
|
|
* @param mixed $instances
|
|
|
|
*/
|
|
|
|
function blocks_preferred_width($instances) {
|
|
|
|
debugging('The function blocks_print_group should no longer be used. Blocks are now printed by the theme.');
|
|
|
|
$width = 210;
|
|
|
|
}
|
|
|
|
|
2009-07-13 11:10:30 +00:00
|
|
|
/**
|
|
|
|
* Print a nicely formatted table.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @param array $table is an object with several properties.
|
|
|
|
*/
|
|
|
|
function print_table($table, $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
// TODO MDL-19755 turn debugging on once we migrate the current core code to use the new API
|
|
|
|
// debugging('print_table() has been deprecated. Please change your code to use $OUTPUT->table().');
|
|
|
|
$newtable = new html_table();
|
|
|
|
foreach ($table as $property => $value) {
|
|
|
|
if (property_exists($newtable, $property)) {
|
|
|
|
$newtable->{$property} = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isset($table->class)) {
|
|
|
|
$newtable->set_classes($table->class);
|
|
|
|
}
|
|
|
|
if (isset($table->rowclass) && is_array($table->rowclass)) {
|
|
|
|
debugging('rowclass[] has been deprecated for html_table and should be replaced by rowclasses[]. please fix the code.');
|
|
|
|
$newtable->rowclasses = $table->rowclass;
|
|
|
|
}
|
|
|
|
$output = $OUTPUT->table($newtable);
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 10:33:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates and displays (or returns) a link to a popup window
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @param string $url Web link. Either relative to $CFG->wwwroot, or a full URL.
|
|
|
|
* @param string $name Name to be assigned to the popup window (this is used by
|
|
|
|
* client-side scripts to "talk" to the popup window)
|
|
|
|
* @param string $linkname Text to be displayed as web link
|
|
|
|
* @param int $height Height to assign to popup window
|
|
|
|
* @param int $width Height to assign to popup window
|
|
|
|
* @param string $title Text to be displayed as popup page title
|
|
|
|
* @param string $options List of additional options for popup window
|
|
|
|
* @param bool $return If true, return as a string, otherwise print
|
|
|
|
* @param string $id id added to the element
|
|
|
|
* @param string $class class added to the element
|
|
|
|
* @return string html code to display a link to a popup window.
|
|
|
|
*/
|
|
|
|
function link_to_popup_window ($url, $name=null, $linkname=null,
|
|
|
|
$height=400, $width=500, $title=null,
|
|
|
|
$options=null, $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('link_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->link_to_popup().');
|
|
|
|
|
|
|
|
if ($options == 'none') {
|
|
|
|
$options = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($linkname)) {
|
|
|
|
throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->link_to_popup() for usage.');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a html_link object
|
|
|
|
$link = new html_link();
|
|
|
|
$link->text = $linkname;
|
|
|
|
$link->url = $url;
|
|
|
|
$link->title = $title;
|
|
|
|
|
|
|
|
// Parse the $options string
|
|
|
|
$popupparams = array();
|
|
|
|
if (!empty($options)) {
|
|
|
|
$optionsarray = explode(',', $options);
|
|
|
|
foreach ($optionsarray as $option) {
|
|
|
|
if (strstr($option, '=')) {
|
|
|
|
$parts = explode('=', $option);
|
|
|
|
if ($parts[1] == '0') {
|
|
|
|
$popupparams[$parts[0]] = false;
|
|
|
|
} else {
|
|
|
|
$popupparams[$parts[0]] = $parts[1];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$popupparams[$option] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$popupaction = new popup_action('click', $url, $name, $popupparams);
|
|
|
|
$link->add_action_object($popupaction);
|
|
|
|
|
|
|
|
// Call the output method
|
|
|
|
$output = $OUTPUT->link_to_popup($link);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates and displays (or returns) a buttons to a popup window.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @param string $url Web link. Either relative to $CFG->wwwroot, or a full URL.
|
|
|
|
* @param string $name Name to be assigned to the popup window (this is used by
|
|
|
|
* client-side scripts to "talk" to the popup window)
|
|
|
|
* @param string $linkname Text to be displayed as web link
|
|
|
|
* @param int $height Height to assign to popup window
|
|
|
|
* @param int $width Height to assign to popup window
|
|
|
|
* @param string $title Text to be displayed as popup page title
|
|
|
|
* @param string $options List of additional options for popup window
|
|
|
|
* @param bool $return If true, return as a string, otherwise print
|
|
|
|
* @param string $id id added to the element
|
|
|
|
* @param string $class class added to the element
|
|
|
|
* @return string html code to display a link to a popup window.
|
|
|
|
*/
|
|
|
|
function button_to_popup_window ($url, $name=null, $linkname=null,
|
|
|
|
$height=400, $width=500, $title=null, $options=null, $return=false,
|
|
|
|
$id=null, $class=null) {
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('link_to_popup_window() has been deprecated. Please change your code to use $OUTPUT->link_to_popup().');
|
|
|
|
|
|
|
|
if ($options == 'none') {
|
|
|
|
$options = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($linkname)) {
|
|
|
|
throw new coding_exception('A link must have a descriptive text value! See $OUTPUT->link_to_popup() for usage.');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a html_button object
|
|
|
|
$button = new html_button();
|
|
|
|
$button->value = $linkname;
|
|
|
|
$button->url = $url;
|
|
|
|
$button->id = $id;
|
|
|
|
$button->add_class($class);
|
|
|
|
$button->method = 'post';
|
|
|
|
$button->title = $title;
|
|
|
|
|
|
|
|
// Parse the $options string
|
|
|
|
$popupparams = array();
|
|
|
|
if (!empty($options)) {
|
|
|
|
$optionsarray = explode(',', $options);
|
|
|
|
foreach ($optionsarray as $option) {
|
|
|
|
if (strstr($option, '=')) {
|
|
|
|
$parts = explode('=', $option);
|
|
|
|
if ($parts[1] == '0') {
|
|
|
|
$popupparams[$parts[0]] = false;
|
|
|
|
} else {
|
|
|
|
$popupparams[$parts[0]] = $parts[1];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$popupparams[$option] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($height)) {
|
|
|
|
$popupparams['height'] = $height;
|
|
|
|
}
|
|
|
|
if (!empty($width)) {
|
|
|
|
$popupparams['width'] = $width;
|
|
|
|
}
|
|
|
|
|
|
|
|
$popupaction = new popup_action('click', $url, $name, $popupparams);
|
|
|
|
$button->add_action_object($popupaction);
|
|
|
|
$output = $OUTPUT->button($button);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a self contained form with a single submit button.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @param string $link used as the action attribute on the form, so the URL that will be hit if the button is clicked.
|
|
|
|
* @param array $options these become hidden form fields, so these options get passed to the script at $link.
|
|
|
|
* @param string $label the caption that appears on the button.
|
|
|
|
* @param string $method HTTP method used on the request of the button is clicked. 'get' or 'post'.
|
|
|
|
* @param string $notusedanymore no longer used.
|
|
|
|
* @param boolean $return if false, output the form directly, otherwise return the HTML as a string.
|
|
|
|
* @param string $tooltip a tooltip to add to the button as a title attribute.
|
|
|
|
* @param boolean $disabled if true, the button will be disabled.
|
|
|
|
* @param string $jsconfirmmessage if not empty then display a confirm dialogue with this string as the question.
|
|
|
|
* @param string $formid The id attribute to use for the form
|
|
|
|
* @return string|void Depending on the $return paramter.
|
|
|
|
*/
|
|
|
|
function print_single_button($link, $options, $label='OK', $method='get', $notusedanymore='',
|
|
|
|
$return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $formid = '') {
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('print_single_button() has been deprecated. Please change your code to use $OUTPUT->button().');
|
|
|
|
|
|
|
|
// Cast $options to array
|
|
|
|
$options = (array) $options;
|
|
|
|
$form = new html_form();
|
|
|
|
$form->url = new moodle_url($link, $options);
|
2009-07-27 15:13:35 +00:00
|
|
|
$form->button = new html_button();
|
2009-07-27 10:33:00 +00:00
|
|
|
$form->button->label = $label;
|
|
|
|
$form->button->disabled = $disabled;
|
|
|
|
$form->button->title = $tooltip;
|
|
|
|
$form->method = $method;
|
|
|
|
$form->id = $formid;
|
|
|
|
|
|
|
|
if ($jsconfirmmessage) {
|
|
|
|
$confirmaction = new component_action('click', 'confirm_dialog', array($jsconfirmmessage));
|
|
|
|
$form->button->add_action_object($confirmaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = $OUTPUT->button($form);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a spacer image with the option of including a line break.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param int $height The height in pixels to make the spacer
|
|
|
|
* @param int $width The width in pixels to make the spacer
|
|
|
|
* @param boolean $br If set to true a BR is written after the spacer
|
|
|
|
*/
|
|
|
|
function print_spacer($height=1, $width=1, $br=true, $return=false) {
|
|
|
|
global $CFG, $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('print_spacer() has been deprecated. Please change your code to use $OUTPUT->spacer().');
|
|
|
|
|
|
|
|
$spacer = new html_spacer();
|
|
|
|
$spacer->height = $height;
|
|
|
|
$spacer->width = $width;
|
|
|
|
|
|
|
|
$output = $OUTPUT->spacer($spacer);
|
|
|
|
|
|
|
|
$output .= '<img class="spacer" height="'. $height .'" width="'. $width .'" src="'. $CFG->wwwroot .'/pix/spacer.gif" alt="" />';
|
|
|
|
|
|
|
|
if ($br) {
|
|
|
|
$output .= '<br />';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given the path to a picture file in a course, or a URL,
|
|
|
|
* this function includes the picture in the page.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*/
|
|
|
|
function print_file_picture($path, $courseid=0, $height='', $width='', $link='', $return=false) {
|
|
|
|
throw new coding_exception('print_file_picture() has been deprecated since Moodle 2.0. Please use $OUTPUT->action_icon() instead.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print the specified user's avatar.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @global object
|
|
|
|
* @param mixed $user Should be a $user object with at least fields id, picture, imagealt, firstname, lastname
|
|
|
|
* If any of these are missing, or if a userid is passed, the the database is queried. Avoid this
|
|
|
|
* if at all possible, particularly for reports. It is very bad for performance.
|
|
|
|
* @param int $courseid The course id. Used when constructing the link to the user's profile.
|
|
|
|
* @param boolean $picture The picture to print. By default (or if NULL is passed) $user->picture is used.
|
|
|
|
* @param int $size Size in pixels. Special values are (true/1 = 100px) and (false/0 = 35px) for backward compatibility
|
|
|
|
* @param boolean $return If false print picture to current page, otherwise return the output as string
|
|
|
|
* @param boolean $link enclose printed image in a link the user's profile (default true).
|
|
|
|
* @param string $target link target attribute. Makes the profile open in a popup window.
|
|
|
|
* @param boolean $alttext add non-blank alt-text to the image. (Default true, set to false for purely
|
|
|
|
* decorative images, or where the username will be printed anyway.)
|
|
|
|
* @return string|void String or nothing, depending on $return.
|
|
|
|
*/
|
|
|
|
function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true) {
|
|
|
|
global $CFG, $DB, $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('print_user_picture() has been deprecated. Please change your code to use $OUTPUT->user_picture($user, $link, $popup).');
|
|
|
|
|
|
|
|
$userpic = new user_picture();
|
|
|
|
$userpic->user = $user;
|
|
|
|
$userpic->courseid = $courseid;
|
|
|
|
$userpic->size = $size;
|
|
|
|
$userpic->link = $link;
|
|
|
|
$userpic->alttext = $alttext;
|
|
|
|
|
|
|
|
if (!empty($picture)) {
|
|
|
|
$userpic->image = new html_image();
|
|
|
|
$userpic->image->src = $picture;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($target)) {
|
|
|
|
$popupaction = new popup_action('click', new moodle_url($target));
|
|
|
|
$userpic->add_action_object($popupaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = $OUTPUT->user_picture($userpic);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a png image.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0: no replacement
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function print_png() {
|
|
|
|
throw new coding_exception('print_png() has been deprecated since Moodle 2.0. Please use $OUTPUT->image() instead.');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a basic textarea field.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* When using this function, you should
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param bool $usehtmleditor Enables the use of the htmleditor for this field.
|
|
|
|
* @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
|
|
|
|
* @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
|
|
|
|
* @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
|
|
|
|
* @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
|
|
|
|
* @param string $name Name to use for the textarea element.
|
|
|
|
* @param string $value Initial content to display in the textarea.
|
|
|
|
* @param int $obsolete deprecated
|
|
|
|
* @param bool $return If false, will output string. If true, will return string value.
|
|
|
|
* @param string $id CSS ID to add to the textarea element.
|
|
|
|
* @return string|void depending on the value of $return
|
|
|
|
*/
|
|
|
|
function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
|
|
|
|
/// $width and height are legacy fields and no longer used as pixels like they used to be.
|
|
|
|
/// However, you can set them to zero to override the mincols and minrows values below.
|
|
|
|
|
|
|
|
// debugging('print_textarea() has been deprecated. Please change your code to use $OUTPUT->textarea().');
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
$mincols = 65;
|
|
|
|
$minrows = 10;
|
|
|
|
$str = '';
|
|
|
|
|
|
|
|
if ($id === '') {
|
|
|
|
$id = 'edit-'.$name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($usehtmleditor) {
|
|
|
|
if ($height && ($rows < $minrows)) {
|
|
|
|
$rows = $minrows;
|
|
|
|
}
|
|
|
|
if ($width && ($cols < $mincols)) {
|
|
|
|
$cols = $mincols;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($usehtmleditor) {
|
|
|
|
editors_head_setup();
|
|
|
|
$editor = get_preferred_texteditor(FORMAT_HTML);
|
|
|
|
$editor->use_editor($id, array('legacy'=>true));
|
|
|
|
} else {
|
|
|
|
$editorclass = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
|
|
|
|
if ($usehtmleditor) {
|
|
|
|
$str .= htmlspecialchars($value); // needed for editing of cleaned text!
|
|
|
|
} else {
|
|
|
|
$str .= s($value);
|
|
|
|
}
|
|
|
|
$str .= '</textarea>'."\n";
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
echo $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a help button.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @param string $page The keyword that defines a help page
|
|
|
|
* @param string $title The title of links, rollover tips, alt tags etc
|
|
|
|
* 'Help with' (or the language equivalent) will be prefixed and '...' will be stripped.
|
|
|
|
* @param string $module Which module is the page defined in
|
|
|
|
* @param mixed $image Use a help image for the link? (true/false/"both")
|
|
|
|
* @param boolean $linktext If true, display the title next to the help icon.
|
|
|
|
* @param string $text If defined then this text is used in the page, and
|
|
|
|
* the $page variable is ignored. DEPRECATED!
|
|
|
|
* @param boolean $return If true then the output is returned as a string, if false it is printed to the current page.
|
|
|
|
* @param string $imagetext The full text for the helpbutton icon. If empty use default help.gif
|
|
|
|
* @return string|void Depending on value of $return
|
|
|
|
*/
|
|
|
|
function helpbutton($page, $title, $module='moodle', $image=true, $linktext=false, $text='', $return=false, $imagetext='') {
|
|
|
|
// debugging('helpbutton() has been deprecated. Please change your code to use $OUTPUT->help_icon().');
|
|
|
|
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
if (!empty($text)) {
|
|
|
|
throw new coding_exception('The $text parameter has been deprecated. Please update your code and use $OUTPUT->help_icon() instead. <br />' .
|
|
|
|
"You will also need to copy the following text into a proper html help file if not already done so: <p>$text</p>");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($imagetext)) {
|
|
|
|
throw new coding_exception('The $imagetext parameter has been deprecated. Please update your code and use $OUTPUT->help_icon() instead.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$helpicon = new help_icon();
|
|
|
|
$helpicon->page = $page;
|
|
|
|
$helpicon->module = $module;
|
|
|
|
$helpicon->text = $title;
|
|
|
|
$helpicon->linktext = $linktext;
|
|
|
|
|
|
|
|
// If image is true, the defaults are handled by the helpicon's prepare method
|
|
|
|
if (!$image) {
|
|
|
|
$helpicon->image = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$output = $OUTPUT->help_icon($helpicon);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
echo $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an image of an up or down arrow, used for column sorting. To avoid unnecessary DB accesses, please
|
|
|
|
* provide this function with the language strings for sortasc and sortdesc.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* TODO migrate to outputlib
|
|
|
|
* If no sort string is associated with the direction, an arrow with no alt text will be printed/returned.
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param string $direction 'up' or 'down'
|
|
|
|
* @param string $strsort The language string used for the alt attribute of this image
|
|
|
|
* @param bool $return Whether to print directly or return the html string
|
|
|
|
* @return string|void depending on $return
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function print_arrow($direction='up', $strsort=null, $return=false) {
|
|
|
|
// debugging('print_arrow() has been deprecated. Please change your code to use $OUTPUT->arrow().');
|
|
|
|
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
if (!in_array($direction, array('up', 'down', 'right', 'left', 'move'))) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$return = null;
|
|
|
|
|
|
|
|
switch ($direction) {
|
|
|
|
case 'up':
|
|
|
|
$sortdir = 'asc';
|
|
|
|
break;
|
|
|
|
case 'down':
|
|
|
|
$sortdir = 'desc';
|
|
|
|
break;
|
|
|
|
case 'move':
|
|
|
|
$sortdir = 'asc';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$sortdir = null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare language string
|
|
|
|
$strsort = '';
|
|
|
|
if (empty($strsort) && !empty($sortdir)) {
|
|
|
|
$strsort = get_string('sort' . $sortdir, 'grades');
|
|
|
|
}
|
|
|
|
|
|
|
|
$return = ' <img src="'.$OUTPUT->old_icon_url('t/' . $direction) . '" alt="'.$strsort.'" /> ';
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $return;
|
|
|
|
} else {
|
|
|
|
echo $return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a string containing a link to the user documentation.
|
|
|
|
* Also contains an icon by default. Shown to teachers and admin only.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param string $path The page link after doc root and language, no leading slash.
|
|
|
|
* @param string $text The text to be displayed for the link
|
|
|
|
* @param string $iconpath The path to the icon to be displayed
|
|
|
|
* @return string Either the link or an empty string
|
|
|
|
*/
|
|
|
|
function doc_link($path='', $text='', $iconpath='') {
|
|
|
|
global $CFG, $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->action_icon().');
|
|
|
|
|
|
|
|
if (empty($CFG->docroot)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$icon = new action_icon();
|
|
|
|
$icon->linktext = $text;
|
|
|
|
|
|
|
|
if (!empty($iconpath)) {
|
|
|
|
$icon->image->src = $iconpath;
|
|
|
|
$icon->image->alt = $text;
|
|
|
|
$icon->image->add_class('iconhelp');
|
|
|
|
} else {
|
|
|
|
$icon->image->src = $CFG->httpswwwroot . '/pix/docs.gif';
|
|
|
|
}
|
|
|
|
|
|
|
|
$icon->link->url = new moodle_url(get_docs_url($path));
|
|
|
|
|
|
|
|
if (!empty($CFG->doctonewwindow)) {
|
|
|
|
$icon->actions[] = new popup_action('click', $icon->link->url);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $OUTPUT->action_icon($icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a single paging bar to provide access to other pages (usually in a search)
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @param int $totalcount Thetotal number of entries available to be paged through
|
|
|
|
* @param int $page The page you are currently viewing
|
|
|
|
* @param int $perpage The number of entries that should be shown per page
|
|
|
|
* @param mixed $baseurl If this is a string then it is the url which will be appended with $pagevar, an equals sign and the page number.
|
|
|
|
* If this is a moodle_url object then the pagevar param will be replaced by the page no, for each page.
|
|
|
|
* @param string $pagevar This is the variable name that you use for the page number in your code (ie. 'tablepage', 'blogpage', etc)
|
|
|
|
* @param bool $nocurr do not display the current page as a link
|
|
|
|
* @param bool $return whether to return an output string or echo now
|
|
|
|
* @return bool|string depending on $result
|
|
|
|
*/
|
|
|
|
function print_paging_bar($totalcount, $page, $perpage, $baseurl, $pagevar='page',$nocurr=false, $return=false) {
|
|
|
|
global $OUTPUT;
|
|
|
|
|
|
|
|
// debugging('print_paging_bar() has been deprecated. Please change your code to use $OUTPUT->paging_bar($pagingbar).');
|
|
|
|
|
|
|
|
$pagingbar = new moodle_paging_bar();
|
|
|
|
$pagingbar->totalcount = $totalcount;
|
|
|
|
$pagingbar->page = $page;
|
|
|
|
$pagingbar->perpage = $perpage;
|
|
|
|
$pagingbar->baseurl = $baseurl;
|
|
|
|
$pagingbar->pagevar = $pagevar;
|
|
|
|
$pagingbar->nocurr = $nocurr;
|
|
|
|
$output = $OUTPUT->paging_bar($pagingbar);
|
|
|
|
|
|
|
|
if ($return) {
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $output;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print a message along with "Yes" and "No" links for the user to continue.
|
|
|
|
*
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*
|
|
|
|
* @global object
|
|
|
|
* @param string $message The text to display
|
|
|
|
* @param string $linkyes The link to take the user to if they choose "Yes"
|
|
|
|
* @param string $linkno The link to take the user to if they choose "No"
|
|
|
|
* @param string $optionyes The yes option to show on the notice
|
|
|
|
* @param string $optionsno The no option to show
|
|
|
|
* @param string $methodyes Form action method to use if yes [post, get]
|
|
|
|
* @param string $methodno Form action method to use if no [post, get]
|
|
|
|
* @return void Output is echo'd
|
|
|
|
*/
|
|
|
|
function notice_yesno($message, $linkyes, $linkno, $optionsyes=NULL, $optionsno=NULL, $methodyes='post', $methodno='post') {
|
|
|
|
|
|
|
|
// debugging('notice_yesno() has been deprecated. Please change your code to use $OUTPUT->confirm($message, $buttoncontinue, $buttoncancel).');
|
|
|
|
|
|
|
|
global $OUTPUT;
|
2009-07-27 15:13:35 +00:00
|
|
|
|
|
|
|
$formcontinue = new html_form();
|
|
|
|
$formcontinue->url = new moodle_url($linkyes, $optionsyes);
|
|
|
|
$formcontinue->button = new html_button();
|
|
|
|
$formcontinue->button->label = get_string('yes');
|
|
|
|
$formcontinue->method = $methodyes;
|
|
|
|
|
|
|
|
$formcancel = new html_form();
|
|
|
|
$formcancel->url = new moodle_url($linkno, $optionsno);
|
|
|
|
$formcancel->button = new html_button();
|
|
|
|
$formcancel->button->label = get_string('no');
|
|
|
|
$formcancel->method = $methodno;
|
2009-07-27 10:33:00 +00:00
|
|
|
|
2009-07-27 15:13:35 +00:00
|
|
|
echo $OUTPUT->confirm($message, $formcontinue, $formcancel);
|
2009-07-27 10:33:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prints a scale menu (as part of an existing form) including help button
|
|
|
|
* @deprecated since Moodle 2.0
|
|
|
|
*/
|
|
|
|
function print_scale_menu() {
|
|
|
|
throw new coding_exception('print_scale_menu() has been deprecated since the Jurassic period. Get with the times!.');
|
|
|
|
}
|
|
|
|
|