Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

-----XML-Envelope--------------------------------- |                                                | |    Encrypted-Symmetric-key----------------     | |    |_____________________________________|     | |                                                | |    Encrypted data-------------------------     | |    |                                     |     | |    |  -XML-Envelope------------------    |     | |    |  |                             |    |     | |    |  |  --Signature-------------   |    |     | |    |  |  |______________________|   |    |     | |    |  |                             |    |     | |    |  |  --Signed-Payload--------   |    |     | |    |  |  |                      |   |    |     | |    |  |  |   XML-RPC Request    |   |    |     | |    |  |  |______________________|   |    |     | |    |  |                             |    |     | |    |  |_____________________________|    |     | |    |_____________________________________|     | |                                                | |________________________________________________|

File Size: 680 lines (27 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

mnet_server_exception:: (1 method):
  __construct()

Defines 1 function


Class: mnet_server_exception  - X-Ref

mnet server exception.  extends moodle_exception, but takes slightly different arguments.
and unlike the rest of moodle, the actual int error code is used.
this exception should only be used during an xmlrpc server request, ie, not for client requests.

__construct($intcode, $languagekey, $module='mnet', $a=null)   X-Ref

param: int    $intcode      the numerical error associated with this fault.  this is <b>not</b> the string errorcode
param: string $langkey      the error message in full (<b>get_string will not be used</b>)
param: string $module       the language module, defaults to 'mnet'
param: mixed  $a            params for get_string

Functions that are not part of a class:

mnet_server_strip_encryption($rawpostdata)   X-Ref
No description

mnet_server_strip_signature($plaintextmessage)   X-Ref
No description

mnet_server_fault($code, $text, $param = null)   X-Ref
Return the proper XML-RPC content to report an error in the local language.

return: string $text   The text of the error message
param: int    $code   The ID code of the error message
param: string $text   The full string of the error message (get_string will <b>not be called</b>)
param: string $param  The $a param for the error message in the lang file

mnet_server_fault_xml($code, $text, $privatekey = null)   X-Ref
Return the proper XML-RPC content to report an error.

return: string   $text   The XML text of the error message
param: int      $code   The ID code of the error message
param: string   $text   The error message
param: resource $privatekey The private key that should be used to sign the response

mnet_server_prepare_response($response, $privatekey = null)   X-Ref
Package a response in any required envelope, and return it to the client

return: string                  The encoded response string
param: string   $response      The XMLRPC response string
param: resource $privatekey    The private key to sign the response with

mnet_server_dispatch($payload)   X-Ref
If security checks are passed, dispatch the request to the function/method

The config variable 'mnet_dispatcher_mode' can be:
strict:      Only execute functions that are in specific files
off:         The default - don't execute anything

return: No return val - just echo the response
param: string  $payload    The XML-RPC request

mnet_system($method, $params, $hostinfo)   X-Ref
Execute the system functions - mostly for introspection

return: mixed              Response data - any kind of PHP variable
param: string  $method    XMLRPC method name, e.g. system.listMethods
param: array   $params    Array of parameters from the XMLRPC request
param: string  $hostinfo  Hostinfo object from the mnet_host table

mnet_server_invoke_plugin_method($method, $callstack, $rpcrecord, $payload)   X-Ref
Invoke a normal style plugin method
This will verify permissions first.

return: mixed the response from the invoked method
param: string   $method the full xmlrpc method that was called eg auth/mnet/auth.php/user_authorise
param: array    $callstack  the exploded callstack
param: stdclass $rpcrecord  the record from mnet_rpc

mnet_server_invoke_dangerous_method($includefile, $methodname, $method, $payload)   X-Ref
Initialize the object (if necessary), execute the method or function, and
return the response

return: string                  The XML-RPC response
param: string  $includefile    The file that contains the object definition
param: string  $methodname     The name of the method to execute
param: string  $method         The full path to the method
param: string  $payload        The XML-RPC request payload
param: string  $class          The name of the class to instantiate (or false)

mnet_keyswap($function, $params)   X-Ref
Accepts a public key from a new remote host and returns the public key for
this host. If 'register all hosts' is turned on, it will bootstrap a record
for the remote host in the mnet_host table (if it's not already there)

return: string                 The XML-RPC response
param: string  $function      XML-RPC requires this but we don't... discard!
param: array   $params        Array of parameters

mnet_verify_permissions($rpcrecord)   X-Ref
Verify that the requested xmlrpc method can be called
This just checks the method exists in the rpc table and is enabled.

param: stdclass $rpcrecord  the record from mnet_rpc

mnet_setup_dummy_method($method, $callstack, $rpcrecord)   X-Ref
Figure out exactly what needs to be called and stashes it in $remoteclient
Does some further verification that the method is callable

param: string   $method the full xmlrpc method that was called eg auth/mnet/auth.php/user_authorise
param: array    $callstack  the exploded callstack
param: stdclass $rpcrecord  the record from mnet_rpc

mnet_server_dummy_method($methodname, $argsarray, $functionname)   X-Ref
Dummy function for the XML-RPC dispatcher - use to call a method on an object
or to call a function

Translate XML-RPC's strange function call syntax into a more straightforward
PHP-friendly alternative. This dummy function will be called by the
dispatcher, and can be used to call a method on an object, or just a function

The methodName argument (eg. mnet/testlib/mnet_concatenate_strings)
is ignored.

return: mixed                   The return value will be that of the real
param: string  $methodname     We discard this - see 'functionname'
param: array   $argsarray      Each element is an argument to the real
param: string  $functionname   The name of the PHP function you want to call