Use extra fields on user registration form to validate

pull/5541/head
Juan Cortizas Ponte 1 year ago
parent 03e1960b1d
commit e8e5949917
  1. 15
      main/admin/user_import.php
  2. 702
      main/auth/inscription.php
  3. 19
      main/inc/lib/api.lib.php
  4. 7
      main/install/configuration.dist.php

@ -197,6 +197,21 @@ function validate_data($users, $checkUniqueEmail = false)
$user['has_error'] = true; $user['has_error'] = true;
} }
} }
// 6. Check if extra fields are duplicated
$extraFields = api_get_configuration_value('extra_fields_to_validate_on_user_registration');
if (!empty($extraFields) && isset($extraFields['extra_fields'])) {
$extraFieldList = $extraFields['extra_fields'];
foreach ($extraFieldList as $extraFieldToCheck) {
if (isset($user[$extraFieldToCheck]) && !empty($user[$extraFieldToCheck])) {
$valueExists = api_user_extra_field_validation($extraFieldToCheck, $user[$extraFieldToCheck]);
if ($valueExists) {
$user['message'] .= Display::return_message(get_lang('DuplicatedFieldAt').' '.$extraFieldToCheck, 'warning');
$user['has_error'] = true;
}
}
}
}
} }
return $users; return $users;

