webservice MDL-17135 add disable javascript to the valid until fields
[moodle.git] / webservice / wsdoc.php
CommitLineData
fbe52a39 1<?php
2///////////////////////////////////////////////////////////////////////////
3// //
4// This file is part of Moodle - http://moodle.org/ //
5// Moodle - Modular Object-Oriented Dynamic Learning Environment //
6// //
7// Moodle is free software: you can redistribute it and/or modify //
8// it under the terms of the GNU General Public License as published by //
9// the Free Software Foundation, either version 3 of the License, or //
10// (at your option) any later version. //
11// //
12// Moodle is distributed in the hope that it will be useful, //
13// but WITHOUT ANY WARRANTY; without even the implied warranty of //
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
15// GNU General Public License for more details. //
16// //
17// You should have received a copy of the GNU General Public License //
18// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
19// //
20///////////////////////////////////////////////////////////////////////////
21
cc93c7da 22// TODO: this needs to be rewritten to use the new description format
23// the problem here is that the list of functions is different for each use or even token
24// I guess this should ne moved to server itself and it should require user auth
25die('TODO');
26
fbe52a39 27/**
28 * This file generate a web service documentation in HTML
29 * This documentation describe how to call a Moodle Web Service
30 */
31require_once('../config.php');
32require_once('lib.php');
33$protocol = optional_param('protocol',"soap",PARAM_ALPHA);
472f56d9 34$username = optional_param('username',"",PARAM_ALPHA);
35$password = optional_param('password',"",PARAM_ALPHA);
36
37/// TODO Retrieve user (authentication)
38$user = "";
fbe52a39 39
40/// PAGE settings
41$PAGE->set_course($COURSE);
42$PAGE->set_url('webservice/wsdoc.php');
43$PAGE->set_title(get_string('wspagetitle', 'webservice'));
44$PAGE->set_heading(get_string('wspagetitle', 'webservice'));
b7510c3a 45$PAGE->set_generaltype("form");
472f56d9 46
47// Display the documentation
fbe52a39 48echo $OUTPUT->header();
472f56d9 49generate_documentation($protocol); //documentation relatif to the protocol
50generate_functionlist($protocol, $user); //documentation relatif to the available function
fbe52a39 51echo $OUTPUT->footer();
52
53
472f56d9 54function generate_functionlist($protocol, $user) {
55
56 /// retrieve all function that the user can access
57 /// =>
58 /// retrieve all function that are available into enable services that
59 /// have (no restriction user or the user is into the restricted user list)
60 /// and (no required capability or the user has the required capability)
61
62 // do SQL request here
63
64 /// load once all externallib.php of the retrieved functions
65
66 /// foreach retrieved functions display the description
67
68 // in order to display the description we need to use an algo similar to the validation
69 // every time we get a scalar value, we need to convert it into a human readable value as
70 // PARAM_INT => 'integer' or PARAM_TEXT => 'string' or PARAM_BOOL => 'boolean' ...
71
72}
73
fbe52a39 74
75/**
76 * Generate documentation specific to a protocol
77 * @param string $protocol
78 */
79function generate_documentation($protocol) {
80 switch ($protocol) {
81
82 case "soap":
83 $documentation = get_string('soapdocumentation','webservice');
84 break;
85 case "xmlrpc":
86 $documentation = get_string('xmlrpcdocumentation','webservice');
87 break;
88 default:
89 break;
90 }
91 echo $documentation;
92 echo "<strong style=\"color:orange\">".get_string('wsuserreminder','webservice')."</strong>";
93
94}
95
96
fbe52a39 97/**
98 * Convert a Moodle type (PARAM_ALPHA, PARAM_NUMBER,...) as a SOAP type (string, interger,...)
99 * @param integer $moodleparam
100 * @return string SOAP type
101 */
102function converterMoodleParamIntoWsParam($moodleparam) {
103 switch ($moodleparam) {
104 case PARAM_NUMBER:
105 return "integer";
106 break;
107 case PARAM_INT:
108 return "integer";
109 break;
110 case PARAM_BOOL:
111 return "boolean";
112 break;
113 case PARAM_ALPHANUM:
114 return "string";
115 break;
b3d58bce 116 case PARAM_ALPHA:
fbe52a39 117 return "string";
118 break;
119 case PARAM_RAW:
120 return "string";
121 break;
122 case PARAM_ALPHANUMEXT:
123 return "string";
124 break;
125 case PARAM_NOTAGS:
126 return "string";
127 break;
128 case PARAM_TEXT:
129 return "string";
130 break;
fbe52a39 131 }
132}