'index.php', "name" => get_lang('PlatformAdmin')); $tool_name = get_lang('AddUserFields'); // Create the form $form = new FormValidator('user_fields_add'); // Field variable name $form->addElement('text','fieldlabel',get_lang('FieldLabel')); $form->applyFilter('fieldlabel','html_filter'); $form->applyFilter('fieldlabel','trim'); $form->addRule('fieldlabel', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('fieldlabel', get_lang('OnlyLettersAndNumbersAllowed'), 'username'); $form->addRule('fieldlabel', '', 'maxlength',20); $form->addRule('fieldlabel', get_lang('FieldTaken'), 'fieldlabel_available'); // Field type $types = array(); $types[USER_FIELD_TYPE_TEXT] = get_lang('FieldTypeText'); //$types[USER_FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea'); //$types[USER_FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio'); //$types[USER_FIELD_TYPE_SELECT] = get_lang('FieldTypeSelect'); //$types[USER_FIELD_TYPE_SELECT_MULTIPLE] = get_lang('FieldTypeSelectMultiple'); $form->addElement('select','fieldtype',get_lang('FieldType'),$types); $form->addRule('fieltype', get_lang('ThisFieldIsRequired'), 'required'); // Field display name $form->addElement('text','fieldtitle',get_lang('FieldTitle')); $form->applyFilter('fieldtitle','html_filter'); $form->applyFilter('fieldtitle','trim'); $form->addRule('fieldtitle', get_lang('ThisFieldIsRequired'), 'required'); // Field default value $form->addElement('text','fielddefaultvalue',get_lang('FieldDefaultValue')); // Set default values $defaults = array(); $form->setDefaults($defaults); // Submit button $form->addElement('submit', 'submit', get_lang('Add')); // Validate form if( $form->validate()) { $check = Security::check_token('post'); if($check) { $field = $form->exportValues(); $fieldlabel = $field['fieldlabel']; $fieldtype = $field['fieldtype']; $fieldtitle = $field['fieldtitle']; $fielddefault = $field['fielddefaultvalue']; $field_id = UserManager::create_extra_field($fieldlabel,$fieldtype,$fieldtitle,$fielddefault); Security::clear_token(); header('Location: user_fields.php?action=show_message&message='.urlencode(get_lang('FieldAdded'))); exit (); } }else{ if(isset($_POST['submit'])){ Security::clear_token(); } $token = Security::get_token(); $form->addElement('hidden','sec_token'); $form->setConstants(array('sec_token' => $token)); } // Display form Display::display_header($tool_name); //api_display_tool_title($tool_name); if(!empty($_GET['message'])){ Display::display_normal_message($_GET['message']); } $form->display(); /* ============================================================================== FOOTER ============================================================================== */ Display::display_footer(); ?>