[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Source view] [Print] [Project Stats]
Support for external API
Copyright: | 2009 Petr Skodak |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 866 lines (32 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
restricted_context_exception:: (1 method):
__construct()
external_api:: (7 methods):
set_context_restriction()
set_timeout()
validate_parameters()
clean_returnvalue()
validate_context()
get_context_from_params()
__construct()
external_value:: (1 method):
__construct()
external_single_structure:: (1 method):
__construct()
external_multiple_structure:: (1 method):
__construct()
external_function_parameters:: (3 methods):
external_generate_token()
external_create_service_token()
external_delete_descriptions()
external_warnings:: (1 method):
__construct()
external_format_value:: (3 methods):
__construct()
external_validate_format()
external_format_text()
external_settings:: (11 methods):
__construct()
__clone()
get_instance()
set_raw()
get_raw()
set_filter()
get_filter()
set_fileurl()
get_fileurl()
set_file()
get_file()
Class: restricted_context_exception - X-Ref
Exception indicating user is not allowed to use external function in the current context.__construct() X-Ref |
Constructor |
Class: external_api - X-Ref
Base class for external api methods.set_context_restriction($context) X-Ref |
Set context restriction for all following subsequent function calls. param: stdClass $context the context restriction |
set_timeout($seconds=360) X-Ref |
This method has to be called before every operation that takes a longer time to finish! param: int $seconds max expected time the next operation needs |
validate_parameters(external_description $description, $params) X-Ref |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. This is a simple recursive method which is intended to be called from each implementation method of external API. param: external_description $description description of parameters param: mixed $params the actual parameters return: mixed params with added defaults for optional items, invalid_parameters_exception thrown if any problem found |
clean_returnvalue(external_description $description, $response) X-Ref |
Clean response If a response attribute is unknown from the description, we just ignore the attribute. If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values. author: 2010 Jerome Mouneyrac param: external_description $description description of the return values param: mixed $response the actual response return: mixed response with added defaults for optional items, invalid_response_exception thrown if any problem found |
validate_context($context) X-Ref |
Makes sure user may execute functions in this context. param: stdClass $context |
get_context_from_params($param) X-Ref |
Get context from passed parameters. The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid. See context_helper::get_all_levels() for a list of valid context levels. param: array $param return: context |
__construct($desc, $required, $default) X-Ref |
Contructor param: string $desc param: bool $required param: mixed $default |
Class: external_value - X-Ref
Scalar value description class__construct($type, $desc='', $required=VALUE_REQUIRED,$default=null, $allownull=NULL_ALLOWED) X-Ref |
Constructor param: mixed $type param: string $desc param: bool $required param: mixed $default param: bool $allownull |
Class: external_function_parameters - X-Ref
Description of top level - PHP function parameters.external_generate_token($tokentype, $serviceorid, $userid, $contextorid, $validuntil=0, $iprestriction='') X-Ref |
Generate a token author: 2010 Jamie Pratt param: string $tokentype EXTERNAL_TOKEN_EMBEDDED|EXTERNAL_TOKEN_PERMANENT param: stdClass|int $serviceorid service linked to the token param: int $userid user linked to the token param: stdClass|int $contextorid param: int $validuntil date when the token expired param: string $iprestriction allowed ip - if 0 or empty then all ips are allowed return: string generated token |
external_create_service_token($servicename, $context) 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: string $servicename name of the web service. Service name as defined in db/services.php param: int $context context within which the web service can operate. return: int returns token id. |
external_delete_descriptions($component) X-Ref |
Delete all pre-built services (+ related tokens) and external functions information defined in the specified component. param: string $component name of component (moodle, mod_assignment, etc.) |
Class: external_warnings - X-Ref
Standard Moodle web service warnings__construct($itemdesc = 'item', $itemiddesc = 'item id',$warningcodedesc = 'the warning code can be used by the client app to implement specific behaviour') X-Ref |
Constructor |
Class: external_format_value - X-Ref
A pre-filled external_value class for text format.__construct($textfieldname, $required = VALUE_REQUIRED) X-Ref |
Constructor param: string $textfieldname Name of the text field param: int $required if VALUE_REQUIRED then set standard default FORMAT_HTML |
external_validate_format($format) X-Ref |
Validate text field format against known FORMAT_XXX param: array $format the format to validate return: the validated format |
external_format_text($text, $textformat, $contextid, $component, $filearea, $itemid) 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 external_settings singleton All web service servers must set this singleton when parsing the $_GET and $_POST. param: string $text The content that may contain ULRs in need of rewriting. param: int $textformat The text format, by default FORMAT_HTML. param: int $contextid This parameter and the next two identify the file area to use. param: string $component param: string $filearea helps identify the file area. param: int $itemid helps identify the file area. return: array text + textformat |
Class: external_settings - X-Ref
Singleton to handle the external settings.__construct() X-Ref |
Constructor - protected - can not be instanciated |
__clone() X-Ref |
Clone - private - can not be cloned |
get_instance() X-Ref |
Return only one instance return: object |
set_raw($raw) X-Ref |
Set raw param: boolean $raw |
get_raw() X-Ref |
Get raw return: boolean |
set_filter($filter) X-Ref |
Set filter param: boolean $filter |
get_filter() X-Ref |
Get filter return: boolean |
set_fileurl($fileurl) X-Ref |
Set fileurl param: boolean $fileurl |
get_fileurl() X-Ref |
Get fileurl return: boolean |
set_file($file) X-Ref |
Set file param: string $file |
get_file() X-Ref |
Get file return: string |
external_function_info($function, $strictness=MUST_EXIST) X-Ref |
Returns detailed function information param: string|object $function name of external function or record from external_function param: int $strictness IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; return: stdClass description or false if not found or exception thrown |
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |