@@ -867,7 +867,7 @@ function WSCreateUsersPasswordCrypted($params)
867
867
$ count_row = Database::num_rows ($ res );
868
868
if ($ count_row > 0 ) {
869
869
// Check if user is not active.
870
- $ sql = "SELECT user_id FROM $ table_user
870
+ $ sql = "SELECT user_id FROM $ table_user
871
871
WHERE user_id =' " .$ row [1 ]."' AND active= '0' " ;
872
872
$ resu = Database::query ($ sql );
873
873
$ r_check_user = Database::fetch_row ($ resu );
@@ -1389,7 +1389,7 @@ function WSCreateUserPasswordCrypted($params)
1389
1389
phone=' " .Database::escape_string ($ phone )."',
1390
1390
expiration_date=' " .Database::escape_string ($ expiration_date )."',
1391
1391
active='1',
1392
- hr_dept_id= " .intval ($ hr_dept_id )."
1392
+ hr_dept_id= " .intval ($ hr_dept_id )."
1393
1393
WHERE user_id=' " .$ r_check_user [0 ]."' " ;
1394
1394
1395
1395
Database::query ($ sql );
@@ -1459,7 +1459,7 @@ function WSCreateUserPasswordCrypted($params)
1459
1459
phone = ' " .Database::escape_string ($ phone )."',
1460
1460
language = ' " .Database::escape_string ($ language )."',
1461
1461
registration_date = ' " .api_get_utc_datetime ()."',
1462
- roles = 'a:0:{}',
1462
+ roles = 'a:0:{}',
1463
1463
" .$ queryExpirationDate ."
1464
1464
hr_dept_id = ' " .Database::escape_string ($ hr_dept_id )."',
1465
1465
active = ' " .Database::escape_string ($ active )."' " ;
@@ -2078,13 +2078,20 @@ function WSEditUser($params)
2078
2078
// Define the method WSEditUserWithPicture
2079
2079
function WSEditUserWithPicture ($ params )
2080
2080
{
2081
+ if (ini_get ('allow_url_fopen ' )) {
2082
+ return new soap_fault (
2083
+ 'Server ' ,
2084
+ '' ,
2085
+ 'WSEditUserWithPicture is disabled because allow_url_fopen is enabled in the server. '
2086
+ );
2087
+ }
2088
+
2081
2089
if (!WSHelperVerifyKey ($ params )) {
2082
2090
return returnError (WS_ERROR_SECRET_KEY );
2083
2091
}
2084
2092
2085
2093
$ userManager = UserManager::getManager ();
2086
2094
$ userRepository = UserManager::getRepository ();
2087
-
2088
2095
$ table_user = Database::get_main_table (TABLE_MAIN_USER );
2089
2096
2090
2097
$ original_user_id_value = $ params ['original_user_id_value ' ];
@@ -2118,28 +2125,19 @@ function WSEditUserWithPicture($params)
2118
2125
$ original_user_id_name
2119
2126
);
2120
2127
2121
- // Get picture and generate uri.
2122
- $ filename = basename ($ picture_url );
2123
- $ tempDir = api_get_path (SYS_ARCHIVE_PATH );
2124
- // Make sure the file download was OK by checking the HTTP headers for OK
2125
- if (strpos (get_headers ($ picture_url )[0 ], "OK " )) {
2126
- file_put_contents ($ tempDir .$ filename , file_get_contents ($ picture_url ));
2127
- $ pictureUri = UserManager::update_user_picture ($ user_id , $ filename , $ tempDir .$ filename );
2128
+ if (empty ($ user_id )) {
2129
+ return 0 ;
2128
2130
}
2129
2131
2130
- if ($ user_id == 0 ) {
2132
+ $ sql = "SELECT id FROM $ table_user WHERE id = $ user_id AND active= 0 " ;
2133
+ $ resu = Database::query ($ sql );
2134
+ $ r_check_user = Database::fetch_row ($ resu );
2135
+ if (!empty ($ r_check_user [0 ])) {
2131
2136
return 0 ;
2132
- } else {
2133
- $ sql = "SELECT id FROM $ table_user WHERE id = $ user_id AND active= 0 " ;
2134
- $ resu = Database::query ($ sql );
2135
- $ r_check_user = Database::fetch_row ($ resu );
2136
- if (!empty ($ r_check_user [0 ])) {
2137
- return 0 ;
2138
- }
2139
2137
}
2140
2138
2141
2139
// Check whether username already exits.
2142
- $ sql = "SELECT username FROM $ table_user
2140
+ $ sql = "SELECT username FROM $ table_user
2143
2141
WHERE username = ' $ username' AND id <> $ user_id " ;
2144
2142
$ res_un = Database::query ($ sql );
2145
2143
$ r_username = Database::fetch_row ($ res_un );
@@ -2148,6 +2146,19 @@ function WSEditUserWithPicture($params)
2148
2146
return 0 ;
2149
2147
}
2150
2148
2149
+ // Get picture and generate uri.
2150
+ $ filename = basename ($ picture_url );
2151
+ $ tempDir = api_get_path (SYS_ARCHIVE_PATH );
2152
+ // Make sure the file download was OK by checking the HTTP headers for OK
2153
+ if (strpos (get_headers ($ picture_url )[0 ], "OK " )) {
2154
+ $ tempFile = $ tempDir .uniqid ('user_image ' , true );
2155
+ file_put_contents ($ tempFile , file_get_contents ($ picture_url ));
2156
+ $ pictureUri = UserManager::update_user_picture ($ user_id , $ filename , $ tempFile );
2157
+ if (file_exists ($ tempFile )) {
2158
+ unlink ($ tempFile );
2159
+ }
2160
+ }
2161
+
2151
2162
/** @var User $user */
2152
2163
$ user = $ userRepository ->find ($ user_id );
2153
2164
@@ -2190,7 +2201,8 @@ function WSEditUserWithPicture($params)
2190
2201
->setExpirationDate ($ expiration_date )
2191
2202
->setHrDeptId ($ hr_dept_id )
2192
2203
->setActive (true )
2193
- ->setPictureUri ($ pictureUri );
2204
+ ->setPictureUri ($ pictureUri )
2205
+ ;
2194
2206
2195
2207
if (!is_null ($ creator_id )) {
2196
2208
$ user ->setCreatorId ($ creator_id );
@@ -4768,7 +4780,7 @@ function WSSubscribeUserToCourseSimple($params)
4768
4780
error_log ('Try to register: user_id= ' .$ user_id .' to course: ' .$ course_data ['code ' ]);
4769
4781
}
4770
4782
if (!CourseManager::subscribeUser ($ user_id , $ course_data ['code ' ], $ status , 0 , false , false )) {
4771
- $ result = 'User was not registered possible reasons: User already registered to the course,
4783
+ $ result = 'User was not registered possible reasons: User already registered to the course,
4772
4784
Course visibility doesnt allow user subscriptions ' ;
4773
4785
if ($ debug ) {
4774
4786
error_log ($ result );
0 commit comments