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 .
*
2010-07-25 13:35:05 +00:00
* @ package core
2009-05-22 09:10:53 +00:00
* @ subpackage deprecated
2010-07-25 13:35:05 +00:00
* @ copyright 1999 onwards Martin Dougiamas { @ link http :// moodle . com }
* @ license http :// www . gnu . org / copyleft / gpl . html GNU GPL v3 or later
2009-05-22 09:10:53 +00:00
* @ deprecated
2006-09-03 08:10:10 +00:00
*/
2010-07-25 13:35:05 +00:00
defined ( 'MOODLE_INTERNAL' ) || die ();
2015-05-11 13:23:11 +05:30
/* === Functions that needs to be kept longer in deprecated lib than normal time period === */
/**
* Add an entry to the legacy log table .
*
* @ deprecated since 2.7 use new events instead
*
* @ param int $courseid The course id
* @ param string $module The module name e . g . forum , journal , resource , course , user etc
* @ param string $action 'view' , 'update' , 'add' or 'delete' , possibly followed by another word to clarify .
* @ param string $url The file and parameters used to see the results of the action
* @ param string $info Additional description information
* @ param int $cm The course_module -> id if there is one
* @ param int | stdClass $user If log regards $user other than $USER
* @ return void
*/
function add_to_log ( $courseid , $module , $action , $url = '' , $info = '' , $cm = 0 , $user = 0 ) {
debugging ( 'add_to_log() has been deprecated, please rewrite your code to the new events API' , DEBUG_DEVELOPER );
// This is a nasty hack that allows us to put all the legacy stuff into legacy storage,
// this way we may move all the legacy settings there too.
$manager = get_log_manager ();
if ( method_exists ( $manager , 'legacy_add_to_log' )) {
$manager -> legacy_add_to_log ( $courseid , $module , $action , $url , $info , $cm , $user );
}
}
/**
* Function to call all event handlers when triggering an event
*
* @ deprecated since 2.6
*
* @ param string $eventname name of the event
* @ param mixed $eventdata event data object
* @ return int number of failed events
*/
function events_trigger ( $eventname , $eventdata ) {
debugging ( 'events_trigger() is deprecated, please use new events instead' , DEBUG_DEVELOPER );
return events_trigger_legacy ( $eventname , $eventdata );
}
/**
* List all core subsystems and their location
*
* This is a whitelist of components that are part of the core and their
* language strings are defined in / lang / en /<< subsystem >>. php . If a given
* plugin is not listed here and it does not have proper plugintype prefix ,
* then it is considered as course activity module .
*
* The location is optionally dirroot relative path . NULL means there is no special
* directory for this subsystem . If the location is set , the subsystem ' s
* renderer . php is expected to be there .
*
* @ deprecated since 2.6 , use core_component :: get_core_subsystems ()
*
* @ param bool $fullpaths false means relative paths from dirroot , use true for performance reasons
* @ return array of ( string ) name => ( string | null ) location
*/
function get_core_subsystems ( $fullpaths = false ) {
global $CFG ;
// NOTE: do not add any other debugging here, keep forever.
$subsystems = core_component :: get_core_subsystems ();
if ( $fullpaths ) {
return $subsystems ;
}
debugging ( 'Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.' , DEBUG_DEVELOPER );
$dlength = strlen ( $CFG -> dirroot );
foreach ( $subsystems as $k => $v ) {
if ( $v === null ) {
continue ;
}
$subsystems [ $k ] = substr ( $v , $dlength + 1 );
}
return $subsystems ;
}
/**
* Lists all plugin types .
*
* @ deprecated since 2.6 , use core_component :: get_plugin_types ()
*
* @ param bool $fullpaths false means relative paths from dirroot
* @ return array Array of strings - name => location
*/
function get_plugin_types ( $fullpaths = true ) {
global $CFG ;
// NOTE: do not add any other debugging here, keep forever.
$types = core_component :: get_plugin_types ();
if ( $fullpaths ) {
return $types ;
}
debugging ( 'Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.' , DEBUG_DEVELOPER );
$dlength = strlen ( $CFG -> dirroot );
foreach ( $types as $k => $v ) {
if ( $k === 'theme' ) {
$types [ $k ] = 'theme' ;
continue ;
}
$types [ $k ] = substr ( $v , $dlength + 1 );
}
return $types ;
}
/**
* Use when listing real plugins of one type .
*
* @ deprecated since 2.6 , use core_component :: get_plugin_list ()
*
* @ param string $plugintype type of plugin
* @ return array name => fulllocation pairs of plugins of given type
*/
function get_plugin_list ( $plugintype ) {
// NOTE: do not add any other debugging here, keep forever.
if ( $plugintype === '' ) {
$plugintype = 'mod' ;
}
return core_component :: get_plugin_list ( $plugintype );
}
/**
* Get a list of all the plugins of a given type that define a certain class
* in a certain file . The plugin component names and class names are returned .
*
* @ deprecated since 2.6 , use core_component :: get_plugin_list_with_class ()
*
* @ param string $plugintype the type of plugin , e . g . 'mod' or 'report' .
* @ param string $class the part of the name of the class after the
* frankenstyle prefix . e . g 'thing' if you are looking for classes with
* names like report_courselist_thing . If you are looking for classes with
* the same name as the plugin name ( e . g . qtype_multichoice ) then pass '' .
* @ param string $file the name of file within the plugin that defines the class .
* @ return array with frankenstyle plugin names as keys ( e . g . 'report_courselist' , 'mod_forum' )
* and the class names as values ( e . g . 'report_courselist_thing' , 'qtype_multichoice' ) .
*/
function get_plugin_list_with_class ( $plugintype , $class , $file ) {
// NOTE: do not add any other debugging here, keep forever.
return core_component :: get_plugin_list_with_class ( $plugintype , $class , $file );
}
/**
* Returns the exact absolute path to plugin directory .
*
* @ deprecated since 2.6 , use core_component :: get_plugin_directory ()
*
* @ param string $plugintype type of plugin
* @ param string $name name of the plugin
* @ return string full path to plugin directory ; NULL if not found
*/
function get_plugin_directory ( $plugintype , $name ) {
// NOTE: do not add any other debugging here, keep forever.
if ( $plugintype === '' ) {
$plugintype = 'mod' ;
}
return core_component :: get_plugin_directory ( $plugintype , $name );
}
/**
* Normalize the component name using the " frankenstyle " names .
*
* @ deprecated since 2.6 , use core_component :: normalize_component ()
*
* @ param string $component
* @ return array as ( string ) $type => ( string ) $plugin
*/
function normalize_component ( $component ) {
// NOTE: do not add any other debugging here, keep forever.
return core_component :: normalize_component ( $component );
}
/**
* Return exact absolute path to a plugin directory .
*
* @ deprecated since 2.6 , use core_component :: normalize_component ()
*
* @ param string $component name such as 'moodle' , 'mod_forum'
* @ return string full path to component directory ; NULL if not found
*/
function get_component_directory ( $component ) {
// NOTE: do not add any other debugging here, keep forever.
return core_component :: get_component_directory ( $component );
}
/**
* Get the context instance as an object . This function will create the
* context instance if it does not exist yet .
*
* @ deprecated since 2.2 , use context_course :: instance () or other relevant class instead
* @ todo This will be deleted in Moodle 2.8 , refer MDL - 34472
* @ param integer $contextlevel The context level , for example CONTEXT_COURSE , or CONTEXT_MODULE .
* @ param integer $instance The instance id . For $level = CONTEXT_COURSE , this would be $course -> id ,
* for $level = CONTEXT_MODULE , this would be $cm -> id . And so on . Defaults to 0
* @ param int $strictness IGNORE_MISSING means compatible mode , false returned if record not found , debug message if more found ;
* MUST_EXIST means throw exception if no record or multiple records found
* @ return context The context object .
*/
function get_context_instance ( $contextlevel , $instance = 0 , $strictness = IGNORE_MISSING ) {
debugging ( 'get_context_instance() is deprecated, please use context_xxxx::instance() instead.' , DEBUG_DEVELOPER );
$instances = ( array ) $instance ;
$contexts = array ();
$classname = context_helper :: get_class_for_level ( $contextlevel );
// we do not load multiple contexts any more, PAGE should be responsible for any preloading
foreach ( $instances as $inst ) {
$contexts [ $inst ] = $classname :: instance ( $inst , $strictness );
}
if ( is_array ( $instance )) {
return $contexts ;
} else {
return $contexts [ $instance ];
}
}
/* === End of long term deprecated api list === */
2014-02-18 09:22:30 +08:00
/**
* Adds a file upload to the log table so that clam can resolve the filename to the user later if necessary
*
* @ deprecated since 2.7 - use new file picker instead
*
*/
function clam_log_upload ( $newfilepath , $course = null , $nourl = false ) {
2014-12-17 15:10:33 +08:00
throw new coding_exception ( 'clam_log_upload() can not be used any more, please use file picker instead' );
2014-02-18 09:22:30 +08:00
}
/**
* This function logs to error_log and to the log table that an infected file has been found and what ' s happened to it .
*
* @ deprecated since 2.7 - use new file picker instead
*
*/
function clam_log_infected ( $oldfilepath = '' , $newfilepath = '' , $userid = 0 ) {
2014-12-17 15:10:33 +08:00
throw new coding_exception ( 'clam_log_infected() can not be used any more, please use file picker instead' );
2014-02-18 09:22:30 +08:00
}
/**
* Some of the modules allow moving attachments ( glossary ), in which case we need to hunt down an original log and change the path .
*
* @ deprecated since 2.7 - use new file picker instead
*
*/
function clam_change_log ( $oldpath , $newpath , $update = true ) {
2014-12-17 15:10:33 +08:00
throw new coding_exception ( 'clam_change_log() can not be used any more, please use file picker instead' );
2014-02-18 09:22:30 +08:00
}
/**
* Replaces the given file with a string .
*
* @ deprecated since 2.7 - infected files are now deleted in file picker
*
*/
function clam_replace_infected_file ( $file ) {
2014-12-17 15:10:33 +08:00
throw new coding_exception ( 'clam_replace_infected_file() can not be used any more, please use file picker instead' );
2014-02-18 09:22:30 +08:00
}
2014-12-22 15:07:59 +00:00
/**
* Deals with an infected file - either moves it to a quarantinedir
* ( specified in CFG -> quarantinedir ) or deletes it .
*
* If moving it fails , it deletes it .
*
* @ deprecated since 2.7
*/
function clam_handle_infected_file ( $file , $userid = 0 , $basiconly = false ) {
throw new coding_exception ( 'clam_handle_infected_file() can not be used any more, please use file picker instead' );
}
/**
* If $CFG -> runclamonupload is set , we scan a given file . ( called from { @ link preprocess_files ()})
*
* @ deprecated since 2.7
*/
function clam_scan_moodle_file ( & $file , $course ) {
throw new coding_exception ( 'clam_scan_moodle_file() can not be used any more, please use file picker instead' );
}
2013-12-22 17:59:35 +08:00
/**
* Checks whether the password compatibility library will work with the current
* version of PHP . This cannot be done using PHP version numbers since the fix
* has been backported to earlier versions in some distributions .
*
* See https :// github . com / ircmaxell / password_compat / issues / 10 for more details .
*
* @ deprecated since 2.7 PHP 5.4 . x should be always compatible .
*
*/
function password_compat_not_supported () {
2015-05-11 12:46:36 +05:30
throw new coding_exception ( 'Do not use password_compat_not_supported() - bcrypt is now always available' );
2013-12-22 17:59:35 +08:00
}
2013-09-08 08:38:52 +02:00
/**
* Factory method that was returning moodle_session object .
*
* @ deprecated since 2.6
*/
function session_get_instance () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_get_instance() is removed, use \core\session\manager instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Returns true if legacy session used .
*
* @ deprecated since 2.6
*/
function session_is_legacy () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_is_legacy() is removed, do not use any more' );
2013-09-08 08:38:52 +02:00
}
/**
* Terminates all sessions , auth hooks are not executed .
*
* @ deprecated since 2.6
*/
function session_kill_all () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_kill_all() is removed, use \core\session\manager::kill_all_sessions() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Mark session as accessed , prevents timeouts .
*
* @ deprecated since 2.6
*/
function session_touch ( $sid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_touch() is removed, use \core\session\manager::touch_session() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Terminates one sessions , auth hooks are not executed .
*
* @ deprecated since 2.6
*/
function session_kill ( $sid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_kill() is removed, use \core\session\manager::kill_session() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Terminates all sessions of one user , auth hooks are not executed .
*
* @ deprecated since 2.6
*/
function session_kill_user ( $userid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_kill_user() is removed, use \core\session\manager::kill_user_sessions() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Setup $USER object - called during login , loginas , etc .
*
* Call sync_user_enrolments () manually after log - in , or log - in - as .
*
* @ deprecated since 2.6
*/
function session_set_user ( $user ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_set_user() is removed, use \core\session\manager::set_user() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Is current $USER logged - in - as somebody else ?
* @ deprecated since 2.6
*/
function session_is_loggedinas () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_is_loggedinas() is removed, use \core\session\manager::is_loggedinas() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Returns the $USER object ignoring current login - as session
* @ deprecated since 2.6
*/
function session_get_realuser () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_get_realuser() is removed, use \core\session\manager::get_realuser() instead' );
2013-09-08 08:38:52 +02:00
}
/**
* Login as another user - no security checks here .
* @ deprecated since 2.6
*/
function session_loginas ( $userid , $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'session_loginas() is removed, use \core\session\manager::loginas() instead' );
2013-09-08 08:38:52 +02:00
}
2013-08-01 23:20:24 +02:00
/**
* Minify JavaScript files .
*
* @ deprecated since 2.6
*/
function js_minify ( $files ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'js_minify() is removed, use core_minify::js_files() or core_minify::js() instead.' );
2013-08-01 23:20:24 +02:00
}
/**
* Minify CSS files .
*
* @ deprecated since 2.6
*/
function css_minify_css ( $files ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'css_minify_css() is removed, use core_minify::css_files() or core_minify::css() instead.' );
2013-08-01 23:20:24 +02:00
}
2013-06-07 18:15:28 +02:00
// === Deprecated before 2.6.0 ===
2013-03-22 16:51:18 +01:00
/**
* Hack to find out the GD version by parsing phpinfo output
*/
function check_gd_version () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'check_gd_version() is removed, GD extension is always available now' );
2013-03-22 16:51:18 +01:00
}
2013-01-03 23:29:43 +01:00
/**
* Not used any more , the account lockout handling is now
* part of authenticate_user_login () .
* @ deprecated
*/
function update_login_count () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'update_login_count() is removed, all calls need to be removed' );
2013-01-03 23:29:43 +01:00
}
/**
* Not used any more , replaced by proper account lockout .
* @ deprecated
*/
function reset_login_count () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'reset_login_count() is removed, all calls need to be removed' );
2013-01-03 23:29:43 +01:00
}
2010-08-03 10:07:18 +00:00
/**
* @ deprecated
*/
function update_log_display_entry ( $module , $action , $mtable , $field ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'The update_log_display_entry() is removed, please use db/log.php description file instead.' );
2010-08-03 10:07:18 +00:00
}
2010-07-30 20:51:01 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use the text formatting in a standard way instead ( http :// docs . moodle . org / dev / Output_functions )
2010-07-30 20:51:01 +00:00
* this was abused mostly for embedding of attachments
*/
function filter_text ( $text , $courseid = NULL ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'filter_text() can not be used anymore, use format_text(), format_string() etc instead.' );
2010-07-30 20:51:01 +00:00
}
2010-10-10 15:04:19 +00:00
/**
* @ deprecated use $PAGE -> https_required () instead
*/
function httpsrequired () {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'httpsrequired() can not be used any more use $PAGE->https_required() instead.' );
2010-10-10 15:04:19 +00:00
}
2010-07-11 13:30:33 +00:00
/**
* Given a physical path to a file , returns the URL through which it can be reached in Moodle .
*
* @ deprecated use moodle_url factory methods instead
*
* @ param string $path Physical path to a file
* @ param array $options associative array of GET variables to append to the URL
* @ param string $type ( questionfile | rssfile | httpscoursefile | coursefile )
* @ return string URL to file
*/
function get_file_url ( $path , $options = null , $type = 'coursefile' ) {
2010-10-10 15:04:19 +00:00
global $CFG ;
2010-07-11 13:30:33 +00:00
$path = str_replace ( '//' , '/' , $path );
$path = trim ( $path , '/' ); // no leading and trailing slashes
// type of file
switch ( $type ) {
case 'questionfile' :
$url = $CFG -> wwwroot . " /question/exportfile.php " ;
break ;
case 'rssfile' :
$url = $CFG -> wwwroot . " /rss/file.php " ;
break ;
case 'httpscoursefile' :
$url = $CFG -> httpswwwroot . " /file.php " ;
break ;
case 'coursefile' :
default :
$url = $CFG -> wwwroot . " /file.php " ;
}
if ( $CFG -> slasharguments ) {
$parts = explode ( '/' , $path );
foreach ( $parts as $key => $part ) {
/// anchor dash character should not be encoded
$subparts = explode ( '#' , $part );
$subparts = array_map ( 'rawurlencode' , $subparts );
$parts [ $key ] = implode ( '#' , $subparts );
}
$path = implode ( '/' , $parts );
$ffurl = $url . '/' . $path ;
$separator = '?' ;
} else {
$path = rawurlencode ( '/' . $path );
$ffurl = $url . '?file=' . $path ;
$separator = '&' ;
}
if ( $options ) {
foreach ( $options as $name => $value ) {
$ffurl = $ffurl . $separator . $name . '=' . $value ;
$separator = '&' ;
}
}
return $ffurl ;
}
2006-09-10 07:07:52 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use get_enrolled_users ( $context ) instead .
2006-09-10 07:07:52 +00:00
*/
2010-03-31 07:41:31 +00:00
function get_course_participants ( $courseid ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'get_course_participants() can not be used any more, use get_enrolled_users() instead.' );
2006-09-10 07:07:52 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use is_enrolled ( $context , $userid ) instead .
2006-09-10 07:07:52 +00:00
*/
2010-03-31 07:41:31 +00:00
function is_course_participant ( $userid , $courseid ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'is_course_participant() can not be used any more, use is_enrolled() instead.' );
2006-09-10 07:07:52 +00:00
}
/**
2015-05-11 12:46:36 +05:30
* @ deprecated
2006-09-10 07:07:52 +00:00
*/
function get_recent_enrolments ( $courseid , $timestart ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_recent_enrolments() is removed as it returned inaccurate results.' );
2006-09-10 07:07:52 +00:00
}
2007-01-20 13:32:15 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use clean_param ( $string , PARAM_FILE ) instead .
2007-01-20 13:32:15 +00:00
*/
function detect_munged_arguments ( $string , $allowdots = 1 ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'detect_munged_arguments() can not be used any more, please use clean_param(,PARAM_FILE) instead.' );
2007-01-20 13:32:15 +00:00
}
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-08-16 11:06:48 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use groups_get_all_groups () instead .
2007-08-16 11:06:48 +00:00
*/
function mygroupid ( $courseid ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'mygroupid() can not be used any more, please use groups_get_all_groups() instead.' );
2007-08-16 11:06:48 +00:00
}
/**
* 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
*
2015-05-18 11:09:43 +05:30
* @ deprecated since Moodle 2.0 MDL - 14617 - please do not use this function any more .
* @ todo MDL - 50273 This will be deleted in Moodle 3.2 .
*
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 ) {
2015-05-18 11:09:43 +05:30
debugging ( 'groupmode() is deprecated, please use groups_get_* instead' , DEBUG_DEVELOPER );
2007-08-16 11:06:48 +00:00
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
*
2015-05-18 11:09:43 +05:30
* @ deprecated Since year 2006 - please do not use this function any more .
* @ todo MDL - 50273 This will be deleted in Moodle 3.2 .
*
2009-05-22 09:10:53 +00:00
* @ global object
2015-06-29 13:03:50 +05:30
* @ 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 ;
2015-05-18 11:09:43 +05:30
debugging ( 'set_current_group() is deprecated, please use $SESSION->currentgroup[$courseid] instead' , DEBUG_DEVELOPER );
2008-05-01 22:32:15 +00:00
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
*
2015-05-18 11:09:43 +05:30
* @ deprecated Since year 2006 - please do not use this function any more .
* @ todo MDL - 50273 This will be deleted in Moodle 3.2 .
*
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 ;
2015-05-18 11:09:43 +05:30
debugging ( 'get_current_group() is deprecated, please use groups_get_* instead' , DEBUG_DEVELOPER );
2007-08-16 11:06:48 +00:00
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 ;
}
}
2014-08-01 15:05:56 +01:00
/**
* @ deprecated Since Moodle 2.8
*/
function groups_filter_users_by_course_module_visible ( $cm , $users ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'groups_filter_users_by_course_module_visible() is removed. ' .
2014-08-01 15:05:56 +01:00
'Replace with a call to \core_availability\info_module::filter_user_list(), ' .
'which does basically the same thing but includes other restrictions such ' .
2015-05-11 12:46:36 +05:30
'as profile restrictions.' );
2014-08-01 15:05:56 +01:00
}
/**
* @ deprecated Since Moodle 2.8
*/
function groups_course_module_visible ( $cm , $userid = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( ' groups_course_module_visible () is removed , use $cm -> uservisible to decide whether the current
user can ' . ' access an activity . ' , DEBUG_DEVELOPER );
2014-08-01 15:05:56 +01:00
}
2007-08-16 11:06:48 +00:00
2008-04-01 04:15:13 +00:00
/**
2015-05-11 12:46:36 +05:30
* @ deprecated since 2.0
2008-04-01 04:15:13 +00:00
*/
2008-06-09 19:48:24 +00:00
function error ( $message , $link = '' ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'notlocalisederrormessage' , 'error' , $link , $message , ' error () is a removed , please call
2015-05-11 12:46:36 +05:30
print_error () instead of error () ' );
2008-06-13 17:51:34 +00:00
}
2008-04-01 04:15:13 +00:00
2009-07-01 05:54:26 +00:00
/**
* @ deprecated use $PAGE -> theme -> name instead .
*/
function current_theme () {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'current_theme() can not be used any more, please use $PAGE->theme->name instead' );
2009-07-01 05:54:26 +00:00
}
2009-06-23 10:41:22 +00:00
/**
* @ deprecated
*/
function formerr ( $error ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'formerr() is removed. Please change your code to use $OUTPUT->error_text($string).' );
2009-06-23 10:41:22 +00:00
}
2009-06-26 09:06:16 +00:00
/**
* @ deprecated use $OUTPUT -> skip_link_target () in instead .
*/
function skip_main_destination () {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'skip_main_destination() can not be used any more, please use $OUTPUT->skip_link_target() instead.' );
2009-06-26 09:06:16 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> container () instead .
2009-06-26 09:06:16 +00:00
*/
function print_container ( $message , $clearfix = false , $classes = '' , $idbase = '' , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_container() can not be used any more. Please use $OUTPUT->container() instead.' );
2009-06-26 09:06:16 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> container_start () instead .
2009-06-26 09:06:16 +00:00
*/
function print_container_start ( $clearfix = false , $classes = '' , $idbase = '' , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_container_start() can not be used any more. Please use $OUTPUT->container_start() instead.' );
2009-06-26 09:06:16 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> container_end () instead .
2009-06-26 09:06:16 +00:00
*/
function print_container_end ( $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_container_end() can not be used any more. Please use $OUTPUT->container_end() instead.' );
2009-06-26 09:06:16 +00:00
}
/**
* 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 ;
}
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> continue_button () instead .
2009-06-26 09:06:16 +00:00
*/
function print_continue ( $link , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_continue() can not be used any more. Please use $OUTPUT->continue_button() instead.' );
2009-06-26 09:06:16 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $PAGE methods instead .
2009-06-26 09:06:16 +00:00
*/
function print_header ( $title = '' , $heading = '' , $navigation = '' , $focus = '' ,
2009-09-01 03:47:07 +00:00
$meta = '' , $cache = true , $button = ' ' , $menu = null ,
2009-06-26 09:06:16 +00:00
$usexml = false , $bodytags = '' , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_header() can not be used any more. Please use $PAGE methods instead.' );
2009-06-26 09:06:16 +00:00
}
2009-09-08 02:41:51 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $PAGE methods instead .
2009-09-08 02:41:51 +00:00
*/
function print_header_simple ( $title = '' , $heading = '' , $navigation = '' , $focus = '' , $meta = '' ,
$cache = true , $button = ' ' , $menu = '' , $usexml = false , $bodytags = '' , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_header_simple() can not be used any more. Please use $PAGE methods instead.' );
2009-09-08 02:41:51 +00:00
}
2009-06-29 08:17:31 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> block () instead .
2009-06-29 08:17:31 +00:00
*/
function print_side_block ( $heading = '' , $content = '' , $list = NULL , $icons = NULL , $footer = '' , $attributes = array (), $title = '' ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_side_block() can not be used any more, please use $OUTPUT->block() instead.' );
2009-06-29 08:17:31 +00:00
}
2009-07-27 10:33:00 +00:00
/**
* Prints a basic textarea field .
*
* @ deprecated since Moodle 2.0
*
* When using this function , you should
*
* @ global object
2013-08-13 11:09:46 +08:00
* @ param bool $unused No longer used .
2009-07-27 10:33:00 +00:00
* @ 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
*/
2013-08-13 11:09:46 +08:00
function print_textarea ( $unused , $rows , $cols , $width , $height , $name , $value = '' , $obsolete = 0 , $return = false , $id = '' ) {
2009-07-27 10:33:00 +00:00
/// $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.
2010-04-30 02:06:44 +00:00
// Disabling because there is not yet a viable $OUTPUT option for cases when mforms can't be used
// debugging('print_textarea() has been deprecated. You should be using mforms and the editor element.');
2009-07-27 10:33:00 +00:00
global $CFG ;
$mincols = 65 ;
$minrows = 10 ;
$str = '' ;
if ( $id === '' ) {
$id = 'edit-' . $name ;
}
2013-08-13 11:09:46 +08:00
if ( $height && ( $rows < $minrows )) {
$rows = $minrows ;
2009-07-27 10:33:00 +00:00
}
2013-08-13 11:09:46 +08:00
if ( $width && ( $cols < $mincols )) {
$cols = $mincols ;
2009-07-27 10:33:00 +00:00
}
2013-08-13 11:09:46 +08:00
editors_head_setup ();
$editor = editors_get_preferred_editor ( FORMAT_HTML );
$editor -> use_editor ( $id , array ( 'legacy' => true ));
2013-04-07 18:18:01 +02:00
$str .= " \n " . '<textarea class="form-textarea" id="' . $id . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '" spellcheck="true">' . " \n " ;
2013-08-13 11:09:46 +08:00
$str .= htmlspecialchars ( $value ); // needed for editing of cleaned text!
2009-07-27 10:33:00 +00:00
$str .= '</textarea>' . " \n " ;
if ( $return ) {
return $str ;
}
echo $str ;
}
/**
* 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 .
*
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> arrow () instead .
2014-11-22 09:34:55 +00:00
* @ todo final deprecation of this function once MDL - 45448 is resolved
2009-07-27 10:33:00 +00:00
*
* 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 ) {
global $OUTPUT ;
2013-07-10 11:00:19 +08:00
debugging ( 'print_arrow() is deprecated. Please use $OUTPUT->arrow() instead.' , DEBUG_DEVELOPER );
2009-07-27 10:33:00 +00:00
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' );
}
2009-12-16 21:50:45 +00:00
$return = ' <img src="' . $OUTPUT -> pix_url ( 't/' . $direction ) . '" alt="' . $strsort . '" /> ' ;
2009-07-27 10:33:00 +00:00
if ( $return ) {
return $return ;
} else {
echo $return ;
}
}
2009-07-28 02:27:04 +00:00
/**
* @ deprecated since Moodle 2.0
*/
function choose_from_menu ( $options , $name , $selected = '' , $nothing = 'choose' , $script = '' ,
$nothingvalue = '0' , $return = false , $disabled = false , $tabindex = 0 ,
$id = '' , $listbox = false , $multiple = false , $class = '' ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'choose_from_menu() is removed. Please change your code to use html_writer::select().' );
2009-07-28 12:12:24 +00:00
}
2009-07-29 01:08:52 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> help_icon_scale ( $courseid , $scale ) instead .
2009-07-29 01:08:52 +00:00
*/
function print_scale_menu_helpbutton ( $courseid , $scale , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_scale_menu_helpbutton() can not be used any more. ' .
'Please use $OUTPUT->help_icon_scale($courseid, $scale) instead.' );
2009-07-29 01:08:52 +00:00
}
2009-08-04 02:05:32 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use html_writer :: checkbox () instead .
2009-08-04 02:05:32 +00:00
*/
2010-02-07 20:12:31 +00:00
function print_checkbox ( $name , $value , $checked = true , $label = '' , $alt = '' , $script = '' , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_checkbox() can not be used any more. Please use html_writer::checkbox() instead.' );
2009-08-04 02:05:32 +00:00
}
2009-08-04 02:42:24 +00:00
2009-08-05 02:03:50 +00:00
/**
* Prints the 'update this xxx' button that appears on module pages .
*
* @ deprecated since Moodle 2.0
*
* @ param string $cmid the course_module id .
* @ param string $ignored not used any more . ( Used to be courseid . )
* @ param string $string the module name - get_string ( 'modulename' , 'xxx' )
* @ return string the HTML for the button , if this user has permission to edit it , else an empty string .
*/
function update_module_button ( $cmid , $ignored , $string ) {
2009-08-10 20:50:51 +00:00
global $CFG , $OUTPUT ;
2009-08-05 02:03:50 +00:00
2009-08-06 00:05:39 +00:00
// debugging('update_module_button() has been deprecated. Please change your code to use $OUTPUT->update_module_button().');
2009-08-05 02:03:50 +00:00
2009-08-10 20:50:51 +00:00
//NOTE: DO NOT call new output method because it needs the module name we do not have here!
2012-07-25 16:25:55 +08:00
if ( has_capability ( 'moodle/course:manageactivities' , context_module :: instance ( $cmid ))) {
2009-08-10 20:50:51 +00:00
$string = get_string ( 'updatethis' , '' , $string );
2010-01-03 15:46:14 +00:00
$url = new moodle_url ( " $CFG->wwwroot /course/mod.php " , array ( 'update' => $cmid , 'return' => true , 'sesskey' => sesskey ()));
return $OUTPUT -> single_button ( $url , $string );
2009-08-10 20:50:51 +00:00
} else {
return '' ;
}
2009-08-05 02:03:50 +00:00
}
2009-08-28 08:47:31 +00:00
/**
2013-07-10 11:00:19 +08:00
* @ deprecated use $OUTPUT -> navbar () instead
2009-08-28 08:47:31 +00:00
*/
function print_navigation ( $navigation , $separator = 0 , $return = false ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'print_navigation() can not be used any more, please update use $OUTPUT->navbar() instead.' );
2009-08-28 08:47:31 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated Please use $PAGE -> navabar methods instead .
2009-08-28 08:47:31 +00:00
*/
function build_navigation ( $extranavlinks , $cm = null ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'build_navigation() can not be used any more, please use $PAGE->navbar methods instead.' );
2009-08-28 08:47:31 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated not relevant with global navigation in Moodle 2. x +
2009-08-28 08:47:31 +00:00
*/
function navmenu ( $course , $cm = NULL , $targetwindow = 'self' ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'navmenu() can not be used any more, it is no longer relevant with global navigation.' );
2009-09-14 07:26:54 +00:00
}
2009-11-02 03:50:56 +00:00
/// CALENDAR MANAGEMENT ////////////////////////////////////////////////////////////////
/**
2013-07-10 11:00:19 +08:00
* @ deprecated please use calendar_event :: create () instead .
2009-11-02 03:50:56 +00:00
*/
function add_event ( $event ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'add_event() can not be used any more, please use calendar_event::create() instead.' );
2009-11-02 03:50:56 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated please calendar_event -> update () instead .
2009-11-02 03:50:56 +00:00
*/
function update_event ( $event ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'update_event() is removed, please use calendar_event->update() instead.' );
2009-11-02 03:50:56 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated please use calendar_event -> delete () instead .
2009-11-02 03:50:56 +00:00
*/
function delete_event ( $id ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'delete_event() can not be used any more, please use ' .
'calendar_event->delete() instead.' );
2009-11-02 03:50:56 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated please use calendar_event -> toggle_visibility ( false ) instead .
2009-11-02 03:50:56 +00:00
*/
function hide_event ( $event ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'hide_event() can not be used any more, please use ' .
'calendar_event->toggle_visibility(false) instead.' );
2009-11-02 03:50:56 +00:00
}
/**
2013-07-10 11:00:19 +08:00
* @ deprecated please use calendar_event -> toggle_visibility ( true ) instead .
2009-11-02 03:50:56 +00:00
*/
function show_event ( $event ) {
2014-11-22 09:34:55 +00:00
throw new coding_exception ( 'show_event() can not be used any more, please use ' .
'calendar_event->toggle_visibility(true) instead.' );
2010-03-18 17:11:16 +00:00
}
2012-01-21 13:34:14 +01:00
2012-02-27 07:51:19 +01:00
/**
2014-12-08 17:02:01 +08:00
* @ deprecated since Moodle 2.2 use core_text :: xxxx () instead .
* @ see core_text
2012-02-27 07:51:19 +01:00
*/
function textlib_get_instance () {
2014-12-08 17:02:01 +08:00
throw new coding_exception ( 'textlib_get_instance() can not be used any more, please use ' .
'core_text::functioname() instead.' );
2012-02-27 07:51:19 +01:00
}
2012-09-18 09:57:37 +08:00
/**
* @ deprecated since 2.4
* @ see get_section_name ()
* @ see format_base :: get_section_name ()
2015-05-11 12:46:36 +05:30
2012-09-18 09:57:37 +08:00
*/
function get_generic_section_name ( $format , stdClass $section ) {
2015-05-11 12:46:36 +05:30
throw new coding_exception ( 'get_generic_section_name() is deprecated. Please use appropriate functionality from class format_base' );
2012-09-18 09:57:37 +08:00
}
2012-09-13 16:30:32 +08:00
/**
* Returns an array of sections for the requested course id
*
* It is usually not recommended to display the list of sections used
* in course because the course format may have it ' s own way to do it .
*
* If you need to just display the name of the section please call :
* get_section_name ( $course , $section )
* { @ link get_section_name ()}
* from 2.4 $section may also be just the field course_sections . section
*
* If you need the list of all sections it is more efficient to get this data by calling
2012-10-10 12:41:04 +08:00
* $modinfo = get_fast_modinfo ( $courseorid );
2012-09-13 16:30:32 +08:00
* $sections = $modinfo -> get_section_info_all ()
* { @ link get_fast_modinfo ()}
* { @ link course_modinfo :: get_section_info_all ()}
*
* Information about one section ( instance of section_info ) :
2012-10-10 12:41:04 +08:00
* get_fast_modinfo ( $courseorid ) -> get_sections_info ( $section )
2012-09-13 16:30:32 +08:00
* { @ link course_modinfo :: get_section_info ()}
*
* @ deprecated since 2.4
*/
function get_all_sections ( $courseid ) {
2015-05-11 12:46:36 +05:30
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_all_sections() is removed. See phpdocs for this function' );
2012-09-13 16:30:32 +08:00
}
2012-09-24 17:08:02 +08:00
/**
* This function is deprecated , please use { @ link course_add_cm_to_section ()}
* Note that course_add_cm_to_section () also updates field course_modules . section and
* calls rebuild_course_cache ()
*
* @ deprecated since 2.4
*/
2012-10-15 16:57:25 +08:00
function add_mod_to_section ( $mod , $beforemod = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function add_mod_to_section() is removed, please use course_add_cm_to_section()' );
2012-09-24 17:08:02 +08:00
}
2012-09-25 10:34:18 +08:00
/**
* Returns a number of useful structures for course displays
*
* Function get_all_mods () is deprecated in 2.4
* Instead of :
* < code >
2012-10-10 12:41:04 +08:00
* get_all_mods ( $courseid , $mods , $modnames , $modnamesplural , $modnamesused );
2012-09-25 10:34:18 +08:00
* </ code >
* please use :
* < code >
2012-10-10 12:41:04 +08:00
* $mods = get_fast_modinfo ( $courseorid ) -> get_cms ();
2012-09-25 10:34:18 +08:00
* $modnames = get_module_types_names ();
* $modnamesplural = get_module_types_names ( true );
2012-10-10 12:41:04 +08:00
* $modnamesused = get_fast_modinfo ( $courseorid ) -> get_used_module_names ();
2012-09-25 10:34:18 +08:00
* </ code >
*
* @ deprecated since 2.4
*/
function get_all_mods ( $courseid , & $mods , & $modnames , & $modnamesplural , & $modnamesused ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_all_mods() is removed. Use get_fast_modinfo() and get_module_types_names() instead. See phpdocs for details' );
2012-09-25 10:34:18 +08:00
}
2012-10-08 10:36:01 +08:00
/**
* Returns course section - creates new if does not exist yet
*
* This function is deprecated . To create a course section call :
2012-10-10 12:41:04 +08:00
* course_create_sections_if_missing ( $courseorid , $sections );
2012-10-08 10:36:01 +08:00
* to get the section call :
2012-10-10 12:41:04 +08:00
* get_fast_modinfo ( $courseorid ) -> get_section_info ( $sectionnum );
2012-10-08 10:36:01 +08:00
*
* @ see course_create_sections_if_missing ()
* @ see get_fast_modinfo ()
* @ deprecated since 2.4
*/
function get_course_section ( $section , $courseid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_course_section() is removed. Please use course_create_sections_if_missing() and get_fast_modinfo() instead.' );
2012-10-08 10:36:01 +08:00
}
2012-11-14 14:31:07 +08:00
/**
* @ deprecated since 2.4
* @ see format_weeks :: get_section_dates ()
*/
function format_weeks_get_section_dates ( $section , $course ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function format_weeks_get_section_dates() is removed. It is not recommended to' .
2015-05-11 12:46:36 +05:30
' use it outside of format_weeks plugin' );
2012-11-14 14:31:07 +08:00
}
2012-12-14 11:32:21 +08:00
/**
* Deprecated . Instead of :
* list ( $content , $name ) = get_print_section_cm_text ( $cm , $course );
* use :
* $content = $cm -> get_formatted_content ( array ( 'overflowdiv' => true , 'noclean' => true ));
* $name = $cm -> get_formatted_name ();
*
* @ deprecated since 2.5
* @ see cm_info :: get_formatted_content ()
* @ see cm_info :: get_formatted_name ()
*/
function get_print_section_cm_text ( cm_info $cm , $course ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_print_section_cm_text() is removed. Please use ' .
2015-05-11 12:46:36 +05:30
'cm_info::get_formatted_content() and cm_info::get_formatted_name()' );
2012-12-14 11:32:21 +08:00
}
/**
* Deprecated . Please use :
* $courserenderer = $PAGE -> get_renderer ( 'core' , 'course' );
* $output = $courserenderer -> course_section_add_cm_control ( $course , $section , $sectionreturn ,
* array ( 'inblock' => $vertical ));
2015-07-10 01:59:31 +02:00
* echo $output ;
2012-12-14 11:32:21 +08:00
*
* @ deprecated since 2.5
* @ see core_course_renderer :: course_section_add_cm_control ()
*/
function print_section_add_menus ( $course , $section , $modnames = null , $vertical = false , $return = false , $sectionreturn = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_section_add_menus() is removed. Please use course renderer ' .
2015-05-11 12:46:36 +05:30
'function course_section_add_cm_control()' );
2012-12-14 11:32:21 +08:00
}
/**
* Deprecated . Please use :
* $courserenderer = $PAGE -> get_renderer ( 'core' , 'course' );
* $actions = course_get_cm_edit_actions ( $mod , $indent , $section );
* return ' ' . $courserenderer -> course_section_cm_edit_actions ( $actions );
*
* @ deprecated since 2.5
* @ see course_get_cm_edit_actions ()
* @ see core_course_renderer -> course_section_cm_edit_actions ()
*/
function make_editing_buttons ( stdClass $mod , $absolute_ignored = true , $moveselect = true , $indent =- 1 , $section = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function make_editing_buttons() is removed, please see PHPdocs in ' .
2015-05-11 12:46:36 +05:30
'lib/deprecatedlib.php on how to replace it' );
2012-12-14 11:32:21 +08:00
}
/**
* Deprecated . Please use :
* $courserenderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $courserenderer -> course_section_cm_list ( $course , $section , $sectionreturn ,
* array ( 'hidecompletion' => $hidecompletion ));
*
* @ deprecated since 2.5
* @ see core_course_renderer :: course_section_cm_list ()
*/
function print_section ( $course , $section , $mods , $modnamesused , $absolute = false , $width = " 100% " , $hidecompletion = false , $sectionreturn = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_section() is removed. Please use course renderer function ' .
2015-05-11 12:46:36 +05:30
'course_section_cm_list() instead.' );
2012-12-14 11:32:21 +08:00
}
2013-01-16 11:01:16 +13:00
2012-12-03 12:44:14 +08:00
/**
* @ deprecated since 2.5
*/
function print_overview ( $courses , array $remote_courses = array ()) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_overview() is removed. Use block course_overview to display this information' );
2012-12-03 12:44:14 +08:00
}
2012-12-05 09:55:16 +08:00
/**
* @ deprecated since 2.5
*/
function print_recent_activity ( $course ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_recent_activity() is removed. It is not recommended to' .
2015-05-11 12:46:36 +05:30
' use it outside of block_recent_activity' );
2012-12-05 09:55:16 +08:00
}
2012-12-10 17:33:09 +08:00
/**
* @ deprecated since 2.5
*/
function delete_course_module ( $id ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function delete_course_module() is removed. Please use course_delete_module() instead.' );
2012-12-10 17:33:09 +08:00
}
2013-01-29 15:06:37 +11:00
/**
* @ deprecated since 2.5
*/
function update_category_button ( $categoryid = 0 ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function update_category_button() is removed. Pages to view ' .
2015-05-11 12:46:36 +05:30
'and edit courses are now separate and no longer depend on editing mode.' );
2013-01-29 15:06:37 +11:00
}
2013-02-21 10:37:52 +11:00
/**
* This function is deprecated ! For list of categories use
* coursecat :: make_all_categories ( $requiredcapability , $excludeid , $separator )
* For parents of one particular category use
* coursecat :: get ( $id ) -> get_parents ()
*
* @ deprecated since 2.5
*/
function make_categories_list ( & $list , & $parents , $requiredcapability = '' ,
$excludeid = 0 , $category = NULL , $path = " " ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Global function make_categories_list() is removed. Please use ' .
2015-05-11 12:46:36 +05:30
'coursecat::make_categories_list() and coursecat::get_parents()' );
2013-02-21 10:37:52 +11:00
}
2013-02-21 10:46:52 +11:00
/**
* @ deprecated since 2.5
*/
function category_delete_move ( $category , $newparentid , $showfeedback = true ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function category_delete_move() is removed. Please use coursecat::delete_move() instead.' );
2013-02-21 10:46:52 +11:00
}
/**
* @ deprecated since 2.5
*/
function category_delete_full ( $category , $showfeedback = true ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function category_delete_full() is removed. Please use coursecat::delete_full() instead.' );
2013-02-21 10:46:52 +11:00
}
2013-02-21 10:55:35 +11:00
/**
* This function is deprecated . Please use
* $coursecat = coursecat :: get ( $category -> id );
* if ( $coursecat -> can_change_parent ( $newparentcat -> id )) {
* $coursecat -> change_parent ( $newparentcat -> id );
* }
*
* Alternatively you can use
* $coursecat -> update ( array ( 'parent' => $newparentcat -> id ));
*
* @ see coursecat :: change_parent ()
* @ see coursecat :: update ()
* @ deprecated since 2.5
*/
function move_category ( $category , $newparentcat ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function move_category() is removed. Please use coursecat::change_parent() instead.' );
2013-02-21 10:55:35 +11:00
}
/**
* This function is deprecated . Please use
* coursecat :: get ( $category -> id ) -> hide ();
*
* @ see coursecat :: hide ()
* @ deprecated since 2.5
*/
function course_category_hide ( $category ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function course_category_hide() is removed. Please use coursecat::hide() instead.' );
2013-02-21 10:55:35 +11:00
}
/**
* This function is deprecated . Please use
* coursecat :: get ( $category -> id ) -> show ();
*
* @ see coursecat :: show ()
* @ deprecated since 2.5
*/
function course_category_show ( $category ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function course_category_show() is removed. Please use coursecat::show() instead.' );
2013-02-21 10:55:35 +11:00
}
2013-02-21 11:22:20 +11:00
/**
* This function is deprecated .
* To get the category with the specified it please use :
* coursecat :: get ( $catid , IGNORE_MISSING );
* or
* coursecat :: get ( $catid , MUST_EXIST );
*
* To get the first available category please use
* coursecat :: get_default ();
*
* @ deprecated since 2.5
*/
function get_course_category ( $catid = 0 ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_course_category() is removed. Please use coursecat::get(), see phpdocs for more details' );
2013-02-21 11:22:20 +11:00
}
2013-02-21 11:33:15 +11:00
/**
* This function is deprecated . It is replaced with the method create () in class coursecat .
* { @ link coursecat :: create ()} also verifies the data , fixes sortorder and logs the action
*
* @ deprecated since 2.5
*/
function create_course_category ( $category ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function create_course_category() is removed. Please use coursecat::create(), see phpdocs for more details' );
2013-02-21 11:33:15 +11:00
}
2013-02-22 10:45:07 +11:00
/**
* This function is deprecated .
*
* To get visible children categories of the given category use :
* coursecat :: get ( $categoryid ) -> get_children ();
* This function will return the array or coursecat objects , on each of them
* you can call get_children () again
*
* @ see coursecat :: get ()
* @ see coursecat :: get_children ()
*
* @ deprecated since 2.5
*/
function get_all_subcategories ( $catid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( ' Function get_all_subcategories () is removed . Please use appropriate methods () of coursecat
2015-05-11 12:46:36 +05:30
class . See phpdocs for more details ' );
2013-02-22 10:45:07 +11:00
}
2013-02-22 12:24:40 +11:00
/**
* This function is deprecated . Please use functions in class coursecat :
* - coursecat :: get ( $parentid ) -> has_children ()
* tells if the category has children ( visible or not to the current user )
*
* - coursecat :: get ( $parentid ) -> get_children ()
* returns an array of coursecat objects , each of them represents a children category visible
* to the current user ( i . e . visible = 1 or user has capability to view hidden categories )
*
* - coursecat :: get ( $parentid ) -> get_children_count ()
* returns number of children categories visible to the current user
*
* - coursecat :: count_all ()
* returns total count of all categories in the system ( both visible and not )
*
* - coursecat :: get_default ()
* returns the first category ( usually to be used if count_all () == 1 )
*
* @ deprecated since 2.5
*/
function get_child_categories ( $parentid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( ' Function get_child_categories () is removed . Use coursecat :: get_children () or see phpdocs for
2015-05-11 12:46:36 +05:30
more details . ' );
2013-02-22 12:24:40 +11:00
}
2013-02-20 20:51:21 +11:00
/**
*
* @ deprecated since 2.5
*
* This function is deprecated . Use appropriate functions from class coursecat .
* Examples :
*
* coursecat :: get ( $categoryid ) -> get_children ()
* - returns all children of the specified category as instances of class
2013-10-17 09:46:17 +11:00
* coursecat , which means on each of them method get_children () can be called again .
* Only categories visible to the current user are returned .
2013-02-20 20:51:21 +11:00
*
2013-10-17 09:46:17 +11:00
* coursecat :: get ( 0 ) -> get_children ()
* - returns all top - level categories visible to the current user .
2013-02-20 20:51:21 +11:00
*
* Sort fields can be specified , see phpdocs to { @ link coursecat :: get_children ()}
*
2013-10-17 09:46:17 +11:00
* coursecat :: make_categories_list ()
* - returns an array of all categories id / names in the system .
* Also only returns categories visible to current user and can additionally be
* filetered by capability , see phpdocs to { @ link coursecat :: make_categories_list ()}
*
* make_categories_options ()
* - Returns full course categories tree to be used in html_writer :: select ()
*
2013-02-20 20:51:21 +11:00
* Also see functions { @ link coursecat :: get_children_count ()}, { @ link coursecat :: count_all ()},
* { @ link coursecat :: get_default ()}
*/
function get_categories ( $parent = 'none' , $sort = NULL , $shallow = true ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_categories() is removed. Please use coursecat::get_children() or see phpdocs for other alternatives' );
2013-02-20 20:51:21 +11:00
}
2013-03-06 16:54:41 +11:00
/**
* This function is deprecated , please use course renderer :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> course_search_form ( $value , $format );
*
* @ deprecated since 2.5
*/
function print_course_search ( $value = " " , $return = false , $format = " plain " ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_course_search() is removed, please use course renderer' );
2013-03-06 16:54:41 +11:00
}
2013-03-26 16:20:22 +11:00
/**
* This function is deprecated , please use :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> frontpage_my_courses ()
*
* @ deprecated since 2.5
*/
function print_my_moodle () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_my_moodle() is removed, please use course renderer function frontpage_my_courses()' );
2013-03-26 16:20:22 +11:00
}
/**
* This function is deprecated , it is replaced with protected function
* { @ link core_course_renderer :: frontpage_remote_course ()}
* It is only used from function { @ link core_course_renderer :: frontpage_my_courses ()}
*
* @ deprecated since 2.5
*/
function print_remote_course ( $course , $width = " 100% " ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_remote_course() is removed, please use course renderer' );
2013-03-26 16:20:22 +11:00
}
/**
* This function is deprecated , it is replaced with protected function
* { @ link core_course_renderer :: frontpage_remote_host ()}
* It is only used from function { @ link core_course_renderer :: frontpage_my_courses ()}
*
* @ deprecated since 2.5
*/
function print_remote_host ( $host , $width = " 100% " ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_remote_host() is removed, please use course renderer' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*
* See http :// docs . moodle . org / dev / Courses_lists_upgrade_to_2 . 5
*/
function print_whole_category_list ( $category = NULL , $displaylist = NULL , $parentslist = NULL , $depth =- 1 , $showcourses = true , $categorycourses = NULL ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_whole_category_list() is removed, please use course renderer' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*/
function print_category_info ( $category , $depth = 0 , $showcourses = false , array $courses = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_category_info() is removed, please use course renderer' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*
* This function is not used any more in moodle core and course renderer does not have render function for it .
* Combo list on the front page is displayed as :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> frontpage_combo_list ()
*
* The new class { @ link coursecat } stores the information about course category tree
* To get children categories use :
* coursecat :: get ( $id ) -> get_children ()
* To get list of courses use :
* coursecat :: get ( $id ) -> get_courses ()
*
* See http :// docs . moodle . org / dev / Courses_lists_upgrade_to_2 . 5
*/
function get_course_category_tree ( $id = 0 , $depth = 0 ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( ' Function get_course_category_tree () is removed , please use course renderer or coursecat class ,
2015-05-11 12:46:36 +05:30
see function phpdocs for more info ' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*
* To print a generic list of courses use :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> courses_list ( $courses );
*
* To print list of all courses :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> frontpage_available_courses ();
*
* To print list of courses inside category :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> course_category ( $category ); // this will also print subcategories
*/
function print_courses ( $category ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_courses() is removed, please use course renderer' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*
* Please use course renderer to display a course information box .
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> courses_list ( $courses ); // will print list of courses
* echo $renderer -> course_info_box ( $course ); // will print one course wrapped in div.generalbox
*/
function print_course ( $course , $highlightterms = '' ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function print_course() is removed, please use course renderer' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*
* This function is not used any more in moodle core and course renderer does not have render function for it .
* Combo list on the front page is displayed as :
* $renderer = $PAGE -> get_renderer ( 'core' , 'course' );
* echo $renderer -> frontpage_combo_list ()
*
* The new class { @ link coursecat } stores the information about course category tree
* To get children categories use :
* coursecat :: get ( $id ) -> get_children ()
* To get list of courses use :
* coursecat :: get ( $id ) -> get_courses ()
*/
function get_category_courses_array ( $categoryid = 0 ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_category_courses_array() is removed, please use methods of coursecat class' );
2013-03-26 16:20:22 +11:00
}
/**
* @ deprecated since 2.5
*/
function get_category_courses_array_recursively ( array & $flattened , $category ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_category_courses_array_recursively() is removed, please use methods of coursecat class' , DEBUG_DEVELOPER );
2013-03-26 16:20:22 +11:00
}
2013-04-12 16:04:44 +08:00
/**
* @ deprecated since Moodle 2.5 MDL - 27814 - please do not use this function any more .
*/
function blog_get_context_url ( $context = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function blog_get_context_url() is removed, getting params from context is not reliable for blogs.' );
2013-04-12 16:04:44 +08:00
}
2013-03-26 16:20:22 +11:00
/**
* @ deprecated since 2.5
*
* To get list of all courses with course contacts ( 'managers' ) use
* coursecat :: get ( 0 ) -> get_courses ( array ( 'recursive' => true , 'coursecontacts' => true ));
*
* To get list of courses inside particular category use
* coursecat :: get ( $id ) -> get_courses ( array ( 'coursecontacts' => true ));
*
* Additionally you can specify sort order , offset and maximum number of courses ,
* see { @ link coursecat :: get_courses ()}
*/
function get_courses_wmanagers ( $categoryid = 0 , $sort = " c.sortorder ASC " , $fields = array ()) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function get_courses_wmanagers() is removed, please use coursecat::get_courses()' );
2013-03-26 16:20:22 +11:00
}
2013-04-11 19:06:52 +10:00
/**
* @ deprecated since 2.5
*/
function convert_tree_to_html ( $tree , $row = 0 ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function convert_tree_to_html() is removed. Consider using class tabtree and core_renderer::render_tabtree()' );
2013-04-11 19:06:52 +10:00
}
/**
* @ deprecated since 2.5
*/
function convert_tabrows_to_tree ( $tabrows , $selected , $inactive , $activated ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function convert_tabrows_to_tree() is removed. Consider using class tabtree' );
2013-04-11 19:06:52 +10:00
}
2013-06-11 10:35:10 +12:00
2013-05-31 14:38:51 +08:00
/**
* @ deprecated since 2.5 - do not use , the textrotate . js will work it out automatically
*/
function can_use_rotated_text () {
2015-06-29 13:03:50 +05:30
debugging ( 'can_use_rotated_text() is removed. JS feature detection is used automatically.' );
2013-05-31 14:38:51 +08:00
}
2013-07-01 11:54:21 +08:00
2013-07-01 14:43:48 +08:00
/**
* @ deprecated since Moodle 2.2 MDL - 35009 - please do not use this function any more .
* @ see context :: instance_by_id ( $id )
*/
function get_context_instance_by_id ( $id , $strictness = IGNORE_MISSING ) {
2014-12-10 13:12:46 +05:30
throw new coding_exception ( 'get_context_instance_by_id() is now removed, please use context::instance_by_id($id) instead.' );
2013-07-01 14:43:48 +08:00
}
2013-07-03 16:26:08 +08:00
2013-07-03 14:35:44 +08:00
/**
* Returns system context or null if can not be created yet .
*
* @ see context_system :: instance ()
2013-07-03 14:51:56 +08:00
* @ deprecated since 2.2
2013-07-03 14:35:44 +08:00
* @ param bool $cache use caching
* @ return context system context ( null if context table not created yet )
*/
function get_system_context ( $cache = true ) {
debugging ( 'get_system_context() is deprecated, please use context_system::instance() instead.' , DEBUG_DEVELOPER );
return context_system :: instance ( 0 , IGNORE_MISSING , $cache );
}
2013-07-04 11:07:12 +08:00
/**
* @ see context :: get_parent_context_ids ()
* @ deprecated since 2.2 , use $context -> get_parent_context_ids () instead
*/
function get_parent_contexts ( context $context , $includeself = false ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_parent_contexts() is removed, please use $context->get_parent_context_ids() instead.' );
2013-07-04 11:07:12 +08:00
}
2013-04-16 16:56:22 +08:00
/**
2013-07-04 12:59:06 +08:00
* @ deprecated since Moodle 2.2
* @ see context :: get_parent_context ()
2013-04-16 16:56:22 +08:00
*/
2013-07-04 12:59:06 +08:00
function get_parent_contextid ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_parent_contextid() is removed, please use $context->get_parent_context() instead.' );
2013-04-16 16:56:22 +08:00
}
2013-07-04 11:52:03 +08:00
/**
* @ see context :: get_child_contexts ()
* @ deprecated since 2.2
*/
function get_child_contexts ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_child_contexts() is removed, please use $context->get_child_contexts() instead.' );
2013-07-04 11:52:03 +08:00
}
2013-07-04 13:42:54 +08:00
/**
* @ see context_helper :: create_instances ()
* @ deprecated since 2.2
*/
function create_contexts ( $contextlevel = null , $buildpaths = true ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'create_contexts() is removed, please use context_helper::create_instances() instead.' );
2013-07-04 13:42:54 +08:00
}
2013-07-04 13:51:39 +08:00
/**
* @ see context_helper :: cleanup_instances ()
* @ deprecated since 2.2
*/
function cleanup_contexts () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'cleanup_contexts() is removed, please use context_helper::cleanup_instances() instead.' );
2013-07-04 13:51:39 +08:00
}
2013-07-04 13:55:27 +08:00
/**
* Populate context . path and context . depth where missing .
*
* @ deprecated since 2.2
*/
function build_context_path ( $force = false ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'build_context_path() is removed, please use context_helper::build_all_paths() instead.' );
2013-07-04 13:55:27 +08:00
}
2013-07-04 14:06:00 +08:00
/**
* @ deprecated since 2.2
*/
function rebuild_contexts ( array $fixcontexts ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'rebuild_contexts() is removed, please use $context->reset_paths(true) instead.' );
2013-07-04 14:06:00 +08:00
}
2013-07-05 08:56:00 +08:00
/**
* @ deprecated since Moodle 2.2
* @ see context_helper :: preload_course ()
*/
function preload_course_contexts ( $courseid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'preload_course_contexts() is removed, please use context_helper::preload_course() instead.' );
2013-07-05 08:56:00 +08:00
}
2013-07-05 11:27:23 +08:00
/**
* @ deprecated since Moodle 2.2
* @ see context :: update_moved ()
*/
function context_moved ( context $context , context $newparent ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'context_moved() is removed, please use context::update_moved() instead.' );
2013-07-05 11:19:46 +08:00
}
2013-07-05 15:38:05 +08:00
/**
* @ see context :: get_capabilities ()
* @ deprecated since 2.2
*/
function fetch_context_capabilities ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'fetch_context_capabilities() is removed, please use $context->get_capabilities() instead.' );
2013-07-05 15:38:05 +08:00
}
2013-07-05 11:19:46 +08:00
/**
* @ deprecated since 2.2
* @ see context_helper :: preload_from_record ()
*/
function context_instance_preload ( stdClass $rec ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'context_instance_preload() is removed, please use context_helper::preload_from_record() instead.' );
2013-07-05 11:19:46 +08:00
}
2013-07-05 10:07:02 +08:00
/**
* Returns context level name
*
* @ deprecated since 2.2
* @ see context_helper :: get_level_name ()
*/
function get_contextlevel_name ( $contextlevel ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_contextlevel_name() is removed, please use context_helper::get_level_name() instead.' );
2013-07-05 10:07:02 +08:00
}
2013-07-05 11:23:44 +08:00
/**
* @ deprecated since 2.2
* @ see context :: get_context_name ()
*/
function print_context_name ( context $context , $withprefix = true , $short = false ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'print_context_name() is removed, please use $context->get_context_name() instead.' );
2013-07-05 11:23:44 +08:00
}
2013-07-08 10:56:26 +08:00
/**
* @ deprecated since 2.2 , use $context -> mark_dirty () instead
* @ see context :: mark_dirty ()
*/
function mark_context_dirty ( $path ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'mark_context_dirty() is removed, please use $context->mark_dirty() instead.' );
2013-07-08 10:56:26 +08:00
}
2013-07-05 15:20:34 +08:00
/**
* @ deprecated since Moodle 2.2
* @ see context_helper :: delete_instance () or context :: delete_content ()
*/
function delete_context ( $contextlevel , $instanceid , $deleterecord = true ) {
if ( $deleterecord ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'delete_context() is removed, please use context_helper::delete_instance() instead.' );
2013-07-05 15:20:34 +08:00
} else {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'delete_context() is removed, please use $context->delete_content() instead.' );
2013-07-05 15:20:34 +08:00
}
}
2013-07-05 14:30:26 +08:00
/**
* @ deprecated since 2.2
* @ see context :: get_url ()
*/
function get_context_url ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_context_url() is removed, please use $context->get_url() instead.' );
2013-07-05 14:30:26 +08:00
}
2013-07-05 15:46:36 +08:00
/**
* @ deprecated since 2.2
* @ see context :: get_course_context ()
*/
function get_course_context ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_course_context() is removed, please use $context->get_course_context(true) instead.' );
2013-07-05 15:46:36 +08:00
}
2013-07-05 16:40:42 +08:00
/**
* @ deprecated since 2.2
* @ see enrol_get_users_courses ()
*/
function get_user_courses_bycap ( $userid , $cap , $accessdata_ignored , $doanything_ignored , $sort = 'c.sortorder ASC' , $fields = null , $limit_ignored = 0 ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_user_courses_bycap() is removed, please use enrol_get_users_courses() instead.' );
2013-07-05 16:40:42 +08:00
}
2013-07-11 15:04:33 +08:00
/**
* @ deprecated since Moodle 2.2
*/
function get_role_context_caps ( $roleid , context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_role_context_caps() is removed, it is really slow. Don\'t use it.' );
2013-07-11 15:04:33 +08:00
}
2013-07-05 15:06:50 +08:00
/**
* @ see context :: get_course_context ()
* @ deprecated since 2.2
*/
function get_courseid_from_context ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_courseid_from_context() is removed, please use $context->get_course_context(false) instead.' );
2013-07-17 01:43:11 +02:00
}
2013-07-05 13:02:00 +08:00
/**
* If you are using this methid , you should have something like this :
*
* list ( $ctxselect , $ctxjoin ) = context_instance_preload_sql ( 'c.id' , CONTEXT_COURSE , 'ctx' );
*
* To prevent the use of this deprecated function , replace the line above with something similar to this :
*
* $ctxselect = ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' );
* ^
* $ctxjoin = " LEFT JOIN { context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel) " ;
* ^ ^ ^ ^
* $params = array ( 'contextlevel' => CONTEXT_COURSE );
* ^
* @ see context_helper : ; get_preload_record_columns_sql ()
* @ deprecated since 2.2
*/
function context_instance_preload_sql ( $joinon , $contextlevel , $tablealias ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'context_instance_preload_sql() is removed, please use context_helper::get_preload_record_columns_sql() instead.' );
2013-07-05 15:06:50 +08:00
}
2013-07-08 18:30:30 +08:00
/**
* @ deprecated since 2.2
* @ see context :: get_parent_context_ids ()
*/
function get_related_contexts_string ( context $context ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_related_contexts_string() is removed, please use $context->get_parent_context_ids(true) instead.' );
2013-07-08 18:30:30 +08:00
}
2013-08-05 09:17:37 +12:00
2013-08-09 11:31:40 +08:00
/**
* @ deprecated since 2.6
* @ see core_component :: get_plugin_list_with_file ()
*/
function get_plugin_list_with_file ( $plugintype , $file , $include = false ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_plugin_list_with_file() is removed, please use core_component::get_plugin_list_with_file() instead.' );
2013-08-09 11:31:40 +08:00
}
2013-07-30 17:00:54 +12:00
/**
* @ deprecated since 2.6
*/
function check_browser_operating_system ( $brand ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'check_browser_operating_system is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function check_browser_version ( $brand , $version = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'check_browser_version is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function get_device_type () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_device_type is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function get_device_type_list ( $incusertypes = true ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_device_type_list is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function get_selected_theme_for_device_type ( $devicetype = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_selected_theme_for_device_type is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function get_device_cfg_var_name ( $devicetype = null ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_device_cfg_var_name is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function set_user_device_type ( $newdevice ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'set_user_device_type is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function get_user_device_type () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_user_device_type is removed, please update your code to use core_useragent instead.' );
2013-07-30 17:00:54 +12:00
}
/**
* @ deprecated since 2.6
*/
function get_browser_version_classes () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'get_browser_version_classes is removed, please update your code to use core_useragent instead.' );
2013-08-30 15:21:37 +08:00
}
/**
* @ deprecated since Moodle 2.6
* @ see core_user :: get_support_user ()
*/
function generate_email_supportuser () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'generate_email_supportuser is removed, please use core_user::get_support_user' );
2013-09-09 22:28:59 +12:00
}
/**
* @ deprecated since Moodle 2.6
*/
function badges_get_issued_badge_info ( $hash ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function badges_get_issued_badge_info() is removed. Please use core_badges_assertion class and methods to generate badge assertion.' );
2013-09-09 22:28:59 +12:00
}
2013-08-13 11:09:46 +08:00
/**
* @ deprecated since 2.6
*/
function can_use_html_editor () {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'can_use_html_editor is removed, please update your code to assume it returns true.' );
2013-08-13 11:09:46 +08:00
}
2014-02-21 16:25:09 +08:00
/**
2014-12-08 16:06:00 +08:00
* @ deprecated since Moodle 2.7 , use { @ link user_count_login_failures ()} instead .
2014-02-21 16:25:09 +08:00
*/
function count_login_failures ( $mode , $username , $lastlogin ) {
2014-12-08 16:06:00 +08:00
throw new coding_exception ( 'count_login_failures() can not be used any more, please use user_count_login_failures().' );
2014-02-21 16:25:09 +08:00
}
2014-04-02 09:54:13 +13:00
2014-03-25 11:27:27 +08:00
/**
2014-12-08 09:12:03 +08:00
* @ deprecated since 2.7 MDL - 33099 / MDL - 44088 - please do not use this function any more .
2014-03-25 11:27:27 +08:00
*/
function ajaxenabled ( array $browsers = null ) {
2014-12-08 09:12:03 +08:00
throw new coding_exception ( 'ajaxenabled() can not be used anymore. Update your code to work with JS at all times.' );
2014-03-25 11:27:27 +08:00
}
2014-03-26 12:01:52 +00:00
/**
2014-12-10 10:23:31 +05:30
* @ deprecated Since Moodle 2.7 MDL - 44070
2014-03-26 12:01:52 +00:00
*/
function coursemodule_visible_for_user ( $cm , $userid = 0 ) {
2014-12-10 10:23:31 +05:30
throw new coding_exception ( ' coursemodule_visible_for_user () can not be used any more ,
please use \core_availability\info_module :: is_user_visible () ' );
2014-03-26 12:01:52 +00:00
}
2014-07-29 17:44:25 +08:00
/**
2014-09-15 10:50:53 +08:00
* @ deprecated since Moodle 2.8 MDL - 36014 , MDL - 35618 this functionality is removed
2014-07-29 17:44:25 +08:00
*/
function enrol_cohort_get_cohorts ( course_enrolment_manager $manager ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function enrol_cohort_get_cohorts() is removed, use enrol_cohort_search_cohorts() or ' .
2015-05-11 12:46:36 +05:30
'cohort_get_available_cohorts() instead' );
2014-07-29 17:44:25 +08:00
}
/**
* This function is deprecated , use { @ link cohort_can_view_cohort ()} instead since it also
* takes into account current context
*
* @ deprecated since Moodle 2.8 MDL - 36014 please use cohort_can_view_cohort ()
*/
function enrol_cohort_can_view_cohort ( $cohortid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'Function enrol_cohort_can_view_cohort() is removed, use cohort_can_view_cohort() instead' );
2014-07-29 17:44:25 +08:00
}
/**
* It is advisable to use { @ link cohort_get_available_cohorts ()} instead .
*
* @ deprecated since Moodle 2.8 MDL - 36014 use cohort_get_available_cohorts () instead
*/
function cohort_get_visible_list ( $course , $onlyenrolled = true ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( ' Function cohort_get_visible_list () is removed . Please use function cohort_get_available_cohorts () " .
2015-05-11 12:46:36 +05:30
" that correctly checks capabilities.');
2014-07-29 17:44:25 +08:00
}
2014-09-15 10:50:53 +08:00
/**
* @ deprecated since Moodle 2.8 MDL - 35618 this functionality is removed
*/
function enrol_cohort_enrol_all_users ( course_enrolment_manager $manager , $cohortid , $roleid ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'enrol_cohort_enrol_all_users() is removed. This functionality is moved to enrol_manual.' );
2014-09-15 10:50:53 +08:00
}
/**
* @ deprecated since Moodle 2.8 MDL - 35618 this functionality is removed
*/
function enrol_cohort_search_cohorts ( course_enrolment_manager $manager , $offset = 0 , $limit = 25 , $search = '' ) {
2015-06-29 13:03:50 +05:30
throw new coding_exception ( 'enrol_cohort_search_cohorts() is removed. This functionality is moved to enrol_manual.' );
2014-09-15 10:50:53 +08:00
}
2015-03-03 11:46:29 +08:00
2015-05-11 14:40:32 +05:30
/* === Apis deprecated in since Moodle 2.9 === */
2015-03-03 11:46:29 +08:00
/**
* Is $USER one of the supplied users ?
*
* $user2 will be null if viewing a user ' s recent conversations
*
* @ deprecated since Moodle 2.9 MDL - 49371 - please do not use this function any more .
* @ todo MDL - 49290 This will be deleted in Moodle 3.1 .
* @ param stdClass the first user
* @ param stdClass the second user or null
* @ return bool True if the current user is one of either $user1 or $user2
*/
function message_current_user_is_involved ( $user1 , $user2 ) {
global $USER ;
debugging ( 'message_current_user_is_involved() is deprecated, please do not use this function.' , DEBUG_DEVELOPER );
if ( empty ( $user1 -> id ) || ( ! empty ( $user2 ) && empty ( $user2 -> id ))) {
throw new coding_exception ( 'Invalid user object detected. Missing id.' );
}
if ( $user1 -> id != $USER -> id && ( empty ( $user2 ) || $user2 -> id != $USER -> id )) {
return false ;
}
return true ;
}
2015-04-07 10:07:20 +08:00
/**
* Print badges on user profile page .
*
* @ deprecated since Moodle 2.9 MDL - 45898 - please do not use this function any more .
* @ param int $userid User ID .
* @ param int $courseid Course if we need to filter badges ( optional ) .
*/
function profile_display_badges ( $userid , $courseid = 0 ) {
global $CFG , $PAGE , $USER , $SITE ;
require_once ( $CFG -> dirroot . '/badges/renderer.php' );
debugging ( 'profile_display_badges() is deprecated.' , DEBUG_DEVELOPER );
// Determine context.
if ( isloggedin ()) {
$context = context_user :: instance ( $USER -> id );
} else {
$context = context_system :: instance ();
}
if ( $USER -> id == $userid || has_capability ( 'moodle/badges:viewotherbadges' , $context )) {
$records = badges_get_user_badges ( $userid , $courseid , null , null , null , true );
$renderer = new core_badges_renderer ( $PAGE , '' );
// Print local badges.
if ( $records ) {
$left = get_string ( 'localbadgesp' , 'badges' , format_string ( $SITE -> fullname ));
$right = $renderer -> print_badges_list ( $records , $userid , true );
echo html_writer :: tag ( 'dt' , $left );
echo html_writer :: tag ( 'dd' , $right );
}
// Print external badges.
if ( $courseid == 0 && ! empty ( $CFG -> badges_allowexternalbackpack )) {
$backpack = get_backpack_settings ( $userid );
if ( isset ( $backpack -> totalbadges ) && $backpack -> totalbadges !== 0 ) {
$left = get_string ( 'externalbadgesp' , 'badges' );
$right = $renderer -> print_badges_list ( $backpack -> badges , $userid , true , true );
echo html_writer :: tag ( 'dt' , $left );
echo html_writer :: tag ( 'dd' , $right );
}
}
}
}
2015-04-08 13:22:49 +08:00
/**
* Adds user preferences elements to user edit form .
*
* @ deprecated since Moodle 2.9 MDL - 45774 - Please do not use this function any more .
* @ todo MDL - 49784 Remove this function in Moodle 3.1
* @ param stdClass $user
* @ param moodleform $mform
* @ param array | null $editoroptions
* @ param array | null $filemanageroptions
*/
function useredit_shared_definition_preferences ( $user , & $mform , $editoroptions = null , $filemanageroptions = null ) {
global $CFG ;
debugging ( 'useredit_shared_definition_preferences() is deprecated.' , DEBUG_DEVELOPER , backtrace );
$choices = array ();
$choices [ '0' ] = get_string ( 'emaildisplayno' );
$choices [ '1' ] = get_string ( 'emaildisplayyes' );
$choices [ '2' ] = get_string ( 'emaildisplaycourse' );
$mform -> addElement ( 'select' , 'maildisplay' , get_string ( 'emaildisplay' ), $choices );
$mform -> setDefault ( 'maildisplay' , $CFG -> defaultpreference_maildisplay );
$choices = array ();
$choices [ '0' ] = get_string ( 'textformat' );
$choices [ '1' ] = get_string ( 'htmlformat' );
$mform -> addElement ( 'select' , 'mailformat' , get_string ( 'emailformat' ), $choices );
$mform -> setDefault ( 'mailformat' , $CFG -> defaultpreference_mailformat );
if ( ! empty ( $CFG -> allowusermailcharset )) {
$choices = array ();
$charsets = get_list_of_charsets ();
if ( ! empty ( $CFG -> sitemailcharset )) {
$choices [ '0' ] = get_string ( 'site' ) . ' (' . $CFG -> sitemailcharset . ')' ;
} else {
$choices [ '0' ] = get_string ( 'site' ) . ' (UTF-8)' ;
}
$choices = array_merge ( $choices , $charsets );
$mform -> addElement ( 'select' , 'preference_mailcharset' , get_string ( 'emailcharset' ), $choices );
}
$choices = array ();
$choices [ '0' ] = get_string ( 'emaildigestoff' );
$choices [ '1' ] = get_string ( 'emaildigestcomplete' );
$choices [ '2' ] = get_string ( 'emaildigestsubjects' );
$mform -> addElement ( 'select' , 'maildigest' , get_string ( 'emaildigest' ), $choices );
$mform -> setDefault ( 'maildigest' , $CFG -> defaultpreference_maildigest );
$mform -> addHelpButton ( 'maildigest' , 'emaildigest' );
$choices = array ();
$choices [ '1' ] = get_string ( 'autosubscribeyes' );
$choices [ '0' ] = get_string ( 'autosubscribeno' );
$mform -> addElement ( 'select' , 'autosubscribe' , get_string ( 'autosubscribe' ), $choices );
$mform -> setDefault ( 'autosubscribe' , $CFG -> defaultpreference_autosubscribe );
if ( ! empty ( $CFG -> forum_trackreadposts )) {
$choices = array ();
$choices [ '0' ] = get_string ( 'trackforumsno' );
$choices [ '1' ] = get_string ( 'trackforumsyes' );
$mform -> addElement ( 'select' , 'trackforums' , get_string ( 'trackforums' ), $choices );
$mform -> setDefault ( 'trackforums' , $CFG -> defaultpreference_trackforums );
}
$editors = editors_get_enabled ();
if ( count ( $editors ) > 1 ) {
$choices = array ( '' => get_string ( 'defaulteditor' ));
$firsteditor = '' ;
foreach ( array_keys ( $editors ) as $editor ) {
if ( ! $firsteditor ) {
$firsteditor = $editor ;
}
$choices [ $editor ] = get_string ( 'pluginname' , 'editor_' . $editor );
}
$mform -> addElement ( 'select' , 'preference_htmleditor' , get_string ( 'textediting' ), $choices );
$mform -> setDefault ( 'preference_htmleditor' , '' );
} else {
// Empty string means use the first chosen text editor.
$mform -> addElement ( 'hidden' , 'preference_htmleditor' );
$mform -> setDefault ( 'preference_htmleditor' , '' );
$mform -> setType ( 'preference_htmleditor' , PARAM_PLUGIN );
}
$mform -> addElement ( 'select' , 'lang' , get_string ( 'preferredlanguage' ), get_string_manager () -> get_list_of_translations ());
$mform -> setDefault ( 'lang' , $CFG -> lang );
}
2015-05-11 14:40:32 +05:30
/**
* Convert region timezone to php supported timezone
*
* @ deprecated since Moodle 2.9
* @ param string $tz value from ical file
* @ return string $tz php supported timezone
*/
function calendar_normalize_tz ( $tz ) {
debugging ( 'calendar_normalize_tz() is deprecated, use core_date::normalise_timezone() instead' , DEBUG_DEVELOPER );
return core_date :: normalise_timezone ( $tz );
}
/**
* Returns a float which represents the user ' s timezone difference from GMT in hours
* Checks various settings and picks the most dominant of those which have a value
* @ deprecated since Moodle 2.9
* @ param float | int | string $tz timezone user timezone
* @ return float
*/
function get_user_timezone_offset ( $tz = 99 ) {
debugging ( 'get_user_timezone_offset() is deprecated, use PHP DateTimeZone instead' , DEBUG_DEVELOPER );
$tz = core_date :: get_user_timezone ( $tz );
$date = new DateTime ( 'now' , new DateTimeZone ( $tz ));
return ( $date -> getOffset () - dst_offset_on ( time (), $tz )) / ( 3600.0 );
}
/**
* Returns an int which represents the systems ' s timezone difference from GMT in seconds
* @ deprecated since Moodle 2.9
* @ param float | int | string $tz timezone for which offset is required .
* { @ link http :// docs . moodle . org / dev / Time_API #Timezone}
* @ return int | bool if found , false is timezone 99 or error
*/
function get_timezone_offset ( $tz ) {
debugging ( 'get_timezone_offset() is deprecated, use PHP DateTimeZone instead' , DEBUG_DEVELOPER );
$date = new DateTime ( 'now' , new DateTimeZone ( core_date :: normalise_timezone ( $tz )));
return $date -> getOffset () - dst_offset_on ( time (), $tz );
}
/**
* Returns a list of timezones in the current language .
* @ deprecated since Moodle 2.9
* @ return array
*/
function get_list_of_timezones () {
debugging ( 'get_list_of_timezones() is deprecated, use core_date::get_list_of_timezones() instead' , DEBUG_DEVELOPER );
return core_date :: get_list_of_timezones ();
}
/**
* Previous internal API , it was not supposed to be used anywhere .
* @ deprecated since Moodle 2.9
* @ param array $timezones
*/
function update_timezone_records ( $timezones ) {
debugging ( 'update_timezone_records() is not available any more, use standard PHP date/time code' , DEBUG_DEVELOPER );
}
/**
* Previous internal API , it was not supposed to be used anywhere .
* @ deprecated since Moodle 2.9
* @ param int $fromyear
* @ param int $toyear
* @ param mixed $strtimezone
* @ return bool
*/
function calculate_user_dst_table ( $fromyear = null , $toyear = null , $strtimezone = null ) {
debugging ( 'calculate_user_dst_table() is not available any more, use standard PHP date/time code' , DEBUG_DEVELOPER );
return false ;
}
/**
* Previous internal API , it was not supposed to be used anywhere .
* @ deprecated since Moodle 2.9
* @ param int | string $year
* @ param mixed $timezone
* @ return null
*/
function dst_changes_for_year ( $year , $timezone ) {
debugging ( 'dst_changes_for_year() is not available any more, use standard PHP date/time code' , DEBUG_DEVELOPER );
return null ;
}
/**
* Previous internal API , it was not supposed to be used anywhere .
* @ deprecated since Moodle 2.9
* @ param string $timezonename
* @ return array
*/
function get_timezone_record ( $timezonename ) {
debugging ( 'get_timezone_record() is not available any more, use standard PHP date/time code' , DEBUG_DEVELOPER );
return array ();
}
2015-06-29 13:03:50 +05:30
/* === Apis deprecated since Moodle 3.0 === */
2015-07-27 10:33:39 +08:00
/**
* Returns the URL of the HTTP_REFERER , less the querystring portion if required .
*
* @ deprecated since Moodle 3.0 MDL - 49360 - please do not use this function any more .
* @ todo Remove this function in Moodle 3.2
* @ param boolean $stripquery if true , also removes the query part of the url .
* @ return string The resulting referer or empty string .
*/
function get_referer ( $stripquery = true ) {
debugging ( 'get_referer() is deprecated. Please use get_local_referer() instead.' , DEBUG_DEVELOPER );
if ( isset ( $_SERVER [ 'HTTP_REFERER' ])) {
if ( $stripquery ) {
return strip_querystring ( $_SERVER [ 'HTTP_REFERER' ]);
} else {
return $_SERVER [ 'HTTP_REFERER' ];
}
} else {
return '' ;
}
}