Web services cleanup

skala
Guillaume Viguier 15 years ago
parent e4ecae4829
commit c939e4d14d
  1. 4
      main/inc/lib/add_course.lib.inc.php
  2. 41
      main/inc/lib/course.lib.php
  3. 18
      main/inc/lib/usermanager.lib.php
  4. 102
      main/webservices/soap.php
  5. 210
      main/webservices/soap_user.php
  6. 218
      main/webservices/webservice.php
  7. 291
      main/webservices/webservice_course.php
  8. 418
      main/webservices/webservice_user.php
  9. 10
      tests/test_webservices.php

@ -28,7 +28,7 @@ require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
* @param integer Course admin ID
* @param string DB prefix
* @param integer Expiration delay in unix timestamp
* @return true if the course creation was succesful, false otherwise.
* @return mixed Course code if course was successfully created, false otherwise
*/
function create_course($wanted_code, $title, $tutor_name, $category_code, $course_language, $course_admin_id, $db_prefix, $firstExpirationDelay) {
$keys = define_course_keys($wanted_code, "", $db_prefix);
@ -46,7 +46,7 @@ function create_course($wanted_code, $title, $tutor_name, $category_code, $cours
fill_Db_course($db_name, $directory, $course_language);
register_course($code, $visual_code, $directory, $db_name, $tutor_name, $category_code, $title, $course_language, $course_admin_id, $expiration_date);
return true;
return $code;
}
else
return false;

@ -1989,6 +1989,47 @@ class CourseManager {
return Database::insert_id();
}
/**
* Updates course attribute. Note that you need to check that your attribute is valid before you use this function
*
* @param int Course id
* @param string Attribute name
* @param string Attribute value
* @return bool True if attribute was successfully updated, false if course was not found or attribute name is invalid
*/
public static function update_attribute($id, $name, $value) {
$id = (int)$id;
$table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "UPDATE $table SET $name = '".Database::escape_string($value)."' WHERE id = '$id';";
return Database::query($sql);
}
/**
* Update course attributes. Will only update attributes with a non-empty value. Note that you NEED to check that your attributes are valid before using this function
*
* @param int Course id
* @param array Associative array with field names as keys and field values as values
* @return bool True if update was successful, false otherwise
*/
public static function update_attributes($id, $attributes) {
$id = (int)$id;
$table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "UPDATE $table SET ";
$i = 0;
foreach($attributes as $name => $value) {
if(!empty($value)) {
if($i > 0) {
$sql .= ", ";
}
$sql .= " $name = '".Database::escape_string($value)."'";
$i++;
}
}
$sql .= " WHERE id = '$id';";
return Database::query($sql);
}
/**
* Update an extra field value for a given course

@ -331,7 +331,7 @@ class UserManager
* @param array A series of additional fields to add to this user as extra fields (optional, defaults to null)
* @return boolean true if the user information was updated
*/
public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english') {
public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '') {
global $userPasswordCrypted;
if ($user_id != strval(intval($user_id))) return false;
if ($user_id === false) return false;
@ -343,7 +343,19 @@ class UserManager
language='".Database::escape_string($language)."',";
if (!is_null($password)) {
//$password = $userPasswordCrypted ? md5($password) : $password;
$password = api_get_encrypted_password($password);
if($encrypt_method == '') {
$password = api_get_encrypted_password($password);
} else {
if ($userPasswordCrypted === $encrypt_method ) {
if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
return api_set_failure('encrypt_method invalid');
} else if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
return api_set_failure('encrypt_method invalid');
}
} else {
return api_set_failure('encrypt_method invalid');
}
}
$sql .= " password='".Database::escape_string($password)."',";
}
if (!is_null($auth_source)) {
@ -366,7 +378,7 @@ class UserManager
if (is_array($extra) && count($extra) > 0) {
$res = true;
foreach($extra as $fname => $fvalue) {
$res = $res && self::update_extra_field($user_id,$fname,$fvalue);
$res = $res && self::update_extra_field_value($user_id,$fname,$fvalue);
}
}
return $return;

@ -10,93 +10,71 @@ require_once $libpath.'nusoap/nusoap.php';
*/
class WSSoapErrorHandler implements WSErrorHandler {
/**
* SOAP server
* Handles the error by sending a SOAP fault through the server
*
* @param WSError Error to handle
*/
public function handle($error) {
$server = WSSoapServer::singleton();
$server->fault(strval($error->code), $error->message);
}
}
/**
* SOAP server wrapper implementing a Singleton
*/
class WSSoapServer {
/**
* SOAP server instance
*
* @var soap_server
*/
protected $_server;
private static $_instance;
/**
* Constructor
* Private constructor
*/
public function __construct($server) {
$this->_server = $server;
private function __construct() {
}
/**
* Handles the error by sending a SOAP fault through the server
*
* @param WSError Error to handle
* Singleton method
*/
public function handle($error) {
$this->_server->fault(strval($error->code), $error->message);
public static function singleton() {
if(!isset(self::$_instance)) {
self::$_instance = new soap_server();
// Set the error handler
WSError::setErrorHandler(new WSSoapErrorHandler());
// Configure the service
self::$_instance->configureWSDL('WSService', 'urn:WSService');
}
return self::$_instance;
}
}
$s = new soap_server();
$error_handler = new WSSoapErrorHandler($s);
WSError::setErrorHandler($error_handler);
// Initialize WSDL support
$s->configureWSDL('WSService', 'urn:WSService');
$s->register(
'WS.test',
array(),
array('return' => 'xsd:string')
);
$s->register(
'WS.DisableUser',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_field_value' => 'xsd:string')
);
$s->register(
'WS.EnableUser',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_field_value' => 'xsd:string')
);
$s->register(
'WS.DeleteUser',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_field_value' => 'xsd:string')
);
$s = WSSoapServer::singleton();
$s->wsdl->addComplexType(
'extra_field',
'result',
'complexType',
'struct',
'all',
'',
array(
'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
'code' => array('name' => 'code', 'type' => 'xsd:int'),
'message' => array('name' => 'message', 'type' => 'xsd:string')
)
);
$s->register(
'WS.CreateUser',
array(
'secret_key' => 'xsd:string',
'firstname' => 'xsd:string',
'lastname' => 'xsd:string',
'status' => 'xsd:int',
'loginname' => 'xsd:string',
'password' => 'xsd:string',
'encrypt_method' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'visibility' => 'xsd:int',
'email' => 'xsd:string',
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:extra_field[]'
),
array('return' => 'xsd:int')
'WS.test',
array(),
array('return' => 'xsd:string')
);
require_once(dirname(__FILE__).'/soap_user.php');
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$s->service($HTTP_RAW_POST_DATA);

@ -0,0 +1,210 @@
<?php
require_once(dirname(__FILE__).'/webservice_user.php');
require_once(dirname(__FILE__).'/soap.php');
/**
* Configures the WSUser SOAP service
*/
$s = WSSoapServer::singleton();
$s->wsdl->addComplexType(
'user_id',
'complexType',
'struct',
'all',
'',
array(
'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string')
)
);
$s->wsdl->addComplexType(
'user_result',
'complexType',
'struct',
'all',
'',
array(
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
);
$s->register(
'WSUser.DisableUser',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string')
);
$s->register(
'WSUser.DisableUsers',
array('secret_key' => 'xsd:string', 'users' => 'tns:user_id[]'),
array('return' => 'tns:user_result[]')
);
$s->register(
'WSUser.EnableUser',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string')
);
$s->register(
'WSUser.EnableUsers',
array('secret_key' => 'xsd:string', 'users' => 'tns:user_id[]'),
array('return' => 'tns:user_result[]')
);
$s->register(
'WSUser.DeleteUser',
array('secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', 'user_id_value' => 'xsd:string')
);
$s->register(
'WSUser.DeleteUsers',
array('secret_key' => 'xsd:string', 'users' => 'tns:user_id[]'),
array('return' => 'tns:user_result[]')
);
$s->wsdl->addComplexType(
'user_extra_field',
'complexType',
'struct',
'all',
'',
array(
'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'),
'field_value' => array('name' => 'field_value', 'type' => 'xsd:string')
)
);
$s->register(
'WSUser.CreateUser',
array(
'secret_key' => 'xsd:string',
'firstname' => 'xsd:string',
'lastname' => 'xsd:string',
'status' => 'xsd:int',
'loginname' => 'xsd:string',
'password' => 'xsd:string',
'encrypt_method' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'visibility' => 'xsd:int',
'email' => 'xsd:string',
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:user_extra_field[]'
),
array('return' => 'xsd:int')
);
$s->wsdl->addComplexType(
'user_create',
'complexType',
'struct',
'all',
'',
array(
'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'),
'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'),
'status' => array('name' => 'status', 'type' => 'xsd:int'),
'loginname' => array('name' => 'loginname', 'type' => 'xsd:string'),
'password' => array('name' => 'password', 'type' => 'xsd:string'),
'encrypt_method' => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'),
'email' => array('name' => 'email', 'type' => 'xsd:string'),
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'phone' => array('name' => 'phone', 'type' => 'xsd:string'),
'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'),
'extras' => array('name' => 'extras', 'type' => 'tns:user_extra_field[]')
)
);
$s->wsdl->addComplexType(
'user_create_result',
'complexType',
'struct',
'all',
'',
array(
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
'user_id_generated' => array('name' => 'user_id_generated', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
);
$s->register(
'WSUser.CreateUsers',
array(
'secret_key' => 'xsd:string',
'users' => 'tns:user_create[]'
),
array('return' => 'tns:user_create_result[]')
);
$s->register(
'WSUser.EditUser',
array(
'secret_key' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'firstname' => 'xsd:string',
'lastname' => 'xsd:string',
'status' => 'xsd:int',
'loginname' => 'xsd:string',
'password' => 'xsd:string',
'encrypt_method' => 'xsd:string',
'email' => 'xsd:string',
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:user_extra_field[]'
)
);
$s->wsdl->addComplexType(
'user_edit',
'complexType',
'struct',
'all',
'',
array(
'user_id_field_name' => array('name' => 'user_id_field_name', 'type' => 'xsd:string'),
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'),
'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'),
'status' => array('name' => 'status', 'type' => 'xsd:int'),
'loginname' => array('name' => 'loginname', 'type' => 'xsd:string'),
'password' => array('name' => 'password', 'type' => 'xsd:string'),
'encrypt_method' => array('name' => 'encrypt_method', 'type' => 'xsd:string'),
'email' => array('name' => 'email', 'type' => 'xsd:string'),
'language' => array('name' => 'language', 'type' => 'xsd:string'),
'phone' => array('name' => 'phone', 'type' => 'xsd:string'),
'expiration_date' => array('name' => 'expiration_date', 'type' => 'xsd:string'),
'extras' => array('name' => 'extras', 'type' => 'tns:user_extra_field[]')
)
);
$s->wsdl->addComplexType(
'user_edit_result',
'complexType',
'struct',
'all',
'',
array(
'user_id_value' => array('name' => 'user_id_value', 'type' => 'xsd:string'),
'result' => array('name' => 'result', 'type' => 'tns:result')
)
);
$s->register(
'WSUser.EditUsers',
array(
'secret_key' => 'xsd:string',
'users' => 'tns:user_edit[]'
),
array('return' => 'tns:user_edit_result[]')
);

@ -1,7 +1,8 @@
<?php
require '../inc/global.inc.php';
require_once(dirname(__FILE__).'/../inc/global.inc.php');
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath.'usermanager.lib.php';
require_once $libpath.'course.lib.php';
/**
* Error returned by one of the methods of the web service. Contains an error code and an error message
@ -58,6 +59,15 @@ class WSError {
public static function getErrorHandler() {
return self::$_handler;
}
/**
* Transforms the error into an array
*
* @return array Associative array with code and message
*/
public function toArray() {
return array('code' => $this->code, 'message' => $this->message);
}
}
/**
@ -73,9 +83,22 @@ interface WSErrorHandler {
}
/**
* Main class of the webservice
* Main class of the webservice. Webservice classes extend this class
*/
class WS {
/**
* Chamilo configuration
*
* @var array
*/
protected $_configuration;
/**
* Constructor
*/
public function __construct() {
$this->_configuration = $GLOBALS['_configuration'];
}
/**
* Verifies the API key
@ -84,9 +107,7 @@ class WS {
* @return mixed WSError in case of failure, null in case of success
*/
protected function verifyKey($secret_key) {
global $_configuration;
$security_key = $_SERVER['REMOTE_ADDR'].$_configuration['security_key'];
$security_key = $_SERVER['REMOTE_ADDR'].$this->_configuration['security_key'];
if(!api_is_valid_secret_key($secret_key, $security_key)) {
return new WSError(1, "API key is invalid");
@ -108,12 +129,12 @@ class WS {
if(UserManager::is_user_id_valid(intval($user_id_value))) {
return intval($user_id_value);
} else {
return new WSError(2, "User was not found");
return new WSError(100, "User not found");
}
} else {
$user_id = UserManager::get_user_id_from_original_id($user_id_value, $user_id_field_name);
if($user_id == 0) {
return new WSError(2, "User was not found");
return new WSError(100, "User not found");
} else {
return $user_id;
}
@ -121,179 +142,56 @@ class WS {
}
/**
* Handles an error by calling the WSError error handler
*
* @param WSError Error
*/
protected function handleError($error) {
$handler = WSError::getErrorHandler();
$handler->handle($error);
}
/**
* Test function. Returns the string success
*
* @return string Success
*/
public function test() {
return "success";
}
/**
* Enables or disables a user
* Gets the real course id based on the course id field name and value. Note that if the course id field name is "chamilo_course_id", it will use the course id
* in the system database
*
* @param string User id field name
* @param string User id value
* @param int Set to 1 to enable and to 0 to disable
* @param string Course id field name
* @param string Course id value
* @return mixed System course id if the course was found, WSError otherwise
*/
protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
$this->handleError($user_id);
} else {
if($state == 0) {
UserManager::disable($user_id);
} else if($state == 1) {
UserManager::enable($user_id);
protected function getCourseId($course_id_field_name, $course_id_value) {
if($course_id_field_name == "chamilo_course_id") {
if(CourseManager::get_course_code_from_course_id(intval($course_id_value)) != null) {
return intval($course_id_value);
} else {
return new WSError(200, "Course not found");
}
}
}
/**
* Disables a user
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
*/
public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
// Let the implementation handle it
$this->handleError($verifKey);
} else {
$this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
}
}
/**
* Enables a user
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
*/
public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
$course_id = CourseManager::get_course_id_from_original_id($course_id_value, $course_id_field_name);
if($course_id == 0) {
return new WSError(200, "Course not found");
} else {
return $course_id;
}
}
}
/**
* Deletes a user
* Handles an error by calling the WSError error handler
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
* @param WSError Error
*/
public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
$this->handleError($user_id);
} else {
if(!UserManager::delete_user($user_id)) {
$error = new WSError(3, "There was a problem while deleting this user");
$this->handleError($error);
}
}
}
protected function handleError($error) {
$handler = WSError::getErrorHandler();
$handler->handle($error);
}
/**
* Creates a user (helper method)
* Gets a successful result
*
* @param string User first name
* @param string User last name
* @param int User status
* @param string Login name
* @param string Password (encrypted or not)
* @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
* to include the salt in the extra fields if you are encrypting the password
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value. Leave blank if you are using the internal user_id
* @param int Visibility.
* @param string User email.
* @param string Language.
* @param string Phone.
* @param string Expiration date
* @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
* @return mixed New user id generated by the system, WSError otherwise
* @return array Array with a code of 0 and a message 'Operation was successful'
*/
protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras) {
// Add the original user id field name and value to the extra fields if needed
$extras_associative = array();
if($user_id_field_name != "chamilo_user_id") {
$extras_associative[$user_id_field_name] = $user_id_value;
}
foreach($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
if($result == false) {
$failure = $api_failureList[0];
if($failure == 'login-pass already taken') {
return new WSError(4, 'This username is already taken');
} else if($failure == 'encrypt_method invalid') {
return new WSError(5, 'The encryption of the password is invalid');
} else {
return new WSError(6, 'There was an error creating the user');
}
} else {
return $result;
}
protected function getSuccessfulResult() {
return array('code' => 0, 'message' => 'Operation was successful');
}
/**
* Creates a user
* Test function. Returns the string success
*
* @param string API secret key
* @param string User first name
* @param string User last name
* @param int User status
* @param string Login name
* @param string Password (encrypted or not)
* @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
* to include the salt in the extra fields if you are encrypting the password
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value. Leave blank if you are using the internal user_id
* @param int Visibility. Set by default to 1
* @param string User email. Set by default to an empty string
* @param string Language. Set by default to english
* @param string Phone. Set by default to an empty string
* @param string Expiration date. Set to null by default
* @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
* @return mixed New user id generated by the system
* @return string Success
*/
public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
// First, verify the secret key
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
if($result instanceof WSError) {
$this->handleError($result);
} else {
return $result;
}
}
public function test() {
return "success";
}

@ -0,0 +1,291 @@
<?php
require_once(dirname(__FILE__).'/../inc/global.inc.php');
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath.'course.lib.php';
require_once $libpath.'add_course.lib.inc.php';
require_once(dirname(__FILE__).'/webservice.php');
/**
* Web services available for the Course module. This class extends the WS class
*/
class WSCourse extends WS {
/**
* Deletes a course (helper method)
*
* @param string Course id field name
* @param string Course id value
* @return mixed True if the course was successfully deleted, WSError otherwise
*/
protected function deleteCourseHelper($course_id_field_name, $course_id_value) {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if($course_id instanceof WSError) {
return $course_id;
} else {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
if(!CourseManager::delete_course($course_code)) {
return new WSError(201, "There was a problem while deleting this course");
} else {
return true;
}
}
}
/**
* Deletes a course
*
* @param string API secret key
* @param string Course id field name
* @param string Course id value
*/
public function DeleteCourse($secret_key, $course_id_field_name, $course_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->deleteCourseHelper($course_id_field_name, $course_id_value);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Deletes multiple courses
*
* @param string API secret key
* @param array Array of courses with elements of the form array('course_id_field_name' => 'name_of_field', 'course_id_value' => 'value')
* @return array Array with elements like array('course_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
* than 0, an error occured
*/
public function DeleteCourses($secret_key, $courses) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$results = array();
foreach($users as $user) {
$result_tmp = array();
$result_op = $this->deleteCourseHelper($course['course_id_field_name'], $course['course_id_value']);
$result_tmp['course_id_value'] = $course['course_id_value'];
if($result_op instanceof WSError) {
// Return the error in the results
$result_tmp['result'] = $result_op->toArray();
} else {
$result_tmp['result'] = $this->getSuccessfulResult();
}
$results[] = $result_tmp;
}
return $results;
}
}
/**
* Creates a course (helper method)
*
* @param string Title
* @param string Category code
* @param string Wanted code. If it's not defined, it will be generated automatically
* @param string Tutor name
* @param string Course admin user id field name
* @param string Course admin user id value
* @param string Course language
* @param string Course id field name
* @param string Course id value
* @param array Course extra fields
* @return mixed Generated id if creation was successful, WSError otherwise
*/
protected function createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
// Add the original course id field name and value to the extra fields if needed
$extras_associative = array();
if($course_id_field_name != "chamilo_course_id") {
$extras_associative[$course_id_field_name] = $course_id_value;
}
foreach($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
$course_admin_id = $this->getUserId($course_admin_user_id_field_name, $course_admin_user_id_value);
if($wanted_code == '') {
$wanted_code = generate_course_code($title);
}
$result = create_course($wanted_code, $title, $tutor_name, $category_code, $course_admin_id, $this->_configuration['db_prefix'], 0);
if($result == false) {
return new WSError(202, 'There was an error creating the course');
} else {
// Update extra fields
foreach($extras_associative as $fname => $fvalue) {
CourseManager::update_course_extra_field_value($result, $fname, $fvalue);
}
// Get course id
$course_info = CourseManager::get_course_information($result);
return $course_info['id'];
}
}
/**
* Creates a course
*
* @param string API secret key
* @param string Title
* @param string Category code
* @param string Wanted code. If it's not defined, it will be generated automatically
* @param string Tutor name
* @param string Course admin user id field name
* @param string Course admin user id value
* @param string Course language
* @param string Course id field name
* @param string Course id value
* @param array Course extra fields
* @return int Course id generated
*/
public function CreateCourse($secret_key, $title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras) {
// First, verify the secret key
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
if($result instanceof WSError) {
$this->handleError($result);
} else {
return $result;
}
}
}
/**
* Create multiple courses
*
* @param string API secret key
* @param array Courses to be created, with elements following the structure presented in CreateCourse
* @return array Array with elements of the form array('course_id_value' => 'original value sent', 'course_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
*/
public function CreateCourses($secret_key, $courses) {
// First, verify the secret key
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$results = array();
foreach($courses as $course) {
$result_tmp = array();
extract($course);
$result = $this->createCourseHelper($title, $category_code, $wanted_code, $tutor_name, $course_admin_user_id_field_name, $course_admin_user_id_value, $language, $course_id_field_name, $course_id_value, $extras);
if($result instanceof WSError) {
$result_tmp['result'] = $result->toArray();
$result_tmp['course_id_value'] = $course_id_value;
$result_tmp['course_id_generated'] = 0;
} else {
$result_tmp['result'] = $this->getSuccessfulResult();
$result_tmp['course_id_value'] = $course_id_value;
$result_tmp['course_id_generated'] = $result;
}
$results[] = $result_tmp;
}
return $results;
}
}
/**
* Edits a course (helper method)
*
* @param string Course id field name
* @param string Course id value
* @param ...
*/
/**
* Subscribe or unsubscribe user to a course (helper method)
*
* @param string Course id field name. Use "chamilo_course_id" to use internal id
* @param string Course id value.
* @param string User id field name. Use "chamilo_user_id" to use internal id
* @param string User id value
* @param int Set to 1 to subscribe, 0 to unsubscribe
* @param int Status (STUDENT or TEACHER) Used for subscription only
* @return mixed True if subscription or unsubscription was successful, false otherwise
*/
protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if($course_id instanceof WSError) {
return $course_id;
} else {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
return $user_id;
} else {
$course_code = CourseManager::get_course_code_from_course_id($course_id);
if($state == 0) {
// Unsubscribe user
CourseManager::unsubscribe_user($user_id, $course_code);
return true;
} else {
// Subscribe user
if(CourseManager::subscribe_user($user_id, $course_code, $status)) {
return true;
} else {
return new WSError(203, 'An error occured subscribing to this course');
}
}
}
}
}
/**
* Subscribe user to a course
*
* @param string API secret key
* @param string Course id field name. Use "chamilo_course_id" to use internal id
* @param string Course id value.
* @param string User id field name. Use "chamilo_user_id" to use internal id
* @param string User id value
* @param int Status (1 = Teacher, 5 = Student)
*/
public function SubscribeUserToCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $status) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 1, $status);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Unsusbscribe user from course
*
* @param string API secret key
* @param string Course id field name. Use "chamilo_course_id" to use internal id
* @param string Course id value.
* @param string User id field name. Use "chamilo_user_id" to use internal id
* @param string User id value
*/
public function UnsubscribeUserFromCourse($secret_key, $course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, 0);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Edit course description
*
* @param string API secret key
* @param string Course id field name
* @param string Course id value
* @param int Course description id
* @param string Description title
* @param string Course description content
*/
}

