Skip to content

Commit aeb458a

Browse files
committed
Add error log
1 parent 891d518 commit aeb458a

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

main/webservices/registration.soap.php

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
define('WS_ERROR_INVALID_INPUT', 3);
1818
define('WS_ERROR_SETTING', 4);
1919

20+
/**
21+
* @param string $code
22+
* @return null|soap_fault
23+
*/
2024
function returnError($code)
2125
{
2226
$fault = null;
@@ -87,7 +91,7 @@ function WSHelperVerifyKey($params)
8791
}
8892

8993
$result = api_is_valid_secret_key($secret_key, $security_key);
90-
//error_log($secret_key.'-'.$security_key);
94+
9195
if ($debug)
9296
error_log('WSHelperVerifyKey result: '.intval($result));
9397
return $result;
@@ -2420,35 +2424,41 @@ function WSEditUsersPasswordCrypted($params) {
24202424
// Define the method WSEditUserPasswordCrypted
24212425
function WSEditUserPasswordCrypted($params)
24222426
{
2423-
global $_configuration;
2427+
global $_configuration, $debug;
24242428

24252429
if (!WSHelperVerifyKey($params)) {
24262430
return returnError(WS_ERROR_SECRET_KEY);
24272431
}
24282432

2433+
if ($debug) {
2434+
error_log('WSEditUserPasswordCrypted');
2435+
}
2436+
24292437
$table_user = Database::get_main_table(TABLE_MAIN_USER);
24302438

24312439
$original_user_id_value = $params['original_user_id_value'];
24322440
$original_user_id_name = $params['original_user_id_name'];
2433-
$firstname = $params['firstname'];
2434-
$lastname = $params['lastname'];
2435-
$username = $params['username'];
2441+
2442+
$firstname = isset($params['firstname']) ? $params['firstname'] : '';
2443+
$lastname = isset($params['lastname']) ? $params['lastname'] : '';
2444+
$username = isset($params['username']) ? $params['username'] : '';
24362445
$password = null;
24372446
$auth_source = null;
2438-
$email = $params['email'];
2439-
$status = $params['status'];
2447+
$email = isset($params['email']) ? $params['email'] : '';
2448+
$status = isset($params['status']) ? $params['status'] : '';
24402449
$official_code = '';
2441-
$phone = $params['phone'];
2450+
$phone = isset($params['phone']) ? $params['phone'] : '';
24422451
$picture_uri = '';
2443-
$expiration_date = $params['expiration_date'];
2452+
$expiration_date = isset($params['expiration_date']) ? $params['expiration_date'] : '';
24442453
$active = 1;
24452454
$creator_id = null;
24462455
$hr_dept_id = 0;
24472456
$extra = null;
2448-
$extra_list = $params['extra'];
2457+
$extra_list = isset($params['extra']) ? $params['extra'] : '';
2458+
$params['password'] = isset($params['password']) ? $params['password'] : '';
2459+
$params['encrypt_method'] = isset($params['encrypt_method']) ? $params['encrypt_method'] : '';
24492460

24502461
if (!empty($params['password']) && !empty($params['encrypt_method'])) {
2451-
24522462
$password = $params['password'];
24532463
$encrypt_method = $params['encrypt_method'];
24542464
if ($_configuration['password_encryption'] === $encrypt_method ) {
@@ -2465,9 +2475,11 @@ function WSEditUserPasswordCrypted($params)
24652475
}
24662476
} elseif (!empty($params['password']) && empty($params['encrypt_method'])) {
24672477
$msg = "If password is not empty the encrypt_method param is required ";
2478+
24682479
return $msg;
24692480
} elseif (empty($params['password']) && !empty($params['encrypt_method'])) {
24702481
$msg = "If encrypt_method is not empty the password param is required ";
2482+
24712483
return $msg;
24722484
}
24732485

@@ -2476,6 +2488,10 @@ function WSEditUserPasswordCrypted($params)
24762488
$original_user_id_name
24772489
);
24782490

2491+
if ($debug) {
2492+
error_log("user: $user_id");
2493+
}
2494+
24792495
if ($user_id == 0) {
24802496
return 0;
24812497
} else {
@@ -2506,10 +2522,12 @@ function WSEditUserPasswordCrypted($params)
25062522
$sql .= " firstname='".Database::escape_string($firstname)."', ";
25072523
}
25082524
$sql .= " username='".Database::escape_string($username)."',";
2509-
if (!is_null($password)) {
2525+
2526+
if (!empty($password)) {
25102527
$sql .= " password='".Database::escape_string($password)."',";
25112528
}
2512-
if (!is_null($auth_source)) {
2529+
2530+
if (!empty($auth_source)) {
25132531
$sql .= " auth_source='".Database::escape_string($auth_source)."',";
25142532
}
25152533

@@ -2540,15 +2558,20 @@ function WSEditUserPasswordCrypted($params)
25402558
if (!is_null($creator_id)) {
25412559
$sql .= ", creator_id='".Database::escape_string($creator_id)."'";
25422560
}
2561+
25432562
$sql .= " WHERE user_id='$user_id'";
25442563
$return = @Database::query($sql);
25452564

2565+
if ($debug) {
2566+
error_log("SQL: $sql");
2567+
}
2568+
25462569
if (is_array($extra_list) && count($extra_list) > 0) {
25472570
foreach ($extra_list as $extra) {
25482571
$extra_field_name = $extra['field_name'];
25492572
$extra_field_value = $extra['field_value'];
25502573
// save the external system's id into user_field_value table'
2551-
$res = UserManager::update_extra_field_value(
2574+
UserManager::update_extra_field_value(
25522575
$user_id,
25532576
$extra_field_name,
25542577
$extra_field_value

0 commit comments

Comments
 (0)