diff --git a/group/external.php b/group/external.php
index 98a9dc3a82a..b1bf8f36ed0 100644
--- a/group/external.php
+++ b/group/external.php
@@ -43,14 +43,14 @@ final class group_external {
}
/**
- * add a group member
+ * Get a group member
* @param array $params
* @subparam integer $params->groupid
- * @return array $group
- * @subreturn integer $group->id
- * @subreturn integer $group->courseid
- * @subreturn string $group->name
- * @subreturn string $group->enrolmentkey
+ * @return array $return
+ * @subreturn integer $return->group->id
+ * @subreturn integer $return->group->courseid
+ * @subreturn string $return->group->name
+ * @subreturn string $return->group->enrolmentkey
*/
static function tmp_get_group($params){
@@ -97,7 +97,7 @@ final class group_external {
}
/**
- *
+ * Add a member to a group
* @param array $params
* @subparam integer $params->groupid
* @subparam integer $params->userid
diff --git a/lang/en_utf8/webservice.php b/lang/en_utf8/webservice.php
index 37a2f46080e..26533c54144 100644
--- a/lang/en_utf8/webservice.php
+++ b/lang/en_utf8/webservice.php
@@ -1,33 +1,39 @@
SOAP Manual
- 1. Call the method tmp_get_token on \"http://remotemoodle/webservice/soap/zend_soap_server.php?wsdl\"
- Function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")
+ 1. Call the method tmp_get_token on \"http://remotemoodle/webservice/soap/server.php?wsdl\"
+ The function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")
Return value is a token (integer)
- 2. Then call a moodle web service method on \"http://remotemoodle/webservice/soap/zend_soap_server.php?token=the_received_token&classpath=the_moodle_path&wsdl\"
+ 2. Then call a moodle web service method on \"http://remotemoodle/webservice/soap/server.php?token=the_received_token&classpath=the_moodle_path&wsdl\"
Every method has only one parameter which is an array.
For example in PHP for this specific function:
Moodle path: user
- tmp_delete_user( string username, integer mnethostid, )
+ tmp_delete_user( string username , integer mnethostid )
You will call something like:
your_client->tmp_delete_user(array(\"username\" => \"username_to_delete\",\"mnethostid\" => 1))
';
$string['xmlrpcdocumentation'] = '
XMLRPC Manual
- 1. Call the method authentication.tmp_get_token on \"http://remotemoodle/webservice/xmlrpc/zend_xmlrpc_server.php\"
- Function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")
+ 1. Call the method authentication.tmp_get_token on \"http://remotemoodle/webservice/xmlrpc/server.php\"
+ The function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")
Return value is a token (integer)
- 2. Then call a moodle web service method on \"http://remotemoodle/webservice/xmlrpc/zend_xmlrpc_server.php?classpath=the_moodle_path&token=the_received_token\"
+ 2. Then call a moodle web service method on \"http://remotemoodle/webservice/xmlrpc/server.php?classpath=the_moodle_path&token=the_received_token\"
Every method has only one parameter which is an array.
For example in PHP for this specific function:
Moodle path: user
- tmp_delete_user( string username, integer mnethostid, )
+ tmp_delete_user( string username , integer mnethostid )
You will call something like:
your_client->call(\"user.tmp_delete_user\", array(array(\"username\" => \"username_to_delete\",\"mnethostid\" => 1)))
';
$string['functionlist'] = 'list of web service functions';
$string['moodlepath'] = 'Moodle path';
+$string['wspagetitle'] = 'Web services documentation';
+$string['webservicesenable'] = 'Web services enable';
+$string['protocolenable'] = '$a[0] protocol enable';
+$string['ok'] = 'OK';
+$string['fail'] = 'FAIL';
+$string['wsuserreminder'] = 'Reminder: the Moodle administrator of this site needs to give you moodle/site:usewebservices capability.';
?>
diff --git a/user/external.php b/user/external.php
index 8f2db86772e..bae11f6a366 100644
--- a/user/external.php
+++ b/user/external.php
@@ -23,20 +23,20 @@ final class user_external {
* @subparam string $params:searches->search2 optional - the string to search
* @subparam string $params:searches->search3 - the string to search
* @subparam string $params:airport->planes:plane->company->employees:employee->name - name of a employee of a company of a plane of an airport
- * @return array users
- * @subreturn integer $users:user->id
- * @subreturn integer $users:user->auth
- * @subreturn integer $users:user->confirmed
- * @subreturn string $users:user->username
- * @subreturn string $users:user->idnumber
- * @subreturn string $users:user->firstname
- * @subreturn string $users:user->lastname
- * @subreturn string $users:user->email
- * @subreturn string $users:user->emailstop
- * @subreturn string $users:user->lang
- * @subreturn string $users:user->theme
- * @subreturn string $users:user->timezone
- * @subreturn string $users:user->mailformat
+ * @return array $return
+ * @subreturn integer $return:user->id
+ * @subreturn integer $return:user->auth
+ * @subreturn integer $return:user->confirmed
+ * @subreturn string $return:user->username
+ * @subreturn string $return:user->idnumber
+ * @subreturn string $return:user->firstname
+ * @subreturn string $return:user->lastname
+ * @subreturn string $return:user->email
+ * @subreturn string $return:user->emailstop
+ * @subreturn string $return:user->lang
+ * @subreturn string $return:user->theme
+ * @subreturn string $return:user->timezone
+ * @subreturn string $return:user->mailformat
*/
static function tmp_do_multiple_user_searches($params) {
global $USER;
@@ -59,20 +59,20 @@ final class user_external {
* Retrieve all user
* @param array|struct $params - need to be define as struct for XMLRPC
* @subparam string $params->search - the string to search
- * @return object users
- * @subreturn integer $users:user->id
- * @subreturn integer $users:user->auth
- * @subreturn integer $users:user->confirmed
- * @subreturn string $users:user->username
- * @subreturn string $users:user->idnumber
- * @subreturn string $users:user->firstname
- * @subreturn string $users:user->lastname
- * @subreturn string $users:user->email
- * @subreturn string $users:user->emailstop
- * @subreturn string $users:user->lang
- * @subreturn string $users:user->theme
- * @subreturn string $users:user->timezone
- * @subreturn string $users:user->mailformat
+ * @return array $return
+ * @subreturn integer $return:user->id
+ * @subreturn integer $return:user->auth
+ * @subreturn integer $return:user->confirmed
+ * @subreturn string $return:user->username
+ * @subreturn string $return:user->idnumber
+ * @subreturn string $return:user->firstname
+ * @subreturn string $return:user->lastname
+ * @subreturn string $return:user->email
+ * @subreturn string $return:user->emailstop
+ * @subreturn string $return:user->lang
+ * @subreturn string $return:user->theme
+ * @subreturn string $return:user->timezone
+ * @subreturn string $return:user->mailformat
*/
static function tmp_get_users($params) {
global $USER;
diff --git a/webservice/documentation.php b/webservice/documentation.php
index 29f3e072133..4e9a809662f 100644
--- a/webservice/documentation.php
+++ b/webservice/documentation.php
@@ -30,10 +30,41 @@
require_once('../config.php');
require_once('lib.php');
$protocol = optional_param('protocol',"soap",PARAM_ALPHA);
+
+print_header(get_string('wspagetitle','webservice'), get_string('wspagetitle','webservice').":", true);
+check_webservices($protocol);
generate_documentation($protocol);
generate_functionlist();
+print_footer();
+function check_webservices($protocol){
+ global $CFG;
+
+ echo get_string('webservicesenable','webservice').": ";
+ if (empty($CFG->enablewebservices)) {
+ echo "".get_string('fail','webservice')."";
+ } else {
+ echo "".get_string('ok','webservice')."";
+ }
+ echo "
";
+
+ foreach(webservice_lib::get_list_protocols() as $wsprotocol) {
+ if (strtolower($wsprotocol->get_protocolname()) == strtolower($protocol)) {
+ echo get_string('protocolenable','webservice',array($wsprotocol->get_protocolname())).": ";
+ if ( get_config($wsprotocol-> get_protocolname(), "enable")) {
+ echo "".get_string('ok','webservice')."";
+ } else {
+ echo "".get_string('fail','webservice')."";
+ }
+ echo "
";
+ continue;
+ }
+ }
+
+
+}
+
/**
*
* @param $protocol
@@ -51,6 +82,8 @@ function generate_documentation($protocol) {
break;
}
echo $documentation;
+ echo "".get_string('wsuserreminder','webservice')."";
+
}
@@ -75,42 +108,55 @@ function generate_functionlist () {
$classpath = str_replace('/','_',$classpath); //convert all / into _
$classname = $classpath."_external";
$api = new $classname();
- $documentation .= "".get_string('moodlepath','webservice').": ".$classpath."
";
+ $documentation .= "".get_string('moodlepath','webservice').": ".$classpath."
";
$description = webservice_lib::generate_webservice_description($file, $classname);
foreach ($description as $functionname => $functiondescription) {
$documentation .= <<{$functionname}(
+ - {$functionname}(
EOF;
$arrayparams = array();
+ $comma="";
foreach($functiondescription['params'] as $param => $type) {
- $documentation .= <<)
-EOF;
- foreach($functiondescription['params'] as $param => $type) {
- if (is_array($type)) {
- $arraytype = "".print_r($type, true)."
";
- $documentation .= <<) :
+EOF;
+ foreach($functiondescription['return'] as $return => $type) {
+ $documentation .= <<
+EOF;
+ }
+ foreach($functiondescription['params'] as $param => $type) {
+
+ if (is_array($type)) {
+ $arraytype = "".print_r($type, true)."
";
+ $documentation .= <<{$param} : {$arraytype}
EOF;
- }
-
- }
-
+ }
+
}
}
-
- echo $documentation;
-
+ $documentation .= <<
+EOF;
+
}
+ echo $documentation;
+
+}
+
/**
* Retrieve all external.php from Moodle
@@ -118,33 +164,33 @@ EOF;
* @param $directorypath
* @return boolean result true if n
*/
- function setListApiFiles( &$files, $directorypath )
- {
- if(is_dir($directorypath)){ //check that we are browsing a folder not a file
+function setListApiFiles( &$files, $directorypath )
+{
+ if(is_dir($directorypath)){ //check that we are browsing a folder not a file
- if( $dh = opendir($directorypath))
+ if( $dh = opendir($directorypath))
+ {
+ while( false !== ($file = readdir($dh)))
{
- while( false !== ($file = readdir($dh)))
- {
- if( $file == '.' || $file == '..') { // Skip '.' and '..'
- continue;
- }
- $path = $directorypath . '/' . $file;
- ///browse the subfolder
- if( is_dir($path) ) {
- setListApiFiles($files, $path);
- }
- ///retrieve api.php file
- else if ($file == "external.php") {
- $files[] = $path;
- }
+ if( $file == '.' || $file == '..') { // Skip '.' and '..'
+ continue;
+ }
+ $path = $directorypath . '/' . $file;
+ ///browse the subfolder
+ if( is_dir($path) ) {
+ setListApiFiles($files, $path);
+ }
+ ///retrieve api.php file
+ else if ($file == "external.php") {
+ $files[] = $path;
}
- closedir($dh);
-
}
+ closedir($dh);
+
}
}
+}
- ?>
+?>