first round of custom profile changes

git-svn-id: file:///svn/phpbb/trunk@5965 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-05-25 19:15:04 +00:00
parent a59f59de21
commit fec41273a4
9 changed files with 623 additions and 500 deletions

View file

@ -31,8 +31,38 @@
<dt><label for="field_ident">{L_FIELD_IDENT}:</label><br /><span>{L_FIELD_IDENT_EXPLAIN}</span></dt>
<dd><input class="medium" type="text" id="field_ident" name="field_ident" value="{FIELD_IDENT}" /></dd>
</dl>
<dl>
<dt><label for="field_no_view">{L_DISPLAY_PROFILE_FIELD}:</label><br /><span>{L_DISPLAY_PROFILE_FIELD_EXPLAIN}</span></dt>
<dd><input type="radio" id="field_no_view" name="field_no_view" value="0"<!-- IF not S_FIELD_NO_VIEW --> checked="checked"<!-- ENDIF --> /> {L_YES} <input type="radio" name="field_no_view" value="1"<!-- IF S_FIELD_NO_VIEW --> checked="checked"<!-- ENDIF --> /> {L_NO}</dd>
</dl>
</fieldset>
<fieldset>
<legend>{L_VISIBILITY_OPTION}</legend>
<dl>
<dt><label for="field_option_none">{L_DISPLAY_AT_PROFILE}:</label></dt>
<dd><input type="radio" id="field_option_none" name="field_option" value="none"<!-- IF not S_SHOW_ON_REG and not S_FIELD_REQUIRED and not S_FIELD_HIDE --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
<dt><label for="field_show_on_reg">{L_DISPLAY_AT_REGISTER}:</label><br /><span>{L_DISPLAY_AT_REGISTER_EXPLAIN}</span></dt>
<dd><input type="radio" id="field_show_on_reg" name="field_option" value="field_show_on_reg"<!-- IF S_SHOW_ON_REG --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
<dt><label for="field_required">{L_REQUIRED_FIELD}:</label><br /><span>{L_REQUIRED_FIELD_EXPLAIN}</span></dt>
<dd><input type="radio" id="field_required" name="field_option" value="field_required"<!-- IF S_FIELD_REQUIRED --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
<dt><label for="field_hide">{L_HIDE_PROFILE_FIELD}:</label><br /><span>{L_HIDE_PROFILE_FIELD_EXPLAIN}</span></dt>
<dd><input type="radio" id="field_hide" name="field_option" value="field_hide"<!-- IF S_FIELD_HIDE --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
</fieldset>
<!-- IF S_EDIT_MODE -->
<fieldset class="quick">
<input class="button1" type="submit" name="save" value="{L_SAVE}" />
</fieldset>
<!-- ENDIF -->
<fieldset>
<legend>{L_LANG_SPECIFIC}</legend>
<dl>
@ -71,22 +101,6 @@
<fieldset>
<legend>{L_TITLE}</legend>
<dl>
<dt><label for="field_required">{L_REQUIRED_FIELD}:</label><br /><span>{L_REQUIRED_FIELD_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="field_required" name="field_required" value="1"<!-- IF S_FIELD_REQUIRED --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
<dt><label for="field_show_on_reg">{L_DISPLAY_AT_REGISTRATION}:</label></dt>
<dd><input type="checkbox" id="field_show_on_reg" name="field_show_on_reg" value="1"<!-- IF S_SHOW_ON_REG --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
<dt><label for="field_hide">{L_HIDE_PROFILE_FIELD}:</label><br /><span>{L_HIDE_PROFILE_FIELD_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="field_hide" name="field_hide" value="1"<!-- IF S_FIELD_HIDE --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
<dt><label for="field_no_view">{L_EXCLUDE_FROM_VIEW}:</label><br /><span>{L_EXCLUDE_FROM_VIEW_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="field_no_view" name="field_no_view" value="1"<!-- IF S_FIELD_NO_VIEW --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<!-- BEGIN option -->
<dl>
<dt><label>{option.TITLE}:</label><!-- IF option.EXPLAIN --><br /><span>{option.EXPLAIN}</span><!-- ENDIF --></dt>
@ -117,7 +131,7 @@
</fieldset>
<fieldset class="quick">
<input class="button1" type="submit" name="update" value="{L_SUBMIT}" />
<input class="button1" type="submit" name="update_preview" value="{L_SUBMIT}" />
</fieldset>
<!-- ELSEIF S_STEP_THREE -->
@ -156,8 +170,8 @@
<tr>
<th>{L_FIELD_IDENT}</th>
<th>{L_FIELD_TYPE}</th>
<th colspan="3">{L_OPTIONS}</th>
<th>{L_REORDER}</th>
<th>&nbsp;</th>
<th>{L_OPTIONS}</th>
</tr>
</thead>
<tbody>
@ -166,10 +180,15 @@
<td>{fields.FIELD_IDENT}</td>
<td>{fields.FIELD_TYPE}</td>
<td><a href="{fields.U_ACTIVATE_DEACTIVATE}">{fields.L_ACTIVATE_DEACTIVATE}</a></td>
<td><a href="{fields.U_EDIT}"><!-- IF fields.S_NEED_EDIT --><span style="color:red">{L_EDIT}</span><!-- ELSE -->{L_EDIT}<!-- ENDIF --></a></td>
<td><a href="{fields.U_DELETE}">{L_DELETE}</a></td>
<td style="text-align: center;"><a href="{fields.U_MOVE_UP}">{L_MOVE_UP}</a> | <a href="{fields.U_MOVE_DOWN}">{L_MOVE_DOWN}</a></td>
<td><a href="{fields.U_ACTIVATE_DEACTIVATE}">{fields.L_ACTIVATE_DEACTIVATE}</a><!-- IF fields.S_NEED_EDIT --> | <a href="{fields.U_EDIT}"><span style="color:red;">{L_EDIT}</span><!-- ENDIF --></td>
<td style="width: 15%; text-align: right; white-space: nowrap;">
<!-- IF not fields.S_FIRST_ROW --><a href="{fields.U_MOVE_UP}"><img src="images/icon_up.gif" alt="{L_MOVE_UP}" title="{L_MOVE_UP}" width="16" height="16" /></a> <!-- ENDIF -->
<!-- IF not fields.S_LAST_ROW --><a href="{fields.U_MOVE_DOWN}"><img src="images/icon_down.gif" alt="{L_MOVE_DOWN}" title="{L_MOVE_DOWN}" width="16" height="16" /></a> <!-- ENDIF -->
<!-- IF not fields.S_NEED_EDIT --><a href="{fields.U_EDIT}"><img src="images/icon_edit.gif" alt="{L_EDIT}" title="{L_EDIT}" width="16" height="16" /></a> <!-- ENDIF -->
<a href="{fields.U_DELETE}"><img src="images/icon_delete.gif" alt="{L_DELETE}" title="{L_DELETE}" width="16" height="16" /></a>
</td>
</tr>
<!-- END fields -->
</tbody>

View file

@ -17,7 +17,7 @@
<!-- IF bool.FIELD_LENGTH eq 1 -->
<!-- BEGIN options --><input type="radio" class="radio" name="{bool.FIELD_IDENT}" value="{bool.options.OPTION_ID}"{bool.options.CHECKED} /> {bool.options.VALUE}&nbsp; &nbsp;<!-- END options -->
<!-- ELSE -->
<input type="checkbox" name="{bool.FIELD_IDENT}"<!-- IF bool.FIELD_VALUE --> checked="checked"<!-- ENDIF --> />
<input type="checkbox" name="{bool.FIELD_IDENT}" value="1"<!-- IF bool.FIELD_VALUE --> checked="checked"<!-- ENDIF --> />
<!-- ENDIF -->
<!-- END bool -->

View file

@ -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 = '<input type="hidden" name="field_type" value="' . $field_type . '" />';
}
// $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')
);
@ -318,6 +319,26 @@ class acp_profile
$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();
@ -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('<br />', $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'])
);
@ -693,7 +704,7 @@ 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)
@ -746,6 +758,10 @@ class acp_profile
break;
}
$template->assign_vars(array(
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
return;
break;

View file

@ -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();

File diff suppressed because it is too large Load diff

View file

@ -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)
*

View file

@ -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',
));
?>

View file

@ -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.',

View file

@ -16,7 +16,7 @@
<!-- IF bool.FIELD_LENGTH eq 1 -->
<!-- BEGIN options --><input type="radio" name="{bool.FIELD_IDENT}" value="{bool.options.OPTION_ID}"{bool.options.CHECKED} /><span class="genmed">{bool.options.VALUE}</span>&nbsp; &nbsp;<!-- END options -->
<!-- ELSE -->
<input type="checkbox" name="{bool.FIELD_IDENT}"<!-- IF bool.FIELD_VALUE --> checked="checked"<!-- ENDIF --> />
<input type="checkbox" name="{bool.FIELD_IDENT}" value="1"<!-- IF bool.FIELD_VALUE eq 1 --> checked="checked"<!-- ENDIF --> />
<!-- ENDIF -->
<!-- END bool -->