diff --git a/phpBB/adm/admin_profile.php b/phpBB/adm/admin_profile.php
new file mode 100644
index 0000000000..2d51219058
--- /dev/null
+++ b/phpBB/adm/admin_profile.php
@@ -0,0 +1,1033 @@
+acl_get('a_user')) ? "$filename$SID&mode=manage" : '';
+
+ return;
+}
+
+define('IN_PHPBB', 1);
+// Include files
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+require('pagestart.' . $phpEx);
+include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
+include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
+include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
+
+// lang_admin - temporary placed here...
+$user->lang += array(
+ 'FIELD_INT' => 'Numbers',
+ 'FIELD_STRING' => 'Single Textfield',
+ 'FIELD_TEXT' => 'Textarea',
+ 'FIELD_BOOL' => 'Boolean (Yes/No)',
+ 'FIELD_DROPDOWN'=> 'Dropdown Box',
+ 'FIELD_DATE' => 'Date',
+
+ 'CUSTOM_PROFILE_FIELDS' => 'Custom Profile Fields',
+ 'NO_FIELD_TYPE' => 'No Field type specified',
+ 'FIRST_OPTION' => 'First Option',
+ 'SECOND_OPTION' => 'Second Option',
+ 'EMPTY_FIELD_NAME' => 'Empty field name',
+ 'EMPTY_USER_FIELD_NAME' => 'Empty Field Name presented to the user',
+ 'FIELD_IDENT_ALREADY_EXIST' => 'Field identifier %s already exist, please choose another Field Name.',
+ 'NEXT_PAGE' => 'Next Page',
+ 'PREVIOUS_PAGE' => 'Previous Page',
+ 'STEP_1_TITLE' => 'Add Profile Field',
+ 'STEP_2_TITLE' => 'Profile type specific options',
+ 'STEP_3_TITLE' => 'Remaining Language Definitions',
+ 'REQUIRED_FIELD_EXPLAIN' => 'Force profile field to be filled out or specified by user',
+ 'REQUIRED_FIELD' => 'Required Field',
+ 'DISPLAY_AT_REGISTRATION' => 'Display at registration screen',
+ 'ROWS' => 'Rows',
+ 'COLUMNS' => 'Columns',
+ 'STEP_X_FROM_X' => 'Step %1$d from %2$d',
+
+ 'STRING_DEFAULT_VALUE' => 'Default Value',
+ 'TEXT_DEFAULT_VALUE' => 'Default Value',
+ 'STRING_DEFAULT_VALUE_EXPLAIN' => 'Enter a default phrase to be displayed, a default value. Leave empty if you want to show it empty at the first place.',
+ 'TEXT_DEFAULT_VALUE_EXPLAIN'=> 'Enter a default text to be displayed, a default value. Leave empty if you want to show it empty at the first place.',
+ 'BOOL_ENTRIES' => 'Entries',
+ 'DROPDOWN_ENTRIES' => 'Entries',
+ 'BOOL_ENTRIES_EXPLAIN' => 'Enter your options now',
+ 'DROPDOWN_ENTRIES_EXPLAIN' => 'Enter your options now, every option in one line',
+
+ 'HIDE_PROFILE_FIELD' => 'Hide Profile Field',
+ 'HIDE_PROFILE_FIELD_EXPLAIN'=> 'Only Administrators and Moderators are able to see this profile field',
+ 'ADDED_PROFILE_FIELD' => 'Successfully added custom profile field',
+ 'CREATE_NEW_FIELD' => 'Create New Field'
+);
+
+if (!$auth->acl_get('a_user'))
+{
+ trigger_error($user->lang['NO_ADMIN']);
+}
+
+$mode = (isset($_POST['add'])) ? 'create' : request_var('mode', '');
+$submit = (isset($_POST['submit'])) ? TRUE : FALSE;
+$create = (isset($_POST['create'])) ? TRUE : FALSE;
+$error = $notify = array();
+
+adm_page_header('CUSTOM_PROFILE_FIELDS');
+
+$default_values = array(
+ 'field_length' => array(FIELD_STRING => 10, FIELD_TEXT => '5|80', FIELD_INT => 5, FIELD_DATE => 10, FIELD_BOOL => 1, FIELD_DROPDOWN => 0),
+ 'field_minlen' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 10, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
+ 'field_maxlen' => array(FIELD_STRING => 20, FIELD_TEXT => 1000, FIELD_INT => 100, FIELD_DATE => 10, FIELD_BOOL => 0, FIELD_DROPDOWN => 5),
+ 'field_validation' => array(FIELD_STRING => '.*', FIELD_TEXT => '.*', FIELD_INT => '', FIELD_DATE => '', FIELD_BOOL => '', FIELD_DROPDOWN => ''),
+ 'field_novalue' => array(FIELD_STRING => '', FIELD_TEXT => '', FIELD_INT => 0, FIELD_DATE => ' 0- 0- 0', FIELD_BOOL => 0, FIELD_DROPDOWN => 1),
+ 'field_default_value' => array(FIELD_STRING => '', FIELD_TEXT => '', FIELD_INT => 0, FIELD_DATE => ' 0- 0- 0', FIELD_BOOL => 0, FIELD_DROPDOWN => 1),
+ 'field_required' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 0, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
+ 'field_hide' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 0, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
+ 'field_show_on_reg' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 0, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
+ 'pf_preview' => array(FIELD_STRING => '', FIELD_TEXT => '', FIELD_INT => '', FIELD_DATE => ' 0- 0- 0', FIELD_BOOL => '', FIELD_DROPDOWN => '')
+);
+
+$cp = new custom_profile_admin();
+
+// Build Language array
+// Based on this, we decide which elements need to be edited later and which language items are missing
+$lang_ids = $lang_entry = $lang_diff = array();
+
+$result = $db->sql_query('SELECT lang_id FROM phpbb_lang');
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $lang_ids[] = $row['lang_id'];
+}
+$db->sql_freeresult($result);
+
+$sql = 'SELECT field_id, lang_id
+ FROM phpbb_profile_lang
+ ORDER BY lang_id';
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $lang_entry[$row['field_id']][] = $row['lang_id'];
+}
+$db->sql_freeresult($result);
+
+foreach ($lang_entry as $field_id => $field_ary)
+{
+ $lang_diff[$field_id] = array_diff($lang_ids, $field_ary);
+}
+unset($lang_ids);
+
+if ($mode == '')
+{
+ trigger_error('INVALID_MODE');
+}
+
+if ($mode == 'create')
+{
+ $field_type = request_var('field_type', 0);
+ $cp->vars['field_name'] = request_var('field_name', '');
+ $field_ident = strtolower(str_replace(array(' ', "'"), array('', ''), $cp->vars['field_name']));
+
+ $step = request_var('step', 1);
+ $s_hidden_fields = '';
+
+ $submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false;
+ $update = (isset($_REQUEST['update'])) ? true : false;
+ $save = (isset($_REQUEST['save'])) ? true : false;
+
+ if (!$field_type)
+ {
+ trigger_error('NO_FIELD_TYPE');
+ }
+
+ // Get all relevant informations about entered values within all steps
+
+ // step 1
+ $exclude[1] = array('lang_name', 'lang_explain', 'field_name');
+
+ // Text-based fields require lang_default_value to be excluded
+ if ($field_type == FIELD_STRING || $field_type == FIELD_TEXT)
+ {
+ $exclude[1][] = 'lang_default_value';
+ }
+
+ // option-specific fields require lang_options to be excluded
+ if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN)
+ {
+ $exclude[1][] = 'lang_options';
+ }
+
+ $cp->vars['lang_name'] = request_var('lang_name', '');
+ $cp->vars['lang_explain'] = request_var('lang_explain', '');
+ $cp->vars['lang_default_value'] = request_var('lang_default_value', '');
+ $cp->vars['lang_options'] = request_var('lang_options', '');
+
+ // step 2
+ $exclude[2] = array('field_length', 'pf_preview', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value', 'field_required', 'field_show_on_reg', 'field_hide');
+ foreach ($exclude[2] as $key)
+ {
+ $var = request_var($key, $default_values[$key][$field_type]);
+
+ // Manipulate the intended variables a little bit if needed
+ if ($field_type == FIELD_DROPDOWN && $key == 'field_maxlen')
+ {
+ $var = sizeof(explode("\n", request_var('lang_options', '')));
+ }
+
+ if ($field_type == FIELD_TEXT && $key == 'field_length')
+ {
+ if (isset($_REQUEST['rows']))
+ {
+ $cp->vars['rows'] = request_var('rows', 0);
+ $cp->vars['columns'] = request_var('columns', 0);
+ $var = $cp->vars['rows'] . '|' . $cp->vars['columns'];
+ }
+ else
+ {
+ $row_col = explode('|', $var);
+ $cp->vars['rows'] = $row_col[0];
+ $cp->vars['columns'] = $row_col[1];
+ }
+ }
+
+ if ($field_type == FIELD_DATE && $key == 'field_default_value')
+ {
+ if (isset($_REQUEST['always_now']) || $var == 'now')
+ {
+ $now = getdate();
+
+ $cp->vars['field_default_value_day'] = $now['mday'];
+ $cp->vars['field_default_value_month'] = $now['mon'];
+ $cp->vars['field_default_value_year'] = $now['year'];
+ $var = $_POST['field_default_value'] = 'now';
+ }
+ else
+ {
+ if (isset($_REQUEST['field_default_value_day']))
+ {
+ $cp->vars['field_default_value_day'] = request_var('field_default_value_day', 0);
+ $cp->vars['field_default_value_month'] = request_var('field_default_value_month', 0);
+ $cp->vars['field_default_value_year'] = request_var('field_default_value_year', 0);
+ $var = $_POST['field_default_value'] = sprintf('%2d-%2d-%4d', $cp->vars['field_default_value_day'], $cp->vars['field_default_value_month'], $cp->vars['field_default_value_year']);
+ }
+ else
+ {
+ list($cp->vars['field_default_value_day'], $cp->vars['field_default_value_month'], $cp->vars['field_default_value_year']) = explode('-', $var);
+ }
+ }
+ }
+/*
+ if (($field_type == FIELD_TEXT || $field_type == FIELD_STRING) && $key == 'options')
+ {
+ $allow_html = (isset($_REQUEST['allow_html'])) ? 1 : 0;
+ $allow_bbcode = (isset($_REQUEST['allow_bbcode'])) ? 1 : 0;
+ $allow_smilies = (isset($_REQUEST['allow_smilies'])) ? 1 : 0;
+ }
+*/
+
+ $cp->vars[$key] = $var;
+ }
+
+ // step 3 - all arrays
+ $exclude[3] = array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options');
+ foreach ($exclude[3] as $key)
+ {
+ $cp->vars[$key] = request_var($key, '');
+ }
+
+ $error = array();
+ if ($submit && $step == 1)
+ {
+ // Check values for step 1
+ if ($cp->vars['field_name'] == '')
+ {
+ $error[] = $user->lang['EMPTY_FIELD_NAME'];
+ }
+ if ($cp->vars['lang_name'] == '')
+ {
+ $error[] = $user->lang['EMPTY_USER_FIELD_NAME'];
+ }
+
+ $sql = "SELECT field_ident
+ FROM phpbb_profile_fields
+ WHERE field_ident = '$field_ident'";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $error[] = sprintf($user->lang['FIELD_IDENT_ALREADY_EXIST'], $field_ident);
+ }
+ }
+
+ $user_error = false;
+ if ($update && $step == 2)
+ {
+ // Validate Field
+ $user_error = $cp->validate_profile_field($field_type, $cp->vars['pf_preview'], $cp->vars);
+ }
+
+ $step = (isset($_REQUEST['next'])) ? $step + 1 : ((isset($_REQUEST['prev'])) ? $step - 1 : $step);
+
+ if (sizeof($error))
+ {
+ $step--;
+ $submit = false;
+ }
+
+ if (isset($_REQUEST['prev']) || isset($_REQUEST['next']))
+ {
+ $update = false;
+ $pf_preview = '';
+ unset($_REQUEST['pf_preview']);
+ }
+
+ // Build up the specific hidden fields
+ foreach ($exclude as $num => $key_ary)
+ {
+ if ($num == $step)
+ {
+ continue;
+ }
+
+ foreach ($key_ary as $key)
+ {
+ $var = $_POST[$key];
+ if (!$var)
+ {
+ continue;
+ }
+
+ if (is_array($var))
+ {
+ foreach ($var as $num => $__var)
+ {
+ if (is_array($__var))
+ {
+ foreach ($__var as $_num => $___var)
+ {
+ $s_hidden_fields .= '' . "\n";
+ }
+ }
+ else
+ {
+ $s_hidden_fields .= '' . "\n";
+ }
+ }
+ }
+ else
+ {
+ $s_hidden_fields .= '' . "\n";
+ }
+ }
+ }
+
+ if (!sizeof($error) && $save && $step == 3)
+ {
+ save_profile_field($field_type, $field_ident);
+ }
+
+?>
+
+
lang['STEP_X_FROM_X'], $step, 3); ?>
+
+
+
+
+ lang['REQUIRED_FIELD']; ?> lang['REQUIRED_FIELD_EXPLAIN']; ?> |
+ vars['field_required']) ? ' checked="checked"' : ''); ?> /> |
+
+
+ lang['DISPLAY_AT_REGISTRATION']; ?> |
+ vars['field_show_on_reg']) ? ' checked="checked"' : ''); ?> /> |
+
+
+ lang['HIDE_PROFILE_FIELD']; ?> lang['HIDE_PROFILE_FIELD_EXPLAIN']; ?> |
+ vars['field_hide']) ? ' checked="checked"' : ''); ?> /> |
+
+
+profile_types[$field_type] . '_options';
+ $options = $cp->$function();
+ foreach ($options as $num => $option_ary)
+ {
+?>
+
+ ' . $option_ary['L_EXPLAIN'] . '' : ''; ?> |
+ |
+
+
+
+ Allow HTML: |
+ vars['options'] & 1 << 1) ? ' checked="checked"' : ''; ?> /> |
+
+
+ Allow BBCode: |
+ vars['options'] & 1 << 2) ? ' checked="checked"' : ''; ?> /> |
+
+
+ Allow Smilies: |
+ vars['options'] & 1 << 3) ? ' checked="checked"' : ''; ?> /> |
+
+
+
+ |
+
+
+
+
+
+
+
+ Preview Profile Field |
+
+
+ ' . $user_error . '' : 'Everything OK'; ?> |
+
+ $cp->vars['lang_name'],
+ 'lang_explain' => $cp->vars['lang_explain'],
+ 'lang_id' => 1,
+ 'field_id' => 1,
+ 'lang_default_value' => $cp->vars['lang_default_value'],
+ 'field_default_value' => $cp->vars['field_default_value'],
+ 'field_ident' => 'preview',
+ 'field_type' => $field_type,
+
+ 'field_length' => $cp->vars['field_length'],
+ 'field_maxlen' => $cp->vars['field_maxlen'],
+ 'lang_options' => $cp->vars['lang_options']
+ );
+
+ preview_field($field_data);
+?>
+
+ |
+
+
+
+ $lang_ary)
+ {
+?>
+
+ |
+
+ $field_ary)
+ {
+?>
+
+ ' . $field_ary['L_EXPLAIN'] . '' : ''; ?> |
+ |
+
+
+
+ |
+
+
+
+
+sql_query($sql);
+ $field_ident = $db->sql_fetchfield('field_ident', 0, $result);
+
+ $db->sql_query('DELETE FROM phpbb_profile_fields WHERE field_id = ' . $field_id);
+ $db->sql_query('DELETE FROM phpbb_profile_fields_lang WHERE field_id = ' . $field_id);
+ $db->sql_query('DELETE FROM phpbb_profile_lang WHERE field_id = ' . $field_id);
+ $db->sql_query('ALTER TABLE phpbb_profile_fields_data DROP ' . $field_ident);
+
+ $order = 0;
+
+ $sql = 'SELECT *
+ FROM phpbb_profile_fields
+ ORDER BY field_order';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ ++$order;
+ if ($row['field_order'] != $order)
+ {
+ $db->sql_query("UPDATE phpbb_profile_fields SET field_order = $order WHERE field_id = " . $row['field_id']);
+ }
+ }
+
+ trigger_error('Successfully deleted profile field.');
+ }
+ else if (!$confirm && !$cancel)
+ {
+ $l_message = '';
+
+ adm_page_message($user->lang['CONFIRM'], $l_message, false);
+
+ adm_page_footer();
+ }
+
+ $mode = 'manage';
+}
+
+if ($mode == 'activate')
+{
+ $field_id = request_var('field_id', 0);
+
+ if (!$field_id)
+ {
+ trigger_error('INVALID_MODE');
+ }
+
+ $result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
+ $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ if (!in_array($default_lang_id, $lang_entry[$field_id]))
+ {
+ trigger_error('DEFAULT_LANGUAGE_NOT_FILLED');
+ }
+
+ $db->sql_query("UPDATE phpbb_profile_fields SET field_active = 1 WHERE field_id = $field_id");
+ trigger_error('PROFILE_FIELD_ACTIVATED');
+}
+
+if ($mode == 'deactivate')
+{
+ $field_id = request_var('field_id', 0);
+
+ if (!$field_id)
+ {
+ trigger_error('INVALID_MODE');
+ }
+
+ $db->sql_query("UPDATE phpbb_profile_fields SET field_active = 0 WHERE field_id = $field_id");
+ trigger_error('PROFILE_FIELD_DEACTIVATED');
+}
+
+if ($mode == 'move_up' || $mode == 'move_down')
+{
+ $field_order = intval($_GET['order']);
+ $order_total = $field_order * 2 + (($mode == 'move_up') ? -1 : 1);
+
+ $sql = "UPDATE phpbb_profile_fields
+ SET field_order = $order_total - field_order
+ WHERE field_order IN ($field_order, " . (($mode == 'move_up') ? $field_order - 1 : $field_order + 1) . ')';
+ $db->sql_query($sql);
+
+ $mode = 'manage';
+}
+
+if ($mode == 'manage')
+{
+?>
+
+process_field_row('preview', $field_data);
+?>
+
+ : ' . $field_data['lang_explain'] . '' : ''; ?> |
+ |
+
+ '" . $config['default_lang'] . "'" : '');
+ $result = $db->sql_query($sql);
+
+ $languages = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $languages[$row['lang_id']] = $row['lang_iso'];
+ }
+ $db->sql_freeresult($result);
+
+ $options = array();
+ $options['lang_name'] = 'string';
+ if (!empty($cp->vars['lang_explain']))
+ {
+ $options['lang_explain'] = 'text';
+ }
+
+ switch ($field_type)
+ {
+ case FIELD_BOOL:
+ $options['lang_options'] = 'two_options';
+ break;
+ case FIELD_DROPDOWN:
+ $options['lang_options'] = 'optionfield';
+ break;
+ case FIELD_TEXT:
+ case FIELD_STRING:
+ if (!empty($cp->vars['lang_default_value']))
+ {
+ $options['lang_default_value'] = ($field_type == FIELD_STRING) ? 'string' : 'text';
+ }
+ break;
+ }
+
+ $lang_options = array();
+
+ if ($mode == 'new')
+ {
+ foreach ($options as $field => $field_type)
+ {
+ $lang_options[1]['lang_iso'] = $config['default_lang'];
+ $lang_options[1]['fields'][$field] = array(
+ 'L_NAME' => 'CP_' . strtoupper($field) . '_TITLE',
+ 'L_EXPLAIN' => 'CP_' . strtoupper($field) . '_EXPLAIN',
+ 'FIELD' => '' . ((is_array($cp->vars[$field])) ? implode('
', $cp->vars[$field]) : str_replace("\n", '
', $cp->vars[$field])) . ''
+ );
+ }
+ }
+
+ foreach ($languages as $lang_id => $lang_iso)
+ {
+ $lang_options[$lang_id]['lang_iso'] = $lang_iso;
+ foreach ($options as $field => $field_type)
+ {
+ $value = ($mode == 'new') ? request_var('l_' . $field, '') : $cp->vars['l_' . $field];
+
+ if ($field == 'lang_options')
+ {
+ $var = ($mode == 'new') ? $cp->vars['lang_options'] : $cp->vars['lang_options'][$lang_id];
+
+ switch ($field_type)
+ {
+ case 'two_options':
+
+ $lang_options[$lang_id]['fields'][$field] = array(
+ 'L_NAME' => 'CP_' . strtoupper($field) . '_TITLE',
+ 'L_EXPLAIN' => 'CP_' . strtoupper($field) . '_EXPLAIN',
+ 'FIELD' => ''
+ );
+ break;
+
+ case 'optionfield':
+
+ $lang_options[$lang_id]['fields'][$field] = array(
+ 'L_NAME' => 'CP_' . strtoupper($field) . '_TITLE',
+ 'L_EXPLAIN' => 'CP_' . strtoupper($field) . '_EXPLAIN',
+ 'FIELD' => ''
+ );
+ break;
+ }
+ }
+ else
+ {
+ $var = ($mode == 'new') ? $cp->vars[$field] : $cp->vars[$field][$lang_id];
+
+ $lang_options[$lang_id]['fields'][$field] = array(
+ 'L_NAME' => 'CP_' . strtoupper($field) . '_TITLE',
+ 'L_EXPLAIN' => 'CP_' . strtoupper($field) . '_EXPLAIN',
+ 'FIELD' => ($field_type == 'string') ? '' : ''
+ );
+ }
+ }
+ }
+
+ return $lang_options;
+}
+
+function save_profile_field($field_type, $field_ident)
+{
+ global $cp, $db, $config, $user;
+
+ // Collect all informations, if something is going wrong, abort the operation
+ $profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();
+
+ $result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
+ $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM phpbb_profile_fields');
+ $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result);
+ $db->sql_freeresult($result);
+
+ // Save the field
+ $profile_fields = array(
+ 'field_name' => $cp->vars['field_name'],
+ 'field_type' => $field_type,
+ 'field_ident' => $field_ident,
+ 'field_length' => $cp->vars['field_length'],
+ 'field_minlen' => $cp->vars['field_minlen'],
+ 'field_maxlen' => $cp->vars['field_maxlen'],
+ 'field_novalue' => $cp->vars['field_novalue'],
+ 'field_default_value' => $cp->vars['field_default_value'],
+ 'field_validation' => $cp->vars['field_validation'],
+ 'field_required' => $cp->vars['field_required'],
+ 'field_show_on_reg' => $cp->vars['field_show_on_reg'],
+ 'field_hide' => $cp->vars['field_hide'],
+ 'field_order' => $new_field_order + 1,
+ 'field_active' => 0
+ );
+
+ $db->sql_query('INSERT INTO phpbb_profile_fields ' . $db->sql_build_array('INSERT', $profile_fields));
+
+ $field_id = $db->sql_nextid();
+
+ $sql = "ALTER TABLE phpbb_profile_fields_data ADD $field_ident ";
+ switch ($field_type)
+ {
+ case FIELD_STRING:
+ $sql .= " VARCHAR(255) DEFAULT NULL NULL";
+ break;
+
+ case FIELD_DATE:
+ $sql .= "VARCHAR(10) DEFAULT NULL NULL";
+ break;
+
+ case FIELD_TEXT:
+ $sql .= "TEXT NULL";
+ break;
+
+ case FIELD_BOOL:
+ $sql .= "TINYINT(2) DEFAULT NULL NULL";
+ break;
+
+ case FIELD_DROPDOWN:
+ $sql .= "MEDIUMINT(8) DEFAULT NULL NULL";
+ break;
+
+ case FIELD_INT:
+ $sql .= (($cp->vars['field_maxlen'] > 60000) ? 'BIGINT(20)' : 'MEDIUMINT(8)') . (($cp->vars['field_minlen'] >= 0) ? ' UNSIGNED' : ' ') . " DEFAULT NULL NULL";
+ break;
+ }
+ $profile_sql[] = $sql;
+
+ $sql_ary = array(
+ 'field_id' => $field_id,
+ 'lang_id' => $default_lang_id,
+ 'lang_name' => $cp->vars['lang_name'],
+ 'lang_explain' => $cp->vars['lang_explain'],
+ 'lang_default_value' => $cp->vars['lang_default_value']
+ );
+ $profile_sql[] = 'INSERT INTO phpbb_profile_lang ' . $db->sql_build_array('INSERT', $sql_ary);
+
+ if (sizeof($cp->vars['l_lang_name']))
+ {
+ foreach ($cp->vars['l_lang_name'] as $lang_id => $data)
+ {
+ if (($cp->vars['lang_name'] != '' && $cp->vars['l_lang_name'][$lang_id] == '')
+ || ($cp->vars['lang_explain'] != '' && $cp->vars['l_lang_explain'][$lang_id] == '')
+ || ($cp->vars['lang_default_value'] != '' && $cp->vars['l_lang_default_value'][$lang_id] == ''))
+ {
+ $empty_lang[$lang_id] = true;
+ break;
+ }
+
+ if (!isset($empty_lang[$lang_id]))
+ {
+ $profile_lang[] = array(
+ 'field_id' => $field_id,
+ 'lang_id' => $lang_id,
+ 'lang_name' => $cp->vars['l_lang_name'][$lang_id],
+ 'lang_explain' => $cp->vars['l_lang_explain'][$lang_id],
+ 'lang_default_value' => $cp->vars['l_lang_default_value'][$lang_id]
+ );
+ }
+ }
+ }
+
+ $cp->vars['l_lang_name'] = request_var('l_lang_name', '');
+ $cp->vars['l_lang_explain'] = request_var('l_lang_explain', '');
+ $cp->vars['l_lang_default_value'] = request_var('l_lang_default_value', '');
+ $cp->vars['l_lang_options'] = request_var('l_lang_options', '');
+
+ if (!empty($cp->vars['lang_options']))
+ {
+ if (!is_array($cp->vars['lang_options']))
+ {
+ $cp->vars['lang_options'] = explode("\n", $cp->vars['lang_options']);
+ }
+
+ foreach ($cp->vars['lang_options'] as $option_id => $value)
+ {
+ $sql_ary = array(
+ 'field_id' => $field_id,
+ 'lang_id' => $default_lang_id,
+ 'option_id' => $option_id,
+ 'field_type' => $field_type,
+ 'value' => $value
+ );
+ $profile_sql[] = 'INSERT INTO phpbb_profile_fields_lang ' . $db->sql_build_array('INSERT', $sql_ary);
+ }
+ }
+
+ if (sizeof($cp->vars['l_lang_options']))
+ {
+ foreach ($cp->vars['l_lang_options'] as $lang_id => $lang_ary)
+ {
+ if (!is_array($lang_ary))
+ {
+ $lang_ary = explode("\n", $lang_ary);
+ }
+
+ if (sizeof($lang_ary) != sizeof($cp->vars['lang_options']))
+ {
+ $empty_lang[$lang_id] = true;
+ }
+
+ if (!isset($empty_lang[$lang_id]))
+ {
+ foreach ($lang_ary as $option_id => $value)
+ {
+ $profile_lang_fields[] = array(
+ 'field_id' => $field_id,
+ 'lang_id' => $lang_id,
+ 'option_id' => $option_id,
+ 'field_type' => $field_type,
+ 'value' => $value
+ );
+ }
+ }
+ }
+ }
+
+ foreach ($profile_lang as $sql)
+ {
+ $profile_sql[] = 'INSERT INTO phpbb_profile_lang ' . $db->sql_build_array('INSERT', $sql);
+ }
+
+ if (sizeof($profile_lang_fields))
+ {
+ foreach ($profile_lang_fields as $sql)
+ {
+ $profile_sql[] = 'INSERT INTO phpbb_profile_fields_lang ' . $db->sql_build_array('INSERT', $sql);
+ }
+ }
+
+// $db->sql_transaction();
+ foreach ($profile_sql as $sql)
+ {
+ $db->sql_query($sql);
+ }
+// $db->sql_transaction('commit');
+
+ trigger_error($user->lang['ADDED_PROFILE_FIELD']);
+}
+
+
+?>
\ No newline at end of file
diff --git a/phpBB/common.php b/phpBB/common.php
index 3bda138d6b..a528ccd395 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -142,6 +142,13 @@ define('THUMB_CAT', 4); // Not used within the database, only while displaying p
// BBCode UID length
define('BBCODE_UID_LEN', 5);
+define('FIELD_INT', 1);
+define('FIELD_STRING', 2);
+define('FIELD_TEXT', 3);
+define('FIELD_BOOL', 4);
+define('FIELD_DROPDOWN', 5);
+define('FIELD_DATE', 6);
+
// Table names
define('ACL_GROUPS_TABLE', $table_prefix.'auth_groups');
define('ACL_OPTIONS_TABLE', $table_prefix.'auth_options');
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
new file mode 100644
index 0000000000..9a2fc5ac77
--- /dev/null
+++ b/phpBB/includes/functions_profile_fields.php
@@ -0,0 +1,666 @@
+ 'int', 2 => 'string', 3 => 'text', 4 => 'bool', 5 => 'dropdown', 6 => 'date');
+ var $options_lang = array();
+
+ // Functions performing operations on register/profile/profile admin
+ function submit_cp_field($mode, &$cp_data, &$cp_error)
+ {
+ global $auth, $db;
+
+ $sql = 'SELECT *
+ FROM phpbb_profile_fields
+ WHERE field_active = 1
+ ' . (($mode == 'register') ? ' AND field_show_on_reg = 1' : '') .
+ (($auth->acl_gets('a_', 'm_') && $mode == 'profile') ? '' : ' AND field_hide = 0') . '
+ ORDER BY field_order';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $cp_data[$row['field_ident']] = $this->get_profile_field($row);
+ if (($cp_result = $this->validate_profile_field($row['field_type'], $cp_data[$row['field_ident']], $row)) !== false)
+ {
+ $cp_error[$row['field_ident']] = $cp_result;
+ }
+ }
+ $db->sql_freeresult($result);
+ }
+
+ function generate_profile_fields($mode, $lang_id, $cp_error)
+ {
+ global $db, $template, $auth;
+
+ $sql = "SELECT l.*, f.*
+ FROM phpbb_profile_lang l, phpbb_profile_fields f
+ WHERE l.lang_id = $lang_id
+ AND f.field_active = 1
+ " . (($mode == 'register') ? ' AND f.field_show_on_reg = 1' : '') .
+ (($auth->acl_gets('a_', 'm_') && $mode == 'profile') ? '' : ' AND f.field_hide = 0') . '
+ AND l.field_id = f.field_id
+ GROUP BY f.field_id
+ ORDER BY f.field_order';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $template->assign_block_vars('profile_fields', array(
+ 'LANG_NAME' => $row['lang_name'],
+ 'LANG_EXPLAIN' => $row['lang_explain'],
+ 'FIELD' => $this->process_field_row('change', $row),
+ 'ERROR' => (isset($cp_error[$row['field_ident']])) ? $cp_error[$row['field_ident']] : '')
+ );
+ }
+ $db->sql_freeresult($result);
+ }
+
+ // Get language entries for options and store them here for later use
+ function get_option_lang($field_id, $lang_id, $field_type, $preview)
+ {
+ global $db;
+
+ if ($preview)
+ {
+ $lang_options = (!is_array($this->vars['lang_options'])) ? explode("\n", $this->vars['lang_options']) : $this->vars['lang_options'];
+
+ foreach ($lang_options as $num => $var)
+ {
+ $this->options_lang[$field_id][$lang_id][($num+1)] = $var;
+ }
+ }
+ else
+ {
+ $sql = "SELECT option_id, value
+ FROM phpbb_profile_fields_lang
+ WHERE field_id = $field_id
+ AND lang_id = $lang_id
+ AND field_type = $field_type
+ ORDER BY option_id";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $this->options_lang[$field_id][$lang_id][$row['option_id']] = $row['value'];
+ }
+ $db->sql_freeresult($result);
+ }
+ }
+
+ // VALIDATE Function - validate entered data
+ function validate_profile_field($field_type, &$field_value, $field_data)
+ {
+ switch ($field_type)
+ {
+ case FIELD_INT:
+ case FIELD_DROPDOWN:
+ $field_value = (int) $field_value;
+ break;
+
+ case FIELD_BOOL:
+ $field_value = (bool) $field_value;
+ break;
+ }
+
+ switch ($field_type)
+ {
+ case FIELD_DATE:
+ $field_validate = explode('-', $field_value);
+
+ $day = (int) $field_validate[0];
+ $month = (int) $field_validate[1];
+ $year = (int) $field_validate[2];
+
+ if ((!$day || !$month || !$year) && !$field_data['field_required'])
+ {
+ return false;
+ }
+
+ if ((!$day || !$month || !$year) && $field_data['field_required'])
+ {
+ return 'FIELD_REQUIRED';
+ }
+
+ if ($day < 0 || $day > 31 || $month < 0 || $month > 12 || ($year < 1901 && $year > 0) || $year > gmdate('Y', time()))
+ {
+ return 'INVALID_DATE';
+ }
+ break;
+
+ case FIELD_INT:
+ if (empty($field_value) && !$field_data['field_required'])
+ {
+ return false;
+ }
+
+ if ($field_value < $field_data['field_minlen'])
+ {
+ return 'TOO_SMALL';
+ }
+ else if ($field_value > $field_data['field_maxlen'])
+ {
+ return 'TOO_LARGE';
+ }
+ break;
+
+ case FIELD_DROPDOWN:
+ if ($field_value == $field_data['field_novalue'] && $field_data['field_required'])
+ {
+ return 'FIELD_REQUIRED';
+ }
+ break;
+
+ case FIELD_STRING:
+ case FIELD_TEXT:
+ if (empty($field_value) && !$field_data['field_required'])
+ {
+ return false;
+ }
+
+ if ($field_data['field_minlen'] && strlen($field_value) < $field_data['field_minlen'])
+ {
+ return 'TOO_SHORT';
+ }
+ else if ($field_data['field_maxlen'] && strlen($field_value) > $field_data['field_maxlen'])
+ {
+ return 'TOO_LONG';
+ }
+
+ if (!empty($field_data['field_validation']))
+ {
+ $field_validate = ($field_type == FIELD_STRING) ? $field_value : str_replace("\n", ' ', $field_value);
+ if (!preg_match('#^' . str_replace('\\\\', '\\', $field_data['field_validation']) . '$#i', $field_validate))
+ {
+ return 'INVALID_CHARS';
+ }
+ }
+ break;
+ }
+
+ return false;
+ }
+
+ function get_profile_value($field_validation, &$profile_row, $default_value, $preview)
+ {
+ global $user;
+
+ $profile_row['field_name'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
+
+ $value = (isset($_REQUEST[$profile_row['field_name']])) ? request_var($profile_row['field_name'], 0) : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]);
+
+ switch ($field_validation)
+ {
+ case 'int':
+ return (int) $value;
+ break;
+ }
+
+ return $value;
+ }
+
+ // GENERATE_* Functions - return templated, storable profile fields
+ function generate_int($profile_row, $preview = false)
+ {
+ global $template;
+
+ $value = $this->get_profile_value('int', $profile_row, $profile_row['field_default_value'], $preview);
+ $this->set_tpl_vars($profile_row, $value);
+
+ return $this->get_cp_html();
+ }
+
+ function generate_date($profile_row, $preview = false)
+ {
+ global $user;
+
+ $profile_row['field_name'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
+ $now = getdate();
+
+ if (!isset($_REQUEST[$profile_row['field_name'] . '_day']))
+ {
+ if ($profile_row['field_default_value'] == 'now')
+ {
+ $profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
+ }
+ list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$profile_row['field_ident']]));
+ }
+ else
+ {
+ if ($preview && $profile_row['field_default_value'] == 'now')
+ {
+ $profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
+ list($day, $month, $year) = explode('-', ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $profile_row['field_default_value'] : $user->profile_fields[$profile_row['field_ident']]));
+ }
+ else
+ {
+ $day = request_var($profile_row['field_name'] . '_day', 0);
+ $month = request_var($profile_row['field_name'] . '_month', 0);
+ $year = request_var($profile_row['field_name'] . '_year', 0);
+ }
+ }
+
+ $profile_row['s_day_options'] = '';
+ for ($i = 1; $i < 32; $i++)
+ {
+ $profile_row['s_day_options'] .= '";
+ }
+
+ $profile_row['s_month_options'] = '';
+ for ($i = 1; $i < 13; $i++)
+ {
+ $profile_row['s_month_options'] .= '";
+ }
+
+ $profile_row['s_year_options'] = '';
+ for ($i = $now['year'] - 100; $i <= $now['year']; $i++)
+ {
+ $profile_row['s_year_options'] .= '";
+ }
+ unset($now);
+
+ $this->set_tpl_vars($profile_row, $value);
+ return $this->get_cp_html();
+ }
+
+ function generate_bool($profile_row, $preview = false)
+ {
+ global $template;
+
+ $value = $this->get_profile_value('int', $profile_row, $profile_row['field_default_value'], $preview);
+ $this->set_tpl_vars($profile_row, $value);
+
+ if ($profile_row['field_length'] == 1)
+ {
+ if (!sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
+ {
+ $this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_BOOL, $preview);
+ }
+
+ foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
+ {
+ $template->assign_block_vars('bool.options', array(
+ 'OPTION_ID' => $option_id,
+ 'CHECKED' => ($value == $option_id) ? ' checked="checked"' : '',
+ 'VALUE' => $option_value)
+ );
+ }
+ }
+
+ return $this->get_cp_html();
+ }
+
+ function generate_string($profile_row, $preview = false)
+ {
+ global $template;
+
+ $value = $this->get_profile_value('', $profile_row, $profile_row['lang_default_value'], $preview);
+ $this->set_tpl_vars($profile_row, $value);
+
+ return $this->get_cp_html();
+ }
+
+ function generate_text($profile_row, $preview = false)
+ {
+ global $template;
+
+ $value = $this->get_profile_value('', $profile_row, $profile_row['lang_default_value'], $preview);
+
+ $field_length = explode('|', $profile_row['field_length']);
+ $profile_row['field_rows'] = $field_length[0];
+ $profile_row['field_cols'] = $field_length[1];
+
+ $this->set_tpl_vars($profile_row, $value);
+
+ return $this->get_cp_html();
+ }
+
+ function generate_dropdown($profile_row, $preview = false)
+ {
+ global $user, $template;
+
+ $value = $this->get_profile_value('int', $profile_row, $profile_row['field_default_value'], $preview);
+
+ if (!sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
+ {
+ $this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_DROPDOWN, $preview);
+ }
+
+ $this->set_tpl_vars($profile_row, $value);
+
+ foreach ($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']] as $option_id => $option_value)
+ {
+ $template->assign_block_vars('dropdown.options', array(
+ 'OPTION_ID' => $option_id,
+ 'SELECTED' => ($value == $option_id) ? ' selected="selected"' : '',
+ 'VALUE' => $option_value)
+ );
+ }
+
+ return $this->get_cp_html();
+ }
+
+
+ // Return Templated value (change == user is able to set/enter profile values; show == just show the value)
+ function process_field_row($mode, $profile_row)
+ {
+ $preview = false;
+
+ switch ($mode)
+ {
+ case 'preview':
+ $preview = true;
+ case 'change':
+ $type_func = 'generate_' . $this->profile_types[$profile_row['field_type']];
+ break;
+ default:
+ return;
+ }
+
+ return $this->$type_func($profile_row, $preview);
+ }
+
+ // Build Array for user insertion into custom profile fields table
+ function build_insert_sql_array($cp_data)
+ {
+ global $db, $user, $auth;
+
+ $sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value
+ FROM phpbb_profile_lang l, phpbb_profile_fields f
+ WHERE l.lang_id = ' . $user->get_iso_lang_id() . '
+ AND f.field_active = 1
+ AND f.field_show_on_reg = 0
+ ' . (($auth->acl_gets('a_', 'm_')) ? '' : ' AND f.field_hide = 0') . '
+ AND l.field_id = f.field_id
+ GROUP BY f.field_id';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if ($row['field_default_value'] == 'now' && $row['field_type'] == FIELD_DATE)
+ {
+ $now = getdate();
+ $row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
+ }
+ $cp_data[$row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value'];
+ }
+ $db->sql_freeresult($result);
+
+ return $cp_data;
+ }
+
+ function get_profile_field($profile_row)
+ {
+ switch ($profile_row['field_type'])
+ {
+ case FIELD_DATE:
+ $var_name = 'pf_' . $profile_row['field_ident'];
+
+ if (!isset($_REQUEST[$var_name . '_day']))
+ {
+ if ($profile_row['field_default_value'] == 'now')
+ {
+ $now = getdate();
+ $profile_row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']);
+ }
+ list($day, $month, $year) = explode('-', $profile_row['field_default_value']);
+ }
+ else
+ {
+ $day = request_var($var_name . '_day', 0);
+ $month = request_var($var_name . '_month', 0);
+ $year = request_var($var_name . '_year', 0);
+ }
+
+ $var = sprintf('%2d-%2d-%4d', $day, $month, $year);
+ break;
+
+ default:
+ $var = request_var('pf_' . $profile_row['field_ident'], $profile_row['field_default_value']);
+ }
+
+ return $var;
+ }
+
+ function set_tpl_vars($profile_row, $field_value)
+ {
+ global $template;
+
+ $template->set_filenames(array(
+ 'cp' => 'custom_profile_fields.html')
+ );
+
+ foreach ($this->profile_types as $field_case => $field_type)
+ {
+ unset($template->_tpldata[$field_type]);
+ }
+
+ foreach ($profile_row as $key => $value)
+ {
+ unset($profile_row[$key]);
+ $profile_row[strtoupper($key)] = $value;
+ }
+
+ $profile_row['FIELD_VALUE'] = $field_value;
+
+ $template->assign_block_vars($this->profile_types[$profile_row['FIELD_TYPE']], $profile_row);
+ }
+
+ function get_cp_html()
+ {
+ global $template;
+
+ ob_start();
+ $template->display('cp', false);
+ $data = ob_get_contents();
+ ob_end_clean();
+
+ return $data;
+ }
+}
+
+class custom_profile_admin extends custom_profile
+{
+ var $vars = array();
+
+
+ // GET_* get admin options for second step
+ function get_string_options()
+ {
+ global $user;
+
+ $options = array();
+
+ $validate_ary = array('CHARS_ANY' => '.*', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
+ $validate_options = '';
+ foreach ($validate_ary as $lang => $value)
+ {
+ $selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
+ $validate_options .= '';
+ }
+
+ $options = array(
+ 0 => array(
+ 'L_NAME' => 'Length of input box',
+ 'FIELD' => ''),
+ 1 => array(
+ 'L_NAME' => 'Minimum number of characters entered',
+ 'FIELD' => ''),
+ 2 => array(
+ 'L_NAME' => 'Maximum number of characters entered',
+ 'FIELD' => ''),
+ 3 => array(
+ 'L_NAME' => 'Field Validation',
+ 'FIELD' => ''),
+ );
+
+ return $options;
+ }
+
+ function get_text_options()
+ {
+ global $user;
+
+ $options = array();
+
+ $validate_ary = array('CHARS_ANY' => '.*', 'ALPHA_ONLY' => '[\w]+', 'ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
+ $validate_options = '';
+ foreach ($validate_ary as $lang => $value)
+ {
+ $selected = ($this->vars['field_validation'] == $value) ? ' selected="selected"' : '';
+ $validate_options .= '';
+ }
+
+ $options = array(
+ 0 => array(
+ 'L_NAME' => 'Field Length',
+ 'FIELD' => ''),
+ 1 => array(
+ 'L_NAME' => 'Minimum number of characters entered',
+ 'FIELD' => ''),
+ 2 => array(
+ 'L_NAME' => 'Maximum number of characters entered',
+ 'FIELD' => ''),
+ 3 => array(
+ 'L_NAME' => 'Field Validation',
+ 'L_EXPLAIN' => '',
+ 'FIELD' => ''),
+ );
+
+ return $options;
+ }
+
+ function get_int_options()
+ {
+ global $user;
+
+ $options = array(
+ 0 => array(
+ 'L_NAME' => 'Length of input box',
+ 'FIELD' => ''),
+ 1 => array(
+ 'L_NAME' => 'Lowest allowed number',
+ 'FIELD' => ''),
+ 2 => array(
+ 'L_NAME' => 'highest allowed number',
+ 'FIELD' => ''),
+ 3 => array(
+ 'L_NAME' => 'Default Value',
+ 'FIELD' => ''),
+ );
+
+ return $options;
+ }
+
+ function get_bool_options()
+ {
+ global $user, $config, $db;
+
+ $result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
+ $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ $profile_row = array(
+ 'var_name' => 'field_default_value',
+ 'lang_name' => $this->vars['lang_name'],
+ 'lang_explain' => $this->vars['lang_explain'],
+ 'lang_id' => $default_lang_id,
+ 'field_default_value' => $this->vars['field_default_value'],
+ 'field_ident' => 'field_default_value',
+ 'field_type' => FIELD_BOOL,
+ 'field_length' => $this->vars['field_length'],
+ 'lang_options' => $this->vars['lang_options']
+ );
+
+
+ $options = array(
+ 0 => array(
+ 'L_NAME' => 'Field Type',
+ 'L_EXPLAIN' => 'Define the Type, either a checkbox or radio buttons',
+ 'FIELD' => 'vars['field_length'] == 1) ? ' checked="checked"' : '') . ' />Radio Buttons vars['field_length'] == 2) ? ' checked="checked"' : '') . ' />Checkbox '),
+ 1 => array(
+ 'L_NAME' => 'Default Value',
+ 'FIELD' => $this->generate_bool($profile_row, true)),
+ );
+
+ return $options;
+ }
+
+ function get_dropdown_options()
+ {
+ global $user, $config, $db;
+
+ $result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
+ $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ $profile_row[0] = array(
+ 'var_name' => 'field_default_value',
+ 'field_id' => 1,
+ 'lang_name' => $this->vars['lang_name'],
+ 'lang_explain' => $this->vars['lang_explain'],
+ 'lang_id' => $default_lang_id,
+ 'field_default_value' => $this->vars['field_default_value'],
+ 'field_ident' => 'field_default_value',
+ 'field_type' => FIELD_DROPDOWN,
+ 'lang_options' => $this->vars['lang_options']
+ );
+
+ $profile_row[1] = $profile_row[0];
+ $profile_row[1]['var_name'] = 'field_no_value';
+ $profile_row[1]['field_ident'] = 'field_no_value';
+
+ $options = array(
+ 0 => array(
+ 'L_NAME' => 'Default Value',
+ 'FIELD' => $this->generate_dropdown($profile_row[0], true)),
+ 1 => array(
+ 'L_NAME' => 'No Value',
+ 'L_EXPLAIN' => 'Value for a non-entry. If the field is required, the user gets an error if he choose the option selected here',
+ 'FIELD' => $this->generate_dropdown($profile_row[1], true)),
+ );
+
+ return $options;
+ }
+
+ function get_date_options()
+ {
+ global $user, $config, $db;
+
+ $result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
+ $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ $profile_row = array(
+ 'var_name' => 'field_default_value',
+ 'lang_name' => $this->vars['lang_name'],
+ 'lang_explain' => $this->vars['lang_explain'],
+ 'lang_id' => $default_lang_id,
+ 'field_default_value' => $this->vars['field_default_value'],
+ 'field_ident' => 'field_default_value',
+ 'field_type' => FIELD_DATE,
+ 'field_length' => $this->vars['field_length']
+ );
+
+ $options = array(
+ 0 => array(
+ 'L_NAME' => 'Default Value',
+ 'FIELD' => $this->generate_date($profile_row, true) . '
vars['field_default_value'] == 'now') ? ' checked="checked"' : '') . ' /> Always the current date'),
+ );
+
+ return $options;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 725957a0c1..185a22546f 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -596,6 +596,42 @@ class user extends session
return strtr(@gmdate($format, $gmepoch + $this->timezone + $this->dst), $lang_dates);
}
+ function get_iso_lang_id()
+ {
+ global $config, $db;
+
+ if ($this->lang_id)
+ {
+ return $this->lang_id;
+ }
+
+ if (empty($this->lang_name))
+ {
+ $this->lang_name = $config['default_lang'];
+ }
+
+ $result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $this->lang_name . "'");
+ return (int) $db->sql_fetchfield('lang_id', 0, $result);
+ }
+
+ // Get profile fields for user
+ function get_profile_fields($user_id)
+ {
+ global $user, $db;
+
+ if (isset($user->profile_fields))
+ {
+ return;
+ }
+
+ $sql = 'SELECT * FROM
+ phpbb_profile_fields_data
+ WHERE user_id = ' . $user_id;
+ $result = $db->sql_query_limit($sql, 1);
+
+ $user->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row;
+ }
+
function img($img, $alt = '', $width = false, $no_cache = false)
{
static $imgs;
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index 6d06d918cc..07d8a49c17 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -112,13 +112,13 @@ class template
// Methods for loading and evaluating the templates
- function display($handle)
+ function display($handle, $include_once = true)
{
global $user;
if ($filename = $this->_tpl_load($handle))
{
- include_once($filename);
+ ($include_once) ? include_once($filename) : include($filename);
}
else
{