diff --git a/phpBB/adm/admin_permissions.php b/phpBB/adm/admin_permissions.php
index c8c79960ab..f78020ecb4 100644
--- a/phpBB/adm/admin_permissions.php
+++ b/phpBB/adm/admin_permissions.php
@@ -225,14 +225,14 @@ switch ($submit)
// Do we need to recache the moderator lists? We do if the mode
// was mod or auth_settings['mod'] is a non-zero size array
- if ($mode == 'mod' || sizeof($auth_settings['mod']))
+ if ($mode == 'mod' || (isset($auth_settings['mod']) && sizeof($auth_settings['mod'])))
{
cache_moderators();
}
// Remove users who are now moderators or admins from everyones foes
// list
- if ($mode == 'mod' || sizeof($auth_settings['mod']) || $mode == 'admin' || sizeof($auth_settings['admin']))
+ if ($mode == 'mod' || (isset($auth_settings['mod']) && sizeof($auth_settings['mod'])) || $mode == 'admin' || (isset($auth_settings['admin']) && sizeof($auth_settings['admin'])))
{
update_foes();
}
diff --git a/phpBB/adm/admin_profile.php b/phpBB/adm/admin_profile.php
index 9f63f6ae38..4c85cce6f6 100644
--- a/phpBB/adm/admin_profile.php
+++ b/phpBB/adm/admin_profile.php
@@ -17,20 +17,21 @@
Taking into consideration
... admin is NOT able to change the field type later
+ ... admin can NOT change field name after creation
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
+ If the admin adds a field, he needs to enter at least the default board language params. Without doing so, he
is not able to activate the field.
- If the default board language is changed, a check has to be made if the profile field language entries are
+ If the default board language is changed a check has to be made if the profile field language entries are
still valid.
TODO:
* Show at profile view (yes/no)
* Viewtopic Integration (Load Switch, Able to show fields with additional template vars populated if enabled)
* Custom Validation (Regex) - not in 2.2
- * Able to use bbcode/smilies/urls - not in 2.2
+ * Fix novalue/default for dropdown boxes. These fields seem to get saved +1 in the database
*/
@@ -72,7 +73,7 @@ $default_values = array(
FIELD_INT => array('field_length' => 5, 'field_minlen' => 0, 'field_maxlen' => 100, 'field_validation' => '', 'field_novalue' => 0, 'field_default_value' => 0),
FIELD_DATE => array('field_length' => 10, 'field_minlen' => 10, 'field_maxlen' => 10, 'field_validation' => '', 'field_novalue' => ' 0- 0- 0', 'field_default_value' => ' 0- 0- 0'),
FIELD_BOOL => array('field_length' => 1, 'field_minlen' => 0, 'field_maxlen' => 0, 'field_validation' => '', 'field_novalue' => 0, 'field_default_value' => 0),
- FIELD_DROPDOWN => array('field_length' => 0, 'field_minlen' => 0, 'field_maxlen' => 5, 'field_validation' => '', 'field_novalue' => 1, 'field_default_value' => 1),
+ FIELD_DROPDOWN => array('field_length' => 0, 'field_minlen' => 0, 'field_maxlen' => 5, 'field_validation' => '', 'field_novalue' => 0, 'field_default_value' => 0),
);
$cp = new custom_profile_admin();
@@ -87,6 +88,7 @@ $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
+ // Make some arrays with all available languages
$lang_defs['id'][] = $row['lang_id'];
$lang_defs['iso'][$row['lang_iso']] = $row['lang_id'];
}
@@ -99,14 +101,17 @@ $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
+ // Which languages are available for each item
$lang_defs['entry'][$row['field_id']][] = $row['lang_id'];
}
$db->sql_freeresult($result);
+// Have some fields been defined?
if (isset($lang_defs['entry']))
{
foreach ($lang_defs['entry'] as $field_id => $field_ary)
{
+ // Fill an array with the languages that are missing for each field
$lang_defs['diff'][$field_id] = array_diff($lang_defs['id'], $field_ary);
}
}
@@ -181,7 +186,7 @@ if ($mode == 'create' || $mode == 'edit')
}
$field_row = array_merge($default_values[$field_type], array(
- 'field_name' => request_var('field_name', ''),
+ 'field_ident' => request_var('field_ident', ''),
'field_required' => 0,
'field_hide' => 0,
'field_show_on_reg' => 0,
@@ -194,14 +199,14 @@ if ($mode == 'create' || $mode == 'edit')
$s_hidden_fields = '';
}
- // Get all relevant informations about entered values within all steps
+ // $exclude contains the data that we gather in each ste
$exclude = array(
- 1 => array('lang_name', 'lang_explain', 'field_name'),
+ 1 => array('field_ident', 'lang_name', 'lang_explain'),
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
+ // Text-based fields require the lang_default_value to be excluded
if ($field_type == FIELD_STRING || $field_type == FIELD_TEXT)
{
$exclude[1][] = 'lang_default_value';
@@ -213,19 +218,22 @@ if ($mode == 'create' || $mode == 'edit')
$exclude[1][] = 'lang_options';
}
- $cp->vars['field_name'] = request_var('field_name', $field_row['field_name']);
- $cp->vars['lang_name'] = request_var('lang_name', $field_row['lang_name']);
+ $cp->vars['field_ident'] = request_var('field_ident', $field_row['field_ident']);
+ $cp->vars['lang_name'] = request_var('field_ident', $field_row['lang_name']);
$cp->vars['lang_explain'] = request_var('lang_explain', $field_row['lang_explain']);
$cp->vars['lang_default_value'] = request_var('lang_default_value', $field_row['lang_default_value']);
$options = request_var('lang_options', '');
- if ($options)
- {
- if (sizeof(explode("\n", $options)) == sizeof($lang_options))
+ // If the user has submitted a form with options (i.e. dropdown field)
+ if (!empty($options))
+ {
+ if (sizeof(explode("\n", $options)) == sizeof($lang_options) || $mode == 'create')
{
+ // The number of options in the field is equal to the number of options already in the database
+ // Or we are creating a new dropdown list.
$cp->vars['lang_options'] = explode("\n", $options);
}
- else
+ else if($mode == 'edit')
{
$cp->vars['lang_options'] = $lang_options;
$error[] = 'You are not allowed to remove or add options within already existing profile fields';
@@ -241,6 +249,7 @@ if ($mode == 'create' || $mode == 'edit')
{
if ($key == 'field_required' || $key == 'field_show_on_reg' || $key == 'field_hide')
{
+ // Are we creating or editing a field?
$var = (!$submit && $step == 1) ? $field_row[$key] : request_var($key, 0);
// Damn checkboxes...
@@ -257,6 +266,7 @@ if ($mode == 'create' || $mode == 'edit')
// Manipulate the intended variables a little bit if needed
if ($field_type == FIELD_DROPDOWN && $key == 'field_maxlen')
{
+ // Get the number of options if this key is 'field_maxlen'
$var = sizeof(explode("\n", request_var('lang_options', '')));
}
@@ -348,7 +358,7 @@ if ($mode == 'create' || $mode == 'edit')
{
$cp->vars[$key] = $$key;
}
- else if ($key == 'l_lang_options')
+ else if ($key == 'l_lang_options' && sizeof($cp->vars[$key]) > 1)
{
foreach ($cp->vars[$key] as $lang_id => $options)
{
@@ -360,13 +370,20 @@ if ($mode == 'create' || $mode == 'edit')
if ($submit && $step == 1)
{
// Check values for step 1
- if ($cp->vars['field_name'] == '')
+ if ($cp->vars['field_ident'] == '')
{
- $error[] = $user->lang['EMPTY_FIELD_NAME'];
+ // Rename $user->lang['EMPTY_FIELD_NAME'] to $user->lang['EMPTY_FIELD_IDENT']
+ $error[] = $user->lang['EMPTY_FIELD_IDENT'];
}
+
+ if(!preg_match('/^[a-z_]$/', $cp->vars['field_ident']))
+ {
+ $error[] = $user->lang['INVALID_CHARS_FIELD_IDENT'];
+ }
+
if ($cp->vars['lang_name'] == '')
{
- $error[] = $user->lang['EMPTY_USER_FIELD_NAME'];
+ $error[] = $user->lang['EMPTY_USER_FIELD_IDENT'];
}
if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN)
@@ -454,8 +471,8 @@ if ($mode == 'create' || $mode == 'edit')
@@ -482,10 +499,20 @@ if ($mode == 'create' || $mode == 'edit')
if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN)
{
- if ($field_type == FIELD_BOOL && !sizeof($cp->vars['lang_options']))
+ // Initialize these array elements if we are creating a new field
+ if (!sizeof($cp->vars['lang_options']))
{
- $cp->vars['lang_options'][0] = '';
- $cp->vars['lang_options'][1] = '';
+ if($field_type == FIELD_BOOL)
+ {
+ // No options have been defined for a boolean field.
+ $cp->vars['lang_options'][0] = '';
+ $cp->vars['lang_options'][1] = '';
+ }
+ else
+ {
+ // No options have been defined for the dropdown menu
+ $cp->vars['lang_options'] = array();
+ }
}
?>