Browse Source

Validate the field extra that it is not required

FraGoTe 11 years ago
parent
commit
43949c7bb4
1 changed files with 6 additions and 4 deletions
  1. 6 4
      main/webservices/webservice_user.php

+ 6 - 4
main/webservices/webservice_user.php

@@ -219,16 +219,18 @@ class WSUser extends WS {
 	 * @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) {
+	protected function createUserHelper($firstname, $lastname, $status, $login, $password, $encrypt_method, $user_id_field_name, $user_id_value, $visibility, $email, $language, $phone, $expiration_date, $extras = array()) {
         global $api_failureList;
 		// 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'];
-		}
+                if (!empty($extras)) {
+                    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) {
 			$failure = $api_failureList[0];