@ -0,0 +1,418 @@
<?php
require_once(dirname(__FILE__).'/../inc/global.inc.php');
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath.'usermanager.lib.php';
require_once(dirname(__FILE__).'/webservice.php');
/**
* Web services available for the User module. This class extends the WS class
*/
class WSUser extends WS {
/**
* Enables or disables a user
*
* @param string User id field name
* @param string User id value
* @param int Set to 1 to enable and to 0 to disable
*/
protected function changeUserActiveState($user_id_field_name, $user_id_value, $state) {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
return $user_id;
} else {
if($state == 0) {
UserManager::disable($user_id);
} else if($state == 1) {
UserManager::enable($user_id);
}
}
}
/**
* Enables or disables multiple users
*
* @param array Users
* @param int Set to 1 to enable and to 0 to disable
* @return array Array of results
*/
protected function changeUsersActiveState($users, $state) {
$results = array();
foreach($users as $user) {
$result_tmp = array();
$result_op = $this->changeUserActiveState($user['user_id_field_name'], $user['user_id_value'], $state);
$result_tmp['user_id_value'] = $user['user_id_value'];
if($result_op instanceof WSError) {
// Return the error in the results
$result_tmp['result'] = $result_op->toArray();
} else {
$result_tmp['result'] = $this->getSuccessfulResult();
}
$results[] = $result_tmp;
}
return $results;
}
/**
* Disables a user
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
*/
public function DisableUser($secret_key, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
// Let the implementation handle it
$this->handleError($verifKey);
} else {
$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 0);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Disables multiple users
*
* @param string API secret key
* @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
* @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
* than 0, an error occured
*/
public function DisableUsers($secret_key, $users) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
// Let the implementation handle it
$this->handleError($verifKey);
} else {
return $this->changeUsersActiveState($users, 0);
}
}
/**
* Enables a user
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
*/
public function EnableUser($secret_key, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->changeUserActiveState($user_id_field_name, $user_id_value, 1);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Enables multiple users
*
* @param string API secret key
* @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
* @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
* than 0, an error occured
*/
public function EnableUsers($secret_key, $users) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
// Let the implementation handle it
$this->handleError($verifKey);
} else {
return $this->changeUsersActiveState($users, 1);
}
}
/**
* Deletes a user (helper method)
*
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
* @return mixed True if user was successfully deleted, WSError otherwise
*/
protected function deleteUserHelper($user_id_field_name, $user_id_value) {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
return $user_id;
} else {
if(!UserManager::delete_user($user_id)) {
return new WSError(101, "There was a problem while deleting this user");
} else {
return true;
}
}
}
/**
* Deletes a user
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
*/
public function DeleteUser($secret_key, $user_id_field_name, $user_id_value) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->deleteUserHelper($user_id_field_name, $user_id_value);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Deletes multiple users
*
* @param string API secret key
* @param array Array of users with elements of the form array('user_id_field_name' => 'name_of_field', 'user_id_value' => 'value')
* @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
* than 0, an error occured
*/
public function DeleteUsers($secret_key, $users) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$results = array();
foreach($users as $user) {
$result_tmp = array();
$result_op = $this->deleteUserHelper($user['user_id_field_name'], $user['user_id_value']);
$result_tmp['user_id_value'] = $user['user_id_value'];
if($result_op instanceof WSError) {
// Return the error in the results
$result_tmp['result'] = $result_op->toArray();
} else {
$result_tmp['result'] = $this->getSuccessfulResult();
}
$results[] = $result_tmp;
}
return $results;
}
}
/**
* Creates a user (helper method)
*
* @param string User first name
* @param string User last name
* @param int User status
* @param string Login name
* @param string Password (encrypted or not)
* @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
* to include the salt in the extra fields if you are encrypting the password
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value. Leave blank if you are using the internal user_id
* @param int Visibility.
* @param string User email.
* @param string Language.
* @param string Phone.
* @param string Expiration date
* @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field').
* @return mixed New user id generated by the system, WSError otherwise
*/
protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras) {
// Add the original user id field name and value to the extra fields if needed
$extras_associative = array();
if($user_id_field_name != "chamilo_user_id") {
$extras_associative[$user_id_field_name] = $user_id_value;
}
foreach($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
$result = UserManager::create_user($firstname, $lastname, $status, $email, $login, $password, '', $language, $phone, '', PLATFORM_AUTH_SOURCE, $expiration_date, $visibility, 0, $extras_associative, $encrypt_method);
if($result == false) {
$failure = $api_failureList[0];
if($failure == 'login-pass already taken') {
return new WSError(102, 'This username is already taken');
} else if($failure == 'encrypt_method invalid') {
return new WSError(103, 'The encryption of the password is invalid');
} else {
return new WSError(104, 'There was an error creating the user');
}
} else {
return $result;
}
}
/**
* Creates a user
*
* @param string API secret key
* @param string User first name
* @param string User last name
* @param int User status
* @param string Login name
* @param string Password (encrypted or not)
* @param string Encrypt method. Leave blank if you are passing the password in clear text, set to the encrypt method used to encrypt the password otherwise. Remember
* to include the salt in the extra fields if you are encrypting the password
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value. Leave blank if you are using the internal user_id
* @param int Visibility. Set by default to 1
* @param string User email. Set by default to an empty string
* @param string Language. Set by default to english
* @param string Phone. Set by default to an empty string
* @param string Expiration date. Set to null by default
* @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Set to an empty array by default
* @return int New user id generated by the system
*/
public function CreateUser($secret_key, $firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility = 1, $email = '', $language = 'english', $phone = '', $expiration_date = '0000-00-00 00:00:00', $extras = array()) {
// First, verify the secret key
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
if($result instanceof WSError) {
$this->handleError($result);
} else {
return $result;
}
}
}
/**
* Creates multiple users
*
* @param string API secret key
* @param array Users array. Each member of this array must follow the structure imposed by the CreateUser method
* @return array Array with elements of the form array('user_id_value' => 'original value sent', 'user_id_generated' => 'value_generated', 'result' => array('code' => 0, 'message' => 'Operation was successful'))
*/
public function CreateUsers($secret_key, $users) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$results = array();
foreach($users as $user) {
$result_tmp = array();
extract($user);
$result = $this->createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras);
if($result instanceof WSError) {
$result_tmp['result'] = $result->toArray();
$result_tmp['user_id_value'] = $user_id_value;
$result_tmp['user_id_generated'] = 0;
} else {
$result_tmp['result'] = $this->getSuccessfulResult();
$result_tmp['user_id_value'] = $user_id_value;
$result_tmp['user_id_generated'] = $result;
}
$results[] = $result_tmp;
}
return $results;
}
}
/**
* Edits user info (helper method)
*
* @param string User id field name. Use "chamilo_user_id" in order to use internal system id
* @param string User id value
* @param string First name
* @param string Last name
* @param int User status
* @param string Login name
* @param string Password. Leave blank if you don't want to update it
* @param string Encrypt method
* @param string User email
* @param string Language. Set by default to english
* @param string Phone. Set by default to an empty string
* @param string Expiration date. Set to null by default
* @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
* @return mixed True if user was successfully updated, WSError otherwise
*/
protected function editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
return $user_id;
} else {
if($password == '') {
$password = null;
}
$user_info = UserManager::get_user_info_by_id($user_id);
if(count($extras) == 0) {
$extras = null;
}
$result = UserManager::update_user($user_id, $firstname, $lastname, $loginname, $password, PLATFORM_AUTH_SOURCE, $email, $status, '', $phone, $user_info['picture_uri'], $expiration_date, $user_info['active'], null, $user_info['hr_dept_id'], $extras, $encrypt_method);
if($result == false) {
$failure = $api_failureList[0];
if($failure == 'encrypt_method invalid') {
return new WSError(103, 'The encryption of the password is invalid');
} else {
return new WSError(105, 'There was an error updating the user');
}
} else {
return $result;
}
}
}
/**
* Edits user info
*
* @param string API secret key
* @param string User id field name. Use "chamilo_user_id" in order to use internal system id
* @param string User id value
* @param string First name
* @param string Last name
* @param int User status
* @param string Login name
* @param string Password. Leave blank if you don't want to update it
* @param string Encrypt method
* @param string User email
* @param string Language. Set by default to english
* @param string Phone. Set by default to an empty string
* @param string Expiration date. Set to null by default
* @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update
*/
public function EditUser($secret_key, $user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) {
// First, verify the secret key
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$result = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $user_id_field_name, $email, $language, $phone, $expiration_date, $extras);
if($result instanceof WSError) {
$this->handleError($result);
}
}
}
/**
* Edits multiple users
*
* @param string API secret key
* @param array Users array. Each member of this array must follow the structure imposed by the EditUser method
* @return array Array with elements like array('user_id_value' => 'value', 'result' => array('code' => 0, 'message' => 'Operation was successful')). Note that if the result array contains a code different
* than 0, an error occured
*/
public function EditUsers($secret_key, $users) {
$verifKey = $this->verifyKey($secret_key);
if($verifKey instanceof WSError) {
$this->handleError($verifKey);
} else {
$results = array();
foreach($users as $user) {
$result_tmp = array();
extract($user);
$result_op = $this->editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras);
$result_tmp['user_id_value'] = $user['user_id_value'];
if($result_op instanceof WSError) {
// Return the error in the results
$result_tmp['result'] = $result_op->toArray();
} else {
$result_tmp['result'] = $this->getSuccessfulResult();
}
$results[] = $result_tmp;
}
return $results;
}
}
}

