|
|
|
@ -673,8 +673,45 @@ if ($extraConditions && $extraFieldsLoaded) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$formValid = $form->validate(); |
|
|
|
|
if ($formValid) { |
|
|
|
|
$values = $form->getSubmitValues(1); |
|
|
|
|
|
|
|
|
|
$extraFields = api_get_configuration_value('extra_fields_to_validate_on_user_registration'); |
|
|
|
|
if (!empty($extraFields) && isset($extraFields['extra_fields'])) { |
|
|
|
|
$extraFieldList = $extraFields['extra_fields']; |
|
|
|
|
foreach ($values 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) { |
|
|
|
|
// Make *sure* the login isn't too long |
|
|
|
|
if (isset($values['username'])) { |
|
|
|
|
$values['username'] = api_substr($values['username'], 0, USERNAME_MAX_LENGTH); |
|
|
|
@ -1059,7 +1096,10 @@ if ($form->validate()) { |
|
|
|
|
$inscription = $tpl->get_template('auth/inscription.tpl'); |
|
|
|
|
$tpl->display($inscription); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$formValid) { |
|
|
|
|
// Custom pages |
|
|
|
|
if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION)) { |
|
|
|
|
CustomPages::display( |
|
|
|
|