17
17
define ('WS_ERROR_INVALID_INPUT ' , 3 );
18
18
define ('WS_ERROR_SETTING ' , 4 );
19
19
20
+ /**
21
+ * @param string $code
22
+ * @return null|soap_fault
23
+ */
20
24
function returnError ($ code )
21
25
{
22
26
$ fault = null ;
@@ -87,7 +91,7 @@ function WSHelperVerifyKey($params)
87
91
}
88
92
89
93
$ result = api_is_valid_secret_key ($ secret_key , $ security_key );
90
- //error_log($secret_key.'-'.$security_key);
94
+
91
95
if ($ debug )
92
96
error_log ('WSHelperVerifyKey result: ' .intval ($ result ));
93
97
return $ result ;
@@ -2420,35 +2424,41 @@ function WSEditUsersPasswordCrypted($params) {
2420
2424
// Define the method WSEditUserPasswordCrypted
2421
2425
function WSEditUserPasswordCrypted ($ params )
2422
2426
{
2423
- global $ _configuration ;
2427
+ global $ _configuration, $ debug ;
2424
2428
2425
2429
if (!WSHelperVerifyKey ($ params )) {
2426
2430
return returnError (WS_ERROR_SECRET_KEY );
2427
2431
}
2428
2432
2433
+ if ($ debug ) {
2434
+ error_log ('WSEditUserPasswordCrypted ' );
2435
+ }
2436
+
2429
2437
$ table_user = Database::get_main_table (TABLE_MAIN_USER );
2430
2438
2431
2439
$ original_user_id_value = $ params ['original_user_id_value ' ];
2432
2440
$ 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 ' ] : '' ;
2436
2445
$ password = null ;
2437
2446
$ 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 ' ] : '' ;
2440
2449
$ official_code = '' ;
2441
- $ phone = $ params ['phone ' ];
2450
+ $ phone = isset ( $ params ['phone ' ]) ? $ params [ ' phone ' ] : '' ;
2442
2451
$ picture_uri = '' ;
2443
- $ expiration_date = $ params ['expiration_date ' ];
2452
+ $ expiration_date = isset ( $ params ['expiration_date ' ]) ? $ params [ ' expiration_date ' ] : '' ;
2444
2453
$ active = 1 ;
2445
2454
$ creator_id = null ;
2446
2455
$ hr_dept_id = 0 ;
2447
2456
$ 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 ' ] : '' ;
2449
2460
2450
2461
if (!empty ($ params ['password ' ]) && !empty ($ params ['encrypt_method ' ])) {
2451
-
2452
2462
$ password = $ params ['password ' ];
2453
2463
$ encrypt_method = $ params ['encrypt_method ' ];
2454
2464
if ($ _configuration ['password_encryption ' ] === $ encrypt_method ) {
@@ -2465,9 +2475,11 @@ function WSEditUserPasswordCrypted($params)
2465
2475
}
2466
2476
} elseif (!empty ($ params ['password ' ]) && empty ($ params ['encrypt_method ' ])) {
2467
2477
$ msg = "If password is not empty the encrypt_method param is required " ;
2478
+
2468
2479
return $ msg ;
2469
2480
} elseif (empty ($ params ['password ' ]) && !empty ($ params ['encrypt_method ' ])) {
2470
2481
$ msg = "If encrypt_method is not empty the password param is required " ;
2482
+
2471
2483
return $ msg ;
2472
2484
}
2473
2485
@@ -2476,6 +2488,10 @@ function WSEditUserPasswordCrypted($params)
2476
2488
$ original_user_id_name
2477
2489
);
2478
2490
2491
+ if ($ debug ) {
2492
+ error_log ("user: $ user_id " );
2493
+ }
2494
+
2479
2495
if ($ user_id == 0 ) {
2480
2496
return 0 ;
2481
2497
} else {
@@ -2506,10 +2522,12 @@ function WSEditUserPasswordCrypted($params)
2506
2522
$ sql .= " firstname=' " .Database::escape_string ($ firstname )."', " ;
2507
2523
}
2508
2524
$ sql .= " username=' " .Database::escape_string ($ username )."', " ;
2509
- if (!is_null ($ password )) {
2525
+
2526
+ if (!empty ($ password )) {
2510
2527
$ sql .= " password=' " .Database::escape_string ($ password )."', " ;
2511
2528
}
2512
- if (!is_null ($ auth_source )) {
2529
+
2530
+ if (!empty ($ auth_source )) {
2513
2531
$ sql .= " auth_source=' " .Database::escape_string ($ auth_source )."', " ;
2514
2532
}
2515
2533
@@ -2540,15 +2558,20 @@ function WSEditUserPasswordCrypted($params)
2540
2558
if (!is_null ($ creator_id )) {
2541
2559
$ sql .= ", creator_id=' " .Database::escape_string ($ creator_id )."' " ;
2542
2560
}
2561
+
2543
2562
$ sql .= " WHERE user_id=' $ user_id' " ;
2544
2563
$ return = @Database::query ($ sql );
2545
2564
2565
+ if ($ debug ) {
2566
+ error_log ("SQL: $ sql " );
2567
+ }
2568
+
2546
2569
if (is_array ($ extra_list ) && count ($ extra_list ) > 0 ) {
2547
2570
foreach ($ extra_list as $ extra ) {
2548
2571
$ extra_field_name = $ extra ['field_name ' ];
2549
2572
$ extra_field_value = $ extra ['field_value ' ];
2550
2573
// save the external system's id into user_field_value table'
2551
- $ res = UserManager::update_extra_field_value (
2574
+ UserManager::update_extra_field_value (
2552
2575
$ user_id ,
2553
2576
$ extra_field_name ,
2554
2577
$ extra_field_value
0 commit comments