From 43949c7bb4644ae46e64938f897dfc3e07f370b2 Mon Sep 17 00:00:00 2001 From: FraGoTe Date: Fri, 28 Mar 2014 15:46:17 -0500 Subject: [PATCH] Validate the field extra that it is not required --- main/webservices/webservice_user.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main/webservices/webservice_user.php b/main/webservices/webservice_user.php index 8dbba122ed..fa5aaeb8f3 100644 --- a/main/webservices/webservice_user.php +++ b/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];