@ -58,7 +58,7 @@ class TestSoapWebService extends UnitTestCase {
public function testInvalidKey() {
$secret_key = 'invalid';
try {
$this->soapCall('WS.DisableUser', array('secret_key' => $secret_key, 'user_id_field_name' => 'chamilo_user_id', 'user_id_value' => 3));
$this->soapCall('WSUser.DisableUser', array('secret_key' => $secret_key, 'user_id_field_name' => 'chamilo_user_id', 'user_id_value' => 3));
$this->fail('Exception was expected');
} catch(SOAPFault $f) {
$this->pass();
@ -67,10 +67,10 @@ class TestSoapWebService extends UnitTestCase {
public function testCreateUser() {
$user = $this->getUserArray();
$result = $this->soapCall('WS.CreateUser', array_merge(array('secret_key' => $this->_secret_key), $user));
$result = $this->soapCall('WSUser.CreateUser', array_merge(array('secret_key' => $this->_secret_key), $user));
$this->assertIsA($result, 'int');
//Delete user created
$this->soapCall('WS.DeleteUser', array('secret_key' => $this->_secret_key, 'user_id_field_name' => 'chamilo_user_id', 'user_id_value' => $result));
$this->soapCall('WSUser.DeleteUser', array('secret_key' => $this->_secret_key, 'user_id_field_name' => 'chamilo_user_id', 'user_id_value' => $result));
}
public function testCreateUserEncrypted() {
@ -82,10 +82,10 @@ class TestSoapWebService extends UnitTestCase {
$user['password'] = sha1('guillaume');
}
$user['extras'] = array(array('field_name' => 'salt', 'field_value' => '1234'));
$result = $this->soapCall('WS.CreateUser', array_merge(array('secret_key' => $this->_secret_key), $user));
$result = $this->soapCall('WSUser.CreateUser', array_merge(array('secret_key' => $this->_secret_key), $user));
$this->assertIsA($result, 'int');
//Delete user created
$this->soapCall('WS.DeleteUser', array('secret_key' => $this->_secret_key, 'user_id_field_name' => 'chamilo_user_id', 'user_id_value' => $result));
$this->soapCall('WSUser.DeleteUser', array('secret_key' => $this->_secret_key, 'user_id_field_name' => 'chamilo_user_id', 'user_id_value' => $result));
}
}

Loading…
Cancel
Save