|
|
|
@ -368,11 +368,47 @@ $html_results_enabled[] = $form->createElement('button', 'submit_plus', get_lang |
|
|
|
|
$form->addGroup($html_results_enabled); |
|
|
|
|
|
|
|
|
|
// Validate form |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$formValid = $form->validate(); |
|
|
|
|
if ($formValid) { |
|
|
|
|
$check = Security::check_token('post'); |
|
|
|
|
if ($check) { |
|
|
|
|
$user = $form->exportValues(); |
|
|
|
|
|
|
|
|
|
$extraFields = api_get_configuration_value('extra_fields_to_validate_on_user_registration'); |
|
|
|
|
if (!empty($extraFields) && isset($extraFields['extra_fields'])) { |
|
|
|
|
$extraFieldList = $extraFields['extra_fields']; |
|
|
|
|
foreach ($user as $key => $value) { |
|
|
|
|
if (substr($key, 0, 6) == 'extra_') { |
|
|
|
|
$extra_value = Security::remove_XSS($value); |
|
|
|
|
$extra_field = substr($key,6); |
|
|
|
|
|
|
|
|
|
if(!empty($extra_value)) { |
|
|
|
|
if (in_array($extra_field, $extraFieldList)) { |
|
|
|
|
$extraValueExists = api_user_extra_field_validation($extra_field, $extra_value); |
|
|
|
|
if ($extraValueExists) { |
|
|
|
|
$formValid = false; |
|
|
|
|
|
|
|
|
|
$element = $form->getElement($key); |
|
|
|
|
if ($element) { |
|
|
|
|
$attrs = ['style' => 'border-color: #a94442;']; |
|
|
|
|
$form->updateElementAttr([$element], $attrs); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message( |
|
|
|
|
get_lang('TheValueEntered ').$extra_field.get_lang('AlreadyExists'), |
|
|
|
|
'error', |
|
|
|
|
false |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($formValid) { |
|
|
|
|
$lastname = $user['lastname']; |
|
|
|
|
$firstname = $user['firstname']; |
|
|
|
|
$official_code = $user['official_code']; |
|
|
|
@ -498,7 +534,10 @@ if ($form->validate()) { |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$formValid) { |
|
|
|
|
if (isset($_POST['submit'])) { |
|
|
|
|
Security::clear_token(); |
|
|
|
|
} |
|
|
|
|