@ -673,393 +673,433 @@ if ($extraConditions && $extraFieldsLoaded) {
} }
} }
if ($form->validate()) { $formValid = $form->validate();
if ($formValid) {
$values = $form->getSubmitValues(1); $values = $form->getSubmitValues(1);
// Make *sure* the login isn't too long
if (isset($values['username'])) {
$values['username'] = api_substr($values['username'], 0, USERNAME_MAX_LENGTH);
}
if (api_get_setting('allow_registration_as_teacher') === 'false') { $extraFields = api_get_configuration_value('extra_fields_to_validate_on_user_registration');
$values['status'] = STUDENT; 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 (empty($values['official_code']) && !empty($values['username'])) { if ($formValid) {
$values['official_code'] = api_strtoupper($values['username']); // Make *sure* the login isn't too long
} if (isset($values['username'])) {
$values['username'] = api_substr($values['username'], 0, USERNAME_MAX_LENGTH);
}
if (api_get_setting('login_is_email') === 'true') { if (api_get_setting('allow_registration_as_teacher') === 'false') {
$values['username'] = $values['email']; $values['status'] = STUDENT;
} }
if ($user_already_registered_show_terms && if (empty($values['official_code']) && !empty($values['username'])) {
api_get_setting('allow_terms_conditions') === 'true' $values['official_code'] = api_strtoupper($values['username']);
) {
$user_id = $_SESSION['term_and_condition']['user_id'];
$is_admin = UserManager::is_admin($user_id);
Session::write('is_platformAdmin', $is_admin);
} else {
// Moved here to include extra fields when creating a user. Formerly placed after user creation
// Register extra fields
$extras = [];
foreach ($values as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
$extras[substr($key, 6)] = $value;
} elseif (strpos($key, 'remove_extra_') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value(
$user_id,
substr($key, 13),
$extra_value
);
}
} }
$status = isset($values['status']) ? $values['status'] : STUDENT; if (api_get_setting('login_is_email') === 'true') {
$phone = isset($values['phone']) ? $values['phone'] : null; $values['username'] = $values['email'];
$values['language'] = isset($values['language']) ? $values['language'] : api_get_interface_language(); }
$values['address'] = isset($values['address']) ? $values['address'] : '';
// Creates a new user
$user_id = UserManager::create_user(
$values['firstname'],
$values['lastname'],
$status,
$values['email'],
$values['username'],
$values['pass1'],
$values['official_code'],
$values['language'],
$phone,
null,
PLATFORM_AUTH_SOURCE,
null,
1,
0,
$extras,
null,
true,
false,
$values['address'],
false,
$form
);
// Update the extra fields if ($user_already_registered_show_terms &&
$count_extra_field = count($extras); api_get_setting('allow_terms_conditions') === 'true'
if ($count_extra_field > 0 && is_int($user_id)) { ) {
foreach ($extras as $key => $value) { $user_id = $_SESSION['term_and_condition']['user_id'];
// For array $value -> if exists key 'tmp_name' then must not be empty $is_admin = UserManager::is_admin($user_id);
// This avoid delete from user field value table when doesn't upload a file Session::write('is_platformAdmin', $is_admin);
if (is_array($value)) { } else {
if (array_key_exists('tmp_name', $value) && empty($value['tmp_name'])) { // Moved here to include extra fields when creating a user. Formerly placed after user creation
//Nothing to do // Register extra fields
} else { $extras = [];
if (array_key_exists('tmp_name', $value)) { foreach ($values as $key => $value) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']); if (substr($key, 0, 6) == 'extra_') {
} //an extra field
if (array_key_exists('name', $value)) { $extras[substr($key, 6)] = $value;
$value['name'] = Security::filter_filename($value['name']); } elseif (strpos($key, 'remove_extra_') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value(
$user_id,
substr($key, 13),
$extra_value
);
}
}
$status = isset($values['status']) ? $values['status'] : STUDENT;
$phone = isset($values['phone']) ? $values['phone'] : null;
$values['language'] = isset($values['language']) ? $values['language'] : api_get_interface_language();
$values['address'] = isset($values['address']) ? $values['address'] : '';
// Creates a new user
$user_id = UserManager::create_user(
$values['firstname'],
$values['lastname'],
$status,
$values['email'],
$values['username'],
$values['pass1'],
$values['official_code'],
$values['language'],
$phone,
null,
PLATFORM_AUTH_SOURCE,
null,
1,
0,
$extras,
null,
true,
false,
$values['address'],
false,
$form
);
// Update the extra fields
$count_extra_field = count($extras);
if ($count_extra_field > 0 && is_int($user_id)) {
foreach ($extras as $key => $value) {
// For array $value -> if exists key 'tmp_name' then must not be empty
// This avoid delete from user field value table when doesn't upload a file
if (is_array($value)) {
if (array_key_exists('tmp_name', $value) && empty($value['tmp_name'])) {
//Nothing to do
} else {
if (array_key_exists('tmp_name', $value)) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']);
}
if (array_key_exists('name', $value)) {
$value['name'] = Security::filter_filename($value['name']);
}
UserManager::update_extra_field_value($user_id, $key, $value);
} }
} else {
UserManager::update_extra_field_value($user_id, $key, $value); UserManager::update_extra_field_value($user_id, $key, $value);
} }
} else {
UserManager::update_extra_field_value($user_id, $key, $value);
} }
} }
}
if ($user_id) { if ($user_id) {
// Storing the extended profile // Storing the extended profile
$store_extended = false; $store_extended = false;
$sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_USER)." SET "; $sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_USER)." SET ";
if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true'
) {
$sql_set[] = "competences = '".Database::escape_string($values['competences'])."'";
$store_extended = true;
}
if (api_get_setting('extended_profile') == 'true' && if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true' api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true'
) { ) {
$sql_set[] = "diplomas = '".Database::escape_string($values['diplomas'])."'"; $sql_set[] = "competences = '".Database::escape_string($values['competences'])."'";
$store_extended = true; $store_extended = true;
} }
if (api_get_setting('extended_profile') == 'true' && if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'myteach') == 'true' api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true'
) { ) {
$sql_set[] = "teach = '".Database::escape_string($values['teach'])."'"; $sql_set[] = "diplomas = '".Database::escape_string($values['diplomas'])."'";
$store_extended = true; $store_extended = true;
} }
if (api_get_setting('extended_profile') == 'true' && if (api_get_setting('extended_profile') == 'true' &&
api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true' api_get_setting('extendedprofile_registration', 'myteach') == 'true'
) { ) {
$sql_set[] = "openarea = '".Database::escape_string($values['openarea'])."'"; $sql_set[] = "teach = '".Database::escape_string($values['teach'])."'";
$store_extended = true; $store_extended = true;
} }
if ($store_extended) { if (api_get_setting('extended_profile') == 'true' &&
$sql .= implode(',', $sql_set); api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true'
$sql .= " WHERE user_id = ".intval($user_id).""; ) {
Database::query($sql); $sql_set[] = "openarea = '".Database::escape_string($values['openarea'])."'";
} $store_extended = true;
}
// Saving user to Session if it was set if ($store_extended) {
if (!empty($sessionToRedirect) && !$sessionPremiumChecker) { $sql .= implode(',', $sql_set);
$sessionInfo = api_get_session_info($sessionToRedirect); $sql .= " WHERE user_id = ".intval($user_id)."";
if (!empty($sessionInfo)) { Database::query($sql);
SessionManager::subscribeUsersToSession(
$sessionToRedirect,
[$user_id],
SESSION_VISIBLE_READ_ONLY,
false
);
} }
}
// Saving user to course if it was set. // Saving user to Session if it was set
if (!empty($course_code_redirect)) { if (!empty($sessionToRedirect) && !$sessionPremiumChecker) {
$course_info = api_get_course_info($course_code_redirect); $sessionInfo = api_get_session_info($sessionToRedirect);
if (!empty($course_info)) { if (!empty($sessionInfo)) {
if (in_array( SessionManager::subscribeUsersToSession(
$course_info['visibility'], $sessionToRedirect,
[ [$user_id],
COURSE_VISIBILITY_OPEN_PLATFORM, SESSION_VISIBLE_READ_ONLY,
COURSE_VISIBILITY_OPEN_WORLD, false
]
)
) {
CourseManager::subscribeUser(
$user_id,
$course_info['code']
); );
} }
} }
}
/* If the account has to be approved then we set the account to inactive, // Saving user to course if it was set.
sent a mail to the platform admin and exit the page.*/ if (!empty($course_code_redirect)) {
if (api_get_setting('allow_registration') === 'approval') { $course_info = api_get_course_info($course_code_redirect);
// 1. Send mail to all platform admin if (!empty($course_info)) {
$chamiloUser = api_get_user_entity($user_id); if (in_array(
MessageManager::sendNotificationOfNewRegisteredUserApproval($chamiloUser); $course_info['visibility'],
[
// 2. set account inactive COURSE_VISIBILITY_OPEN_PLATFORM,
UserManager::disable($user_id); COURSE_VISIBILITY_OPEN_WORLD,
]
// 3. exit the page )
unset($user_id); ) {
CourseManager::subscribeUser(
Display::display_header($tool_name); $user_id,
echo Display::page_header($tool_name); $course_info['code']
echo $content; );
Display::display_footer(); }
exit; }
} elseif (api_get_setting('allow_registration') === 'confirmation') { }
// 1. Send mail to the user
$thisUser = api_get_user_entity($user_id);
UserManager::sendUserConfirmationMail($thisUser);
// 2. set account inactive
UserManager::disable($user_id);
// 3. exit the page
unset($user_id);
Display::addFlash(
Display::return_message(
get_lang('YouNeedConfirmYourAccountViaEmailToAccessThePlatform'),
'warning'
)
);
Display::display_header($tool_name); /* If the account has to be approved then we set the account to inactive,
//echo $content; sent a mail to the platform admin and exit the page.*/
Display::display_footer(); if (api_get_setting('allow_registration') === 'approval') {
exit; // 1. Send mail to all platform admin
$chamiloUser = api_get_user_entity($user_id);
MessageManager::sendNotificationOfNewRegisteredUserApproval($chamiloUser);
// 2. set account inactive
UserManager::disable($user_id);
// 3. exit the page
unset($user_id);
Display::display_header($tool_name);
echo Display::page_header($tool_name);
echo $content;
Display::display_footer();
exit;
} elseif (api_get_setting('allow_registration') === 'confirmation') {
// 1. Send mail to the user
$thisUser = api_get_user_entity($user_id);
UserManager::sendUserConfirmationMail($thisUser);
// 2. set account inactive
UserManager::disable($user_id);
// 3. exit the page
unset($user_id);
Display::addFlash(
Display::return_message(
get_lang('YouNeedConfirmYourAccountViaEmailToAccessThePlatform'),
'warning'
)
);
Display::display_header($tool_name);
//echo $content;
Display::display_footer();
exit;
}
} }
} }
}
// Terms & Conditions // Terms & Conditions
if (api_get_setting('allow_terms_conditions') === 'true') { if (api_get_setting('allow_terms_conditions') === 'true') {
// Update the terms & conditions. // Update the terms & conditions.
if (isset($values['legal_accept_type'])) { if (isset($values['legal_accept_type'])) {
$cond_array = explode(':', $values['legal_accept_type']); $cond_array = explode(':', $values['legal_accept_type']);
if (!empty($cond_array[0]) && !empty($cond_array[1])) { if (!empty($cond_array[0]) && !empty($cond_array[1])) {
$conditionToSave = (int) $cond_array[0].':'.(int) $cond_array[1].':'.time(); $conditionToSave = (int) $cond_array[0].':'.(int) $cond_array[1].':'.time();
Event::addEvent( Event::addEvent(
LOG_TERM_CONDITION_ACCEPTED, LOG_TERM_CONDITION_ACCEPTED,
LOG_USER_OBJECT, LOG_USER_OBJECT,
api_get_user_info($user_id), api_get_user_info($user_id),
api_get_utc_datetime() api_get_utc_datetime()
); );
LegalManager::sendEmailToUserBoss($user_id, $conditionToSave); LegalManager::sendEmailToUserBoss($user_id, $conditionToSave);
}
} }
$values = api_get_user_info($user_id);
} }
$values = api_get_user_info($user_id);
}
/* SESSION REGISTERING */ /* SESSION REGISTERING */
/* @todo move this in a function */ /* @todo move this in a function */
$_user['firstName'] = stripslashes($values['firstname']); $_user['firstName'] = stripslashes($values['firstname']);
$_user['lastName'] = stripslashes($values['lastname']); $_user['lastName'] = stripslashes($values['lastname']);
$_user['mail'] = $values['email']; $_user['mail'] = $values['email'];
$_user['language'] = $values['language']; $_user['language'] = $values['language'];
$_user['user_id'] = $user_id; $_user['user_id'] = $user_id;
$_user['status'] = $values['status'] ?? STUDENT; $_user['status'] = $values['status'] ?? STUDENT;
ConditionalLogin::check_conditions($_user); ConditionalLogin::check_conditions($_user);
Session::write('_user', $_user); Session::write('_user', $_user);
$is_allowedCreateCourse = isset($values['status']) && $values['status'] == 1; $is_allowedCreateCourse = isset($values['status']) && $values['status'] == 1;
$usersCanCreateCourse = api_is_allowed_to_create_course(); $usersCanCreateCourse = api_is_allowed_to_create_course();
Session::write('is_allowedCreateCourse', $is_allowedCreateCourse); Session::write('is_allowedCreateCourse', $is_allowedCreateCourse);
// Stats // Stats
Event::eventLogin($user_id); Event::eventLogin($user_id);
// last user login date is now // last user login date is now
$user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970 $user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970
Session::write('user_last_login_datetime', $user_last_login_datetime); Session::write('user_last_login_datetime', $user_last_login_datetime);
$recipient_name = api_get_person_name($values['firstname'], $values['lastname']); $recipient_name = api_get_person_name($values['firstname'], $values['lastname']);
$text_after_registration = $text_after_registration =
'<p>'. '<p>'.
get_lang('Dear').' '. get_lang('Dear').' '.
stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'. stripslashes(Security::remove_XSS($recipient_name)).',<br /><br />'.
get_lang('PersonalSettings').".</p>"; get_lang('PersonalSettings').".</p>";
$form_data = [ $form_data = [
'button' => Display::button( 'button' => Display::button(
'next', 'next',
get_lang('Next'), get_lang('Next'),
['class' => 'btn btn-primary btn-large'] ['class' => 'btn btn-primary btn-large']
), ),
'message' => '', 'message' => '',
'action' => api_get_path(WEB_PATH).'user_portal.php', 'action' => api_get_path(WEB_PATH).'user_portal.php',
'go_button' => '', 'go_button' => '',
]; ];
if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_registered_show_terms) { if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_registered_show_terms) {
if (api_get_setting('load_term_conditions_section') === 'login') { if (api_get_setting('load_term_conditions_section') === 'login') {
$form_data['action'] = api_get_path(WEB_PATH).'user_portal.php';
} else {
$courseInfo = api_get_course_info();
if (!empty($courseInfo)) {
$form_data['action'] = $courseInfo['course_public_url'].'?id_session='.api_get_session_id();
$cidReset = true;
Session::erase('_course');
Session::erase('_cid');
} else {
$form_data['action'] = api_get_path(WEB_PATH).'user_portal.php'; $form_data['action'] = api_get_path(WEB_PATH).'user_portal.php';
} else {
$courseInfo = api_get_course_info();
if (!empty($courseInfo)) {
$form_data['action'] = $courseInfo['course_public_url'].'?id_session='.api_get_session_id();
$cidReset = true;
Session::erase('_course');
Session::erase('_cid');
} else {
$form_data['action'] = api_get_path(WEB_PATH).'user_portal.php';
}
} }
} } else {
} else { if (!empty($values['email'])) {
if (!empty($values['email'])) { $text_after_registration .= '<p>'.get_lang('MailHasBeenSent').'.</p>';
$text_after_registration .= '<p>'.get_lang('MailHasBeenSent').'.</p>';
}
if ($is_allowedCreateCourse) {
if ($usersCanCreateCourse) {
$form_data['message'] = '<p>'.get_lang('NowGoCreateYourCourse').'</p>';
} }
$form_data['action'] = api_get_path(WEB_CODE_PATH).'create_course/add_course.php';
if (api_get_setting('course_validation') === 'true') { if ($is_allowedCreateCourse) {
$form_data['button'] = Display::button( if ($usersCanCreateCourse) {
'next', $form_data['message'] = '<p>'.get_lang('NowGoCreateYourCourse').'</p>';
get_lang('CreateCourseRequest'), }
['class' => 'btn btn-primary btn-large'] $form_data['action'] = api_get_path(WEB_CODE_PATH).'create_course/add_course.php';
);
if (api_get_setting('course_validation') === 'true') {
$form_data['button'] = Display::button(
'next',
get_lang('CreateCourseRequest'),
['class' => 'btn btn-primary btn-large']
);
} else {
$form_data['button'] = Display::button(
'next',
get_lang('CourseCreate'),
['class' => 'btn btn-primary btn-large']
);
$form_data['go_button'] = '&nbsp;&nbsp;<a href="'.api_get_path(WEB_PATH).'index.php'.'">'.
Display::span(
get_lang('Next'),
['class' => 'btn btn-primary btn-large']
).'</a>';
}
} else { } else {
if (api_get_setting('allow_students_to_browse_courses') == 'true') {
$form_data['action'] = 'courses.php?action=subscribe';
$form_data['message'] = '<p>'.get_lang('NowGoChooseYourCourses').".</p>";
} else {
$form_data['action'] = api_get_path(WEB_PATH).'user_portal.php';
}
$form_data['button'] = Display::button( $form_data['button'] = Display::button(
'next', 'next',
get_lang('CourseCreate'), get_lang('Next'),
['class' => 'btn btn-primary btn-large'] ['class' => 'btn btn-primary btn-large']
); );
$form_data['go_button'] = '&nbsp;&nbsp;<a href="'.api_get_path(WEB_PATH).'index.php'.'">'.
Display::span(
get_lang('Next'),
['class' => 'btn btn-primary btn-large']
).'</a>';
}
} else {
if (api_get_setting('allow_students_to_browse_courses') == 'true') {
$form_data['action'] = 'courses.php?action=subscribe';
$form_data['message'] = '<p>'.get_lang('NowGoChooseYourCourses').".</p>";
} else {
$form_data['action'] = api_get_path(WEB_PATH).'user_portal.php';
} }
$form_data['button'] = Display::button(
'next',
get_lang('Next'),
['class' => 'btn btn-primary btn-large']
);
} }
}
if ($sessionPremiumChecker && $sessionId) { if ($sessionPremiumChecker && $sessionId) {
$url = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process.php?i='.$sessionId.'&t=2'; $url = api_get_path(WEB_PLUGIN_PATH).'buycourses/src/process.php?i='.$sessionId.'&t=2';
Session::erase('SessionIsPremium'); Session::erase('SessionIsPremium');
Session::erase('sessionId'); Session::erase('sessionId');
header('Location:'.$url); header('Location:'.$url);
exit; exit;
} }
SessionManager::redirectToSession(); SessionManager::redirectToSession();
$redirectBuyCourse = Session::read('buy_course_redirect'); $redirectBuyCourse = Session::read('buy_course_redirect');
if (!empty($redirectBuyCourse)) { if (!empty($redirectBuyCourse)) {
$form_data['action'] = api_get_path(WEB_PATH).$redirectBuyCourse; $form_data['action'] = api_get_path(WEB_PATH).$redirectBuyCourse;
Session::erase('buy_course_redirect'); Session::erase('buy_course_redirect');
} }
$form_data = CourseManager::redirectToCourse($form_data); $form_data = CourseManager::redirectToCourse($form_data);
$form_register = new FormValidator('form_register', 'post', $form_data['action']); $form_register = new FormValidator('form_register', 'post', $form_data['action']);
if (!empty($form_data['message'])) { if (!empty($form_data['message'])) {
$form_register->addElement('html', $form_data['message'].'<br /><br />'); $form_register->addElement('html', $form_data['message'].'<br /><br />');
} }
if ($usersCanCreateCourse) { if ($usersCanCreateCourse) {
$form_register->addElement('html', $form_data['button']); $form_register->addElement('html', $form_data['button']);
} else {
if (!empty($redirectBuyCourse)) {
$form_register->addButtonNext(get_lang('Next'));
} else { } else {
$form_register->addElement('html', $form_data['go_button']); if (!empty($redirectBuyCourse)) {
$form_register->addButtonNext(get_lang('Next'));
} else {
$form_register->addElement('html', $form_data['go_button']);
}
} }
}
$text_after_registration .= $form_register->returnForm(); $text_after_registration .= $form_register->returnForm();
// Just in case // Just in case
Session::erase('course_redirect'); Session::erase('course_redirect');
Session::erase('exercise_redirect'); Session::erase('exercise_redirect');
Session::erase('session_redirect'); Session::erase('session_redirect');
Session::erase('only_one_course_session_redirect'); Session::erase('only_one_course_session_redirect');
if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION_FEEDBACK)) { if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION_FEEDBACK)) {
CustomPages::display( CustomPages::display(
CustomPages::REGISTRATION_FEEDBACK, CustomPages::REGISTRATION_FEEDBACK,
['info' => $text_after_registration] ['info' => $text_after_registration]
); );
} else { } else {
$tpl = new Template($tool_name); $tpl = new Template($tool_name);
$tpl->assign('inscription_content', $content); $tpl->assign('inscription_content', $content);
$tpl->assign('text_after_registration', $text_after_registration); $tpl->assign('text_after_registration', $text_after_registration);
$tpl->assign('hide_header', $hideHeaders); $tpl->assign('hide_header', $hideHeaders);
$inscription = $tpl->get_template('auth/inscription.tpl'); $inscription = $tpl->get_template('auth/inscription.tpl');
$tpl->display($inscription); $tpl->display($inscription);
}
} }
} else { }
if (!$formValid) {
// Custom pages // Custom pages
if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION)) { if (CustomPages::enabled() && CustomPages::exists(CustomPages::REGISTRATION)) {
CustomPages::display( CustomPages::display(

@ -10683,3 +10683,22 @@ function api_encrypt_hash($data, $secret)
return base64_encode($iv) . base64_encode($encrypted . $tag); return base64_encode($iv) . base64_encode($encrypted . $tag);
} }
/**
* Check existence of a user extra field with a specific value
*
* @param string $extraField The name of the extra field to check.
* @param string $extraFieldValue The value of the extra field to validate against.
*
* @return bool True if the extra field with the specified value exists, false otherwise.
*/
function api_user_extra_field_validation($extraField, $extraFieldValue) {
$fieldValue = new ExtraFieldValue('user');
$data = $fieldValue->get_item_id_from_field_variable_and_field_value($extraField, $extraFieldValue, false, true);
if ($data) {
return true;
}
return false;
}

@ -1675,6 +1675,13 @@ ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_USER FOREIGN KEY (user
// Add help text to put 2 names in registration form // Add help text to put 2 names in registration form
//$_configuration['registration_add_helptext_for_2_names'] = false; //$_configuration['registration_add_helptext_for_2_names'] = false;
// Add extra fields to validate on user registration
/*$_configuration['extra_fields_to_validate_on_user_registration'] = [
'extra_fields' => [
'passport', 'employee_id'
]
];*/
// Allow career/promotions in global announcements // Allow career/promotions in global announcements
// ALTER TABLE sys_announcement ADD COLUMN career_id INT DEFAULT 0; // ALTER TABLE sys_announcement ADD COLUMN career_id INT DEFAULT 0;
// ALTER TABLE sys_announcement ADD COLUMN promotion_id INT DEFAULT 0; // ALTER TABLE sys_announcement ADD COLUMN promotion_id INT DEFAULT 0;

Loading…
Cancel
Save