diff --git a/phpBB/adm/admin_profile.php b/phpBB/adm/admin_profile.php
index f51fb22a5f..01261b39c8 100644
--- a/phpBB/adm/admin_profile.php
+++ b/phpBB/adm/admin_profile.php
@@ -18,7 +18,7 @@
Taking into consideration
... admin is NOT able to change the field type later
- Admin is able to preview/test the input and output of a profile field at every time.
+ Admin is able to preview/test the input and output of a profile field at any time.
If the admin adds a field, he have to enter at least the default board language params. Without doing so, he
is not able to activate the field.
@@ -26,9 +26,10 @@
If the default board language is changed, a check has to be made if the profile field language entries are
still valid.
+ TODO M-3:
* Show at profile view (yes/no)
* Viewtopic Integration (Load Switch, Able to show fields with additional template vars populated if enabled)
- * Custom Validation (Regex)?
+ * Custom Validation (Regex) - not in 2.2
* Try to build the edit screen with the existing create screen...
*/
@@ -51,49 +52,6 @@ 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']);
@@ -104,7 +62,7 @@ $submit = (isset($_POST['submit'])) ? TRUE : FALSE;
$create = (isset($_POST['create'])) ? TRUE : FALSE;
$error = $notify = array();
-adm_page_header('CUSTOM_PROFILE_FIELDS');
+adm_page_header($user->lang['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),
@@ -123,32 +81,34 @@ $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();
+$lang_defs = array();
-$result = $db->sql_query('SELECT lang_id FROM ' . LANG_TABLE);
+$sql = 'SELECT lang_id, lang_iso
+ FROM ' . LANG_TABLE;
+$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- $lang_ids[] = $row['lang_id'];
+ $lang_defs['id'][] = $row['lang_id'];
+ $lang_defs['iso'][$row['lang_iso']] = $row['lang_id'];
}
$db->sql_freeresult($result);
$sql = 'SELECT field_id, lang_id
- FROM phpbb_profile_lang
+ FROM ' . PROFILE_LANG_TABLE . '
ORDER BY lang_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- $lang_entry[$row['field_id']][] = $row['lang_id'];
+ $lang_defs['entry'][$row['field_id']][] = $row['lang_id'];
}
$db->sql_freeresult($result);
-foreach ($lang_entry as $field_id => $field_ary)
+foreach ($lang_defs['entry'] as $field_id => $field_ary)
{
- $lang_diff[$field_id] = array_diff($lang_ids, $field_ary);
+ $lang_defs['diff'][$field_id] = array_diff($lang_defs['id'], $field_ary);
}
-unset($lang_ids);
if ($mode == '')
{
@@ -175,8 +135,11 @@ if ($mode == 'create')
// Get all relevant informations about entered values within all steps
- // step 1
- $exclude[1] = array('lang_name', 'lang_explain', 'field_name');
+ $exclude = array(
+ 1 => array('lang_name', 'lang_explain', 'field_name'),
+ 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'),
+ 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options')
+ );
// Text-based fields require lang_default_value to be excluded
if ($field_type == FIELD_STRING || $field_type == FIELD_TEXT)
@@ -190,13 +153,12 @@ if ($mode == 'create')
$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', '');
+ $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]);
@@ -249,20 +211,11 @@ if ($mode == 'create')
}
}
}
-/*
- 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, '');
@@ -281,8 +234,8 @@ if ($mode == 'create')
$error[] = $user->lang['EMPTY_USER_FIELD_NAME'];
}
- $sql = "SELECT field_ident
- FROM phpbb_profile_fields
+ $sql = 'SELECT field_ident
+ FROM ' . PROFILE_FIELDS_TABLE . "
WHERE field_ident = '$field_ident'";
$result = $db->sql_query($sql);
@@ -322,46 +275,20 @@ if ($mode == 'create')
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";
- }
- }
+ $s_hidden_fields .= build_hidden_fields($key_ary);
}
- if (!sizeof($error) && $save && $step == 3)
+ if (!sizeof($error))
{
- save_profile_field($field_type, $field_ident);
+ if ($step == 3 && (sizeof($lang_defs['iso']) == 1 || $save))
+ {
+ save_profile_field($field_type, $field_ident);
+ }
}
?>
-
lang['STEP_X_FROM_X'], $step, 3); ?>
+ lang['STEP_' . $step . '_EXPLAIN']; ?>
';
+ $l_message = '';
- adm_page_message($user->lang['CONFIRM'], $l_message, false);
+ adm_page_message($user->lang['CONFIRM'], $l_message, false, false);
adm_page_footer();
}
@@ -640,13 +557,18 @@ if ($mode == 'activate')
$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]))
+ if (!in_array($default_lang_id, $lang_defs['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');
+ $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
+ SET field_active = 1
+ WHERE field_id = $field_id";
+ $db->sql_query($sql);
+
+ // TODO: add_log
+ trigger_error($user->lang['PROFILE_FIELD_ACTIVATED']);
}
if ($mode == 'deactivate')
@@ -658,16 +580,21 @@ if ($mode == 'deactivate')
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');
+ $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
+ SET field_active = 0
+ WHERE field_id = $field_id";
+ $db->sql_query($sql);
+
+ // TODO: add_log
+ trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED']);
}
if ($mode == 'move_up' || $mode == 'move_down')
{
- $field_order = intval($_GET['order']);
+ $field_order = request_var('order', 0);
$order_total = $field_order * 2 + (($mode == 'move_up') ? -1 : 1);
- $sql = "UPDATE phpbb_profile_fields
+ $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
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);
@@ -680,14 +607,6 @@ if ($mode == 'manage')
?>