Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
|
Classes | |
class | emoticon_manager |
Provides core support for plugins that have to deal with emoticons (like HTML editor or emoticon filter). More... | |
class | lang_string |
The lang_string class. More... | |
Functions | |
address_in_subnet ($addr, $subnetstr, $checkallzeros=false) | |
Function to check the passed address is within the passed subnet. | |
ajax_capture_output () | |
Starts capturing output whilst processing an AJAX request. | |
ajax_check_captured_output () | |
Check captured output for content. | |
array_is_nested ($array) | |
Check if there is a nested array within the passed array. | |
authenticate_user_login ( $username, $password, $ignorelockout=false, &$failurereason=null, $logintoken=false, string|bool $loginrecaptcha=false,) | |
Authenticates a user against the chosen authentication mechanism. | |
bounded_number ($min, $value, $max) | |
Used to make sure that $min <= $value <= $max. | |
calculate_entropy (#[\SensitiveParameter] string $pepper) | |
Calculate the Shannon entropy of a string. | |
can_send_from_real_email_address ($from, $user, $unused=null) | |
Check to see if a user's real email address should be used for the "From" field. | |
check_consecutive_identical_characters ($password, $maxchars) | |
Check whether the given password has no more than the specified number of consecutive identical characters. | |
check_password_policy ($password, &$errmsg, $user=null) | |
Validate a password against the configured password policy. | |
check_php_version ($version='5.2.4') | |
Returns true if the current version of PHP is greater that the specified one. | |
check_user_preferences_loaded (stdClass $user, $cachelifetime=120) | |
Refresh user preference cache. | |
clean_filename ($string) | |
Cleans a given filename by removing suspicious or troublesome characters. | |
clean_param ($param, $type) | |
Used by optional_param() and required_param() to clean the variables and/or cast to specific types, based on an options field. | |
clean_param_array (?array $param, $type, $recursive=false) | |
Makes sure array contains only the allowed types, this function does not validate array key names! | |
cleanremoteaddr ($addr, $compress=false) | |
Cleans an ip address. | |
cleardoubleslashes ($path) | |
Replace 1 or more slashes or backslashes to 1 slash. | |
complete_user_login ($user, array $extrauserinfo=[]) | |
Call to complete the user login process after authenticate_user_login() has succeeded. | |
complex_random_string ($length=null) | |
Generate a complex random string (useful for md5 salts) | |
component_callback ($component, $function, array $params=array(), $default=null, bool $migratedtohook=false) | |
Invoke component's callback functions. | |
component_callback_exists ($component, $function) | |
Determine if a component callback exists and return the function name to call. | |
component_class_callback ($classname, $methodname, array $params, $default=null) | |
Call the specified callback method on the provided class. | |
convert_to_array ($var) | |
Converts an object into an associative array. | |
count_letters ($string, $format=null) | |
Count letters in a string. | |
count_words ($string, $format=null) | |
Count words in a string. | |
create_user_key ($script, $userid, $instance=null, $iprestriction=null, $validuntil=null) | |
Creates a new private user access key. | |
create_user_record ($username, $password, $auth='manual') | |
Creates a bare-bones user record. | |
current_language () | |
Returns the code for the current language. | |
custom_script_path () | |
Detect a custom script replacement in the data directory that will replace an existing moodle script. | |
date_format_string ($date, $format, $tz=99) | |
Returns a formatted date ensuring it is UTF-8. | |
dayofweek ($day, $month, $year) | |
Calculate the position in the week of a specific calendar day. | |
days_in_month ($month, $year) | |
Calculate the number of days in a given month. | |
delete_course ($courseorid, $showfeedback=true) | |
Delete a course, including all related data from the database, and any associated files. | |
delete_user (stdClass $user) | |
Marks user deleted in internal user database and notifies the auth plugin. | |
delete_user_key ($script, $userid) | |
Delete the user's new private user access keys for a particular script. | |
display_size ($size, int $decimalplaces=1, string $fixedunits='') | |
Converts bytes into display form. | |
draw_rand_array ($array, $draws) | |
Given an arbitrary array, and a number of draws, this function returns an array with that amount of items. | |
dst_offset_on ($time, $strtimezone=null) | |
Calculates the Daylight Saving Offset for a given date/time (timestamp) | |
email_is_not_allowed ($email) | |
Check that an email is allowed. | |
email_should_be_diverted ($email) | |
A helper function to test for email diversion. | |
email_to_user ($user, $from, $subject, $messagetext, $messagehtml='', $attachment='', $attachname='', $usetrueaddress=true, $replyto='', $replytoname='', $wordwrapwidth=79) | |
Send an email to a specified user. | |
endecrypt ($pwd, $data, $case) | |
Based on a class by Mukul Sabharwal [mukulsabharwal @ yahoo.com]. | |
exceeds_password_length (string $password, int $pepperlength=0) | |
Validates user's password length. | |
exists_auth_plugin ($auth) | |
Returns whether a given authentication plugin exists. | |
find_day_in_month ($startday, $weekday, $month, $year) | |
Calculates when the day appears in specific month. | |
fix_current_language (string $lang) | |
Fix the current language to the given language code. | |
fix_utf8 ($value) | |
Makes sure the data is using valid utf8, invalid characters are discarded. | |
force_current_language ($language) | |
Force the current language to get strings and dates localised in the given language. | |
format_float ($float, $decimalpoints=1, $localized=true, $stripzeros=false) | |
Given a float, prints it nicely. | |
format_time ($totalsecs, $str=null) | |
Format a date/time (seconds) as weeks, days, hours etc as needed. | |
fullclone ($thing) | |
This function will make a complete copy of anything it's given, regardless of whether it's an object or not. | |
fullname ($user, $override=false) | |
Returns a persons full name. | |
gc_cache_flags () | |
Garbage-collect volatile flags. | |
generate_email_messageid ($localpart=null) | |
Generate a unique email Message-ID using the moodle domain and install path. | |
generate_email_processing_address ($modid, $modargs) | |
Generate an email processing address. | |
generate_email_signoff () | |
Generate a signoff for emails based on support settings. | |
generate_password ($maxlen=10) | |
Returns a randomly generated password of length $maxlen. | |
get_auth_plugin ($auth) | |
Returns an authentication plugin instance. | |
get_cache_flag ($type, $name, $changedsince=null) | |
Get volatile flags. | |
get_cache_flags ($type, $changedsince=null) | |
Get volatile flags. | |
get_callable_name ($callable) | |
Get human readable name describing the given callable. | |
get_complete_user_data ($field, $value, $mnethostid=null, $throwexception=false) | |
Get a complete user record, which includes all the info in the user record. | |
get_config ($plugin, $name=null) | |
Get configuration values from the global config table or the config_plugins table. | |
get_course_display_name_for_list ($course) | |
Gets the name of a course to be displayed when showing a list of courses. | |
get_default_home_page () | |
Returns the default home page to display if current one is not defined or can't be applied. | |
get_directory_list ($rootdir, $excludefiles='', $descend=true, $getdirs=false, $getfiles=true) | |
Returns an array with all the filenames in all subdirectories, relative to the given rootdir. | |
get_directory_size ($rootdir, $excludefile='') | |
Adds up all the files in a directory and works out the size. | |
get_emoticon_manager () | |
Factory function for emoticon_manager. | |
get_enabled_auth_plugins ($fix=false) | |
Returns array of active auth plugins. | |
get_file_browser () | |
Returns local file storage instance. | |
get_file_packer ($mimetype='application/zip') | |
Returns file packer. | |
get_file_storage ($reset=false) | |
Returns local file storage instance. | |
get_home_page () | |
Gets the homepage to use for the current user. | |
get_host_from_url ($url) | |
Returns host part from url. | |
get_list_of_charsets () | |
Returns a list of charset codes. | |
get_list_of_plugins ($directory='mod', $exclude='', $basedir='') | |
Lists plugin-like directories within specified directory. | |
get_list_of_themes () | |
Returns a list of valid and compatible themes. | |
get_login_url () | |
Returns full login url. | |
get_mailer ($action='get') | |
Get mailer instance, enable buffering, flush buffer or disable buffering. | |
get_max_upload_file_size ($sitebytes=0, $coursebytes=0, $modulebytes=0, $unused=false) | |
Returns the maximum size for uploading files. | |
get_max_upload_sizes ($sitebytes=0, $coursebytes=0, $modulebytes=0, $custombytes=null) | |
Returns an array of possible sizes in local language. | |
get_mnet_environment () | |
helper function to load up and initialise the mnet environment this must be called before you use mnet functions. | |
get_mnet_remote_client () | |
during xmlrpc server code execution, any code wishing to access information about the remote peer must use this to get it. | |
get_newuser_language () | |
Returns the string of the language for the new user. | |
get_parent_language ($lang=null) | |
Returns parent language of current active language if defined. | |
get_password_peppers () | |
Get the available password peppers. | |
get_performance_info () | |
get_performance_info() pairs up with init_performance_info() loaded in setup.php. | |
get_plugin_list_with_function ($plugintype, $function, $file='lib.php') | |
Get a list of all the plugins of a given type that define a certain API function in a certain file. | |
get_plugins_with_function ($function, $file='lib.php', $include=true, bool $migratedtohook=false) | |
Get a list of all the plugins that define a certain API function in a certain file. | |
get_site_identifier () | |
Returns the site identifier. | |
get_string ($identifier, $component='', $a=null, $lazyload=false) | |
Returns a localized string. | |
get_string_manager ($forcereload=false) | |
Returns current string_manager instance. | |
get_strings ($array, $component='') | |
Converts an array of strings to their localized value. | |
get_time_interval_string (int $time1, int $time2, string $format='', bool $dropzeroes=false, bool $fullformat=false) | |
Get a formatted string representation of an interval between two unix timestamps. | |
get_user_fieldnames () | |
Returns an array of user fields. | |
get_user_key ($script, $userid, $instance=null, $iprestriction=null, $validuntil=null) | |
Gets a private user access key (and creates one if one doesn't exist). | |
get_user_max_upload_file_size ($context, $sitebytes=0, $coursebytes=0, $modulebytes=0, $user=null, $unused=false) | |
Returns the maximum size for uploading files for the current user. | |
get_user_preferences ($name=null, $default=null, $user=null) | |
Used to fetch user preference(s) | |
get_user_timezone ($tz=99) | |
Returns a float or a string which denotes the user's timezone A float value means that a simple offset from GMT is used, while a string (it will be the name of a timezone in the database) means that for this timezone there are also DST rules to be taken into account Checks various settings and picks the most dominant of those which have a value. | |
get_users_from_config ($value, $capability, $includeadmins=true) | |
Use this function to get a list of users from a config setting of type admin_setting_users_with_capability. | |
getremoteaddr ($default='0.0.0.0') | |
Returns most reliable client address. | |
getweek ($startdate, $thedate) | |
Given dates in seconds, how many weeks is the date from startdate The first week is 1, the second 2 etc ... | |
guest_user () | |
Retrieve the guest user object. | |
hash_internal_user_password (#[\SensitiveParameter] string $password, $fasthash=false, $pepperlength=0) | |
Calculate hash for a plain text password. | |
html_is_blank ($string) | |
Tests whether anything was returned by text editor. | |
in_object_vars ($var, $object) | |
Checks whether the given variable name is defined as a variable within the given object. | |
ip_is_public ($ip) | |
Is IP address a public address? | |
is_enabled_auth ($auth) | |
Checks if a given plugin is in the list of enabled authentication plugins. | |
is_internal_auth ($auth) | |
Returns true if an internal authentication method is being used. | |
is_mnet_remote_user ($user) | |
Returns whether or not the user object is a remote MNET user. | |
is_newnav ($navigation) | |
Check if the passed navigation is of the new style. | |
is_number ($value) | |
Return true if given value is integer or string with integer value. | |
is_primary_admin ($userid) | |
Is a userid the primary administrator? | |
is_proxybypass ( $url) | |
Check if $url matches anything in proxybypass list. | |
is_restored_user ($username) | |
Returns true if the user is a 'restored' one. | |
is_rtl_compatible ($paramtype) | |
Whether the PARAM_* type is compatible in RTL. | |
is_valid_plugin_name ($name) | |
This method validates a plug name. | |
ismoving ($courseid) | |
Determines if the logged in user is currently moving an activity. | |
make_grades_menu ($gradingtype) | |
Creates an array that represents all the current grades that can be chosen using the given grading type. | |
make_menu_from_list ($list, $separator=',') | |
Given a list (eg a,b,c,d,e) this function returns an array of 1->a, 2->b, 3->c etc. | |
make_timestamp ($year, $month=1, $day=1, $hour=0, $minute=0, $second=0, $timezone=99, $applydst=true) | |
Given Gregorian date parts in user time produce a GMT timestamp. | |
make_unique_id_code ($extra='') | |
make_unique_id_code | |
microtime_diff ($a, $b) | |
Calculate the difference between two microtimes. | |
mnet_get_idp_jump_url ($user) | |
return the jump url for a given remote user this is used for rewriting forum post links in emails, etc | |
moodle_getlocale () | |
Gets the system locale. | |
moodle_major_version ($fromdisk=false) | |
Returns the major version of this site. | |
moodle_needs_upgrading ($checkupgradeflag=true) | |
Determine if moodle installation requires update. | |
moodle_process_email ($modargs, $body) | |
? | |
moodle_setlocale ($locale='') | |
Sets the system locale. | |
mtrace ($string, $eol="\n", $sleep=0) | |
For outputting debugging info. | |
mtrace_exception (Throwable $e) | |
Helper to {. | |
object_array_unique ($array, $keepkeyassoc=true) | |
Returns an array without repeated objects. | |
object_property_exists ( $obj, $property) | |
Detect if an object or a class contains a given property will take an actual object or the name of a class. | |
optional_param ($parname, $default, $type) | |
Returns a particular value for the named variable, taken from POST or GET, otherwise returning a given default. | |
optional_param_array ($parname, $default, $type) | |
Returns a particular array value for the named variable, taken from POST or GET, otherwise returning a given default. | |
order_in_string ($values, $stringformat) | |
Returns an array of values in order of occurance in a provided string. | |
over_bounce_threshold ($user) | |
Check whether the user has exceeded the bounce threshold. | |
partial () | |
Helper function to do partial function binding. | |
password_is_legacy_hash (#[\SensitiveParameter] string $password) | |
Check a password hash to see if it was hashed using the legacy hash algorithm (bcrypt). | |
plugin_callback ($type, $name, $feature, $action, $params=null, $default=null, bool $migratedtohook=false) | |
Invoke plugin's callback functions. | |
plugin_supports ($type, $name, $feature, $default=null) | |
Checks whether a plugin supports a specified feature. | |
print_string ($identifier, $component='', $a=null) | |
Prints out a translated string. | |
purge_all_caches () | |
Invalidates browser caches and cached data in temp. | |
purge_caches ($options=[]) | |
Selectively invalidate different types of cache. | |
purge_other_caches () | |
Purge all non-MUC caches not otherwise purged in purge_caches. | |
random_string ($length=15) | |
Generate and return a random string of the specified length. | |
rc4decrypt ($data) | |
rc4decrypt | |
rc4encrypt ($data) | |
rc4encrypt | |
remoteip_in_list ($list) | |
Is the current ip in a given list? | |
remove_course_contents ($courseid, $showfeedback=true, array $options=null) | |
Clear a course out completely, deleting all content but don't delete the course itself. | |
remove_dir ($dir, $contentonly=false) | |
Delete directory or only its content. | |
rename_to_unused_name (string $filepath, string $prefix='_temp_') | |
Renames a file or directory to a unique name within the same directory. | |
require_admin () | |
A convenience function for where we must be logged in as admin. | |
require_course_login ($courseorid, $autologinguest=true, $cm=null, $setwantsurltome=true, $preventredirect=false) | |
Weaker version of require_login() | |
require_login ($courseorid=null, $autologinguest=true, $cm=null, $setwantsurltome=true, $preventredirect=false) | |
This function checks that the current user is logged in and has the required privileges. | |
require_logout () | |
This function just makes sure a user is logged out. | |
require_user_key_login ($script, $instance=null, $keyvalue=null) | |
Require key login. | |
required_param ($parname, $type) | |
Returns a particular value for the named variable, taken from POST or GET. | |
required_param_array ($parname, $type) | |
Returns a particular array value for the named variable, taken from POST or GET. | |
reset_course_userdata ($data) | |
This function will empty a course of user data. | |
reset_password_and_mail ($user) | |
Resets specified user's password and send the new password to the user via email. | |
send_confirmation_email ($user, $confirmationurl=null) | |
Send email to specified user with confirmation text and activation link. | |
send_password_change_confirmation_email ($user, $resetrecord) | |
Sends a password change confirmation email. | |
send_password_change_info ($user) | |
Sends an email containing information on how to change your password. | |
set_bounce_count ($user, $reset=false) | |
Increment or reset user's email bounce count. | |
set_cache_flag ($type, $name, $value, $expiry=null) | |
Set a volatile flag. | |
set_config ($name, $value, $plugin=null) | |
Set a key in global configuration. | |
set_login_session_preferences () | |
When logging in, this function is run to set certain preferences for the current SESSION. | |
set_mnet_remote_client ($client) | |
during the xmlrpc server code execution, this will be called to setup the object returned by get_mnet_remote_client | |
set_send_count ($user, $reset=false) | |
Used to increment or reset email sent count. | |
set_user_preference ($name, $value, $user=null) | |
Sets a preference for the specified user. | |
set_user_preferences (array $prefarray, $user=null) | |
Sets a whole array of preferences for the current user. | |
setnew_password_and_mail ($user, $fasthash=false) | |
Sets specified user's password and send the new password to the user via email. | |
setup_lang_from_browser () | |
This function will search for browser prefereed languages, setting Moodle to use the best one available if $SESSION->lang is undefined. | |
shift_course_mod_dates ($modname, $fields, $timeshift, $courseid, $modid=0) | |
Change dates in module - used from course reset. | |
shorten_filename ($filename, $length=MAX_FILENAME_SIZE, $includehash=false) | |
Shortens a given filename by removing characters positioned after the ideal string length. | |
shorten_filenames (array $path, $length=MAX_FILENAME_SIZE, $includehash=false) | |
Shortens a given array of filenames by removing characters positioned after the ideal string length. | |
shorten_text ($text, $ideal=30, $exact=false, $ending='...') | |
Given some text (which may contain HTML) and an ideal length, this function truncates the text neatly on a word boundary if possible. | |
site_is_public () | |
Tries to guess if $CFG->wwwroot is publicly accessible or not. | |
swapshuffle ($array) | |
Given a simple array, this shuffles it up just like shuffle() Unlike PHP's shuffle() this function works on any machine. | |
swapshuffle_assoc ($array) | |
Like swapshuffle(), but works on associative arrays. | |
truncate_userinfo (array $info) | |
Will truncate userinfo as it comes from auth_get_userinfo (from external auth) which may have large fields. | |
unformat_float ($localefloat, $strict=false) | |
Converts locale specific floating point/comma number back to standard PHP float value Do NOT try to do any math operations before this conversion on any user submitted floats! | |
unserialize_array ($expression) | |
Safe analogue of unserialize() that can only parse arrays. | |
unserialize_object (string $input) | |
Safe method for unserializing given input that is expected to contain only a serialized instance of an stdClass object. | |
unset_all_config_for_plugin ($plugin) | |
Remove all the config variables for a given plugin. | |
unset_cache_flag ($type, $name) | |
Removes a single volatile flag. | |
unset_config ($name, $plugin=null) | |
Removes a key from global configuration. | |
unset_user_preference ($name, $user=null) | |
Unsets a preference completely by deleting it from the database. | |
update_internal_user_password (stdClass $user, #[\SensitiveParameter] ?string $password, bool $fasthash=false) | |
Update password hash in user object (if necessary). | |
update_user_login_times () | |
Modify the user table by setting the currently logged in user's last login to now. | |
update_user_record ($username) | |
Will update a local user record from an external source (MNET users can not be updated using this method!). | |
update_user_record_by_id ($id) | |
Will update a local user record from an external source (MNET users can not be updated using this method!). | |
user_not_fully_set_up ($user, $strict=true) | |
Determines if a user has completed setting up their account. | |
user_preference_allow_ajax_update ($name, $paramtype) | |
Library functions to facilitate the use of ajax JavaScript in Moodle. | |
userdate ($date, $format='', $timezone=99, $fixday=true, $fixhour=true) | |
Returns a formatted string that represents a date in user time. | |
userdate_htmltime ($date, $format='', $timezone=99, $fixday=true, $fixhour=true) | |
Returns a html "time" tag with both the exact user date with timezone information as a datetime attribute in the W3C format, and the user readable date and time as text. | |
usergetdate ($time, $timezone=99) | |
Given a $time timestamp in GMT (seconds since epoch), returns an array that represents the Gregorian date in user time. | |
usergetmidnight ($date, $timezone=99) | |
Given a time, return the GMT timestamp of the most recent midnight for the current user. | |
username_load_fields_from_object ($addtoobject, $secondobject, $prefix=null, $additionalfields=null) | |
Reduces lines of duplicated code for getting user name fields. | |
usertime ($date, $timezone=99) | |
Given a GMT timestamp (seconds since epoch), offsets it by the timezone. | |
usertimezone ($timezone=99) | |
Returns a string that prints the user's timezone. | |
valid_uploaded_file ($newfile) | |
Returns current name of file on disk if it exists. | |
validate_internal_user_password (stdClass $user, #[\SensitiveParameter] string $password) | |
Compare password against hash stored in user object to determine if it is valid. | |
validate_param ($param, $type, $allownull=NULL_NOT_ALLOWED, $debuginfo='') | |
Strict validation of parameter values, the values are only converted to requested PHP type. | |
validate_user_key ($keyvalue, $script, $instance) | |
Validates a user key, checking if the key exists, is not expired and the remote ip is correct. | |
Variables | |
const | AUTH_PASSWORD_NOT_CACHED 'not cached' |
Authentication constant: String used in password field when password is not stored. | |
const | BLOG_COURSE_LEVEL 3 |
const | BLOG_GLOBAL_LEVEL 5 |
const | BLOG_GROUP_LEVEL 2 |
const | BLOG_SITE_LEVEL 4 |
const | BLOG_USER_LEVEL 1 |
const | CONTACT_SUPPORT_ANYONE 2 |
Contact site support form/link available to anyone visiting the site. | |
const | CONTACT_SUPPORT_AUTHENTICATED 1 |
Contact site support form/link only available to authenticated users. | |
const | CONTACT_SUPPORT_DISABLED 0 |
Contact site support form/link disabled. | |
const | COURSE_DISPLAY_MULTIPAGE 1 |
Course display settings: split pages into a page per section. | |
const | COURSE_DISPLAY_SINGLEPAGE 0 |
Course display settings: display all sections on one page. | |
const | DAYMINS 1440 |
Time constant - the number of minutes in a day. | |
const | DAYSECS 86400 |
Time constant - the number of seconds in a day. | |
defined ( 'HUB_MOODLEORGHUBURL')||define( 'HUB_MOODLEORGHUBURL' | |
URL of the Moodle sites registration portal. | |
const | EMAIL_VIA_ALWAYS 1 |
Email from header to always include via information. | |
const | EMAIL_VIA_NEVER 0 |
Email from header to never include via information. | |
const | EMAIL_VIA_NO_REPLY_ONLY 2 |
Email from header to only include via information if the address is no-reply. | |
const | EXTERNAL_TOKEN_EMBEDDED 1 |
Security token used for allowing access of embedded applications, the code is executed in the active user session. | |
const | EXTERNAL_TOKEN_PERMANENT 0 |
Security token used for allowing access from external application such as web services. | |
const | FEATURE_ADVANCED_GRADING 'grade_advanced_grading' |
True if module supports advanced grading methods. | |
const | FEATURE_BACKUP_MOODLE2 'backup_moodle2' |
True if module supports backup/restore of moodle2 format. | |
const | FEATURE_COMMENT 'comment' |
const | FEATURE_COMPLETION_HAS_RULES 'completion_has_rules' |
True if module has custom completion rules. | |
const | FEATURE_COMPLETION_TRACKS_VIEWS 'completion_tracks_views' |
True if module has code to track whether somebody viewed it. | |
const | FEATURE_CONTROLS_GRADE_VISIBILITY 'controlsgradevisbility' |
True if module controls the grade visibility over the gradebook. | |
const | FEATURE_GRADE_HAS_GRADE 'grade_has_grade' |
True if module can provide a grade. | |
const | FEATURE_GRADE_OUTCOMES 'outcomes' |
True if module supports outcomes. | |
const | FEATURE_GROUPINGS 'groupings' |
True if module supports groupings. | |
const | FEATURE_GROUPMEMBERSONLY 'groupmembersonly' |
True if module supports groupmembersonly (which no longer exists) | |
const | FEATURE_GROUPS 'groups' |
True if module supports groups. | |
const | FEATURE_IDNUMBER 'idnumber' |
True (which is default) if the module wants support for setting the ID number for grade calculation purposes. | |
const | FEATURE_MOD_ARCHETYPE 'mod_archetype' |
Type of module. | |
const | FEATURE_MOD_INTRO 'mod_intro' |
True if module supports intro editor. | |
const | FEATURE_MOD_PURPOSE 'mod_purpose' |
Type of module. | |
const | FEATURE_MODEDIT_DEFAULT_COMPLETION 'modedit_default_completion' |
True if module has default completion. | |
const | FEATURE_NO_VIEW_LINK 'viewlink' |
True if module has no 'view' page (like label) | |
const | FEATURE_PLAGIARISM 'plagiarism' |
True if module supports plagiarism plugins. | |
const | FEATURE_RATE 'rate' |
const | FEATURE_SHOW_DESCRIPTION 'showdescription' |
True if module can show description on course main page. | |
const | FEATURE_USES_QUESTIONS 'usesquestions' |
True if module uses the question bank. | |
const | GETREMOTEADDR_SKIP_DEFAULT GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP |
GETREMOTEADDR_SKIP_DEFAULT defines the default behavior remote IP address validation. | |
const | GETREMOTEADDR_SKIP_HTTP_CLIENT_IP '1' |
Get remote addr constant. | |
const | GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR '2' |
Get remote addr constant. | |
const | HOMEPAGE_MY 1 |
The home page should be the users my page. | |
const | HOMEPAGE_MYCOURSES 3 |
The home page should be the users my courses page. | |
const | HOMEPAGE_SITE 0 |
The home page should be the site home. | |
const | HOMEPAGE_USER 2 |
The home page can be chosen by the user. | |
const | HOURMINS 60 |
Time constant - the number of minutes in an hour. | |
const | HOURSECS 3600 |
Time constant - the number of seconds in an hour. | |
const | MAX_FILENAME_SIZE 100 |
Maximum filename char size. | |
const | MAX_PASSWORD_CHARACTERS 128 |
Maximum number of characters for password. | |
const | MINSECS 60 |
Time constant - the number of seconds in a minute. | |
const | MOD_ARCHETYPE_ASSIGNMENT 2 |
Assignment module archetype. | |
const | MOD_ARCHETYPE_OTHER 0 |
Unspecified module archetype. | |
const | MOD_ARCHETYPE_RESOURCE 1 |
Resource-like type module. | |
const | MOD_ARCHETYPE_SYSTEM 3 |
System (not user-addable) module archetype. | |
const | MOD_PURPOSE_ADMINISTRATION 'administration' |
Module purpose administration. | |
const | MOD_PURPOSE_ASSESSMENT 'assessment' |
Module purpose assessment. | |
const | MOD_PURPOSE_COLLABORATION 'collaboration' |
Module purpose communication. | |
const | MOD_PURPOSE_COMMUNICATION 'communication' |
Module purpose communication. | |
const | MOD_PURPOSE_CONTENT 'content' |
Module purpose content. | |
const | MOD_PURPOSE_INTERFACE 'interface' |
Module purpose interface. | |
const | MOD_PURPOSE_OTHER 'other' |
Module purpose other. | |
const | MOODLE_OFFICIAL_MOBILE_SERVICE 'moodle_mobile_app' |
Moodle mobile app service name. | |
const | NULL_ALLOWED true |
NULL_ALLOWED - the parameter can be set to null in the database. | |
const | NULL_NOT_ALLOWED false |
NULL_NOT_ALLOWED - the parameter can not be set to null in the database. | |
const | PAGE_COURSE_VIEW 'course-view' |
PAGE_COURSE_VIEW is a definition of a page type. | |
const | PARAM_ACTION 'alphanumext' |
PARAM_ACTION - deprecated alias for PARAM_ALPHANUMEXT, use for various actions in forms and urls NOTE: originally alias for PARAM_APLHA. | |
const | PARAM_ALPHA 'alpha' |
PARAM_ALPHA - contains only English ascii letters [a-zA-Z]. | |
const | PARAM_ALPHAEXT 'alphaext' |
PARAM_ALPHAEXT the same contents as PARAM_ALPHA (English ascii letters [a-zA-Z]) plus the chars in quotes: "_-" allowed NOTE: originally this allowed "/" too, please use PARAM_SAFEPATH if "/" needed. | |
const | PARAM_ALPHANUM 'alphanum' |
PARAM_ALPHANUM - expected numbers 0-9 and English ascii letters [a-zA-Z] only. | |
const | PARAM_ALPHANUMEXT 'alphanumext' |
PARAM_ALPHANUMEXT - expected numbers 0-9, letters (English ascii letters [a-zA-Z]) and _- only. | |
const | PARAM_AREA 'area' |
PARAM_AREA is a name of area used when addressing files, comments, ratings, etc. | |
const | PARAM_AUTH 'auth' |
PARAM_AUTH - actually checks to make sure the string is a valid auth plugin. | |
const | PARAM_BASE64 'base64' |
PARAM_BASE64 - Base 64 encoded format. | |
const | PARAM_BOOL 'bool' |
PARAM_BOOL - converts input into 0 or 1, use for switches in forms and urls. | |
const | PARAM_CAPABILITY 'capability' |
PARAM_CAPABILITY - A capability name, like 'moodle/role:manage'. | |
const | PARAM_CLEAN 'clean' |
PARAM_CLEAN - obsoleted, please use a more specific type of parameter. | |
const | PARAM_CLEANFILE 'file' |
PARAM_CLEANFILE - deprecated alias of PARAM_FILE; originally was removing regional chars too. | |
const | PARAM_CLEANHTML 'cleanhtml' |
PARAM_CLEANHTML - cleans submitted HTML code. | |
const | PARAM_COMPONENT 'component' |
PARAM_COMPONENT is used for full component names (aka frankenstyle) such as 'mod_forum', 'core_rating', 'auth_ldap'. | |
const | PARAM_EMAIL 'email' |
PARAM_EMAIL - an email address following the RFC. | |
const | PARAM_FILE 'file' |
PARAM_FILE - safe file name, all dangerous chars are stripped, protects against XSS, SQL injections and directory traversals. | |
const | PARAM_FLOAT 'float' |
PARAM_FLOAT - a real/floating point number. | |
const | PARAM_FORMAT 'alphanumext' |
PARAM_FORMAT - deprecated alias for PARAM_ALPHANUMEXT, use for names of plugins, formats, etc. | |
const | PARAM_HOST 'host' |
PARAM_HOST - expected fully qualified domain name (FQDN) or an IPv4 dotted quad (IP address) | |
const | PARAM_INT 'int' |
PARAM_INT - integers only, use when expecting only numbers. | |
const | PARAM_INTEGER 'int' |
PARAM_INTEGER - deprecated alias for PARAM_INT. | |
const | PARAM_LANG 'lang' |
PARAM_LANG - checks to see if the string is a valid installed language in the current site. | |
const | PARAM_LOCALISEDFLOAT 'localisedfloat' |
PARAM_LOCALISEDFLOAT - a localised real/floating point number. | |
const | PARAM_LOCALURL 'localurl' |
PARAM_LOCALURL - expected properly formatted URL as well as one that refers to the local server itself. | |
const | PARAM_MULTILANG 'text' |
PARAM_MULTILANG - deprecated alias of PARAM_TEXT. | |
const | PARAM_NOTAGS 'notags' |
PARAM_NOTAGS - all html tags are stripped from the text. | |
const | PARAM_NUMBER 'float' |
PARAM_NUMBER - deprecated alias of PARAM_FLOAT. | |
const | PARAM_PATH 'path' |
PARAM_PATH - safe relative path name, all dangerous chars are stripped, protects against XSS, SQL injections and directory traversals note: the leading slash is not removed, window drive letter is not allowed. | |
const | PARAM_PEM 'pem' |
PARAM_PEM - Privacy Enhanced Mail format. | |
const | PARAM_PERMISSION 'permission' |
PARAM_PERMISSION - A permission, one of CAP_INHERIT, CAP_ALLOW, CAP_PREVENT or CAP_PROHIBIT. | |
const | PARAM_PLUGIN 'plugin' |
PARAM_PLUGIN is used for plugin names such as 'forum', 'glossary', 'ldap', 'paypal', 'completionstatus'. | |
const | PARAM_RAW 'raw' |
PARAM_RAW specifies a parameter that is not cleaned/processed in any way except the discarding of the invalid utf-8 characters. | |
const | PARAM_RAW_TRIMMED 'raw_trimmed' |
PARAM_RAW_TRIMMED like PARAM_RAW but leading and trailing whitespace is stripped. | |
const | PARAM_SAFEDIR 'safedir' |
PARAM_SAFEDIR - safe directory name, suitable for include() and require() | |
const | PARAM_SAFEPATH 'safepath' |
PARAM_SAFEPATH - several PARAM_SAFEDIR joined by "/", suitable for include() and require(), plugin paths and other references to Moodle code files. | |
const | PARAM_SEQUENCE 'sequence' |
PARAM_SEQUENCE - expects a sequence of numbers like 8 to 1,5,6,4,6,8,9. | |
const | PARAM_STRINGID 'stringid' |
PARAM_STRINGID - used to check if the given string is valid string identifier for get_string() | |
const | PARAM_TAG 'tag' |
PARAM_TAG - one tag (interests, blogs, etc.) - mostly international characters and space, <> not supported. | |
const | PARAM_TAGLIST 'taglist' |
PARAM_TAGLIST - list of tags separated by commas (interests, blogs, etc.) | |
const | PARAM_TEXT 'text' |
PARAM_TEXT - general plain text compatible with multilang filter, no other html tags. | |
const | PARAM_THEME 'theme' |
PARAM_THEME - Checks to see if the string is a valid theme name in the current site. | |
const | PARAM_TIMEZONE 'timezone' |
PARAM_TIMEZONE - expected timezone. | |
const | PARAM_URL 'url' |
PARAM_URL - expected properly formatted URL. | |
const | PARAM_USERNAME 'username' |
PARAM_USERNAME - Clean username to only contains allowed characters. | |
const | PASSWORD_DIGITS '0123456789' |
const | PASSWORD_LOWER 'abcdefghijklmnopqrstuvwxyz' |
const | PASSWORD_NONALPHANUM '.,;:!?_-+/*@#&$' |
const | PASSWORD_UPPER 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
const | PEPPER_ENTROPY 112 |
Required password pepper entropy. | |
const | TAG_MAX_LENGTH 50 |
To prevent problems with multibytes strings,Flag updating in nav not working on the review page. | |
const | USER_CAN_IGNORE_FILE_SIZE_LIMITS -1 |
Indicates the user has the capabilities required to ignore activity and course file size restrictions. | |
const | VALUE_DEFAULT 0 |
VALUE_DEFAULT - if the parameter is not supplied, then the default value is used. | |
const | VALUE_OPTIONAL 2 |
VALUE_OPTIONAL - if the parameter is not supplied, then the param has no value. | |
const | VALUE_REQUIRED 1 |
VALUE_REQUIRED - if the parameter is not supplied, there is an error. | |
const | WEEKSECS 604800 |
Time constant - the number of seconds in a week. | |
const | YEARSECS 31536000 |
Time constant - the number of seconds in a year. | |
address_in_subnet | ( | $addr, | |
$subnetstr, | |||
$checkallzeros = false ) |
Function to check the passed address is within the passed subnet.
The parameter is a comma separated string of subnet definitions. Subnet strings can be in one of three formats: 1: xxx.xxx.xxx.xxx/nn or xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/nnn (number of bits in net mask) 2: xxx.xxx.xxx.xxx-yyy or xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx::xxxx-yyyy (a range of IP addresses in the last group) 3: xxx.xxx or xxx.xxx. or xxx:xxx:xxxx or xxx:xxx:xxxx. (incomplete address, a bit non-technical ;-) Code for type 1 modified from user posted comments by mediator at
string | $addr | The address you are checking |
string | $subnetstr | The string of subnet addresses |
bool | $checkallzeros | The state to whether check for 0.0.0.0 |
bool |
ajax_capture_output | ( | ) |
Starts capturing output whilst processing an AJAX request.
This should be used in combination with ajax_check_captured_output to report any captured output to the user.
Boolean | Returns true on success or false on failure. |
ajax_check_captured_output | ( | ) |
Check captured output for content.
If the site has a debug level of debugdeveloper set, and the content is non-empty, then throw a coding exception which can be captured by the Y.IO request and displayed to the user.
Any | output that was captured. |
array_is_nested | ( | $array | ) |
Check if there is a nested array within the passed array.
array | $array |
bool | true if there is a nested array false otherwise |
authenticate_user_login | ( | $username, | |
$password, | |||
$ignorelockout = false, | |||
& | $failurereason = null, | ||
$logintoken = false, | |||
string|bool | $loginrecaptcha = false ) |
Authenticates a user against the chosen authentication mechanism.
Given a username and password, this function looks them up using the currently selected authentication mechanism, and if the authentication is successful, it returns a valid $user object from the 'user' table.
Uses auth_ functions from the currently active auth module
After authenticate_user_login() returns success, you will need to log that the user has logged in, and call complete_user_login() to set the session up.
Note: this function works only with non-mnet accounts!
string | $username | User's username (or also email if $CFG->authloginviaemail enabled) |
string | $password | User's password |
bool | $ignorelockout | useful when guessing is prevented by other mechanism such as captcha or SSO |
int | $failurereason | login failure reason, can be used in renderers (it may disclose if account exists) |
string | bool | $logintoken | If this is set to a string it is validated against the login token for the session. |
string | bool | $loginrecaptcha | If this is set to a string it is validated against Google reCaptcha. |
stdClass|false | A $USER object or false if error |
bounded_number | ( | $min, | |
$value, | |||
$max ) |
Used to make sure that $min <= $value <= $max.
Make sure that value is between min, and max
int | $min | The minimum value |
int | $value | The value to check |
int | $max | The maximum value |
int |
calculate_entropy | ( | # string | $pepper[\SensitiveParameter] | ) |
Calculate the Shannon entropy of a string.
string | $pepper | The pepper to calculate the entropy of. |
float | The Shannon entropy of the string. |
can_send_from_real_email_address | ( | $from, | |
$user, | |||
$unused = null ) |
Check to see if a user's real email address should be used for the "From" field.
object | $from | The user object for the user we are sending the email from. |
object | $user | The user object that we are sending the email to. |
array | $unused | No longer used. |
bool | Returns true if we can use the from user's email adress in the "From" field. |
check_consecutive_identical_characters | ( | $password, | |
$maxchars ) |
Check whether the given password has no more than the specified number of consecutive identical characters.
string | $password | password to be checked against the password policy |
integer | $maxchars | maximum number of consecutive identical characters |
bool |
check_password_policy | ( | $password, | |
& | $errmsg, | ||
$user = null ) |
Validate a password against the configured password policy.
string | $password | the password to be checked against the password policy |
string | $errmsg | the error message to display when the password doesn't comply with the policy. |
stdClass | $user | the user object to perform password validation against. Defaults to null if not provided. |
bool | true if the password is valid according to the policy. false otherwise. |
check_php_version | ( | $version = '5.2.4' | ) |
Returns true if the current version of PHP is greater that the specified one.
string | $version | The version of php being tested. |
bool |
check_user_preferences_loaded | ( | stdClass | $user, |
$cachelifetime = 120 ) |
Refresh user preference cache.
This is used most often for $USER object that is stored in session, but it also helps with performance in cron script.
Preferences for each user are loaded on first use on every page, then again after the timeout expires.
stdClass | $user | User object. Preferences are preloaded into 'preference' property |
int | $cachelifetime | Cache life time on the current page (in seconds) |
coding_exception |
null |
clean_filename | ( | $string | ) |
Cleans a given filename by removing suspicious or troublesome characters.
string | $string | file name |
string | cleaned file name |
clean_param | ( | $param, | |
$type ) |
Used by optional_param() and required_param() to clean the variables and/or cast to specific types, based on an options field.
$course->format = clean_param($course->format, PARAM_ALPHA); $selectedgradeitem = clean_param($selectedgradeitem, PARAM_INT);
mixed | $param | the variable we are cleaning |
string | $type | expected format of param after cleaning. |
mixed |
coding_exception |
clean_param_array | ( | ?array | $param, |
$type, | |||
$recursive = false ) |
Makes sure array contains only the allowed types, this function does not validate array key names!
$options = clean_param($options, PARAM_INT);
array | null | $param | the variable array we are cleaning |
string | $type | expected format of param after cleaning. |
bool | $recursive | clean recursive arrays |
array |
coding_exception |
cleanremoteaddr | ( | $addr, | |
$compress = false ) |
Cleans an ip address.
Internal addresses are now allowed. (Originally local addresses were not allowed.)
string | $addr | IPv4 or IPv6 address |
bool | $compress | use IPv6 address compression |
string | normalised ip address string, null if error |
cleardoubleslashes | ( | $path | ) |
Replace 1 or more slashes or backslashes to 1 slash.
string | $path | The path to strip |
string | the path with double slashes removed |
complete_user_login | ( | $user, | |
array | $extrauserinfo = [] ) |
Call to complete the user login process after authenticate_user_login() has succeeded.
It will setup the $USER variable and other required bits and pieces.
NOTE:
stdClass | $user | |
array | $extrauserinfo |
stdClass | A $USER object - BC only, do not use |
complex_random_string | ( | $length = null | ) |
Generate a complex random string (useful for md5 salts)
This function is based on the above random_string() however it uses a larger pool of characters and generates a string between 24 and 32 characters
int | $length | Optional if set generates a string to exactly this length |
string |
component_callback | ( | $component, | |
$function, | |||
array | $params = array(), | ||
$default = null, | |||
bool | $migratedtohook = false ) |
Invoke component's callback functions.
string | $component | frankenstyle component name, e.g. 'mod_quiz' |
string | $function | the rest of the function name, e.g. 'cron' will end up calling 'mod_quiz_cron' |
array | $params | parameters of callback function |
mixed | $default | default value if callback function hasn't been defined, or if it retursn null. |
bool | $migratedtohook | if true this is a deprecated callback, if hook callback is present then do nothing |
mixed |
component_callback_exists | ( | $component, | |
$function ) |
Determine if a component callback exists and return the function name to call.
Note that this function will include the required library files so that the functioname returned can be called directly.
string | $component | frankenstyle component name, e.g. 'mod_quiz' |
string | $function | the rest of the function name, e.g. 'cron' will end up calling 'mod_quiz_cron' |
mixed | Complete function name to call if the callback exists or false if it doesn't. |
coding_exception | if invalid component specfied |
component_class_callback | ( | $classname, | |
$methodname, | |||
array | $params, | ||
$default = null ) |
Call the specified callback method on the provided class.
If the callback returns null, then the default value is returned instead. If the class does not exist, then the default value is returned.
string | $classname | The name of the class to call upon. |
string | $methodname | The name of the staticically defined method on the class. |
array | $params | The arguments to pass into the method. |
mixed | $default | The default value. |
mixed | The return value. |
convert_to_array | ( | $var | ) |
Converts an object into an associative array.
This function converts an object into an associative array by iterating over its public properties. Because this function uses the foreach construct, Iterators are respected. It works recursively on arrays of objects. Arrays and simple values are returned as is.
If class has magic properties, it can implement IteratorAggregate and return all available properties in getIterator()
mixed | $var |
array |
count_letters | ( | $string, | |
$format = null ) |
Count letters in a string.
Letters are defined as chars not in tags and different from whitespace.
string | $string | The text to be searched for letters. May be HTML. |
int | null | $format |
int | The count of letters in the specified text. |
count_words | ( | $string, | |
$format = null ) |
Count words in a string.
Words are defined as things between whitespace.
string | $string | The text to be searched for words. May be HTML. |
int | null | $format |
int | The count of words in the specified string |
create_user_key | ( | $script, | |
$userid, | |||
$instance = null, | |||
$iprestriction = null, | |||
$validuntil = null ) |
Creates a new private user access key.
string | $script | unique target identifier |
int | $userid | |
int | $instance | optional instance id |
string | $iprestriction | optional ip restricted access |
int | $validuntil | key valid only until given data |
string | access key value |
create_user_record | ( | $username, | |
$password, | |||
$auth = 'manual' ) |
Creates a bare-bones user record.
string | $username | New user's username to add to record |
string | $password | New user's password to add to record |
string | $auth | Form of authentication required |
stdClass | A complete user object |
current_language | ( | ) |
Returns the code for the current language.
string |
custom_script_path | ( | ) |
Detect a custom script replacement in the data directory that will replace an existing moodle script.
string|bool | full path name if a custom script exists, false if no custom script exists |
date_format_string | ( | $date, | |
$format, | |||
$tz = 99 ) |
Returns a formatted date ensuring it is UTF-8.
If we are running under Windows convert to Windows encoding and then back to UTF-8 (because it's impossible to specify UTF-8 to fetch locale info in Win32).
int | $date | the timestamp - since Moodle 2.9 this is a real UTC timestamp |
string | $format | strftime format. |
int | float | string | $tz | the user timezone |
string | the formatted date/time. |
dayofweek | ( | $day, | |
$month, | |||
$year ) |
Calculate the position in the week of a specific calendar day.
int | $day | The day of the date whose position in the week is sought |
int | $month | The month of the date whose position in the week is sought |
int | $year | The year of the date whose position in the week is sought |
int |
days_in_month | ( | $month, | |
$year ) |
Calculate the number of days in a given month.
int | $month | The month whose day count is sought |
int | $year | The year of the month whose day count is sought |
int |
delete_course | ( | $courseorid, | |
$showfeedback = true ) |
Delete a course, including all related data from the database, and any associated files.
mixed | $courseorid | The id of the course or course object to delete. |
bool | $showfeedback | Whether to display notifications of each action the function performs. |
bool | true if all the removals succeeded. false if there were any failures. If this method returns false, some of the removals will probably have succeeded, and others failed, but you have no way of knowing which. |
delete_user | ( | stdClass | $user | ) |
Marks user deleted in internal user database and notifies the auth plugin.
Also unenrols user from all roles and does other cleanup.
Any plugin that needs to purge user data should register the 'user_deleted' event.
stdClass | $user | full user object before delete |
boolean | success |
coding_exception | if invalid $user parameter detected |
delete_user_key | ( | $script, | |
$userid ) |
Delete the user's new private user access keys for a particular script.
string | $script | unique target identifier |
int | $userid |
void |
display_size | ( | $size, | |
int | $decimalplaces = 1, | ||
string | $fixedunits = '' ) |
Converts bytes into display form.
int | $size | The size to convert to human readable form |
int | $decimalplaces | If specified, uses fixed number of decimal places |
string | $fixedunits | If specified, uses fixed units (e.g. 'KB') |
string | Display version of size |
draw_rand_array | ( | $array, | |
$draws ) |
Given an arbitrary array, and a number of draws, this function returns an array with that amount of items.
The indexes are retained.
array | $array | |
int | $draws |
array |
dst_offset_on | ( | $time, | |
$strtimezone = null ) |
Calculates the Daylight Saving Offset for a given date/time (timestamp)
int | $time | must NOT be compensated at all, it has to be a pure timestamp |
int | float | string | $strtimezone | user timezone |
int |
email_is_not_allowed | ( | ) |
Check that an email is allowed.
It returns an error message if there was a problem.
string | Content of email |
string|false |
email_should_be_diverted | ( | ) |
A helper function to test for email diversion.
string |
bool | Returns true if the email should be diverted |
email_to_user | ( | $user, | |
$from, | |||
$subject, | |||
$messagetext, | |||
$messagehtml = '', | |||
$attachment = '', | |||
$attachname = '', | |||
$usetrueaddress = true, | |||
$replyto = '', | |||
$replytoname = '', | |||
$wordwrapwidth = 79 ) |
Send an email to a specified user.
stdClass | $user | A $USER object |
stdClass | $from | A $USER object |
string | $subject | plain text subject line of the email |
string | $messagetext | plain text version of the message |
string | $messagehtml | complete html version of the message (optional) |
string | $attachment | a file on the filesystem, either relative to $CFG->dataroot or a full path to a file in one of the following directories: $CFG->cachedir, $CFG->dataroot, $CFG->dirroot, $CFG->localcachedir, $CFG->tempdir |
string | $attachname | the name of the file (extension indicates MIME) |
bool | $usetrueaddress | determines whether $from email address should be sent out. Will be overruled by user profile setting for maildisplay |
string | $replyto | Email address to reply to |
string | $replytoname | Name of reply to recipient |
int | $wordwrapwidth | custom word wrap width, default 79 |
bool | Returns true if mail was sent OK and false if there was an error. |
endecrypt | ( | $pwd, | |
$data, | |||
$case ) |
Based on a class by Mukul Sabharwal [mukulsabharwal @ yahoo.com].
string | $pwd | The password to use when encrypting or decrypting |
string | $data | The data to be decrypted/encrypted |
string | $case | Either 'de' for decrypt or '' for encrypt |
string |
exceeds_password_length | ( | string | $password, |
int | $pepperlength = 0 ) |
Validates user's password length.
string | $password | |
int | $pepperlength | The length of the used peppers |
bool |
exists_auth_plugin | ( | $auth | ) |
Returns whether a given authentication plugin exists.
string | $auth | Form of authentication to check for. Defaults to the global setting in $CFG. |
boolean | Whether the plugin is available. |
find_day_in_month | ( | $startday, | |
$weekday, | |||
$month, | |||
$year ) |
Calculates when the day appears in specific month.
int | $startday | starting day of the month |
int | $weekday | The day when week starts (normally taken from user preferences) |
int | $month | The month whose day is sought |
int | $year | The year of the month whose day is sought |
int |
fix_current_language | ( | string | $lang | ) |
Fix the current language to the given language code.
string | $lang | The language code to use. |
void |
fix_utf8 | ( | $value | ) |
Makes sure the data is using valid utf8, invalid characters are discarded.
Note: this function is not intended for full objects with methods and private properties.
mixed | $value |
mixed | with proper utf-8 encoding |
force_current_language | ( | $language | ) |
Force the current language to get strings and dates localised in the given language.
After calling this function, all strings will be provided in the given language until this function is called again, or equivalent code is run.
string | $language |
string | previous $SESSION->forcelang value |
format_float | ( | $float, | |
$decimalpoints = 1, | |||
$localized = true, | |||
$stripzeros = false ) |
Given a float, prints it nicely.
Localized floats must not be used in calculations!
The stripzeros feature is intended for making numbers look nicer in small areas where it is not necessary to indicate the degree of accuracy by showing ending zeros. If you turn it on with $decimalpoints set to 3, for example, then it will display '5.4' instead of '5.400' or '5' instead of '5.000'.
float | $float | The float to print |
int | $decimalpoints | The number of decimal places to print. -1 is a special value for auto detect (full precision). |
bool | $localized | use localized decimal separator |
bool | $stripzeros | If true, removes final zeros after decimal point. It will be ignored and the trailing zeros after the decimal point are always striped if $decimalpoints is -1. |
string | locale float |
format_time | ( | $totalsecs, | |
$str = null ) |
Format a date/time (seconds) as weeks, days, hours etc as needed.
Given an amount of time in seconds, returns string formatted nicely as years, days, hours etc as needed
@uses MINSECS @uses HOURSECS @uses DAYSECS @uses YEARSECS
int | $totalsecs | Time in seconds |
stdClass | $str | Should be a time object |
string | A nicely formatted date/time string |
fullclone | ( | $thing | ) |
This function will make a complete copy of anything it's given, regardless of whether it's an object or not.
mixed | $thing | Something you want cloned |
mixed | What ever it is you passed it |
fullname | ( | $user, | |
$override = false ) |
Returns a persons full name.
Given an object containing all of the users name values, this function returns a string with the full name of the person. The result may depend on system settings or language. 'override' will force the alternativefullnameformat to be used. In English, fullname as well as alternativefullnameformat is set to 'firstname lastname' by default. But you could have fullname set to 'firstname lastname' and alternativefullnameformat set to 'firstname middlename alternatename lastname'.
stdClass | $user | A $USER object to get full name of. |
bool | $override | If true then the alternativefullnameformat format rather than fullnamedisplay format will be used. |
string |
gc_cache_flags | ( | ) |
Garbage-collect volatile flags.
bool | Always returns true |
generate_email_messageid | ( | $localpart = null | ) |
Generate a unique email Message-ID using the moodle domain and install path.
string | $localpart | An optional unique message id prefix. |
string | The formatted ID ready for appending to the email headers. |
generate_email_processing_address | ( | $modid, | |
$modargs ) |
Generate an email processing address.
int | $modid | |
string | $modargs |
string | Returns email processing address |
generate_email_signoff | ( | ) |
Generate a signoff for emails based on support settings.
string |
generate_password | ( | $maxlen = 10 | ) |
get_auth_plugin | ( | $auth | ) |
Returns an authentication plugin instance.
string | $auth | name of authentication plugin |
auth_plugin_base | An instance of the required authentication plugin. |
get_cache_flag | ( | $type, | |
$name, | |||
$changedsince = null ) |
Get volatile flags.
string | $type | |
string | $name | |
int | $changedsince | default null |
string|false | The cache flag value or false |
get_cache_flags | ( | $type, | |
$changedsince = null ) |
Get volatile flags.
string | $type | |
int | $changedsince | default null |
array | records array |
get_callable_name | ( | $callable | ) |
Get human readable name describing the given callable.
This performs syntax check only to see if the given param looks like a valid function, method or closure. It does not check if the callable actually exists.
callable | string | array | $callable |
string|bool | Human readable name of callable, or false if not a valid callable. |
get_complete_user_data | ( | $field, | |
$value, | |||
$mnethostid = null, | |||
$throwexception = false ) |
Get a complete user record, which includes all the info in the user record.
Intended for setting as $USER session variable
string | $field | The user field to be checked for a given value. |
string | $value | The value to match for $field. |
int | $mnethostid | |
bool | $throwexception | If true, it will throw an exception when there's no record found or when there are multiple records found. Otherwise, it will just return false. |
mixed | False, or A $USER object. |
get_config | ( | $plugin, | |
$name = null ) |
Get configuration values from the global config table or the config_plugins table.
If called with one parameter, it will load all the config variables for one plugin, and return them as an object.
If called with 2 parameters it will return a string single value or false if the value is not found.
NOTE: this function is called from lib/db/upgrade.php
string | $plugin | full component name |
string | $name | default null |
mixed | hash-like object or single value, return false no config found |
dml_exception |
get_course_display_name_for_list | ( | $course | ) |
Gets the name of a course to be displayed when showing a list of courses.
By default this is just $course->fullname but user can configure it. The result of this function should be passed through print_string.
stdClass | core_course_list_element | $course | Moodle course object |
string | Display name of course (either fullname or short + fullname) |
get_default_home_page | ( | ) |
Returns the default home page to display if current one is not defined or can't be applied.
The default behaviour is to return Dashboard if it's enabled or My courses page if it isn't.
int | The default home page. |
get_directory_list | ( | $rootdir, | |
$excludefiles = '', | |||
$descend = true, | |||
$getdirs = false, | |||
$getfiles = true ) |
Returns an array with all the filenames in all subdirectories, relative to the given rootdir.
If excludefiles is defined, then that file/directory is ignored If getdirs is true, then (sub)directories are included in the output If getfiles is true, then files are included in the output (at least one of these must be true!)
string | $rootdir | A given root directory to start from |
string | array | $excludefiles | If defined then the specified file/directory is ignored |
bool | $descend | If true then subdirectories are recursed as well |
bool | $getdirs | If true then (sub)directories are included in the output |
bool | $getfiles | If true then files are included in the output |
array | An array with all the filenames in all subdirectories, relative to the given rootdir |
get_directory_size | ( | $rootdir, | |
$excludefile = '' ) |
Adds up all the files in a directory and works out the size.
string | $rootdir | The directory to start from |
string | $excludefile | A file to exclude when summing directory size |
int | The summed size of all files and subfiles within the root directory |
get_emoticon_manager | ( | ) |
Factory function for emoticon_manager.
emoticon_manager | singleton |
get_enabled_auth_plugins | ( | $fix = false | ) |
Returns array of active auth plugins.
bool | $fix | fix $CFG->auth if needed. Only set if logged in as admin. |
array |
get_file_browser | ( | ) |
Returns local file storage instance.
file_browser |
get_file_packer | ( | $mimetype = 'application/zip' | ) |
get_file_storage | ( | $reset = false | ) |
Returns local file storage instance.
file_storage |
get_home_page | ( | ) |
Gets the homepage to use for the current user.
int | One of HOMEPAGE_* |
get_host_from_url | ( | $url | ) |
Returns host part from url.
string | $url | full url |
string | host, null if not found |
get_list_of_charsets | ( | ) |
Returns a list of charset codes.
Returns a list of charset codes. It's hardcoded, so they should be added manually (checking that such charset is supported by the texlib library!)
array | And associative array with contents in the form of charset => charset |
get_list_of_plugins | ( | $directory = 'mod', | |
$exclude = '', | |||
$basedir = '' ) |
Lists plugin-like directories within specified directory.
This function was originally used for standard Moodle plugins, please use new core_component\get_plugin_list() now.
This function is used for general directory listing and backwards compatility.
string | $directory | relative directory from root |
string | $exclude | dir name to exclude from the list (defaults to none) |
string | $basedir | full path to the base dir where $plugin resides (defaults to $CFG->dirroot) |
array | Sorted array of directory names found under the requested parameters |
get_list_of_themes | ( | ) |
Returns a list of valid and compatible themes.
array |
get_login_url | ( | ) |
Returns full login url.
Any form submissions for authentication to this URL must include username, password as well as a logintoken generated by core\session\manager\get_login_token().
string | login url |
get_mailer | ( | $action = 'get' | ) |
Get mailer instance, enable buffering, flush buffer or disable buffering.
string | $action | 'get', 'buffer', 'close' or 'flush' |
moodle_phpmailer|null | mailer instance if 'get' used or nothing |
get_max_upload_file_size | ( | $sitebytes = 0, | |
$coursebytes = 0, | |||
$modulebytes = 0, | |||
$unused = false ) |
Returns the maximum size for uploading files.
There are seven possible upload limits:
These last two are passed to this function as arguments (in bytes). Anything defined as 0 is ignored. The smallest of all the non-zero numbers is returned.
int | $sitebytes | Set maximum size |
int | $coursebytes | Current course $course->maxbytes (in bytes) |
int | $modulebytes | Current module ->maxbytes (in bytes) |
bool | $unused | This parameter has been deprecated and is not used any more. |
int | The maximum size for uploading files. |
get_max_upload_sizes | ( | $sitebytes = 0, | |
$coursebytes = 0, | |||
$modulebytes = 0, | |||
$custombytes = null ) |
Returns an array of possible sizes in local language.
Related to get_max_upload_file_size() - this function returns an array of possible sizes in an array, translated to the local language.
The list of options will go up to the minimum of $sitebytes, $coursebytes or $modulebytes.
If $coursebytes or $sitebytes is not 0, an option will be included for "Course/Site upload limit (X)" with the value set to 0. This option will be the first in the list.
@uses SORT_NUMERIC
int | $sitebytes | Set maximum size |
int | $coursebytes | Current course $course->maxbytes (in bytes) |
int | $modulebytes | Current module ->maxbytes (in bytes) |
int | array | $custombytes | custom upload size/s which will be added to list, Only value/s smaller then maxsize will be added to list. |
array |
get_mnet_environment | ( | ) |
helper function to load up and initialise the mnet environment this must be called before you use mnet functions.
mnet_environment | the equivalent of old $MNET global |
get_mnet_remote_client | ( | ) |
during xmlrpc server code execution, any code wishing to access information about the remote peer must use this to get it.
mnet_remote_client | the equivalent of old $MNETREMOTE_CLIENT global |
get_newuser_language | ( | ) |
Returns the string of the language for the new user.
string | language for the new user |
get_parent_language | ( | $lang = null | ) |
Returns parent language of current active language if defined.
string | $lang | null means current language |
string |
get_password_peppers | ( | ) |
Get the available password peppers.
The latest pepper is checked for minimum entropy as part of this function. We only calculate the entropy of the most recent pepper, because passwords are always updated to the latest pepper, and in the past we may have enforced a lower minimum entropy. Also, we allow the latest pepper to be empty, to allow admins to migrate off peppers.
array | The password peppers. |
coding_exception | If the entropy of the password pepper is less than the recommended minimum. |
get_performance_info | ( | ) |
get_performance_info() pairs up with init_performance_info() loaded in setup.php.
Returns an array with 'html' and 'txt' values ready for use, and each of the individual stats provided separately as well.
array |
get_plugin_list_with_function | ( | $plugintype, | |
$function, | |||
$file = 'lib.php' ) |
Get a list of all the plugins of a given type that define a certain API function in a certain file.
The plugin component names and function names are returned.
string | $plugintype | the type of plugin, e.g. 'mod' or 'report'. |
string | $function | the part of the name of the function after the frankenstyle prefix. e.g 'hook' if you are looking for functions with names like report_courselist_hook. |
string | $file | the name of file within the plugin that defines the function. Defaults to lib.php. |
array | with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum') and the function names as values (e.g. 'report_courselist_hook', 'forum_hook'). |
get_plugins_with_function | ( | $function, | |
$file = 'lib.php', | |||
$include = true, | |||
bool | $migratedtohook = false ) |
Get a list of all the plugins that define a certain API function in a certain file.
string | $function | the part of the name of the function after the frankenstyle prefix. e.g 'hook' if you are looking for functions with names like report_courselist_hook. |
string | $file | the name of file within the plugin that defines the function. Defaults to lib.php. |
bool | $include | Whether to include the files that contain the functions or not. |
bool | $migratedtohook | if true this is a deprecated lib.php callback, if hook callback is present then do nothing |
array | with [plugintype][plugin] = functionname |
get_site_identifier | ( | ) |
Returns the site identifier.
string\$CFG-,>siteidentifier,first | making sure it is properly initialised. |
get_string | ( | $identifier, | |
$component = '', | |||
$a = null, | |||
$lazyload = false ) |
Returns a localized string.
Returns the translated string specified by $identifier as for $module. Uses the same format files as STphp. $a is an object, string or number that can be used within translation strings
eg 'hello {$a->firstname} {$a->lastname}' or 'hello {$a}'
If you would like to directly echo the localized string use the function print_string()
Example usage of this function involves finding the string you would like a local equivalent of and using its identifier and module information to retrieve it.
If you open moodle/lang/en/moodle.php and look near line 278 you will find a string to prompt a user for their word for 'course' $string['course'] = 'Course';
So if you want to display the string 'Course' in any language that supports it on your site you just need to use the identifier 'course' $mystring = ''. get_string('course') .''; or
If the string you want is in another file you'd take a slightly different approach. Looking in moodle/lang/en/calendar.php you find around line 75: $string['typecourse'] = 'Course event';
If you want to display the string "Course event" in any language supported you would use the identifier 'typecourse' and the module 'calendar' (because it is in the file calendar.php): $mystring = '
';
As a last resort, should the identifier fail to map to a string the returned string will be [[ $identifier ]]
In Moodle 2.3 there is a new argument to this function $lazyload. Setting $lazyload to true causes get_string to return a lang_string object rather than the string itself. The fetching of the string is then put off until the string object is first used. The object can be used by calling it's out method or by casting the object to a string, either directly e.g. (string)$stringobject or indirectly by using the string within another string or echoing it out e.g. echo $stringobject return "<p>{$stringobject}</p>"; It is worth noting that using $lazyload and attempting to use the string as an array key will cause a fatal error as objects cannot be used as array keys. But you should never do that anyway! For more information lang_string
string | $identifier | The key identifier for the localized string |
string | $component | The module where the key identifier is stored, usually expressed as the filename in the language pack without the .php on the end but can also be written as mod/forum or grade/export/xls. If none is specified then moodle.php is used. |
string | object | array | int | $a | An object, string or number that can be used within translation strings |
bool | $lazyload | If set to true a string object is returned instead of the string itself. The string then isn't calculated until it is first used. |
string | The localized string. |
coding_exception |
get_string_manager | ( | $forcereload = false | ) |
Returns current string_manager instance.
The param $forcereload is needed for CLI installer only where the string_manager instance must be replaced during the install.php script life time.
bool | $forcereload | shall the singleton be released and new instance created instead? |
core_string_manager |
get_strings | ( | $array, | |
$component = '' ) |
Converts an array of strings to their localized value.
array | $array | An array of strings |
string | $component | The language module that these strings can be found in. |
stdClass | translated strings. |
get_time_interval_string | ( | int | $time1, |
int | $time2, | ||
string | $format = '', | ||
bool | $dropzeroes = false, | ||
bool | $fullformat = false ) |
Get a formatted string representation of an interval between two unix timestamps.
E.g. $intervalstring = get_time_interval_string(12345600, 12345660); Will produce the string: '0d 0h 1m'
int | $time1 | unix timestamp |
int | $time2 | unix timestamp |
string | $format | string (can be lang string) containing format chars: https://www.php.net/manual/en/dateinterval.format.php. |
bool | $dropzeroes | If format is not provided and this is set to true, do not include zero time units. e.g. a duration of 3 days and 2 hours will be displayed as '3d 2h' instead of '3d 2h 0s' |
bool | $fullformat | If format is not provided and this is set to true, display time units in full format. e.g. instead of showing "3d", "3 days" will be returned. |
string | the formatted string describing the time difference, e.g. '10d 11h 45m'. |
get_user_fieldnames | ( | ) |
Returns an array of user fields.
array | User field/column names |
get_user_key | ( | $script, | |
$userid, | |||
$instance = null, | |||
$iprestriction = null, | |||
$validuntil = null ) |
Gets a private user access key (and creates one if one doesn't exist).
string | $script | unique target identifier |
int | $userid | |
int | $instance | optional instance id |
string | $iprestriction | optional ip restricted access |
int | $validuntil | key valid only until given date |
string | access key value |
get_user_max_upload_file_size | ( | $context, | |
$sitebytes = 0, | |||
$coursebytes = 0, | |||
$modulebytes = 0, | |||
$user = null, | |||
$unused = false ) |
Returns the maximum size for uploading files for the current user.
This function takes in account get_max_upload_file_size() the user's capabilities
context | $context | The context in which to check user capabilities |
int | $sitebytes | Set maximum size |
int | $coursebytes | Current course $course->maxbytes (in bytes) |
int | $modulebytes | Current module ->maxbytes (in bytes) |
stdClass | $user | The user |
bool | $unused | This parameter has been deprecated and is not used any more. |
int | The maximum size for uploading files. |
get_user_preferences | ( | $name = null, | |
$default = null, | |||
$user = null ) |
Used to fetch user preference(s)
If no arguments are supplied this function will return all of the current user preferences as an array.
If a name is specified then this function attempts to return that particular preference value. If none is found, then the optional value $default is returned, otherwise null.
If a $user object is submitted it's 'preference' property is used for the preferences cache.
string | $name | Name of the key to use in finding a preference value |
mixed | null | $default | Value to be returned if the $name key is not set in the user preferences |
stdClass | int | null | $user | A moodle user object or id, null means current user |
coding_exception |
string|mixed|null | A string containing the value of a single preference. An array with all of the preferences or null |
get_user_timezone | ( | $tz = 99 | ) |
Returns a float or a string which denotes the user's timezone A float value means that a simple offset from GMT is used, while a string (it will be the name of a timezone in the database) means that for this timezone there are also DST rules to be taken into account Checks various settings and picks the most dominant of those which have a value.
float | int | string | $tz | timezone to calculate GMT time offset before calculating user timezone, 99 is default user timezone |
float|string |
get_users_from_config | ( | $value, | |
$capability, | |||
$includeadmins = true ) |
Use this function to get a list of users from a config setting of type admin_setting_users_with_capability.
All users are verified if they still have the necessary capability.
string | $value | the value of the config setting. |
string | $capability | the capability - must match the one passed to the admin_setting_users_with_capability constructor. |
bool | $includeadmins | include administrators. |
array | of user objects. |
getremoteaddr | ( | $default = '0.0.0.0' | ) |
Returns most reliable client address.
string | $default | If an address can't be determined, then return this |
string | The remote IP address |
getweek | ( | $startdate, | |
$thedate ) |
Given dates in seconds, how many weeks is the date from startdate The first week is 1, the second 2 etc ...
int | $startdate | Timestamp for the start date |
int | $thedate | Timestamp for the end date |
string |
guest_user | ( | ) |
Retrieve the guest user object.
stdClass | A $USER object |
hash_internal_user_password | ( | # string | $password[\SensitiveParameter], |
$fasthash = false, | |||
$pepperlength = 0 ) |
Calculate hash for a plain text password.
string | $password | Plain text password to be hashed. |
bool | $fasthash | If true, use a low number of rounds when generating the hash This is faster to generate but makes the hash less secure. It is used when lots of hashes need to be generated quickly. |
int | $pepperlength | Lenght of the peppers |
string | The hashed password. |
moodle_exception | If a problem occurs while generating the hash. |
html_is_blank | ( | $string | ) |
Tests whether anything was returned by text editor.
This function is useful for testing whether something you got back from the HTML editor actually contains anything. Sometimes the HTML editor appear to be empty, but actually you get back a
tag or something.
string | $string | a string containing HTML. |
boolean | does the string contain any actual content - that is text, images, objects, etc. |
in_object_vars | ( | $var, | |
$object ) |
Checks whether the given variable name is defined as a variable within the given object.
This will NOT work with stdClass objects, which have no class variables.
string | $var | The variable name |
object | $object | The object to check |
boolean |
ip_is_public | ( | $ip | ) |
Is IP address a public address?
string | $ip | The ip to check |
bool | true if the ip is public |
is_enabled_auth | ( | $auth | ) |
Checks if a given plugin is in the list of enabled authentication plugins.
string | $auth | Authentication plugin. |
boolean | Whether the plugin is enabled. |
is_internal_auth | ( | $auth | ) |
Returns true if an internal authentication method is being used.
if method not specified then, global default is assumed
string | $auth | Form of authentication required |
bool |
is_mnet_remote_user | ( | $user | ) |
Returns whether or not the user object is a remote MNET user.
This function is in moodlelib because it does not rely on loading any of the MNET code.
object | $user | A valid user object |
bool | True if the user is from a remote Moodle. |
is_newnav | ( | $navigation | ) |
Check if the passed navigation is of the new style.
mixed | $navigation |
bool | true for yes false for no |
is_number | ( | $value | ) |
Return true if given value is integer or string with integer value.
mixed | $value | String or Int |
bool | true if number, false if not |
is_primary_admin | ( | $userid | ) |
Is a userid the primary administrator?
int | $userid | int id of user to check |
boolean |
is_proxybypass | ( | $url | ) |
Check if $url matches anything in proxybypass list.
Any errors just result in the proxy being used (least bad)
string | $url | url to check |
boolean | true if we should bypass the proxy |
is_restored_user | ( | $username | ) |
Returns true if the user is a 'restored' one.
Used in the login process to inform the user and allow him/her to reset the password
string | $username | username to be checked |
bool |
is_rtl_compatible | ( | $paramtype | ) |
Whether the PARAM_* type is compatible in RTL.
Being compatible with RTL means that the data they contain can flow from right-to-left or left-to-right without compromising the user experience.
Take URLs for example, they are not RTL compatible as they should always flow from the left to the right. This also applies to numbers, email addresses, configuration snippets, base64 strings, etc...
This function tries to best guess which parameters can contain localised strings.
string | $paramtype | Constant PARAM_*. |
bool |
is_valid_plugin_name | ( | $name | ) |
This method validates a plug name.
It is much faster than calling clean_param.
string | $name | a string that might be a plugin name. |
bool | if this string is a valid plugin name. |
ismoving | ( | $courseid | ) |
Determines if the logged in user is currently moving an activity.
int | $courseid | The id of the course being tested |
bool |
make_grades_menu | ( | $gradingtype | ) |
Creates an array that represents all the current grades that can be chosen using the given grading type.
Negative numbers are scales, zero is no grade, and positive numbers are maximum grades.
int | $gradingtype |
array |
make_menu_from_list | ( | $list, | |
$separator = ',' ) |
Given a list (eg a,b,c,d,e) this function returns an array of 1->a, 2->b, 3->c etc.
string | $list | The string to explode into array bits |
string | $separator | The separator used within the list string |
array | The now assembled array |
make_timestamp | ( | $year, | |
$month = 1, | |||
$day = 1, | |||
$hour = 0, | |||
$minute = 0, | |||
$second = 0, | |||
$timezone = 99, | |||
$applydst = true ) |
Given Gregorian date parts in user time produce a GMT timestamp.
int | GMT timestamp |
make_unique_id_code | ( | $extra = '' | ) |
make_unique_id_code
@uses $_SERVER
string | $extra | Extra string to append to the end of the code |
string |
microtime_diff | ( | $a, | |
$b ) |
Calculate the difference between two microtimes.
string | $a | The first Microtime |
string | $b | The second Microtime |
string |
mnet_get_idp_jump_url | ( | $user | ) |
return the jump url for a given remote user this is used for rewriting forum post links in emails, etc
stdclass | $user | the user to get the idp url for |
moodle_getlocale | ( | ) |
Gets the system locale.
string | Retuns the current locale. |
moodle_major_version | ( | $fromdisk = false | ) |
Returns the major version of this site.
Moodle version numbers consist of three numbers separated by a dot, for example 1.9.11 or 2.0.2. The first two numbers, like 1.9 or 2.0, represent so called major version. This function extracts the major version from either $CFG->release (default) or eventually from the $release variable defined in the main version.php.
bool | $fromdisk | should the version if source code files be used |
string|false | the major version like '2.3', false if could not be determined |
moodle_needs_upgrading | ( | $checkupgradeflag = true | ) |
Determine if moodle installation requires update.
Checks version numbers of main code and all plugins to see if there are any mismatches.
bool | $checkupgradeflag | check the outagelessupgrade flag to see if an upgrade is running. |
bool |
moodle_process_email | ( | $modargs, | |
$body ) |
moodle_setlocale | ( | $locale = '' | ) |
Sets the system locale.
string | $locale | Can be used to force a locale |
mtrace | ( | $string, | |
$eol = "\n", | |||
$sleep = 0 ) |
For outputting debugging info.
string | $string | The string to write |
string | $eol | The end of line char(s) to use |
string | $sleep | Period to make the application sleep This ensures any messages have time to display before redirect |
mtrace_exception | ( | Throwable | $e | ) |
Helper to {.
Throwable | $e | the error to ouptput. |
object_array_unique | ( | $array, | |
$keepkeyassoc = true ) |
Returns an array without repeated objects.
This function is similar to array_unique, but for arrays that have objects as values
array | $array | |
bool | $keepkeyassoc |
array |
object_property_exists | ( | $obj, | |
$property ) |
Detect if an object or a class contains a given property will take an actual object or the name of a class.
mixed | $obj | Name of class or real object to test |
string | $property | name of property to find |
bool | true if property exists |
optional_param | ( | $parname, | |
$default, | |||
$type ) |
Returns a particular value for the named variable, taken from POST or GET, otherwise returning a given default.
This function should be used to initialise all optional values in a script that are based on parameters. Usually it will be used like this: $name = optional_param('name', 'Fred', PARAM_TEXT);
Please note the $type parameter is now required and the value can not be array.
string | $parname | the name of the page parameter we want |
mixed | $default | the default value to return if nothing is found |
string | $type | expected type of parameter |
mixed |
coding_exception |
optional_param_array | ( | $parname, | |
$default, | |||
$type ) |
Returns a particular array value for the named variable, taken from POST or GET, otherwise returning a given default.
This function should be used to initialise all optional values in a script that are based on parameters. Usually it will be used like this: $ids = optional_param('id', array(), PARAM_INT);
Note: arrays of arrays are not supported, only alphanumeric keys with _ and - are supported
string | $parname | the name of the page parameter we want |
mixed | $default | the default value to return if nothing is found |
string | $type | expected type of parameter |
array |
coding_exception |
order_in_string | ( | $values, | |
$stringformat ) |
Returns an array of values in order of occurance in a provided string.
The key in the result is the character postion in the string.
array | $values | Values to be found in the string format |
string | $stringformat | The string which may contain values being searched for. |
array | An array of values in order according to placement in the string format. |
over_bounce_threshold | ( | $user | ) |
Check whether the user has exceeded the bounce threshold.
stdClass | $user | A $USER object |
bool | true => User has exceeded bounce threshold |
partial | ( | ) |
Helper function to do partial function binding.
so we can use it for preg_replace_callback, for example this works with php functions, user functions, static methods and class methods it returns you a callback that you can pass on like so:
$callback = partial('somefunction', $arg1, $arg2); or $callback = partial(array('someclass', 'somestaticmethod'), $arg1, $arg2); or even $obj = new someclass(); $callback = partial(array($obj, 'somemethod'), $arg1, $arg2);
and then the arguments that are passed through at calltime are appended to the argument list.
mixed | $function | a php callback |
mixed | $arg1,... | $argv arguments to partially bind with |
array | Array callback |
password_is_legacy_hash | ( | # string | $password[\SensitiveParameter] | ) |
Check a password hash to see if it was hashed using the legacy hash algorithm (bcrypt).
string | $password | String to check. |
bool | True if the $password matches the format of a bcrypt hash. |
plugin_callback | ( | $type, | |
$name, | |||
$feature, | |||
$action, | |||
$params = null, | |||
$default = null, | |||
bool | $migratedtohook = false ) |
Invoke plugin's callback functions.
string | $type | plugin type e.g. 'mod' |
string | $name | plugin name |
string | $feature | feature name |
string | $action | feature's action |
array | $params | parameters of callback function, should be an array |
mixed | $default | default value if callback function hasn't been defined, or if it retursn null. |
bool | $migratedtohook | if true this is a deprecated callback, if hook callback is present then do nothing |
mixed |
plugin_supports | ( | $type, | |
$name, | |||
$feature, | |||
$default = null ) |
Checks whether a plugin supports a specified feature.
string | $type | Plugin type e.g. 'mod' |
string | $name | Plugin name e.g. 'forum' |
string | $feature | Feature code (FEATURE_xx constant) |
mixed | $default | default value if feature support unknown |
mixed | Feature result (false if not supported, null if feature is unknown, otherwise usually true but may have other feature-specific value such as array) |
coding_exception |
print_string | ( | $identifier, | |
$component = '', | |||
$a = null ) |
Prints out a translated string.
Prints out a translated string using the return value from the get_string() function.
Example usage of this function when the string is in the moodle.php file:
echo ''; print_string('course'); echo '';
Example usage of this function when the string is not in the moodle.php file:
echo '
';
string | $identifier | The key identifier for the localized string |
string | $component | The module where the key identifier is stored. If none is specified then moodle.php is used. |
string | object | array | $a | An object, string or number that can be used within translation strings |
purge_all_caches | ( | ) |
Invalidates browser caches and cached data in temp.
void |
purge_caches | ( | $options = [] | ) |
Selectively invalidate different types of cache.
Purges the cache areas specified. By default, this will purge all caches but can selectively purge specific areas alone or in combination.
bool[] | $options | Specific parts of the cache to purge. Valid options are: 'muc' Purge MUC caches? 'theme' Purge theme cache? 'lang' Purge language string cache? 'js' Purge javascript cache? 'filter' Purge text filter cache? 'other' Purge all other caches? |
purge_other_caches | ( | ) |
Purge all non-MUC caches not otherwise purged in purge_caches.
IMPORTANT - If you are adding anything here to do with the cache directory you should also have a look at phpunit_util::reset_dataroot()
random_string | ( | $length = 15 | ) |
Generate and return a random string of the specified length.
int | $length | The length of the string to be created. |
string |
rc4decrypt | ( | $data | ) |
rc4decrypt
string | $data | Data to decrypt. |
string | The now decrypted data. |
rc4encrypt | ( | $data | ) |
rc4encrypt
string | $data | Data to encrypt. |
string | The now encrypted data. |
remoteip_in_list | ( | $list | ) |
Is the current ip in a given list?
string | $list |
bool |
remove_course_contents | ( | $courseid, | |
$showfeedback = true, | |||
array | $options = null ) |
Clear a course out completely, deleting all content but don't delete the course itself.
This function does not verify any permissions.
Please note this function also deletes all user enrolments, enrolment instances and role assignments by default.
$options:
int | $courseid | The id of the course that is being deleted |
bool | $showfeedback | Whether to display notifications of each action the function performs. |
array | $options | extra options |
bool | true if all the removals succeeded. false if there were any failures. If this method returns false, some of the removals will probably have succeeded, and others failed, but you have no way of knowing which. |
remove_dir | ( | $dir, | |
$contentonly = false ) |
Delete directory or only its content.
string | $dir | directory path |
bool | $contentonly |
bool | success, true also if dir does not exist |
rename_to_unused_name | ( | string | $filepath, |
string | $prefix = '_temp_' ) |
Renames a file or directory to a unique name within the same directory.
This function is designed to avoid any potential race conditions, and select an unused name.
string | $filepath | Original filepath |
string | $prefix | Prefix to use for the temporary name |
string|bool | New file path or false if failed |
require_admin | ( | ) |
A convenience function for where we must be logged in as admin.
void |
require_course_login | ( | $courseorid, | |
$autologinguest = true, | |||
$cm = null, | |||
$setwantsurltome = true, | |||
$preventredirect = false ) |
Weaker version of require_login()
This is a weaker version of require_login() which only requires login when called from within a course rather than the site page, unless the forcelogin option is turned on.
mixed | $courseorid | The course object or id in question |
bool | $autologinguest | Allow autologin guests if that is wanted |
object | $cm | Course activity module if known |
bool | $setwantsurltome | Define if we want to set $SESSION->wantsurl, defaults to true. Used to avoid (=false) some scripts (file.php...) to set that variable, in order to keep redirects working properly. MDL-14495 |
bool | $preventredirect | set to true in scripts that can not redirect (CLI, rss feeds, etc.), throws exceptions |
void |
coding_exception |
require_login | ( | $courseorid = null, | |
$autologinguest = true, | |||
$cm = null, | |||
$setwantsurltome = true, | |||
$preventredirect = false ) |
This function checks that the current user is logged in and has the required privileges.
This function checks that the current user is logged in, and optionally whether they are allowed to be in a particular course and view a particular course module. If they are not logged in, then it redirects them to the site login unless $autologinguest is set and $CFG->autologinguests is set to 1 in which case they are automatically logged in as guests. If $courseid is given and the user is not enrolled in that course then the user is redirected to the course enrolment page. If $cm is given and the course module is hidden and the user is not a teacher in the course then the user is redirected to the course home page.
When $cm parameter specified, this function sets page layout to 'module'. You need to change it manually later if some other layout needed.
mixed | $courseorid | id of the course or course object |
bool | $autologinguest | default true |
object | $cm | course module object |
bool | $setwantsurltome | Define if we want to set $SESSION->wantsurl, defaults to true. Used to avoid (=false) some scripts (file.php...) to set that variable, in order to keep redirects working properly. MDL-14495 |
bool | $preventredirect | set to true in scripts that can not redirect (CLI, rss feeds, etc.), throws exceptions |
mixed | Void, exit, and die depending on path |
require_user_key_login | ( | $script, | |
$instance = null, | |||
$keyvalue = null ) |
Require key login.
Function terminates with error if key not found or incorrect.
@uses NO_MOODLE_COOKIES @uses PARAM_ALPHANUM
string | $script | unique script identifier |
int | $instance | optional instance id |
string | $keyvalue | The key. If not supplied, this will be fetched from the current session. |
int | Instance ID |
required_param | ( | $parname, | |
$type ) |
Returns a particular value for the named variable, taken from POST or GET.
If the parameter doesn't exist then an error is thrown because we require this variable.
This function should be used to initialise all required values in a script that are based on parameters. Usually it will be used like this: $id = required_param('id', PARAM_INT);
Please note the $type parameter is now required and the value can not be array.
string | $parname | the name of the page parameter we want |
string | $type | expected type of parameter |
mixed |
coding_exception |
required_param_array | ( | $parname, | |
$type ) |
Returns a particular array value for the named variable, taken from POST or GET.
If the parameter doesn't exist then an error is thrown because we require this variable.
This function should be used to initialise all required values in a script that are based on parameters. Usually it will be used like this: $ids = required_param_array('ids', PARAM_INT);
Note: arrays of arrays are not supported, only alphanumeric keys with _ and - are supported
string | $parname | the name of the page parameter we want |
string | $type | expected type of parameter |
array |
coding_exception |
reset_course_userdata | ( | $data | ) |
This function will empty a course of user data.
It will retain the activities and the structure of the course.
object | $data | an object containing all the settings including courseid (without magic quotes) |
array | status array of array component, item, error |
reset_password_and_mail | ( | $user | ) |
Resets specified user's password and send the new password to the user via email.
stdClass | $user | A $USER object |
bool | Returns true if mail was sent OK and false if there was an error. |
send_confirmation_email | ( | $user, | |
$confirmationurl = null ) |
Send email to specified user with confirmation text and activation link.
stdClass | $user | A $USER object |
string | $confirmationurl | user confirmation URL |
bool | Returns true if mail was sent OK and false if there was an error. |
send_password_change_confirmation_email | ( | $user, | |
$resetrecord ) |
Sends a password change confirmation email.
stdClass | $user | A $USER object |
stdClass | $resetrecord | An object tracking metadata regarding password reset request |
bool | Returns true if mail was sent OK and false if there was an error. |
send_password_change_info | ( | $user | ) |
Sends an email containing information on how to change your password.
stdClass | $user | A $USER object |
bool | Returns true if mail was sent OK and false if there was an error. |
set_bounce_count | ( | $user, | |
$reset = false ) |
Increment or reset user's email bounce count.
stdClass | $user | object containing an id |
bool | $reset | will reset the count to 0 |
set_cache_flag | ( | $type, | |
$name, | |||
$value, | |||
$expiry = null ) |
Set a volatile flag.
string | $type | the "type" namespace for the key |
string | $name | the key to set |
string | $value | the value to set (without magic quotes) - null will remove the flag |
int | $expiry | (optional) epoch indicating expiry - defaults to now()+ 24hs |
bool | Always returns true |
set_config | ( | $name, | |
$value, | |||
$plugin = null ) |
Set a key in global configuration.
Set a key/value pair in both this session's $CFG global variable and in the 'config' database table for future sessions.
Can also be used to update keys for plugin-scoped configs in config_plugin table. In that case it doesn't affect $CFG.
A NULL value will delete the entry.
NOTE: this function is called from lib/db/upgrade.php
string | $name | the key to set |
string | $value | the value to set (without magic quotes) |
string | $plugin | (optional) the plugin scope, default null |
bool | true or exception |
set_mnet_remote_client | ( | $client | ) |
during the xmlrpc server code execution, this will be called to setup the object returned by get_mnet_remote_client
mnet_remote_client | $client | the client to set up |
moodle_exception |
set_send_count | ( | $user, | |
$reset = false ) |
Used to increment or reset email sent count.
stdClass | $user | object containing an id |
bool | $reset | will reset the count to 0 |
void |
set_user_preference | ( | $name, | |
$value, | |||
$user = null ) |
Sets a preference for the specified user.
If a $user object is submitted it's 'preference' property is used for the preferences cache.
When additional validation/permission check is needed it is better to use {
string | $name | The key to set as preference for the specified user |
string | $value | The value to set for the $name key in the specified user's record, null means delete current value. |
stdClass | int | null | $user | A moodle user object or id, null means current user |
coding_exception |
bool | Always true or exception |
set_user_preferences | ( | array | $prefarray, |
$user = null ) |
Sets a whole array of preferences for the current user.
If a $user object is submitted it's 'preference' property is used for the preferences cache.
array | $prefarray | An array of key/value pairs to be set |
stdClass | int | null | $user | A moodle user object or id, null means current user |
bool | Always true or exception |
setnew_password_and_mail | ( | $user, | |
$fasthash = false ) |
Sets specified user's password and send the new password to the user via email.
stdClass | $user | A $USER object |
bool | $fasthash | If true, use a low cost factor when generating the hash for speed. |
bool|string | Returns "true" if mail was sent OK and "false" if there was an error |
shift_course_mod_dates | ( | $modname, | |
$fields, | |||
$timeshift, | |||
$courseid, | |||
$modid = 0 ) |
Change dates in module - used from course reset.
string | $modname | forum, assignment, etc |
array | $fields | array of date fields from mod table |
int | $timeshift | time difference |
int | $courseid | |
int | $modid | (Optional) passed if specific mod instance in course needs to be updated. |
bool | success |
shorten_filename | ( | $filename, | |
$length = MAX_FILENAME_SIZE, | |||
$includehash = false ) |
Shortens a given filename by removing characters positioned after the ideal string length.
When the filename is too long, the file cannot be created on the filesystem due to exceeding max byte size. Limiting the filename to a certain size (considering multibyte characters) will prevent this.
string | $filename | file name |
int | $length | ideal string length |
bool | $includehash | Whether to include a file hash in the shortened version. This ensures uniqueness. |
string\$shortened | shortened file name |
shorten_filenames | ( | array | $path, |
$length = MAX_FILENAME_SIZE, | |||
$includehash = false ) |
Shortens a given array of filenames by removing characters positioned after the ideal string length.
array | $path | The paths to reduce the length. |
int | $length | Ideal string length |
bool | $includehash | Whether to include a file hash in the shortened version. This ensures uniqueness. |
array\$result | Shortened paths in array. |
shorten_text | ( | $text, | |
$ideal = 30, | |||
$exact = false, | |||
$ending = '...' ) |
Given some text (which may contain HTML) and an ideal length, this function truncates the text neatly on a word boundary if possible.
string | $text | text to be shortened |
int | $ideal | ideal string length |
boolean | $exact | if false, $text will not be cut mid-word |
string | $ending | The string to append if the passed string is truncated |
string\$truncate | shortened string |
site_is_public | ( | ) |
Tries to guess if $CFG->wwwroot is publicly accessible or not.
Never put your faith on this function and rely on its accuracy as there might be false positives. It just performs some simple checks, and mainly is used for places where we want to hide some options such as site registration when $CFG->wwwroot is not publicly accessible. Good thing is there is no false negative. Note that it's possible to force the result of this check by specifying $CFG->site_is_public in config.php
bool |
swapshuffle | ( | $array | ) |
Given a simple array, this shuffles it up just like shuffle() Unlike PHP's shuffle() this function works on any machine.
array | $array | The array to be rearranged |
array |
swapshuffle_assoc | ( | $array | ) |
Like swapshuffle(), but works on associative arrays.
array | $array | The associative array to be rearranged |
array |
truncate_userinfo | ( | array | $info | ) |
Will truncate userinfo as it comes from auth_get_userinfo (from external auth) which may have large fields.
array | $info | Array of user properties to truncate if needed |
array | The now truncated information that was passed in |
unformat_float | ( | $localefloat, | |
$strict = false ) |
Converts locale specific floating point/comma number back to standard PHP float value Do NOT try to do any math operations before this conversion on any user submitted floats!
string | $localefloat | locale aware float representation |
bool | $strict | If true, then check the input and return false if it is not a valid number. |
mixed | float|bool - false or the parsed float. |
unserialize_array | ( | $expression | ) |
Safe analogue of unserialize() that can only parse arrays.
Arrays may contain only integers or strings as both keys and values. Nested arrays are allowed.
string | $expression |
array|bool | either parsed array or false if parsing was impossible. |
unserialize_object | ( | string | $input | ) |
Safe method for unserializing given input that is expected to contain only a serialized instance of an stdClass object.
If any class type other than stdClass is included in the input string, it will not be instantiated and will be cast to an stdClass object. The initial cast to array, then back to object is to ensure we are always returning the correct type, otherwise we would return an instances of {
string | $input |
stdClass |
unset_all_config_for_plugin | ( | $plugin | ) |
Remove all the config variables for a given plugin.
NOTE: this function is called from lib/db/upgrade.php
string | $plugin | a plugin, for example 'quiz' or 'qtype_multichoice'; |
boolean | whether the operation succeeded. |
unset_cache_flag | ( | $type, | |
$name ) |
Removes a single volatile flag.
string | $type | the "type" namespace for the key |
string | $name | the key to set |
bool |
unset_config | ( | $name, | |
$plugin = null ) |
Removes a key from global configuration.
NOTE: this function is called from lib/db/upgrade.php
string | $name | the key to set |
string | $plugin | (optional) the plugin scope |
boolean | whether the operation succeeded. |
unset_user_preference | ( | $name, | |
$user = null ) |
Unsets a preference completely by deleting it from the database.
If a $user object is submitted it's 'preference' property is used for the preferences cache.
string | $name | The key to unset as preference for the specified user |
stdClass | int | null | $user | A moodle user object or id, null means current user |
coding_exception |
bool | Always true or exception |
update_internal_user_password | ( | stdClass | $user, |
# ?string | $password[\SensitiveParameter], | ||
bool | $fasthash = false ) |
Update password hash in user object (if necessary).
The password is updated if:
The password is peppered with the latest pepper before hashing, if peppers are available. Updating the password will modify the $user object and the database record to use the current hashing algorithm. It will remove Web Services user tokens too.
stdClass | $user | User object (password property may be updated). |
string | null | $password | Plain text password. |
bool | $fasthash | If true, use a low cost factor when generating the hash This is much faster to generate but makes the hash less secure. It is used when lots of hashes need to be generated quickly. |
bool | Always returns true. |
update_user_login_times | ( | ) |
Modify the user table by setting the currently logged in user's last login to now.
bool | Always returns true |
update_user_record | ( | $username | ) |
Will update a local user record from an external source (MNET users can not be updated using this method!).
string | $username | user's username to update the record |
stdClass | A complete user object |
update_user_record_by_id | ( | $id | ) |
Will update a local user record from an external source (MNET users can not be updated using this method!).
int | $id | user id |
stdClass | A complete user object |
user_not_fully_set_up | ( | $user, | |
$strict = true ) |
Determines if a user has completed setting up their account.
The lax mode (with $strict = false) has been introduced for special cases only where we want to skip certain checks intentionally. This is valid in certain mnet or ajax scenarios when the user cannot / should not be redirected to edit their profile. In most cases, you should perform the strict check.
stdClass | $user | A $USER object to test for the existence of a valid name and email |
bool | $strict | Be more strict and assert id and custom profile fields set, too |
bool |
user_preference_allow_ajax_update | ( | $name, | |
$paramtype ) |
Library functions to facilitate the use of ajax JavaScript in Moodle.
string | $name | the name of the user_perference we should allow to be updated by remote calls. |
integer | $paramtype | one of the PARAM_{TYPE} constants, user to clean submitted values before set_user_preference is called. |
null |
userdate | ( | $date, | |
$format = '', | |||
$timezone = 99, | |||
$fixday = true, | |||
$fixhour = true ) |
Returns a formatted string that represents a date in user time.
string | the formatted date/time. |
userdate_htmltime | ( | $date, | |
$format = '', | |||
$timezone = 99, | |||
$fixday = true, | |||
$fixhour = true ) |
Returns a html "time" tag with both the exact user date with timezone information as a datetime attribute in the W3C format, and the user readable date and time as text.
string | the formatted date/time. |
usergetdate | ( | $time, | |
$timezone = 99 ) |
Given a $time timestamp in GMT (seconds since epoch), returns an array that represents the Gregorian date in user time.
int | $time | Timestamp in GMT |
float | int | string | $timezone | user timezone |
array | An array that represents the date in user time |
usergetmidnight | ( | $date, | |
$timezone = 99 ) |
Given a time, return the GMT timestamp of the most recent midnight for the current user.
int | $date | Timestamp in GMT |
float | int | string | $timezone | user timezone |
int | Returns a GMT timestamp |
username_load_fields_from_object | ( | $addtoobject, | |
$secondobject, | |||
$prefix = null, | |||
$additionalfields = null ) |
Reduces lines of duplicated code for getting user name fields.
See also user_picture::unalias()
object | $addtoobject | Object to add user name fields to. |
object | $secondobject | Object that contains user name field information. |
string | $prefix | prefix to be added to all fields (including $additionalfields) e.g. authorfirstname. |
array | $additionalfields | Additional fields to be matched with data in the second object. The key can be set to the user table field name. |
object | User name fields. |
usertime | ( | $date, | |
$timezone = 99 ) |
Given a GMT timestamp (seconds since epoch), offsets it by the timezone.
eg 3pm in India is 3pm GMT - 7 * 3600 seconds
NOTE: this function does not include DST properly, you should use the PHP date stuff instead!
int | $date | Timestamp in GMT |
float | int | string | $timezone | user timezone |
int |
usertimezone | ( | $timezone = 99 | ) |
Returns a string that prints the user's timezone.
float | int | string | $timezone | user timezone |
string |
valid_uploaded_file | ( | $newfile | ) |
Returns current name of file on disk if it exists.
string | $newfile | File to be verified |
string | Current name of file on disk if true |
validate_internal_user_password | ( | stdClass | $user, |
# string | $password[\SensitiveParameter] ) |
Compare password against hash stored in user object to determine if it is valid.
If necessary it also updates the stored hash to the current format.
stdClass | $user | (Password property may be updated). |
string | $password | Plain text password. |
bool | True if password is valid. |
validate_param | ( | $param, | |
$type, | |||
$allownull = NULL_NOT_ALLOWED, | |||
$debuginfo = '' ) |
Strict validation of parameter values, the values are only converted to requested PHP type.
Internally it is using clean_param, the values before and after cleaning must be equal - otherwise an invalid_parameter_exception is thrown. Objects and classes are not accepted.
mixed | $param | |
string | $type | PARAM_ constant |
bool | $allownull | are nulls valid value? |
string | $debuginfo | optional debug information |
mixed | the $param value converted to PHP type |
invalid_parameter_exception | if $param is not of given type |
validate_user_key | ( | $keyvalue, | |
$script, | |||
$instance ) |
Validates a user key, checking if the key exists, is not expired and the remote ip is correct.
string | $keyvalue | the key value |
string | $script | unique script identifier |
int | $instance | instance id |
stdClass | the key entry in the user_private_key table |
moodle_exception |
defined('HUB_STATSPUBLICKEY')||define('HUB_STATSPUBLICKEY' | ( | 'HUB_MOODLEORGHUBURL' | ) |
URL of the Moodle sites registration portal.
URL of the statistic server public key.
const EXTERNAL_TOKEN_EMBEDDED 1 |
Security token used for allowing access of embedded applications, the code is executed in the active user session.
Token is invalidated after user logs out. Scripts are executed serially - normal session locking is used.
const EXTERNAL_TOKEN_PERMANENT 0 |
Security token used for allowing access from external application such as web services.
Scripts do not use any session, performance is relatively low because we need to load access info in each request. Scripts are executed in parallel.
const FEATURE_GROUPMEMBERSONLY 'groupmembersonly' |
True if module supports groupmembersonly (which no longer exists)
const PAGE_COURSE_VIEW 'course-view' |
PAGE_COURSE_VIEW is a definition of a page type.
For more information on the page class see moodle/lib/pagelib.php.
const PARAM_ACTION 'alphanumext' |
PARAM_ACTION - deprecated alias for PARAM_ALPHANUMEXT, use for various actions in forms and urls NOTE: originally alias for PARAM_APLHA.
const PARAM_AREA 'area' |
PARAM_AREA is a name of area used when addressing files, comments, ratings, etc.
It is usually used together with context id and component. Only lowercase ascii letters, numbers and underscores are allowed, it has to start with a letter.
const PARAM_CAPABILITY 'capability' |
PARAM_CAPABILITY - A capability name, like 'moodle/role:manage'.
Actually checked against the list of capabilities in the database.
const PARAM_CLEAN 'clean' |
PARAM_CLEAN - obsoleted, please use a more specific type of parameter.
It was one of the first types, that is why it is abused so much ;-)
const PARAM_CLEANHTML 'cleanhtml' |
PARAM_CLEANHTML - cleans submitted HTML code.
Note that you almost never want to use this. The normal mode of operation is to use PARAM_RAW when receiving the input (required/optional_param or formslib) and then sanitise the HTML using format_text on output. This is for the rare cases when you want to sanitise the HTML on input. This cleaning may also fix xhtml strictness.
const PARAM_COMPONENT 'component' |
PARAM_COMPONENT is used for full component names (aka frankenstyle) such as 'mod_forum', 'core_rating', 'auth_ldap'.
Short legacy subsystem names and module names are accepted too ex: 'forum', 'rating', 'user'. Only lowercase ascii letters, numbers and underscores are allowed, it has to start with a letter. NOTE: numbers and underscores are strongly discouraged in plugin names!
const PARAM_FLOAT 'float' |
PARAM_FLOAT - a real/floating point number.
Note that you should not use PARAM_FLOAT for numbers typed in by the user. It does not work for languages that use , as a decimal separator. Use PARAM_LOCALISEDFLOAT instead.
const PARAM_FORMAT 'alphanumext' |
PARAM_FORMAT - deprecated alias for PARAM_ALPHANUMEXT, use for names of plugins, formats, etc.
NOTE: originally alias for PARAM_APLHA
const PARAM_INTEGER 'int' |
PARAM_INTEGER - deprecated alias for PARAM_INT.
const PARAM_LOCALISEDFLOAT 'localisedfloat' |
PARAM_LOCALISEDFLOAT - a localised real/floating point number.
This is preferred over PARAM_FLOAT for numbers typed in by the user. Cleans localised numbers to computer readable numbers; false for invalid numbers.
const PARAM_LOCALURL 'localurl' |
PARAM_LOCALURL - expected properly formatted URL as well as one that refers to the local server itself.
(NOT orthogonal to the others! Implies PARAM_URL!)
const PARAM_MULTILANG 'text' |
PARAM_MULTILANG - deprecated alias of PARAM_TEXT.
const PARAM_NOTAGS 'notags' |
PARAM_NOTAGS - all html tags are stripped from the text.
Do not abuse this type.
const PARAM_NUMBER 'float' |
PARAM_NUMBER - deprecated alias of PARAM_FLOAT.
const PARAM_PLUGIN 'plugin' |
PARAM_PLUGIN is used for plugin names such as 'forum', 'glossary', 'ldap', 'paypal', 'completionstatus'.
Only lowercase ascii letters, numbers and underscores are allowed, it has to start with a letter. NOTE: numbers and underscores are strongly discouraged in plugin names! Underscores are forbidden in module names.
const PARAM_SAFEPATH 'safepath' |
PARAM_SAFEPATH - several PARAM_SAFEDIR joined by "/", suitable for include() and require(), plugin paths and other references to Moodle code files.
This is NOT intended to be used for absolute paths or any user uploaded files.
const PARAM_SEQUENCE 'sequence' |
PARAM_SEQUENCE - expects a sequence of numbers like 8 to 1,5,6,4,6,8,9.
Numbers and comma only.
const PARAM_TEXT 'text' |
PARAM_TEXT - general plain text compatible with multilang filter, no other html tags.
Please note '<', or '>' are allowed here.
const PARAM_TIMEZONE 'timezone' |
PARAM_TIMEZONE - expected timezone.
Timezone can be int +-(0-13) or float +-(0.5-12.5) or string separated by '/' and can have '-' &/ '_' (eg. America/North_Dakota/New_Salem America/Port-au-Prince)
const PARAM_URL 'url' |
PARAM_URL - expected properly formatted URL.
Please note that domain part is required, http://localhost/ is not accepted but http://localhost.localdomain/ is ok.
const PARAM_USERNAME 'username' |
PARAM_USERNAME - Clean username to only contains allowed characters.
This is to be used ONLY when manually creating user accounts, do NOT use when syncing with external systems!!
const TAG_MAX_LENGTH 50 |
To prevent problems with multibytes strings,Flag updating in nav not working on the review page.
this should not exceed the length of "varchar(255) / 3 (bytes / utf-8 character) = 85". TODO: this is not correct, varchar(255) are 255 unicode chars ;-)