Differences Between: [Versions 402 and 403]
(no description)
File Size: | 648 lines (27 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
util:: (12 methods):
validate_courses()
get_area_files()
generate_token()
get_service_by_id()
get_service_by_name()
log_token_request()
generate_token_for_current_user()
format_string()
format_text()
validate_format()
delete_service_descriptions()
generate_token_name()
validate_courses($courseids,$courses = [],$addcontext = false,$keepfails = false) X-Ref |
Validate a list of courses, returning the complete course objects for valid courses. Each course has an additional 'contextvalidated' field, this will be set to true unless you set $keepfails, in which case it will be false if validation fails for a course. param: array $courseids A list of course ids param: array $courses An array of courses already pre-fetched, indexed by course id. param: bool $addcontext True if the returned course object should include the full context object. param: bool $keepfails True to keep all the course objects even if validation fails return: array An array of courses and the validation warnings |
get_area_files($contextid, $component, $filearea, $itemid = false, $useitemidinurl = true) X-Ref |
Returns all area files (optionally limited by itemid). param: int $contextid context ID param: string $component component param: string $filearea file area param: int $itemid item ID or all files if not specified param: bool $useitemidinurl wether to use the item id in the file URL (modules intro don't use it) return: array of files, compatible with the external_files structure. |
generate_token(int $tokentype,stdClass $service,int $userid,context $context,int $validuntil = 0,string $iprestriction = '',string $name = '') X-Ref |
Create and return a session linked token. Token to be used for html embedded client apps that want to communicate with the Moodle server through web services. The token is linked to the current session for the current page request. It is expected this will be called in the script generating the html page that is embedding the client app and that the returned token will be somehow passed into the client app being embedded in the page. param: int $tokentype EXTERNAL_TOKEN_EMBEDDED|EXTERNAL_TOKEN_PERMANENT param: stdClass $service service linked to the token param: int $userid user linked to the token param: context $context param: int $validuntil date when the token expired param: string $iprestriction allowed ip - if 0 or empty then all ips are allowed param: string $name token name as a note or token identity at the table view. return: string generated token |
get_service_by_id(int $serviceid) X-Ref |
Get a service by its id. param: int $serviceid return: stdClass |
get_service_by_name(string $name) X-Ref |
Get a service by its name. param: string $name The service name. return: stdClass |
log_token_request(stdClass $token) X-Ref |
Set the last time a token was sent and trigger the \core\event\webservice_token_sent event. This function is used when a token is generated by the user via login/token.php or admin/tool/mobile/launch.php. In order to protect the privatetoken, we remove it from the event params. param: stdClass $token token object |
generate_token_for_current_user(stdClass $service) X-Ref |
Generate or return an existing token for the current authenticated user. This function is used for creating a valid token for users authenticathing via places, including: - login/token.php - admin/tool/mobile/launch.php. param: stdClass $service external service object return: stdClass token object |
format_string($content,$context,$striplinks = true,$options = []) X-Ref |
Format the string to be returned properly as requested by the either the web service server, either by an internally call. The caller can change the format (raw) with the settings singleton All web service servers must set this singleton when parsing the $_GET and $_POST. <pre> Options are the same that in {@see format_string()} with some changes: filter : Can be set to false to force filters off, else observes {@see settings}. </pre> param: string|null $content The string to be filtered. Should be plain text, expect param: context $context The id of the context for the string or the context (affects filters). param: boolean $striplinks To strip any link in the result text. Moodle 1.8 default changed from false to true! MDL-8713 param: array $options options array/object or courseid return: string text |
format_text($text,$textformat,$context,$component = null,$filearea = null,$itemid = null,$options = null) X-Ref |
Format the text to be returned properly as requested by the either the web service server, either by an internally call. The caller can change the format (raw, filter, file, fileurl) with the \core_external\settings singleton All web service servers must set this singleton when parsing the $_GET and $_POST. <pre> Options are the same that in {@see format_text()} with some changes in defaults to provide backwards compatibility: trusted : If true the string won't be cleaned. Default false. noclean : If true the string won't be cleaned only if trusted is also true. Default false. nocache : If true the string will not be cached and will be formatted every call. Default false. filter : Can be set to false to force filters off, else observes {@see \core_external\settings}. para : If true then the returned string will be wrapped in div tags. Default (different from format_text) false. Default changed because div tags are not commonly needed. newlines : If true then lines newline breaks will be converted to HTML newline breaks. Default true. context : Not used! Using contextid parameter instead. overflowdiv : If set to true the formatted text will be encased in a div with the class no-overflow before being returned. Default false. allowid : If true then id attributes will not be removed, even when using htmlpurifier. Default (different from format_text) true. Default changed id attributes are commonly needed. blanktarget : If true all <a> tags will have target="_blank" added unless target is explicitly specified. </pre> param: string|null $text The content that may contain ULRs in need of rewriting. param: string|int|null $textformat The text format. param: context $context This parameter and the next two identify the file area to use. param: string|null $component param: string|null $filearea helps identify the file area. param: int|string|null $itemid helps identify the file area. param: array|stdClass|null $options text formatting options return: array text + textformat |
validate_format($format) X-Ref |
Validate text field format against known FORMAT_XXX param: string $format the format to validate return: string the validated format |
delete_service_descriptions(string $component) X-Ref |
Delete all pre-built services, related tokens, and external functions information defined for the specified component. param: string $component The frankenstyle component name |
generate_token_name() X-Ref |
Generate token name. return: string |