. // // // /////////////////////////////////////////////////////////////////////////// // TODO: this needs to be rewritten to use the new description format // the problem here is that the list of functions is different for each use or even token // I guess this should be moved to server itself and it should require user auth, // SOAP does already support WSDL when parameters &wsdl=1 used die('TODO'); /** * This file generate a web service documentation in HTML * This documentation describe how to call a Moodle Web Service */ require_once('../config.php'); require_once('lib.php'); $protocol = optional_param('protocol',"soap",PARAM_ALPHA); $username = optional_param('username',"",PARAM_ALPHA); $password = optional_param('password',"",PARAM_ALPHA); /// TODO Retrieve user (authentication) $user = ""; /// PAGE settings $PAGE->set_course($COURSE); $PAGE->set_url('webservice/wsdoc.php'); $PAGE->set_title(get_string('wspagetitle', 'webservice')); $PAGE->set_heading(get_string('wspagetitle', 'webservice')); $PAGE->set_generaltype("form"); // Display the documentation echo $OUTPUT->header(); generate_documentation($protocol); //documentation relatif to the protocol generate_functionlist($protocol, $user); //documentation relatif to the available function echo $OUTPUT->footer(); function generate_functionlist($protocol, $user) { /// retrieve all function that the user can access /// => /// retrieve all function that are available into enable services that /// have (no restriction user or the user is into the restricted user list) /// and (no required capability or the user has the required capability) // do SQL request here /// load once all externallib.php of the retrieved functions /// foreach retrieved functions display the description // in order to display the description we need to use an algo similar to the validation // every time we get a scalar value, we need to convert it into a human readable value as // PARAM_INT => 'integer' or PARAM_TEXT => 'string' or PARAM_BOOL => 'boolean' ... } /** * Generate documentation specific to a protocol * @param string $protocol */ function generate_documentation($protocol) { switch ($protocol) { case "soap": $documentation = get_string('soapdocumentation','webservice'); break; case "xmlrpc": $documentation = get_string('xmlrpcdocumentation','webservice'); break; default: break; } echo $documentation; echo "".get_string('wsuserreminder','webservice').""; } /** * Convert a Moodle type (PARAM_ALPHA, PARAM_NUMBER,...) as a SOAP type (string, interger,...) * @param integer $moodleparam * @return string SOAP type */ function converterMoodleParamIntoWsParam($moodleparam) { switch ($moodleparam) { case PARAM_NUMBER: return "integer"; break; case PARAM_INT: return "integer"; break; case PARAM_BOOL: return "boolean"; break; case PARAM_ALPHANUM: return "string"; break; case PARAM_ALPHA: return "string"; break; case PARAM_RAW: return "string"; break; case PARAM_ALPHANUMEXT: return "string"; break; case PARAM_NOTAGS: return "string"; break; case PARAM_TEXT: return "string"; break; } }