diff --git a/main/auth/inscription.php b/main/auth/inscription.php index 4f2544d37c..5a91cd773f 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -13,9 +13,21 @@ if (!empty($_POST['language'])) { $_GET['language'] = $_POST['language']; } require_once '../inc/global.inc.php'; - $hideHeaders = isset($_GET['hide_headers']); +$allowedFields = [ + 'official_code', + 'phone', + 'status', + 'language', + 'extra_fields' +]; + +$allowedFieldsConfiguration = api_get_configuration_value('allow_fields_inscription'); +if ($allowedFieldsConfiguration != false) { + $allowedFields = $allowedFieldsConfiguration; +} + $htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1'); // User is not allowed if Terms and Conditions are disabled and @@ -88,13 +100,20 @@ if ($user_already_registered_show_terms == false) { // OFFICIAL CODE if (CONFVAL_ASK_FOR_OFFICIAL_CODE) { - $form->addElement('text', 'official_code', get_lang('OfficialCode'), array('size' => 40)); - if (api_get_setting('registration', 'officialcode') == 'true') { - $form->addRule( + if (in_array('official_code', $allowedFields)) { + $form->addElement( + 'text', 'official_code', - get_lang('ThisFieldIsRequired'), - 'required' + get_lang('OfficialCode'), + array('size' => 40) ); + if (api_get_setting('registration', 'officialcode') == 'true') { + $form->addRule( + 'official_code', + get_lang('ThisFieldIsRequired'), + 'required' + ); + } } } @@ -131,19 +150,50 @@ if ($user_already_registered_show_terms == false) { } // PHONE - $form->addElement('text', 'phone', get_lang('Phone'), array('size' => 20)); - if (api_get_setting('registration', 'phone') == 'true') { - $form->addRule('phone', get_lang('ThisFieldIsRequired'), 'required'); + if (in_array('phone', $allowedFields)) { + $form->addElement( + 'text', + 'phone', + get_lang('Phone'), + array('size' => 20) + ); + if (api_get_setting('registration', 'phone') == 'true') { + $form->addRule( + 'phone', + get_lang('ThisFieldIsRequired'), + 'required' + ); + } } // LANGUAGE - if (api_get_setting('registration', 'language') == 'true') { - $form->addElement('select_language', 'language', get_lang('Language')); + if (in_array('language', $allowedFields)) { + if (api_get_setting('registration', 'language') == 'true') { + $form->addElement( + 'select_language', + 'language', + get_lang('Language') + ); + } } // STUDENT/TEACHER if (api_get_setting('allow_registration_as_teacher') != 'false') { - $form->addElement('radio', 'status', get_lang('Profile'), get_lang('RegStudent'), STUDENT); - $form->addElement('radio', 'status', null, get_lang('RegAdmin'), COURSEMANAGER); + if (in_array('status', $allowedFields)) { + $form->addElement( + 'radio', + 'status', + get_lang('Profile'), + get_lang('RegStudent'), + STUDENT + ); + $form->addElement( + 'radio', + 'status', + null, + get_lang('RegAdmin'), + COURSEMANAGER + ); + } } $captcha = api_get_setting('allow_captcha'); @@ -218,8 +268,10 @@ if ($user_already_registered_show_terms == false) { } // EXTRA FIELDS - $extraField = new ExtraField('user'); - $returnParams = $extraField->addElements($form); + if (in_array('extra_fields', $allowedFields)) { + $extraField = new ExtraField('user'); + $returnParams = $extraField->addElements($form); + } } if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') { @@ -405,7 +457,7 @@ if ($form->validate()) { $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(); // Creates a new user $user_id = UserManager::create_user( $values['firstname'], diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 773bf7bcec..bde57c8c34 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -215,3 +215,11 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE; // Allow anonymous users to see the courses/sessions catalogue //$_configuration['course_catalog_published'] = 'false'; +// Only shows the fields in this list +/*$_configuration['allow_fields_inscription'] = [ + 'official_code', + 'phone', + 'status', + 'language', + 'extra_fields' +];*/