From fec41273a4ae2f24ec8beb11dc473222cfd04b53 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 25 May 2006 19:15:04 +0000 Subject: [PATCH] first round of custom profile changes git-svn-id: file:///svn/phpbb/trunk@5965 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/style/acp_profile.html | 65 +- phpBB/adm/style/custom_profile_fields.html | 2 +- phpBB/includes/acp/acp_profile.php | 96 +- phpBB/includes/functions_display.php | 2 +- phpBB/includes/functions_profile_fields.php | 881 ++++++++++-------- phpBB/includes/template.php | 60 +- phpBB/language/en/acp/profile.php | 14 +- phpBB/language/en/common.php | 1 + .../template/custom_profile_fields.html | 2 +- 9 files changed, 623 insertions(+), 500 deletions(-) diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 1cfa154da1..ce260d1b98 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -31,8 +31,38 @@

{L_FIELD_IDENT_EXPLAIN}
+
+

{L_DISPLAY_PROFILE_FIELD_EXPLAIN}
+
checked="checked" /> {L_YES} checked="checked" /> {L_NO}
+
+
+ {L_VISIBILITY_OPTION} +
+
+
checked="checked" />
+
+
+

{L_DISPLAY_AT_REGISTER_EXPLAIN}
+
checked="checked" />
+
+
+

{L_REQUIRED_FIELD_EXPLAIN}
+
checked="checked" />
+
+
+

{L_HIDE_PROFILE_FIELD_EXPLAIN}
+
checked="checked" />
+
+
+ + +
+ +
+ +
{L_LANG_SPECIFIC}
@@ -71,22 +101,6 @@
{L_TITLE} -
-

{L_REQUIRED_FIELD_EXPLAIN}
-
checked="checked" />
-
-
-
-
checked="checked" />
-
-
-

{L_HIDE_PROFILE_FIELD_EXPLAIN}
-
checked="checked" />
-
-
-

{L_EXCLUDE_FROM_VIEW_EXPLAIN}
-
checked="checked" />
-

