addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); } else { // LAST NAME and FIRST NAME $form->addElement('text', 'lastname', get_lang('LastName'), array('size' => 40)); $form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40)); } $form->applyFilter(array('lastname', 'firstname'), 'trim'); $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); // EMAIL $form->addElement('text', 'email', get_lang('Email'), array('size' => 40)); if (api_get_setting('registration', 'email') == 'true') { $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required'); } if (api_get_setting('login_is_email') == 'true') { $form->applyFilter('email', 'trim'); if (api_get_setting('registration', 'email') != 'true') { $form->addRule('email', get_lang('ThisFieldIsRequired'), 'required'); } $form->addRule('email', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); $form->addRule('email', get_lang('UserTaken'), 'username_available'); } $form->addRule('email', get_lang('EmailWrong'), 'email'); if (api_get_setting('openid_authentication') == 'true') { $form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40)); } // OFFICIAL CODE if (CONFVAL_ASK_FOR_OFFICIAL_CODE) { if (in_array('official_code', $allowedFields)) { $form->addElement( 'text', 'official_code', get_lang('OfficialCode'), array('size' => 40) ); if (api_get_setting('registration', 'officialcode') == 'true') { $form->addRule( 'official_code', get_lang('ThisFieldIsRequired'), 'required' ); } } } // USERNAME if (api_get_setting('login_is_email') != 'true') { $form->addElement('text', 'username', get_lang('UserName'), array('id' => 'username', 'size' => USERNAME_MAX_LENGTH)); $form->applyFilter('username', 'trim'); $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); $form->addRule('username', get_lang('UsernameWrong'), 'username'); $form->addRule('username', get_lang('UserTaken'), 'username_available'); } // PASSWORD $form->addElement('password', 'pass1', get_lang('Pass'), array('id' => 'pass1', 'size' => 20, 'autocomplete' => 'off')); $checkPass = api_get_setting('allow_strength_pass_checker'); if ($checkPass == 'true') { $form->addElement('label', null, '
'); } $form->addElement('password', 'pass2', get_lang('Confirmation'), array('id' => 'pass2', 'size' => 20, 'autocomplete' => 'off')); $form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare'); if (CHECK_PASS_EASY_TO_FIND) { $form->addRule( 'password1', get_lang('PassTooEasy') . ': ' . api_generate_password(), 'callback', 'api_check_password' ); } // PHONE 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 (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') { 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'); $allowCaptcha = $captcha == 'true'; if ($allowCaptcha) { $ajax = api_get_path(WEB_AJAX_PATH).'form.ajax.php?a=get_captcha'; $options = array( 'width' => 220, 'height' => 90, 'callback' => $ajax.'&var='.basename(__FILE__, '.php'), 'sessionVar' => basename(__FILE__, '.php'), 'imageOptions' => array( 'font_size' => 20, 'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/', 'font_file' => 'OpenSans-Regular.ttf', //'output' => 'gif' ) ); $captcha_question = $form->addElement('CAPTCHA_Image', 'captcha_question', '', $options); $form->addElement('static', null, null, get_lang('ClickOnTheImageForANewOne')); $form->addElement('text', 'captcha', get_lang('EnterTheLettersYouSee'), array('size' => 40)); $form->addRule('captcha', get_lang('EnterTheCharactersYouReadInTheImage'), 'required', null, 'client'); $form->addRule('captcha', get_lang('TheTextYouEnteredDoesNotMatchThePicture'), 'CAPTCHA', $captcha_question); } // EXTENDED FIELDS if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true' ) { $form->addHtmlEditor('competences', get_lang('MyCompetences'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130')); } if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true' ) { $form->addHtmlEditor('diplomas', get_lang('MyDiplomas'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130')); } if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'myteach') == 'true' ) { $form->addHtmlEditor('teach', get_lang('MyTeach'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130')); } if (api_get_setting('extended_profile') == 'true' && api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true' ) { $form->addHtmlEditor('openarea', get_lang('MyPersonalOpenArea'), false, false, array('ToolbarSet' => 'register', 'Width' => '100%', 'Height' => '130')); } if (api_get_setting('extended_profile') == 'true') { if (api_get_setting('extendedprofile_registration', 'mycomptetences') == 'true' && api_get_setting('extendedprofile_registrationrequired', 'mycomptetences') == 'true' ) { $form->addRule('competences', get_lang('ThisFieldIsRequired'), 'required'); } if (api_get_setting('extendedprofile_registration', 'mydiplomas') == 'true' && api_get_setting('extendedprofile_registrationrequired', 'mydiplomas') == 'true' ) { $form->addRule('diplomas', get_lang('ThisFieldIsRequired'), 'required'); } if (api_get_setting('extendedprofile_registration', 'myteach') == 'true' && api_get_setting('extendedprofile_registrationrequired', 'myteach') == 'true' ) { $form->addRule('teach', get_lang('ThisFieldIsRequired'), 'required'); } if (api_get_setting('extendedprofile_registration', 'mypersonalopenarea') == 'true' && api_get_setting('extendedprofile_registrationrequired', 'mypersonalopenarea') == 'true' ) { $form->addRule('openarea', get_lang('ThisFieldIsRequired'), 'required'); } } // EXTRA FIELDS if (in_array('extra_fields', $allowedFields)) { $extraField = new ExtraField('user'); $returnParams = $extraField->addElements($form); } } if (isset($_SESSION['user_language_choice']) && $_SESSION['user_language_choice'] != '') { $defaults['language'] = $_SESSION['user_language_choice']; } else { $defaults['language'] = api_get_setting('platformLanguage'); } if (!empty($_GET['username'])) { $defaults['username'] = Security::remove_XSS($_GET['username']); } if (!empty($_GET['email'])) { $defaults['email'] = Security::remove_XSS($_GET['email']); } if (!empty($_GET['phone'])) { $defaults['phone'] = Security::remove_XSS($_GET['phone']); } if (api_get_setting('openid_authentication') == 'true' && !empty($_GET['openid'])) { $defaults['openid'] = Security::remove_XSS($_GET['openid']); } $defaults['status'] = STUDENT; $defaults['extra_mail_notify_invitation'] = 1; $defaults['extra_mail_notify_message'] = 1; $defaults['extra_mail_notify_group_message'] = 1; $form->setDefaults($defaults); $content = null; if (!CustomPages::enabled()) { // Load terms & conditions from the current lang if (api_get_setting('allow_terms_conditions') == 'true') { $get = array_keys($_GET); if (isset($get)) { if ($get[0] == 'legal') { $language = api_get_interface_language(); $language = api_get_language_id($language); $term_preview = LegalManager::get_last_condition($language); if (!$term_preview) { //look for the default language $language = api_get_setting('platformLanguage'); $language = api_get_language_id($language); $term_preview = LegalManager::get_last_condition($language); } $tool_name = get_lang('TermsAndConditions'); Display :: display_header($tool_name); if (!empty($term_preview['content'])) { echo $term_preview['content']; } else { echo get_lang('ComingSoon'); } Display :: display_footer(); exit; } } } $tool_name = get_lang('Registration', null, (!empty($_POST['language'])?$_POST['language']: $_user['language'])); if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) { $tool_name = get_lang('TermsAndConditions'); } $home = api_get_path(SYS_APP_PATH).'home/'; if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); $clean_url = api_replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $home_old = api_get_path(SYS_APP_PATH).'home/'; $home = api_get_path(SYS_APP_PATH).'home/'.$clean_url; } } if (file_exists($home.'register_top_'.$user_selected_language.'.html')) { $home_top_temp = @(string)file_get_contents($home.'register_top_'.$user_selected_language.'.html'); $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); if (!empty($open)) { $content = ''.
get_lang('Dear', null, $_user['language']).' '.
stripslashes(Security::remove_XSS($recipient_name)).',
'.
get_lang('PersonalSettings',null,$_user['language']).".
'.get_lang('MailHasBeenSent', null, $_user['language']).'.
'; } if ($is_allowedCreateCourse) { if ($usersCanCreateCourse) { $form_data['message'] = ''. get_lang('NowGoCreateYourCourse', null, $_user['language']). "
"; } $form_data['action'] = '../create_course/add_course.php'; if (api_get_setting('course_validation') == 'true') { $form_data['button'] = Display::button( 'next', get_lang('CreateCourseRequest', null, $_user['language']), array('class' => 'btn btn-primary btn-large') ); } else { $form_data['button'] = Display::button( 'next', get_lang('CourseCreate', null, $_user['language']), array('class' => 'btn btn-primary btn-large') ); $form_data['go_button'] = ' '. Display::span(get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large')).''; } } else { if (api_get_setting('allow_students_to_browse_courses') == 'true') { $form_data['action'] = 'courses.php?action=subscribe'; $form_data['message'] = ''. get_lang('NowGoChooseYourCourses', null, $_user['language']). ".
"; } else { $form_data['action'] = api_get_path(WEB_PATH).'user_portal.php'; } $form_data['button'] = Display::button( 'next', get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large') ); } } $form_data = CourseManager::redirectToCourse($form_data); $form_register = new FormValidator('form_register', 'post', $form_data['action']); if (!empty($form_data['message'])) { $form_register->addElement('html', $form_data['message'].'