Skip to content

Commit

Permalink
web service MDL-12886
Browse files Browse the repository at this point in the history
* Remove description array => all these information are now into the phpdoc. Remove all call/reference to moodleexternal.php
* Adapt our own REST server to these changes
* Remove Zend REST server as it's going to be deprecated in Zend Framework 1.8
* Remove our own SOAP server as we use the Zend SOAP server
  • Loading branch information
jerome committed Feb 24, 2009
1 parent 60cd5b5 commit 40f024c
Show file tree
Hide file tree
Showing 17 changed files with 457 additions and 835 deletions.
13 changes: 10 additions & 3 deletions group/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @author Ferran Recio
*/

require_once(dirname(dirname(__FILE__)) . '/lib/moodleexternal.php');
require_once(dirname(dirname(__FILE__)) . '/group/lib.php');
require_once(dirname(dirname(__FILE__)) . '/lib/grouplib.php');

Expand All @@ -18,11 +17,12 @@
*
* WORK IN PROGRESS, DO NOT USE IT
*/
final class group_external extends moodle_external {
final class group_external {

/**
* Constructor - We set the description of this API in order to be access by Web service
*/
/*
function __construct () {
$this->descriptions = array();
Expand All @@ -47,7 +47,7 @@ function __construct () {
'optionalparams' => array( ),
'return' => array('result' => PARAM_BOOL));
}
}*/

/**
* Creates a group
Expand All @@ -72,6 +72,13 @@ static function tmp_create_group($params) {
}
}

/**
* add a group member
* @param array $params
* ->groupid int
* ->userid int
* @return boolean success
*/
static function tmp_get_group($params){

// @TODO: any capability to check?
Expand Down
110 changes: 53 additions & 57 deletions user/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,38 @@
*
* @author Jerome Mouneyrac
*/
require_once(dirname(dirname(__FILE__)) . '/lib/moodleexternal.php');
require_once(dirname(dirname(__FILE__)) . '/user/lib.php');

/**
* WORK IN PROGRESS, DO NOT USE IT
*/
final class user_external extends moodle_external {
final class user_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( 'params' => array('username'=> PARAM_RAW, 'firstname'=> PARAM_RAW, 'lastname'=> PARAM_RAW, 'email'=> PARAM_RAW, 'password'=> PARAM_RAW),
'optionalparams' => array( ),
'return' => array('userid' => PARAM_RAW));

$this->descriptions['tmp_get_users'] = array( 'params' => array('search'=> PARAM_ALPHANUM),
'optionalparams' => array( ),
'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( 'params' => array('username'=> PARAM_ALPHANUM, 'mnethostid'=> PARAM_NUMBER),
'optionalparams' => array( ),
'return' => array('result' => PARAM_BOOL));

$this->descriptions['tmp_update_user'] = array( 'params' => array('username'=> PARAM_ALPHANUM, 'mnethostid'=> PARAM_NUMBER),
'optionalparams' => array( 'newusername' => PARAM_ALPHANUM, 'firstname' => PARAM_ALPHANUM),
'return' => array('result' => PARAM_BOOL));

$this->descriptions['tmp_do_multiple_user_searches'] = array( 'params' => array(array('search'=> PARAM_RAW)),
'optionalparams' => array( ),
'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 docblock has a right syntax but it does not match the real function parameters - except @ param and @ return
* I just keep it for a while till we implement a real ws function using complex blockdoc syntax as this one
* Understand, this dockblock is a example...
* @global object $USER
* @param array|struct $params
* @return array
* @subparam string $params:searches->search - the string to search
* @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
*/

static function tmp_do_multiple_user_searches($params) {
global $USER;
if (has_capability('moodle/user:viewdetails', get_context_instance(CONTEXT_SYSTEM))) {
Expand All @@ -79,11 +58,27 @@ static function tmp_do_multiple_user_searches($params) {
/**
* Retrieve all user
* @param array|struct $params - need to be define as struct for XMLRPC
* ->search string
* @return object user
* @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
*/
static function tmp_get_users($params) {
global $USER;

$params['search'] = clean_param($params['search'], PARAM_ALPHANUM);

if (has_capability('moodle/user:viewdetails', get_context_instance(CONTEXT_SYSTEM))) {
// return "toto";
return get_users(true, $params['search'], false, null, 'firstname ASC','', '', '', 1000, 'id, auth, confirmed, username, idnumber, firstname, lastname, email, emailstop, lang, theme, timezone, mailformat');
Expand All @@ -96,10 +91,11 @@ static function tmp_get_users($params) {
/**
* Create a user
* @param array|struct $params - need to be define as struct for XMLRPC
* ->firstname string
* ->lastname string
* ->email string
* ->password string
* @subparam string $params->username
* @subparam string $params->firstname
* @subparam string $params->lastname
* @subparam string $params->email
* @subparam string $params->password
* @return integer id of new user
*/
static function tmp_create_user($params) {
Expand All @@ -122,9 +118,9 @@ static function tmp_create_user($params) {
* Delete a user
* @global object $DB
* @param array|struct $params - need to be define as struct for XMLRPC
* ->username string
* ->mnethostid integer
* @return boolean true if success
* @subparam string $params->username
* @subparam integer $params->mnethostid
* @return boolean result true if success
*/
static function tmp_delete_user($params) {
global $DB,$USER;
Expand All @@ -142,11 +138,11 @@ static function tmp_delete_user($params) {
* Update some user information
* @global object $DB
* @param array|struct $params - need to be define as struct for XMLRPC
* ->username string
* ->mnethostid integer
* ->newusername string
* ->firstname string
* @return string true if success
* @subparam string $params->username
* @subparam integer $params->mnethostid
* @subparam string $params->newusername
* @subparam string $params->firstname
* @return boolean result true if success
*/
static function tmp_update_user($params) {
global $DB,$USER;
Expand Down
Loading

0 comments on commit 40f024c

Please sign in to comment.