{option.EXPLAIN}
@@ -117,7 +131,7 @@
- +
@@ -156,8 +170,8 @@ {L_FIELD_IDENT} {L_FIELD_TYPE} - {L_OPTIONS} - {L_REORDER} +   + {L_OPTIONS} @@ -166,10 +180,15 @@ {fields.FIELD_IDENT} {fields.FIELD_TYPE} - {fields.L_ACTIVATE_DEACTIVATE} - {L_EDIT}{L_EDIT} - {L_DELETE} - {L_MOVE_UP} | {L_MOVE_DOWN} + {fields.L_ACTIVATE_DEACTIVATE} | {L_EDIT} + + + {L_MOVE_UP} + {L_MOVE_DOWN} + {L_EDIT} + {L_DELETE} + + diff --git a/phpBB/adm/style/custom_profile_fields.html b/phpBB/adm/style/custom_profile_fields.html index abca1c9ff3..c1f0d5c216 100644 --- a/phpBB/adm/style/custom_profile_fields.html +++ b/phpBB/adm/style/custom_profile_fields.html @@ -17,7 +17,7 @@ {bool.options.VALUE}    - checked="checked" /> + checked="checked" /> diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 4c7a268f09..853d54b14f 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -223,7 +223,8 @@ class acp_profile $step = request_var('step', 1); $submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; - $update = (isset($_REQUEST['update'])) ? true : false; + $update_preview = (isset($_REQUEST['update_preview'])) ? true : false; + $update = (isset($_REQUEST['update']) || $update_preview) ? true : false; $save = (isset($_REQUEST['save'])) ? true : false; // We are editing... we need to grab basic things @@ -294,10 +295,10 @@ class acp_profile $s_hidden_fields = ''; } - // $exclude contains the data that we gather in each step + // $exclude contains the data we gather in each step $exclude = array( - 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', 'field_no_view'), + 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option', 'field_no_view'), + 2 => array('field_length', 'pf_preview', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'), 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options') ); @@ -317,6 +318,26 @@ class acp_profile $cp->vars['lang_name'] = request_var('lang_name', $field_row['lang_name'], true); $cp->vars['lang_explain'] = request_var('lang_explain', $field_row['lang_explain'], true); $cp->vars['lang_default_value'] = request_var('lang_default_value', $field_row['lang_default_value'], true); + + // Field option... + if (isset($_REQUEST['field_option'])) + { + $field_option = request_var('field_option', ''); + + $cp->vars['field_required'] = ($field_option == 'field_required') ? 1 : 0; + $cp->vars['field_show_on_reg'] = ($field_option == 'field_show_on_reg') ? 1 : 0; + $cp->vars['field_hide'] = ($field_option == 'field_hide') ? 1 : 0; + } + else + { + $cp->vars['field_required'] = $field_row['field_required']; + $cp->vars['field_show_on_reg'] = $field_row['field_show_on_reg']; + $cp->vars['field_hide'] = $field_row['field_hide']; + + $field_option = ($field_row['field_required']) ? 'field_required' : (($field_row['field_show_on_reg']) ? 'field_show_on_reg' : (($field_row['field_hide']) ? 'field_hide' : '')); + } + + $cp->vars['field_no_view'] = request_var('field_no_view', $field_row['field_no_view']); // A boolean field expects an array as the lang options if ($field_type == FIELD_BOOL) @@ -353,21 +374,7 @@ class acp_profile // step 2 foreach ($exclude[2] as $key) { - if ($key == 'field_required' || $key == 'field_show_on_reg' || $key == 'field_hide' || $key == 'field_no_view') - { - // Are we creating or editing a field? - $var = (!$submit && $step == 1) ? $field_row[$key] : request_var($key, 0); - - // Damn checkboxes... - if (!$submit && $step == 1) - { - $_REQUEST[$key] = $var; - } - } - else - { - $var = request_var($key, $field_row[$key], true); - } + $var = request_var($key, $field_row[$key], true); // Manipulate the intended variables a little bit if needed if ($field_type == FIELD_DROPDOWN && $key == 'field_maxlen') @@ -394,7 +401,9 @@ class acp_profile if ($field_type == FIELD_DATE && $key == 'field_default_value') { - if (isset($_REQUEST['always_now']) || $var == 'now') + $always_now = request_var('always_now', 0); + + if ($always_now || $var == 'now') { $now = getdate(); @@ -529,9 +538,9 @@ class acp_profile { continue; } - + $_new_key_ary = array(); - + foreach ($key_ary as $key) { if (!isset($_REQUEST[$key])) @@ -553,10 +562,15 @@ class acp_profile { $this->save_profile_field($cp, $field_type, $lang_defs, $action); } + else if ($action == 'edit' && $save) + { + $this->save_profile_field($cp, $field_type, $lang_defs, $action); + } } $template->assign_vars(array( 'S_EDIT' => true, + 'S_EDIT_MODE' => ($action == 'edit') ? true : false, 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', 'L_TITLE' => $user->lang['STEP_' . $step . '_TITLE_' . strtoupper($action)], @@ -575,7 +589,10 @@ class acp_profile // Build common create options $template->assign_vars(array( 'S_STEP_ONE' => true, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false, + 'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false, + 'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false, + 'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false, 'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']), 'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($cp->profile_types[$field_type])], @@ -631,12 +648,6 @@ class acp_profile $template->assign_vars(array( 'S_STEP_TWO' => true, - 'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false, - 'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false, - 'S_FIELD_HIDE' => ($cp->vars['field_hide']) ? true : false, - 'S_FIELD_NO_VIEW' => ($cp->vars['field_no_view']) ? true : false, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, - 'L_NEXT' => (sizeof($lang_defs['iso']) == 1) ? $user->lang['SAVE'] : $user->lang['PROFILE_LANG_OPTIONS']) ); @@ -692,8 +703,8 @@ class acp_profile $template->assign_var('USER_ERROR', $user_error); } - - $preview_field = $cp->process_field_row('preview', array( + + $preview_field = array( 'lang_name' => $cp->vars['lang_name'], 'lang_explain' => $cp->vars['lang_explain'], 'lang_id' => $lang_defs['iso'][$config['default_lang']], @@ -706,13 +717,18 @@ class acp_profile 'field_length' => $cp->vars['field_length'], 'field_maxlen' => $cp->vars['field_maxlen'], - 'lang_options' => $cp->vars['lang_options']) + 'lang_options' => $cp->vars['lang_options'], ); - + + if ($update_preview) + { + $preview_field['acp_preview'] = true; + } + $template->assign_vars(array( 'PREVIEW_LANG_NAME' => $cp->vars['lang_name'], 'PREVIEW_LANG_EXPLAIN' => $cp->vars['lang_explain'], - 'PREVIEW_FIELD' => $preview_field) + 'PREVIEW_FIELD' => $cp->process_field_row(($update_preview) ? 'change' : 'preview', $preview_field)) ); break; @@ -720,11 +736,7 @@ class acp_profile // Define remaining language variables case 3: - $template->assign_vars(array( - 'S_STEP_THREE' => true, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) - ); - + $template->assign_var('S_STEP_THREE', true); $options = $this->build_language_options($cp, $field_type, $action); foreach ($options as $lang_id => $lang_ary) @@ -745,7 +757,11 @@ class acp_profile break; } - + + $template->assign_vars(array( + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + return; break; diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 7dc2fe9a98..407a592c13 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -703,7 +703,7 @@ function display_attachments($forum_id, $blockname, &$attachment_data, &$update_ foreach ($attachment_data as $attachment) { // We need to reset/empty the _file block var, because this function might be called more than once - $template->reset_block_vars('_file'); + $template->destroy_block_vars('_file'); $block_array = array(); diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index f3f78e625b..6bea346ef3 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -19,269 +19,62 @@ class custom_profile var $options_lang = array(); /** - * Build profile cache, used for display - */ - function build_cache() - { - global $db, $user, $auth; - - $this->profile_cache = array(); - - // Display hidden/no_view fields for admin/moderator - $sql = 'SELECT l.*, f.* - FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f - WHERE l.lang_id = ' . $user->get_iso_lang_id() . ' - AND f.field_active = 1 ' . - ((!$auth->acl_gets('a_', 'm_')) ? ' AND f.field_hide = 0 AND f.field_no_view = 0 ' : '') . ' - AND l.field_id = f.field_id - ORDER BY f.field_order'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $this->profile_cache[$row['field_ident']] = $row; - } - $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 ' . PROFILE_FIELDS_LANG_TABLE . " - 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); - } - } - - /** - * Submit profile field - */ - function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error) - { - global $auth, $db, $user; - - $sql = 'SELECT l.*, f.* - FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " 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 - ORDER BY f.field_order'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $cp_data[$row['field_ident']] = $this->get_profile_field($row); - - // get_profile_field returns an array with values for TEXT fields. - if (is_array($cp_data[$row['field_ident']])) - { - // Contains the original text without bbcode processing etc -// $check_value = $cp_data[$row['field_ident']]['submitted']; - - foreach ($cp_data[$row['field_ident']] as $key => $value) - { - $cp_data[$key] = $value; -/* if ($key != 'submitted') - { - $cp_data[$key] = $value; - }*/ - } - } - else - { - $check_value = $cp_data[$row['field_ident']]; - } - - if (($cp_result = $this->validate_profile_field($row['field_type'], $check_value, $row)) !== false) - { - // If not and only showing common error messages, use this one - $error = ''; - switch ($cp_result) - { - case 'FIELD_INVALID_DATE': - case 'FIELD_REQUIRED': - $error = sprintf($user->lang[$cp_result], $row['lang_name']); - break; - case 'FIELD_TOO_SHORT': - case 'FIELD_TOO_SMALL': - $error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_minlen']); - break; - case 'FIELD_TOO_LONG': - case 'FIELD_TOO_LARGE': - $error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_maxlen']); - break; - case 'FIELD_INVALID_CHARS': - switch ($row['field_validation']) - { - case '[0-9]+': - $error = sprintf($user->lang[$cp_result . '_NUMBERS_ONLY'], $row['lang_name']); - break; - case '[\w]+': - $error = sprintf($user->lang[$cp_result . '_ALPHA_ONLY'], $row['lang_name']); - break; - case '[\w_\+\. \-\[\]]+': - $error = sprintf($user->lang[$cp_result . '_SPACERS_ONLY'], $row['lang_name']); - break; - } - break; - } - - if ($error != '') - { - $cp_error[] = $error; - } - } - } - $db->sql_freeresult($result); - } - - /** - * Assign fields to template, mode can be profile (for profile change) or register (for registration) + * Assign editable fields to template, mode can be profile (for profile change) or register (for registration) + * Called by ucp_profile and ucp_register + * @public */ function generate_profile_fields($mode, $lang_id) { global $db, $template, $auth; + $sql_where = ''; + switch ($mode) + { + case 'register': + // If the field is required we show it on the registration page and do not show hidden fields + $sql_where .= ' AND (f.field_show_on_reg = 1 OR f.field_required = 1) AND f.field_hide = 0'; + break; + + case 'profile': + // Show hidden fields to moderators/admins + if (!$auth->acl_gets('a_', 'm_')) + { + $sql_where .= ' AND f.field_hide = 0'; + } + break; + + default: + trigger_error('Wrong profile mode specified', E_USER_ERROR); + break; + } + $sql = 'SELECT l.*, f.* FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " 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') . ' + WHERE f.field_active = 1 + $sql_where + AND l.lang_id = $lang_id AND l.field_id = f.field_id - ORDER BY f.field_order'; + ORDER BY f.field_order"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { + // Return templated field + $tpl_snippet = $this->process_field_row('change', $row); + $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' => $error) + 'LANG_NAME' => $row['lang_name'], + 'LANG_EXPLAIN' => $row['lang_explain'], + 'FIELD' => $tpl_snippet) ); } $db->sql_freeresult($result); } /** - * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) - * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template + * Validate entered profile field data + * @public */ - function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false) - { - global $db; - - if ($mode == 'grab') - { - if (!is_array($user_id)) - { - $user_id = array($user_id); - } - - if (!sizeof($this->profile_cache)) - { - $this->build_cache(); - } - - if (!implode(', ', $user_id)) - { - return array(); - } - - $sql = 'SELECT * - FROM ' . PROFILE_DATA_TABLE . ' - WHERE user_id IN (' . implode(', ', array_map('intval', $user_id)) . ')'; - $result = $db->sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - return array(); - } - - $user_fields = array(); - do - { - foreach ($row as $ident => $value) - { - if (isset($this->profile_cache[$ident])) - { - $user_fields[$row['user_id']][$ident]['value'] = $value; - $user_fields[$row['user_id']][$ident]['data'] = $this->profile_cache[$ident]; - } -/* else if ($i = strpos($ident, '_bbcode')) - { - // Add extra data (bbcode_uid and bbcode_bitfield) to the data for this profile field. - // TODO: Maybe we should try to make this a bit more generic (not limited to bbcode)? - $field = substr($ident, 0, $i); - $subfield = substr($ident, $i+1); - $user_fields[$row['user_id']][$field]['data'][$subfield] = $value; - }*/ - } - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - return $user_fields; - } - else if ($mode == 'show') - { - // $profile_row == $user_fields[$row['user_id']]; - $tpl_fields = array(); - $tpl_fields['row'] = $tpl_fields['blockrow'] = array(); - foreach ($profile_row as $ident => $ident_ary) - { - $tpl_fields['row'] += array( - 'PROFILE_' . strtoupper($ident) . '_VALUE' => $this->get_profile_value($ident_ary), - 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'], - 'PROFILE_' . strtoupper($ident) . '_NAME' => $ident_ary['data']['lang_name'], - 'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $ident_ary['data']['lang_explain'], - - 'S_PROFILE_' . strtoupper($ident) => true - ); - - $tpl_fields['blockrow'][] = array( - 'PROFILE_FIELD_VALUE' => $this->get_profile_value($ident_ary), - 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'], - 'PROFILE_FIELD_NAME' => $ident_ary['data']['lang_name'], - 'PROFILE_FIELD_EXPLAIN' => $ident_ary['data']['lang_explain'], - - 'S_PROFILE_' . strtoupper($ident) => true - ); - } - - return $tpl_fields; - } - } - - // VALIDATE Function - validate entered data function validate_profile_field($field_type, &$field_value, $field_data) { switch ($field_type) @@ -289,11 +82,11 @@ class custom_profile case FIELD_INT: case FIELD_DROPDOWN: $field_value = (int) $field_value; - break; + break; case FIELD_BOOL: $field_value = (bool) $field_value; - break; + break; } switch ($field_type) @@ -319,7 +112,7 @@ class custom_profile { return 'FIELD_INVALID_DATE'; } - break; + break; case FIELD_INT: if (empty($field_value) && !$field_data['field_required']) @@ -335,14 +128,14 @@ class custom_profile { return 'FIELD_TOO_LARGE'; } - break; + break; case FIELD_DROPDOWN: if ($field_value == $field_data['field_novalue'] && $field_data['field_required']) { return 'FIELD_REQUIRED'; } - break; + break; case FIELD_STRING: case FIELD_TEXT: @@ -372,13 +165,260 @@ class custom_profile return 'FIELD_INVALID_CHARS'; } } - break; + break; } return false; } - // Get Profile Value for display + /** + * Build profile cache, used for display + * @private + */ + function build_cache() + { + global $db, $user, $auth; + + $this->profile_cache = array(); + + // Display hidden/no_view fields for admin/moderator + $sql = 'SELECT l.*, f.* + FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f + WHERE l.lang_id = ' . $user->get_iso_lang_id() . ' + AND f.field_active = 1 ' . + ((!$auth->acl_gets('a_', 'm_')) ? ' AND f.field_hide = 0 ' : '') . ' + AND f.field_no_view = 0 + AND l.field_id = f.field_id + ORDER BY f.field_order'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $this->profile_cache[$row['field_ident']] = $row; + } + $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 ' . PROFILE_FIELDS_LANG_TABLE . " + 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'] + 1)] = $row['value']; + } + $db->sql_freeresult($result); + } + } + + /** + * Submit profile field + * @public + */ + function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error) + { + global $auth, $db, $user; + + $sql_where = ''; + switch ($mode) + { + case 'register': + // If the field is required we show it on the registration page and do not show hidden fields + $sql_where .= ' AND (f.field_show_on_reg = 1 OR f.field_required = 1) AND f.field_hide = 0'; + break; + + case 'profile': + // Show hidden fields to moderators/admins + if (!$auth->acl_gets('a_', 'm_')) + { + $sql_where .= ' AND f.field_hide = 0'; + } + break; + + default: + trigger_error('Wrong profile mode specified', E_USER_ERROR); + break; + } + + $sql = 'SELECT l.*, f.* + FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f + WHERE l.lang_id = $lang_id + AND f.field_active = 1 + $sql_where + AND l.field_id = f.field_id + ORDER BY f.field_order"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $cp_data[$row['field_ident']] = $this->get_profile_field($row); + $check_value = $cp_data[$row['field_ident']]; + + if (($cp_result = $this->validate_profile_field($row['field_type'], $check_value, $row)) !== false) + { + // If not and only showing common error messages, use this one + $error = ''; + switch ($cp_result) + { + case 'FIELD_INVALID_DATE': + case 'FIELD_REQUIRED': + $error = sprintf($user->lang[$cp_result], $row['lang_name']); + break; + + case 'FIELD_TOO_SHORT': + case 'FIELD_TOO_SMALL': + $error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_minlen']); + break; + + case 'FIELD_TOO_LONG': + case 'FIELD_TOO_LARGE': + $error = sprintf($user->lang[$cp_result], $row['lang_name'], $row['field_maxlen']); + break; + + case 'FIELD_INVALID_CHARS': + switch ($row['field_validation']) + { + case '[0-9]+': + $error = sprintf($user->lang[$cp_result . '_NUMBERS_ONLY'], $row['lang_name']); + break; + + case '[\w]+': + $error = sprintf($user->lang[$cp_result . '_ALPHA_ONLY'], $row['lang_name']); + break; + + case '[\w_\+\. \-\[\]]+': + $error = sprintf($user->lang[$cp_result . '_SPACERS_ONLY'], $row['lang_name']); + break; + } + break; + } + + if ($error != '') + { + $cp_error[] = $error; + } + } + } + $db->sql_freeresult($result); + } + + /** + * Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled) + * This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template + * @public + */ + function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false) + { + global $db; + + if ($mode == 'grab') + { + if (!is_array($user_id)) + { + $user_id = array($user_id); + } + + if (!sizeof($this->profile_cache)) + { + $this->build_cache(); + } + + if (!implode(', ', $user_id)) + { + return array(); + } + + $sql = 'SELECT * + FROM ' . PROFILE_DATA_TABLE . ' + WHERE user_id IN (' . implode(', ', array_map('intval', $user_id)) . ')'; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + $db->sql_freeresult($result); + return array(); + } + + $user_fields = array(); + do + { + foreach ($row as $ident => $value) + { + if (isset($this->profile_cache[$ident])) + { + $user_fields[$row['user_id']][$ident]['value'] = $value; + $user_fields[$row['user_id']][$ident]['data'] = $this->profile_cache[$ident]; + } + } + } + while ($row = $db->sql_fetchrow($result)); + $db->sql_freeresult($result); + + return $user_fields; + } + else if ($mode == 'show') + { + // $profile_row == $user_fields[$row['user_id']]; + $tpl_fields = array(); + $tpl_fields['row'] = $tpl_fields['blockrow'] = array(); + + foreach ($profile_row as $ident => $ident_ary) + { + $value = $this->get_profile_value($ident_ary); + + if ($value === NULL) + { + continue; + } + + $tpl_fields['row'] += array( + 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value, + 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'], + 'PROFILE_' . strtoupper($ident) . '_NAME' => $ident_ary['data']['lang_name'], + 'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $ident_ary['data']['lang_explain'], + + 'S_PROFILE_' . strtoupper($ident) => true + ); + + $tpl_fields['blockrow'][] = array( + 'PROFILE_FIELD_VALUE' => $value, + 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'], + 'PROFILE_FIELD_NAME' => $ident_ary['data']['lang_name'], + 'PROFILE_FIELD_EXPLAIN' => $ident_ary['data']['lang_explain'], + + 'S_PROFILE_' . strtoupper($ident) => true + ); + } + + return $tpl_fields; + } + } + + /** + * Get Profile Value for display + */ function get_profile_value($ident_ary) { $value = $ident_ary['value']; @@ -391,33 +431,36 @@ class custom_profile break; case 'string': - $value = make_clickable($value); - $value = censor_text($value); - $value = str_replace("\n", '
', $value); - return $value; - break; - case 'text': - /* - @todo Prepare further, censor_text, smilies, bbcode, whatever - - if ($ident_ary['data']['bbcode_bitfield']) + if (!$value) { - $bbcode = new bbcode($ident_ary['data']['bbcode_bitfield']); - $bbcode->bbcode_second_pass($value, $ident_ary['data']['bbcode_uid'], $ident_ary['data']['bbcode_bitfield']); - $value = smiley_text($value); - $value = censor_text($value); + return NULL; } - return str_replace("\n", '
', $value);*/ $value = make_clickable($value); $value = censor_text($value); $value = str_replace("\n", '
', $value); return $value; - break; - + case 'date': + $date = explode('-', $value); + $month = (isset($date[0])) ? (int) $date[0] : 0; + $day = (isset($date[1])) ? (int) $date[1] : 0; + $year = (isset($date[2])) ? (int) $date[2] : 0; + + if (!$day && !$month && !$year) + { + return NULL; + } + else if ($day && $month && $year) + { + global $user; + + return $user->format_date(mktime(0, 0, 1, $day, $month, $year)); + } + + return $value; break; case 'dropdown': @@ -428,19 +471,46 @@ class custom_profile $this->get_option_lang($field_id, $lang_id, FIELD_DROPDOWN, false); } + if ($value == $ident_ary['data']['field_novalue']) + { + return NULL; + } + return $this->options_lang[$field_id][$lang_id][(int) $value]; break; case 'bool': + $field_id = $ident_ary['data']['field_id']; + $lang_id = $ident_ary['data']['lang_id']; + if (!isset($this->options_lang[$field_id][$lang_id])) + { + $this->get_option_lang($field_id, $lang_id, FIELD_BOOL, false); + } + + if ($ident_ary['data']['field_length'] == 1) + { + $this->options_lang[$field_id][$lang_id][(int) $value]; + } + else if (!$value) + { + return NULL; + } + else + { + return $this->options_lang[$field_id][$lang_id][(int) ($value + 1)]; + } break; default: - trigger_error('Unknown profile type'); + trigger_error('Unknown profile type', E_USER_ERROR); break; } } - // Get field value for registration/profile + /** + * Get field value for registration/profile + * @private + */ function get_var($field_validation, &$profile_row, $default_value, $preview) { global $user; @@ -450,7 +520,7 @@ class custom_profile // checkbox - only testing for isset if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2) { - $value = (isset($_REQUEST[$profile_row['field_ident']])) ? true : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]); + $value = (isset($_REQUEST[$profile_row['field_ident']])) ? true : ((!isset($user->profile_fields[str_replace('pf_', '', $profile_row['field_ident'])]) || $preview) ? $default_value : $user->profile_fields[str_replace('pf_', '', $profile_row['field_ident'])]); } else { @@ -461,26 +531,31 @@ class custom_profile { case 'int': return (int) $value; - break; + break; } return $value; } - - // GENERATE_* Functions - return templated, storable profile fields + + /** + * Process int-type + * @private + */ function generate_int($profile_row, $preview = false) { global $template; - $value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview); - $this->set_tpl_vars($profile_row, $value); - - return $this->get_cp_html(); + $profile_row['field_value'] = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview); + $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); } + /** + * Process date-type + * @private + */ function generate_date($profile_row, $preview = false) { - global $user; + global $user, $template; $profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident']; $now = getdate(); @@ -527,70 +602,75 @@ class custom_profile } unset($now); - $this->set_tpl_vars($profile_row, 0); - return $this->get_cp_html(); + $profile_row['field_value'] = 0; + $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); } + /** + * Process bool-type + * @private + */ function generate_bool($profile_row, $preview = false) { global $template; $value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview); - $this->set_tpl_vars($profile_row, $value); + $profile_row['field_value'] = $value; + $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); if ($profile_row['field_length'] == 1) { if (!isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !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); + $s_preview = ($preview || isset($profile_row['acp_preview'])) ? true : false; + $this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_BOOL, $s_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) + 'OPTION_ID' => $option_id, + 'CHECKED' => ($value == $option_id) ? ' checked="checked"' : '', + 'VALUE' => $option_value) ); } } - - return $this->get_cp_html(); } + /** + * Process string-type + * @private + */ function generate_string($profile_row, $preview = false) { global $template; - // Get the data associated with this field for this user - $value = $this->get_var('', $profile_row, $profile_row['lang_default_value'], $preview); - $this->set_tpl_vars($profile_row, $value); - - return $this->get_cp_html(); + $profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview); + $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); } + /** + * Process text-type + * @private + */ function generate_text($profile_row, $preview = false) { global $template; global $user, $phpEx, $phpbb_root_path; - $value = $this->get_var('', $profile_row, $profile_row['lang_default_value'], $preview); - -/* if ($preview == false) - { - decode_message($value, $user->profile_fields[str_replace('pf_', '', $profile_row['field_ident']) . '_bbcode_uid']); - }*/ - $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(); + $profile_row['field_value'] = $this->get_var('string', $profile_row, $profile_row['lang_default_value'], $preview); + $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); } + /** + * Process dropdown-type + * @private + */ function generate_dropdown($profile_row, $preview = false) { global $user, $template; @@ -599,54 +679,70 @@ class custom_profile if (!isset($this->options_lang[$profile_row['field_id']]) || !isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !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); + $s_preview = ($preview || isset($profile_row['acp_preview'])) ? true : false; + $this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_DROPDOWN, $s_preview); } - $this->set_tpl_vars($profile_row, $value); + $profile_row['field_value'] = $value; + $template->assign_block_vars($this->profile_types[$profile_row['field_type']], array_change_key_case($profile_row, CASE_UPPER)); 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) + '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; preview == just show the value) + /** + * Return Templated value/field. Possible values for $mode are: + * change == user is able to set/enter profile values; preview == just show the value + * @private + */ function process_field_row($mode, $profile_row) { - $preview = false; + global $template; - switch ($mode) + $preview = ($mode == 'preview') ? true : false; + + // set template filename + $template->set_filenames(array( + 'cp_body' => 'custom_profile_fields.html') + ); + + // empty previously filled blockvars + foreach ($this->profile_types as $field_case => $field_type) { - case 'preview': - $preview = true; - case 'change': - $type_func = 'generate_' . $this->profile_types[$profile_row['field_type']]; - break; - default: - return; + $template->destroy_block_vars($field_type); } - return $this->$type_func($profile_row, $preview); + // Assign template variables + $type_func = 'generate_' . $this->profile_types[$profile_row['field_type']]; + $this->$type_func($profile_row, $preview); + + // Return templated data + return $template->assign_display('cp_body'); } - // Build Array for user insertion into custom profile fields table + /** + * Build Array for user insertion into custom profile fields table + */ function build_insert_sql_array($cp_data) { global $db, $user, $auth; + $sql_not_in = array(); + foreach ($cp_data as $key => $null) + { + $sql_not_in[] = "'" . $db->sql_escape($key) . "'"; + } + $sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' 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') . ' + ' . ((sizeof($sql_not_in)) ? ' AND f.field_ident NOT IN (' . implode(', ', $sql_not_in) . ')' : '') . ' AND l.field_id = f.field_id'; $result = $db->sql_query($sql); @@ -664,6 +760,10 @@ class custom_profile return $cp_data; } + /** + * Get profile field value on submit + * @private + */ function get_profile_field($profile_row) { global $phpbb_root_path, $phpEx; @@ -694,69 +794,30 @@ class custom_profile $var = sprintf('%2d-%2d-%4d', $day, $month, $year); break; -/** - case FIELD_TEXT: - include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx); - - $message_parser = new parse_message(request_var($var_name, '')); - - * Get the allowed settings from the global settings. Magic URLs are always set to true. - * @todo It might be nice to make this a per field setting. - - $message_parser->parse($config['allow_bbcode'], true, $config['allow_smilies']); - - $var = array( - $profile_row['field_ident'] => $message_parser->message, - $profile_row['field_ident'] . '_bbcode_uid' => $message_parser->bbcode_uid, - $profile_row['field_ident'] . '_bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'submitted' => request_var($var_name, '') - ); + case FIELD_BOOL: + // Checkbox + if ($profile_row['field_length'] == 2) + { + $var = (isset($_REQUEST[$var_name])) ? 1 : 0; + } + else + { + $var = request_var($var_name, $profile_row['field_default_value']); + } + break; + + case FIELD_STRING: + case FIELD_TEXT: + $var = request_var($var_name, $profile_row['field_default_value'], true); break; -*/ default: - $var = request_var($var_name, $profile_row['field_default_value'], true); + $var = request_var($var_name, $profile_row['field_default_value']); break; } 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; - } } /** @@ -766,8 +827,10 @@ class custom_profile class custom_profile_admin extends custom_profile { var $vars = array(); - + /** + * Return possible validation options + */ function validate_options() { global $user; @@ -784,49 +847,60 @@ class custom_profile_admin extends custom_profile return $validate_options; } - // GET_* get admin options for second step + /** + * Get string options for second step in ACP + */ function get_string_options() { global $user; $options = array( - 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ''), - 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), - 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), - 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '') + 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ''), + 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), + 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), + 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '') ); return $options; } + /** + * Get text options for second step in ACP + */ function get_text_options() { global $user; $options = array( - 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ' ' . $user->lang['ROWS'] . '
' . $user->lang['COLUMNS'] . ' '), - 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), - 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), - 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '') + 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ' ' . $user->lang['ROWS'] . '
' . $user->lang['COLUMNS'] . ' '), + 1 => array('TITLE' => $user->lang['MIN_FIELD_CHARS'], 'FIELD' => ''), + 2 => array('TITLE' => $user->lang['MAX_FIELD_CHARS'], 'FIELD' => ''), + 3 => array('TITLE' => $user->lang['FIELD_VALIDATION'], 'FIELD' => '') ); return $options; } + /** + * Get int options for second step in ACP + */ function get_int_options() { global $user; $options = array( - 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ''), - 1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'], 'FIELD' => ''), - 2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'], 'FIELD' => ''), - 3 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => '') + 0 => array('TITLE' => $user->lang['FIELD_LENGTH'], 'FIELD' => ''), + 1 => array('TITLE' => $user->lang['MIN_FIELD_NUMBER'], 'FIELD' => ''), + 2 => array('TITLE' => $user->lang['MAX_FIELD_NUMBER'], 'FIELD' => ''), + 3 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => '') ); return $options; } + /** + * Get bool options for second step in ACP + */ function get_bool_options() { global $user, $config, $lang_defs; @@ -848,12 +922,15 @@ class custom_profile_admin extends custom_profile $options = array( 0 => array('TITLE' => $user->lang['FIELD_TYPE'], 'EXPLAIN' => $user->lang['BOOL_TYPE_EXPLAIN'], 'FIELD' => 'vars['field_length'] == 1) ? ' checked="checked"' : '') . ' />' . $user->lang['RADIO_BUTTONS'] . '   vars['field_length'] == 2) ? ' checked="checked"' : '') . ' />' . $user->lang['CHECKBOX'] . '   '), - 1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->generate_bool($profile_row, true)) + 1 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)) ); return $options; } + /** + * Get dropdown options for second step in ACP + */ function get_dropdown_options() { global $user, $config, $lang_defs; @@ -877,15 +954,17 @@ class custom_profile_admin extends custom_profile $profile_row[1]['field_ident'] = 'field_novalue'; $profile_row[1]['field_default_value'] = $this->vars['field_novalue']; - $options = array( - 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->generate_dropdown($profile_row[0], true)), - 1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->generate_dropdown($profile_row[1], true)) + 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row[0])), + 1 => array('TITLE' => $user->lang['NO_VALUE_OPTION'], 'EXPLAIN' => $user->lang['NO_VALUE_OPTION_EXPLAIN'], 'FIELD' => $this->process_field_row('preview', $profile_row[1])) ); return $options; } + /** + * Get date options for second step in ACP + */ function get_date_options() { global $user, $config, $lang_defs; @@ -903,8 +982,12 @@ class custom_profile_admin extends custom_profile 'field_length' => $this->vars['field_length'] ); + $always_now = request_var('always_now', 0); + $s_checked = ($always_now || $this->vars['field_default_value'] == 'now') ? true : false; + $options = array( - 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->generate_date($profile_row, true) . '
vars['field_default_value'] == 'now') ? ' checked="checked"' : '') . ' />  ' . $user->lang['ALWAYS_TODAY']) + 0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->process_field_row('preview', $profile_row)), + 1 => array('TITLE' => $user->lang['ALWAYS_TODAY'], 'FIELD' => ' ' . $user->lang['YES'] . ' ' . $user->lang['NO']), ); return $options; diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 9ba7086913..d8f78a77c1 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -105,6 +105,36 @@ class template $this->_tpldata = array(); } + /** + * Reset/empty complete block + * @public + */ + function destroy_block_vars($blockname) + { + if (strpos($blockname, '.') !== false) + { + // Nested block. + $blocks = explode('.', $blockname); + $blockcount = sizeof($blocks) - 1; + + $str = &$this->_tpldata; + for ($i = 0; $i < $blockcount; $i++) + { + $str = &$str[$blocks[$i]]; + $str = &$str[sizeof($str) - 1]; + } + + unset($str[$blocks[$blockcount]]); + } + else + { + // Top-level block. + unset($this->_tpldata[$blockname]); + } + + return true; + } + /** * Display handle * @public @@ -333,36 +363,6 @@ class template return true; } - /** - * Reset/empty complete block - * @public - */ - function reset_block_vars($blockname) - { - if (strpos($blockname, '.') !== false) - { - // Nested block. - $blocks = explode('.', $blockname); - $blockcount = sizeof($blocks) - 1; - - $str = &$this->_tpldata; - for ($i = 0; $i < $blockcount; $i++) - { - $str = &$str[$blocks[$i]]; - $str = &$str[sizeof($str) - 1]; - } - - unset($str[$blocks[$blockcount]]); - } - else - { - // Top-level block. - unset($this->_tpldata[$blockname]); - } - - return true; - } - /** * Change already assigned key variable pair (one-dimensional - single loop entry) * diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php index 2ca370a731..252ab1c683 100644 --- a/phpBB/language/en/acp/profile.php +++ b/phpBB/language/en/acp/profile.php @@ -53,15 +53,17 @@ $lang = array_merge($lang, array( 'DEFAULT_VALUE' => 'Default Value', 'DELETE_PROFILE_FIELD' => 'Remove profile field', 'DELETE_PROFILE_FIELD_CONFIRM' => 'Are you sure you want to delete this profile field?', - 'DISPLAY_AT_REGISTRATION' => 'Display at registration screen', + 'DISPLAY_AT_PROFILE' => 'Display at users profile', + 'DISPLAY_AT_REGISTER' => 'Display at registration screen', + 'DISPLAY_AT_REGISTER_EXPLAIN' => 'If this option is enabled, the field will be additionally displayed on registration.', + 'DISPLAY_PROFILE_FIELD' => 'Display profile field', + 'DISPLAY_PROFILE_FIELD_EXPLAIN' => 'The profile field will be shown on viewtopic/viewprofile/memberlist/etc.', 'DROPDOWN_ENTRIES_EXPLAIN' => 'Enter your options now, every option in one line', 'EMPTY_FIELD_IDENT' => 'Empty field name', 'EMPTY_USER_FIELD_NAME' => 'Empty Field Name presented to the user', 'ENTRIES' => 'Entries', 'EVERYTHING_OK' => 'Everything OK', - 'EXCLUDE_FROM_VIEW' => 'Do not display profile field', - 'EXCLUDE_FROM_VIEW_EXPLAIN' => 'The profile field will not be shown on viewtopic/viewprofile/memberlist/etc.', 'FIELD_BOOL' => 'Boolean (Yes/No)', 'FIELD_DATE' => 'Date', @@ -81,7 +83,7 @@ $lang = array_merge($lang, array( 'FIRST_OPTION' => 'First Option', 'HIDE_PROFILE_FIELD' => 'Hide Profile Field', - 'HIDE_PROFILE_FIELD_EXPLAIN' => 'Only Administrators and Moderators are able to see/fill out this profile field', + 'HIDE_PROFILE_FIELD_EXPLAIN' => 'Only Administrators and Moderators are able to see/fill out this profile field. If this option is enabled, the profile field will be only displayed in user profiles.', 'INVALID_CHARS_FIELD_IDENT' => 'Field name can only contain lowercase a-z and _', 'ISO_LANGUAGE' => 'Language [%s]', @@ -110,7 +112,7 @@ $lang = array_merge($lang, array( 'RADIO_BUTTONS' => 'Radio Buttons', 'REMOVED_PROFILE_FIELD' => 'Successfully removed profile field.', 'REQUIRED_FIELD' => 'Required Field', - 'REQUIRED_FIELD_EXPLAIN' => 'Force profile field to be filled out or specified by user', + 'REQUIRED_FIELD_EXPLAIN' => 'Force profile field to be filled out or specified by user. This will display the profile field at registration too.', 'ROWS' => 'Rows', 'SAVE' => 'Save', @@ -133,6 +135,8 @@ $lang = array_merge($lang, array( 'UPDATE_PREVIEW' => 'Update Preview', 'USER_FIELD_NAME' => 'Field Name presented to the user', + + 'VISIBILITY_OPTION' => 'Visibility Option', )); ?> \ No newline at end of file diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index ea0bb08680..00c1383a92 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -426,6 +426,7 @@ $lang = array_merge($lang, array( 'TOO_LONG_USER_PASSWORD' => 'The password you entered is too long.', 'TOO_LONG_USERNAME' => 'The username you entered is too long.', 'TOO_MANY_VOTE_OPTIONS' => 'You have tried to vote for too many options.', + 'TOO_SHORT_CONFIRM_CODE' => 'The confirm code you entered is too short.', 'TOO_SHORT_NEW_PASSWORD' => 'The password you entered is too short.', 'TOO_SHORT_PASSWORD_CONFIRM' => 'The password confirmation you entered is too short.', 'TOO_SHORT_USER_PASSWORD' => 'The password you entered is too short.', diff --git a/phpBB/styles/subSilver/template/custom_profile_fields.html b/phpBB/styles/subSilver/template/custom_profile_fields.html index df45191f58..0a1448a9f8 100644 --- a/phpBB/styles/subSilver/template/custom_profile_fields.html +++ b/phpBB/styles/subSilver/template/custom_profile_fields.html @@ -16,7 +16,7 @@ {bool.options.VALUE}    - checked="checked" /> + checked="checked" />