sloodle_access_level_option_choice (line
755)
void
sloodle_access_level_option_choice
( $option, $current_config, $show, [ $prefix = ''], [ $suffix = ''])
-
$option
-
$current_config
-
$show
-
$prefix
-
$suffix
sloodle_add_to_log (line
163)
Old logging function
void
sloodle_add_to_log
([ $courseid = null], [ $module = null], [ $action = null], [ $url = null], [ $cmid = null], [ $info = null])
-
$courseid
-
$module
-
$action
-
$url
-
$cmid
-
$info
sloodle_array_to_vector (line
297)
Converts an array vector to a string vector.
Array vector should be associative, containing elements 'x', 'y', and 'z'. Converts to a string vector of format "<x,y,z>".
string
sloodle_array_to_vector
( $arr)
sloodle_autoenrol_enabled_site (line
109)
Determines whether or not auto-enrolment is allowed for the site.
bool
sloodle_autoenrol_enabled_site
()
sloodle_autoreg_enabled_site (line
100)
Determines whether or not auto-registration is allowed for the site.
bool
sloodle_autoreg_enabled_site
()
sloodle_check_course_module_instance_type (line
345)
Determines if the specified course module instance is of the named type.
For example, this can check if a particular instance is a "forum" or a "chat".
bool
sloodle_check_course_module_instance_type
(int $id, string $module_name)
-
int
$id: The integer ID of a course module instance
-
string
$module_name: Module type to check (must be the exact name of an installed module, e.g. 'sloodle' or 'quiz')
sloodle_clean_for_db (line
1059)
Returns the given string, 'cleaned' and ready for storage in the database.
Note: removes tags and slash-characters.
string
sloodle_clean_for_db
(string $str)
-
string
$str: str The string to clean.
sloodle_clean_for_output (line
1048)
Returns the given string, 'cleaned' and ready for output to SL as UTF-8.
Removes tags and slash-characters.
string
sloodle_clean_for_output
(string $str)
-
string
$str: str The string to clean.
sloodle_convert_file_size_shorthand (line
1070)
Converts a shorthand file size to a number of bytes, if necessary.
This follows PHP shorthand, with K for Kilobytes, M for Megabytes, and G for Gigabytes.
integer
sloodle_convert_file_size_shorthand
(string $size)
-
string
$size: size The shorthand size to conert
sloodle_describe_approx_time (line
796)
Returns a very approximate natural language description of a period of time (in minutes, hours, days, or weeks).
Can also be used to describe how long ago something happened, in which case anything less than 1 minute is treated as 'now'.
string
sloodle_describe_approx_time
(int $secs, [bool $ago = false])
-
int
$secs: Number of seconds in period of time
-
bool
$ago: If true (not default), then the time will be described in past tense, e.g. "3 days ago", as opposed to simply "3 days".
sloodle_finished_login_coordinates (line
415)
Generates teleport coordinates for a user who has already finished the LoginZone process.
array,
sloodle_finished_login_coordinates
(string $pos, string $size)
-
string
$pos: A string vector giving the position of the LoginZone
-
string
$size: A string vector giving the size of the LoginZone
sloodle_get_config (line
80)
Gets a Sloodle configuration value from Moodle's "config" table.
This function does not necessarily need to be used. All configuration data is available as named members of Moodle's $CFG global variable. NOTE: in Sloodle debug mode, this function will terminate the script with an error if the name is not prefixed with "sloodle_".
mixed
sloodle_get_config
(string $name)
-
string
$name: The name of the value to be stored (should be prefixed with "sloodle_")
sloodle_get_course_module_instance (line
308)
Obtains the identified course module instance database record.
mixed
sloodle_get_course_module_instance
(int $id)
-
int
$id: The integer ID of a course module instance
sloodle_get_files (line
899)
Gets an array of files within the given directory.
Ignores anything which starts with a .
array|false
sloodle_get_files
(string $dir, [bool $relative = true])
-
string
$dir: The directory to search WITHOUT a trailing slash. (Note: cannot search the current directory or higher in the file hierarchy)
-
bool
$relative: If TRUE (default) the array of results will be relative to the input directory. Otherwise, they will include the input directory path.
sloodle_get_installed_object_types (line
951)
Gets all object types and versions available in this installation.
Creates a 2-dimensional associative array. The top level is the object name, and the second is the object version (both as strings). The associated value is the path to the configuration form script, or boolean false if the object has no configuration options.
array|false
sloodle_get_installed_object_types
()
sloodle_get_max_post_upload (line
1112)
Gets the maximum size of a file (in bytes) that can be uploaded using POST.
integer
sloodle_get_max_post_upload
()
sloodle_get_module_id (line
366)
Obtains the ID number of the specified module (type not instance).
mixed
sloodle_get_module_id
(string $name)
-
string
$name: The name of the module type to check, e.g. 'sloodle' or 'forum'
sloodle_get_size_description (line
1091)
Converts a file size to plain text.
For example, will convert "1024" to "1 kilobyte".
string
sloodle_get_size_description
(integer|string $size)
-
integer|string
$size: size If an integer, then it is the number of bytes. If a string, then it can be PHP shorthand, such as "1M" for 1 megabyte.
sloodle_get_subdirectories (line
867)
Gets an array of subdirectories within the given directory.
Ignores anything which starts with a .
array|false
sloodle_get_subdirectories
(string $dir, [bool $relative = true])
-
string
$dir: The directory to search WITHOUT a trailing slash. (Note: cannot search the current directory or higher in the file hierarchy)
-
bool
$relative: If TRUE (default) the array of results will be relative to the input directory. Otherwise, they will include the input directory path.
sloodle_get_value (line
683)
Extracts a value from a name-value associative array if it is set.
(The array should associate name to value).
mixed
sloodle_get_value
(array $settings, string $name, [mixed $default = null])
-
array
$settings: The array of names and values
-
string
$name: The name of the value to retrieve
-
mixed
$default: The default value to return if the specified value was not found
sloodle_get_web_path (line
847)
Gets the basic URL of the current web-page being accessed.
Includes the protocol, hostname, and script path/name.
string
sloodle_get_web_path
()
sloodle_is_course_module_instance_visible (line
319)
Determines whether or not the specified course module instance is visible.
Checks that the instance itself and the course section are both valid.
bool
sloodle_is_course_module_instance_visible
(int $id)
-
int
$id: The integer ID of a course module instance.
sloodle_is_installed (line
204)
Determines whether or not Sloodle is installed.
Queries Moodle's modules table for a Sloodle entry. NOTE: does not check for the presence of the Sloodle files.
bool
sloodle_is_installed
()
sloodle_login_notification (line
597)
Stores a pending login notification for an auto-registered user.
A cron job will process the pending notification queue.
bool
sloodle_login_notification
(string $destination, string $avatar, string $username, string $password)
-
string
$destination: Identifies the destination of the notification (for SL, this will be the object UUID. The send function will construct the email address)
-
string
$avatar: Identifier for the avatar being notified
-
string
$username: The username to notify the user of
-
string
$password: The (plaintext) password to notify the user of
sloodle_login_zone_bounds (line
496)
Calculates the maximum and minimum bounds of the specified LoginZone Returns the bounds as a numeric array of two associate array vectors: ($max, $min).
(Or returns false if no LoginZone position/size could be found in the Moodle configuration table).
array
sloodle_login_zone_bounds
(string $pos, string $size)
-
string
$pos: A string vector giving the position of the LoginZone
-
string
$size: A string vector giving the size of the LoginZone
sloodle_parse_object_identifier (line
929)
Extracts the object name and version number from an object identifier.
array
sloodle_parse_object_identifier
(string $objid)
-
string
$objid: An object identifier, such as "chat-1.0"
sloodle_position_is_in_login_zone (line
383)
Checks if the specified position is in the current (site-wide) loginzone.
bool
sloodle_position_is_in_login_zone
(mixed $pos)
-
mixed
$pos: A string vector or an associated array vector
sloodle_print_access_level_options (line
700)
Outputs the standard form elements for access levels in object configuration.
Each part can be optionally hidden, and default values can be provided. (Note: the server access level must be communicated from the object back to Moodle... rubbish implementation, but it works!)
void
sloodle_print_access_level_options
(array $current_config, [bool $show_use_object = true], [bool $show_control_object = true], [bool $show_server = true])
-
array
$current_config: An associative array of setting names to values, containing defaults. (Ignored if null).
-
bool
$show_use_object: Determines whether or not the "Use Object" setting is shown
-
bool
$show_control_object: Determines whether or not the "Control Object" setting is shown
-
bool
$show_server: Determines whether or not the server access setting is shown
sloodle_process_login_notifications (line
633)
Processes pending login notifications, up to a certain limit.
Retrieves the requests one-at-a-time for processing. This is slower, but ensures minimal damage if the process is terminated, e.g. due to server timeout.
void
sloodle_process_login_notifications
([int $limit = 25])
-
int
$limit: The maximum number of pending requests to process.
sloodle_random_position_in_zone (line
438)
Generates a random position within a cuboid zone of the specified size.
(Note: leaves a 2 metre margin round the outside)
array
sloodle_random_position_in_zone
(array $size)
-
array
$size: Associative array giving the size of the zone
sloodle_random_prim_password (line
262)
Generates a random prim password (7 to 9 digit number).
string
sloodle_random_prim_password
()
sloodle_random_security_token (line
216)
Generates a random login security token.
Uses mixed-case letters and numbers to generate a random 16-character string.
string
sloodle_random_security_token
()
sloodle_random_web_password (line
240)
Generates a random web password Uses mixed-case letters and numbers to generate a random 8-character string.
string
sloodle_random_web_password
()
sloodle_require_login_no_guest (line
29)
Force the user to login, but reject guest logins.
This function exists to workaround some Moodle 1.8 bugs.
void
sloodle_require_login_no_guest
()
sloodle_round_vector (line
461)
Rounds the specified 3d vector integer values.
Can handle/return a string vector, or an array vector. (Output type matches input type).
mixed
sloodle_round_vector
(mixed $pos)
-
mixed
$pos: Either a string vector or an array vector
sloodle_send_login_notification (line
620)
Send a login notification.
bool
sloodle_send_login_notification
(string $destination, string $avatar, string $username, string $password)
-
string
$destination: Identifies the destination of the notification (for SL, this will be the object UUID. The target email address will be constructed)
-
string
$avatar: Identifier for the avatar being notified
-
string
$username: The username to notify the user of
-
string
$password: The (plaintext) password to notify the user of
sloodle_send_xmlrpc_message (line
121)
Sends an XMLRPC message into Second Life.
bool
sloodle_send_xmlrpc_message
(string $channel, int $intval, string $strval)
-
string
$channel: A string containing a UUID identifying the XMLRPC channel in SL to be used
-
int
$intval: An integer value to be sent in the message
-
string
$strval: A string value to be sent in the message
sloodle_set_config (line
59)
Sets a Sloodle configuration value.
This data will be stored in Moodle's "config" table, so it will persist even after Sloodle is uninstalled. After being set, it will be available (read-only) as a named member of Moodle's $CFG variable. NOTE: in Sloodle debug mode, this function will terminate the script with an error if the name is not prefixed with "sloodle_".
bool
sloodle_set_config
(string $name, string $value)
-
string
$name: The name of the value to be stored (should be prefixed with "sloodle_")
-
string
$value: The string representation of the value to be stored
sloodle_validate_prim_password (line
524)
Checks if the given prim password is valid.
bool
sloodle_validate_prim_password
(string $password)
-
string
$password: The password string to check
sloodle_validate_prim_password_verbose (line
550)
Checks if the given prim password is valid, and provides feedback.
An array is written to by reference, each element containing error codes. Each error code is a word. The full text of the error message may be obtained from the string file by looking for "primpass:errorcode".
bool
sloodle_validate_prim_password_verbose
(string $password, array &$errors)
-
string
$password: The password to validate
-
array
&$errors: An array (passed by reference) which will contain any error messages
sloodle_vector_to_array (line
277)
Converts a string vector to an array vector.
String vector should be of format "<x,y,z>". Converts to associative array with members 'x', 'y', and 'z'. Returns false if input parameter was not of correct format.
mixed
sloodle_vector_to_array
(string $vector)
-
string
$vector: A string vector of format "<x,y,z>".
sloodle_view (line
994)
Render a page viewing a particular feature, or a SLOODLE module.
Outputs error text in SLOODLE debug mode.
bool
sloodle_view
(string $feature)
-
string
$feature: The name of a feature to view ("course", "user", "users"), or "module" to indicate that we are viewing some kind of module. Note: features should contain only alphanumric characters.