skala
Julio Montoya 14 years ago
commit 731ba6537c
  1. BIN
      main/img/icons/128/scorms_na.png
  2. BIN
      main/img/icons/32/scorms.png
  3. BIN
      main/img/icons/32/scorms_na.png
  4. 27
      main/webservices/example_fill_users_fields.php
  5. 84
      main/webservices/registration.soap.php

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,27 @@
<?php
/**
* This script populates the user_extra_fields_value table with a new field which
* contains the username for each user. This allows you to use web
* services to update users based on their username (which is assumed
* to be the same as in the application which calls the webservice).
* This script should be called any time a new user (or a large group of new
* users) is added to the database.
* @package chamilo.webservices
*/
//remove the next line to enable the script (this can harm your database so
// don't enable unless you know what you're doing and you have a backup)
die();
// update this ID after you create the corresponding field through the Chamilo
// profile fields manager (admin page, users section) as text field.
// Give this field a name you will later use in original_field_id_name, while
// you will use the normal username of Chamilo users.
$extra_field_id = 9;
require_once('../inc/global.inc.php');
$tuser = Database::get_main_table(TABLE_MAIN_USER);
$tuserfv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$sql = "SELECT user_id, username FROM $tuser ORDER BY user_id";
$res = Database::query($sql);
while($row = Database::fetch_array($res)) {
$sql2 = "INSERT INTO $tuserfv (user_id, field_id, field_value) VALUES (".$row['user_id'].", 11,'".$row['username']."')";
$res2 = Database::query($sql2);
}

@ -1056,6 +1056,88 @@ $server->wsdl->addComplexType(
)
);
/* Register WSEditUserCredentials function */
// Register the data structures used by the service
$server->wsdl->addComplexType(
'editUserCredentials',
'complexType',
'struct',
'all',
'',
array(
'username' => array('name' => 'username', 'type' => 'xsd:string'),
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'password' => array('name' => 'password', 'type' => 'xsd:string'),
'original_user_id_name' => array('name' => 'original_user_id_name', 'type' => 'xsd:string'),
'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSEditUserCredentials', // method name
array('editUserCredentials' => 'tns:editUserCredentials'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSEditUserCredentials', // soapaction
'rpc', // style
'encoded', // use
'This service edits the username and password of a user' // documentation
);
// Define the method WSEditUser
function WSEditUserCredentials($params) {
global $userPasswordCrypted;
if(!WSHelperVerifyKey($params)) {
return -1;
}
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD);
$t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$original_user_id_value = $params['original_user_id_value'];
$original_user_id_name = $params['original_user_id_name'];
$username = $params['username'];
$password = null;
if (!empty($params['password'])) { $password = $params['password']; }
// Get user id from id wiener
$user_id = UserManager::get_user_id_from_original_id($original_user_id_value, $original_user_id_name);
if ($user_id == 0) {
return 0;
} else {
$sql = "SELECT user_id FROM $table_user WHERE user_id ='$user_id' AND active= '0'";
$resu = Database::query($sql);
$r_check_user = Database::fetch_row($resu);
if (!empty($r_check_user[0])) {
return 0;
}
}
// Check whether username already exits.
$sql = "SELECT username FROM $table_user WHERE username = '$username' AND user_id <> '$user_id'";
$res_un = Database::query($sql);
$r_username = Database::fetch_row($res_un);
if (!empty($r_username[0])) {
return 0;
}
$sql = "UPDATE $table_user SET
username='".Database::escape_string($username)."'";
if (!is_null($password)) {
$password = $userPasswordCrypted ? api_get_encrypted_password($password) : $password;
$sql .= ", password='".Database::escape_string($password)."' ";
}
$sql .= " WHERE user_id='$user_id'";
$return = @Database::query($sql);
return $return;
}
// Prepare output params, in this case will return an array
$server->wsdl->addComplexType(
'result_editUsers',
@ -4865,4 +4947,4 @@ function WSUpdateUserApiKey($params) {
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
$server->service($HTTP_RAW_POST_DATA);

Loading…
Cancel
Save