--- /dev/null
+<?php
+/**
+ * Created on 05/03/2008
+ *
+ * users webservice api
+ *
+ * @author Jerome Mouneyrac
+ */
+require_once(dirname(dirname(__FILE__)) . '/lib/moodleexternal.php');
+require_once(dirname(dirname(__FILE__)) . '/user/api.php');
+
+/**
+ * WORK IN PROGRESS, DO NOT USE IT
+ */
+final class user_external extends moodle_external {
+
+ /**
+ * Constructor - We set the description of this API in order to be access by Web service
+ */
+ function __construct () {
+ $this->descriptions = array();
+ ///The desciption of the web service
+ ///
+ ///'wsparams' and 'return' are used to described the web services to the end user (can build WSDL file from these information)
+ ///
+ ///Note: web services param names have not importance. However 'paramorder' must match the function params order.
+ ///And all web services param names defined into 'wsparams' should be included into 'paramorder' (otherwise they will not be used)
+ $this->descriptions['tmp_create_user'] = array( 'wsparams' => array('username'=> PARAM_RAW, 'firstname'=> PARAM_RAW, 'lastname'=> PARAM_RAW, 'email'=> PARAM_RAW, 'password'=> PARAM_RAW),
+ 'return' => array('userid' => PARAM_RAW));
+
+ $this->descriptions['tmp_get_users'] = array( 'wsparams' => array('search'=> PARAM_ALPHANUM),
+ 'return' => array('user' => array('id' => PARAM_RAW, 'auth' => PARAM_RAW, 'confirmed' => PARAM_RAW, 'username' => PARAM_RAW, 'idnumber' => PARAM_RAW,
+ 'firstname' => PARAM_RAW, 'lastname' => PARAM_RAW, 'email' => PARAM_RAW, 'emailstop' => PARAM_RAW,
+ 'lang' => PARAM_RAW, 'theme' => PARAM_RAW, 'timezone' => PARAM_RAW, 'mailformat' => PARAM_RAW)));
+
+ $this->descriptions['tmp_delete_user'] = array( 'wsparams' => array('username'=> PARAM_ALPHANUM, 'mnethostid'=> PARAM_NUMBER),
+ 'return' => array('result' => PARAM_BOOL));
+
+ $this->descriptions['tmp_update_user'] = array( 'wsparams' => array('username'=> PARAM_ALPHANUM, 'mnethostid'=> PARAM_NUMBER, 'newusername' => PARAM_ALPHANUM, 'firstname' => PARAM_ALPHANUM),
+ 'return' => array('result' => PARAM_BOOL));
+ }
+
+ /**
+ * Retrieve all user
+ * @param string $search
+ * @return object user
+ */
+ static function tmp_get_users($search) {
+ $selectioncriteria = new stdClass();
+ $selectioncriteria->search = $search;
+ return user_api::tmp_get_users('firstname ASC', 999999, 0, 'id, auth, confirmed, username, idnumber, firstname, lastname, email, emailstop, lang, theme, timezone, mailformat', $selectioncriteria);
+ }
+
+ /**
+ * Create a user
+ * @param string $username
+ * @param string $firstname
+ * @param string $lastname
+ * @param string $email
+ * @param string $password
+ * @return integer id of new user
+ */
+ static function tmp_create_user($username, $firstname, $lastname, $email, $password) {
+ $user = array();
+ $user['username'] = $username;
+ $user['firstname'] = $firstname;
+ $user['lastname'] = $lastname;
+ $user['email'] = $email;
+ $user['password'] = $password;
+ return user_api::tmp_create_user($user);
+ }
+
+ /**
+ * Delete a user
+ * @global object $DB
+ * @param string $username
+ * @param integer $mnethostid
+ * @return boolean true if success
+ */
+ static function tmp_delete_user($username, $mnethostid) {
+ global $DB;
+ $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$mnethostid));
+ /// PLEASE UNCOMMENT HERE ONCE AUTHENTICATION IS IMPLEMENTED - $USER/context need to be set here
+ //if (require_capability('moodle/user:delete', get_context_instance(CONTEXT_SYSTEM))) {
+ return delete_user($user); //this function is in moodlelib.php
+ //}
+ //else {
+ // throw new moodle_exception('couldnotdeleteuser');
+ //}
+ }
+
+ /**
+ * Update some user information
+ * @global object $DB
+ * @param string $username
+ * @param integer $mnethostid
+ * @param string $newusername
+ * @param string $firstname
+ * @return boolean true if success
+ */
+ static function tmp_update_user($username, $mnethostid, $newusername, $firstname) {
+ global $DB;
+ $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$mnethostid));
+ $user->username = $newusername;
+ $user->firstname = $firstname;
+
+ return user_api::tmp_update_user($user);
+ }
+
+}
+
+?>
<?xml version ='1.0' encoding ='UTF-8' ?>
- <definitions name='User'
- targetNamespace='http://example.org/User'
- xmlns:tns=' http://example.org/User '
- xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
- xmlns:xsd='http://www.w3.org/2001/XMLSchema'
- xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
- xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
- xmlns='http://schemas.xmlsoap.org/wsdl/'>
-
- <types>
- <xsd:schema
- targetNamespace="http://example.org/User"
- xmlns="http://www.w3.org/2001/XMLSchema">
- <xsd:complexType name="user">
- </xsd:complexType>
- </xsd:schema>
- </types>
-
-
- <message name='getusersRequest'>
- <part name='search' type='xsd:string'/>
+ <definitions name='User'
+ targetNamespace='http://example.org/User'
+ xmlns:tns=' http://example.org/User '
+ xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
+ xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+ xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
+ xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
+ xmlns='http://schemas.xmlsoap.org/wsdl/'>
+
+ <types>
+ <xsd:schema targetNamespace="http://example.org/User"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <xsd:complexType name="object">
+ </xsd:complexType>
+ </xsd:schema>
+ </types>
+
+ <message name="tmp_get_usersRequest">
+ <part name="search" type="xsd:string"/>
+ </message>
+ <message name="tmp_get_usersResponse">
+ <part name="user" type="xsd:object"/>
</message>
- <message name='getusersResponse'>
- <part name='user' type='xsd:user'/>
+ <message name="tmp_create_userRequest">
+ <part name="username" type="xsd:string"/>
+ <part name="firstname" type="xsd:string"/>
+
+ <part name="lastname" type="xsd:string"/>
+ <part name="email" type="xsd:string"/>
+ <part name="password" type="xsd:string"/>
+ </message>
+ <message name="tmp_create_userResponse">
+ <part name="userid" type="xsd:string"/>
</message>
- <message name='createuserRequest'>
- <part name='username' type='xsd:string'/>
- <part name='firstname' type='xsd:string'/>
- <part name='lastname' type='xsd:string'/>
- <part name='email' type='xsd:string'/>
- <part name='password' type='xsd:string'/>
+ <message name="tmp_namedparams_get_usersRequest">
+ <part name="search" type="xsd:string"/>
+
</message>
- <message name='createuserResponse'>
- <part name='useris' type='xsd:string'/>
+ <message name="tmp_namedparams_get_usersResponse">
+ <part name="user" type="xsd:object"/>
</message>
- <message name='deleteuserRequest'>
- <part name='username' type='xsd:string'/>
- <part name='mnethostid' type='xsd:string'/>
+ <message name="tmp_delete_userRequest">
+ <part name="username" type="xsd:string"/>
+ <part name="mnethostid" type="xsd:integer"/>
</message>
- <message name='deleteuserResponse'>
- <part name='result' type='xsd:integer'/>
+ <message name="tmp_delete_userResponse">
+
+ <part name="result" type="xsd:object"/>
</message>
- <message name='updateuserRequest'>
- <part name='username' type='xsd:string'/>
- <part name='mnethostid' type='xsd:string'/>
- <part name='newusername' type='xsd:string'/>
- <part name='firstname' type='xsd:string'/>
+ <message name="tmp_update_userRequest">
+ <part name="username" type="xsd:string"/>
+ <part name="mnethostid" type="xsd:integer"/>
+ <part name="newusername" type="xsd:string"/>
+ <part name="firstname" type="xsd:string"/>
</message>
- <message name='updateuserResponse'>
- <part name='result' type='xsd:integer'/>
+ <message name="tmp_update_userResponse">
+
+ <part name="result" type="xsd:object"/>
</message>
+ <portType name='userPortType'>
+ <operation name='tmp_get_users'>
+ <input message='tns:tmp_get_usersRequest'/>
+ <output message='tns:tmp_get_usersResponse'/>
+ </operation>
+
+ <operation name='tmp_create_user'>
+
+ <input message='tns:tmp_create_userRequest'/>
+ <output message='tns:tmp_create_userResponse'/>
+ </operation>
+
+ <operation name='tmp_namedparams_get_users'>
+ <input message='tns:tmp_namedparams_get_usersRequest'/>
+ <output message='tns:tmp_namedparams_get_usersResponse'/>
+ </operation>
+
+ <operation name='tmp_delete_user'>
- <portType name='UserPortType'>
- <operation name='tmp_get_users'>
- <input message='tns:getusersRequest'/>
- <output message='tns:getusersResponse'/>
- </operation>
- <operation name='tmp_create_user'>
- <input message='tns:createuserRequest'/>
- <output message='tns:createuserResponse'/>
- </operation>
- <operation name='tmp_delete_user'>
- <input message='tns:deleteuserRequest'/>
- <output message='tns:deleteuserResponse'/>
- </operation>
- <operation name='tmp_update_user'>
- <input message='tns:updateuserRequest'/>
- <output message='tns:updateuserResponse'/>
- </operation>
+ <input message='tns:tmp_delete_userRequest'/>
+ <output message='tns:tmp_delete_userResponse'/>
+ </operation>
+
+ <operation name='tmp_update_user'>
+ <input message='tns:tmp_update_userRequest'/>
+ <output message='tns:tmp_update_userResponse'/>
+ </operation>
</portType>
- <binding name='UserBinding' type='tns:UserPortType'>
- <soap:binding style='rpc'
- transport='http://schemas.xmlsoap.org/soap/http'/>
- <operation name='tmp_get_users'>
- <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_get_users'/>
- <input>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </input>
- <output>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </output>
- </operation>
- <operation name='tmp_create_user'>
- <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_create_user'/>
- <input>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </input>
- <output>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </output>
- </operation>
- <operation name='tmp_delete_user'>
- <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_delete_user'/>
- <input>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </input>
- <output>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </output>
- </operation>
- <operation name='tmp_update_user'>
- <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_update_user'/>
- <input>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </input>
- <output>
- <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
- encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
- </output>
- </operation>
+ <binding name='userBinding' type='tns:userPortType'>
+ <soap:binding style='rpc'
+ transport='http://schemas.xmlsoap.org/soap/http'/>
+
+ <operation name='tmp_get_users'>
+ <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_get_users'/>
+ <input>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </input>
+ <output>
+
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </output>
+ </operation>
+
+ <operation name='tmp_create_user'>
+ <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_create_user'/>
+ <input>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </input>
+
+ <output>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </output>
+ </operation>
+
+ <operation name='tmp_namedparams_get_users'>
+ <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_namedparams_get_users'/>
+ <input>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+
+ </input>
+ <output>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </output>
+ </operation>
+
+ <operation name='tmp_delete_user'>
+ <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_delete_user'/>
+ <input>
+
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </input>
+ <output>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </output>
+ </operation>
+
+ <operation name='tmp_update_user'>
+ <soap:operation soapAction='urn:xmethods-delayed-quotes#tmp_update_user'/>
+
+ <input>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </input>
+ <output>
+ <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
+ encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </output>
+ </operation>
</binding>
- <service name='UserService'>
- <port name='UserPort' binding='UserBinding'>
- <soap:address location='http://jerome.moodle.com/Moodle_HEAD/moodle/webservice/soap/server.php?classpath=user'/>
- </port>
+ <service name='userService'>
+ <port name='userPort' binding='userBinding'>
+ <soap:address location='http://jerome.moodle.com/Moodle_HEAD/moodle/webservice/soap/server.php?classpath=user'/>
+ </port>
</service>
- </definitions>
\ No newline at end of file
+ </definitions>