From b41525229be3e754f288e48e184626e53b211171 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 10 Dec 2005 23:20:21 +0000 Subject: [PATCH] - custom profile fields - prune users - prune forums git-svn-id: file:///svn/phpbb/trunk@5325 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_profile.php | 1335 ------------------- phpBB/adm/admin_prune.php | 254 ---- phpBB/adm/admin_prune_users.php | 254 ---- phpBB/includes/acp/acp_profile.php | 1268 ++++++++++++++++++ phpBB/includes/acp/acp_prune.php | 409 ++++++ phpBB/includes/functions.php | 8 + phpBB/includes/functions_admin.php | 2 + phpBB/includes/functions_module.php | 6 +- phpBB/includes/functions_profile_fields.php | 30 +- phpBB/language/en/acp/common.php | 19 + phpBB/language/en/acp/profile.php | 138 ++ phpBB/language/en/acp/prune.php | 77 ++ phpBB/mcp.php | 12 +- 13 files changed, 1946 insertions(+), 1866 deletions(-) delete mode 100644 phpBB/adm/admin_profile.php delete mode 100644 phpBB/adm/admin_prune.php delete mode 100644 phpBB/adm/admin_prune_users.php create mode 100644 phpBB/includes/acp/acp_profile.php create mode 100644 phpBB/includes/acp/acp_prune.php create mode 100644 phpBB/language/en/acp/profile.php create mode 100644 phpBB/language/en/acp/prune.php diff --git a/phpBB/adm/admin_profile.php b/phpBB/adm/admin_profile.php deleted file mode 100644 index 587947d66b..0000000000 --- a/phpBB/adm/admin_profile.php +++ /dev/null @@ -1,1335 +0,0 @@ -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); - -if (!$auth->acl_get('a_user')) -{ - trigger_error('NO_ADMIN'); -} - -$user->add_lang('ucp'); - -$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($user->lang['CUSTOM_PROFILE_FIELDS']); - -// Define some default values for each field type -$default_values = array( - FIELD_STRING => array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), - FIELD_TEXT => array('field_length' => '5|80', 'field_minlen' => 0, 'field_maxlen' => 1000, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), - 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' => 0, 'field_default_value' => 0), -); - -$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_defs = array(); - -$sql = 'SELECT lang_id, lang_iso - FROM ' . LANG_TABLE; -$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']; -} -$db->sql_freeresult($result); - -$sql = 'SELECT field_id, lang_id - FROM ' . PROFILE_LANG_TABLE . ' - ORDER BY lang_id'; -$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); - } -} - -if ($mode == '') -{ - trigger_error('INVALID_MODE'); -} - -if ($mode == 'create' || $mode == 'edit') -{ - $field_id = request_var('field_id', 0); - $step = request_var('step', 1); - $error = array(); - - $submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; - $update = (isset($_REQUEST['update'])) ? true : false; - $save = (isset($_REQUEST['save'])) ? true : false; - - // We are editing... we need to grab basic things - if ($mode == 'edit') - { - if (!$field_id) - { - trigger_error('NO_FIELD_ID'); - } - - $sql = 'SELECT l.*, f.* - FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f - WHERE l.lang_id = ' . $lang_defs['iso'][$config['default_lang']] . " - AND f.field_id = $field_id - AND l.field_id = f.field_id"; - $result = $db->sql_query($sql); - $field_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$field_row) - { - trigger_error('FIELD_NOT_FOUND'); - } - $field_type = $field_row['field_type']; - - // Get language entries - $sql = 'SELECT * FROM ' . PROFILE_FIELDS_LANG_TABLE . ' - WHERE lang_id = ' . $lang_defs['iso'][$config['default_lang']] . " - AND field_id = $field_id - ORDER BY option_id ASC"; - $result = $db->sql_query($sql); - - $lang_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $lang_options[$row['option_id']] = $row['value']; - } - $db->sql_freeresult($result); - - $field_row['pf_preview'] = ''; - - $s_hidden_fields = ''; - } - else - { - // We are adding a new field, define basic params - $lang_options = $field_row = array(); - - $field_type = request_var('field_type', 0); - - if (!$field_type) - { - trigger_error('NO_FIELD_TYPE'); - } - - $field_row = array_merge($default_values[$field_type], array( - 'field_ident' => request_var('field_ident', ''), - 'field_required' => 0, - 'field_hide' => 0, - 'field_no_view' => 0, - 'field_show_on_reg' => 0, - 'lang_name' => '', - 'lang_explain' => '', - 'lang_default_value'=> '', - 'pf_preview' => '') - ); - - $s_hidden_fields = ''; - } - - // $exclude contains the data that 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'), - 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options') - ); - - // 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'; - } - - // option-specific fields require lang_options to be excluded - if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN) - { - $exclude[1][] = 'lang_options'; - } - - $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 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 if ($mode == 'edit') - { - // Changing the number of options? (We remove and re-create the option fields) - $cp->vars['lang_options'] = explode("\n", $options); - } - } - else - { - $cp->vars['lang_options'] = $lang_options; - } - - // 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]); - } - - // 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', ''))); - } - - 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); - } - } - } - - $cp->vars[$key] = $var; - } - - // step 3 - all arrays - if ($mode == 'edit') - { - // Get language entries - $sql = 'SELECT * FROM ' . PROFILE_FIELDS_LANG_TABLE . ' - WHERE lang_id <> ' . $lang_defs['iso'][$config['default_lang']] . " - AND field_id = $field_id - ORDER BY option_id ASC"; - $result = $db->sql_query($sql); - - $l_lang_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $l_lang_options[$row['lang_id']][$row['option_id']] = $row['value']; - } - $db->sql_freeresult($result); - - - $sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value FROM ' . PROFILE_LANG_TABLE . ' - WHERE lang_id <> ' . $lang_defs['iso'][$config['default_lang']] . " - AND field_id = $field_id - ORDER BY lang_id ASC"; - $result = $db->sql_query($sql); - - $l_lang_name = $l_lang_explain = $l_lang_default_value = array(); - while ($row = $db->sql_fetchrow($result)) - { - $l_lang_name[$row['lang_id']] = $row['lang_name']; - $l_lang_explain[$row['lang_id']] = $row['lang_explain']; - $l_lang_default_value[$row['lang_id']] = $row['lang_default_value']; - } - $db->sql_freeresult($result); - } - - foreach ($exclude[3] as $key) - { - $cp->vars[$key] = request_var($key, ''); - - if (!$cp->vars[$key] && $mode == 'edit') - { - $cp->vars[$key] = $$key; - } - else if ($key == 'l_lang_options' && sizeof($cp->vars[$key]) > 1) - { - foreach ($cp->vars[$key] as $lang_id => $options) - { - $cp->vars[$key][$lang_id] = explode("\n", $options); - } - } - } - - if ($submit && $step == 1) - { - // Check values for step 1 - if ($cp->vars['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_IDENT']; - } - - if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN) - { - if (!sizeof($cp->vars['lang_options'])) - { - $error[] = $user->lang['NO_FIELD_ENTRIES']; - } - } - } - - $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; - } - - $s_hidden_fields .= build_hidden_keys($key_ary); - } - - if (!sizeof($error)) - { - if ($step == 3 && (sizeof($lang_defs['iso']) == 1 || $save)) - { - save_profile_field($field_type, $mode); - } - } - -?> - -

lang['STEP_' . $step . '_EXPLAIN_' . strtoupper($mode)]; ?>

- -
"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -vars['lang_options'])) - { - 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(); - } - } -?> - - - - - - - - - -
lang['STEP_' . $step . '_TITLE_' . strtoupper($mode)]; ?>
', $error); ?>
lang['FIELD_TYPE']; ?>:
lang['FIELD_TYPE_EXPLAIN']; ?>
lang['FIELD_' . strtoupper($cp->profile_types[$field_type])]; ?>
lang['FIELD_IDENT']; ?>:
lang['FIELD_IDENT_EXPLAIN']; ?>
lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']); ?>
lang['USER_FIELD_NAME']; ?>:
lang['FIELD_DESCRIPTION']; ?>:
lang['FIELD_DESCRIPTION_EXPLAIN']; ?>
lang['DEFAULT_VALUE']; ?>:
lang[strtoupper($cp->profile_types[$field_type]) . '_DEFAULT_VALUE_EXPLAIN']; ?>
vars['lang_default_value'] . '" />' : ''; ?>
lang['ENTRIES']; ?>:
lang[strtoupper($cp->profile_types[$field_type]) . '_ENTRIES_EXPLAIN']; ?>
' . implode("\n", $cp->vars['lang_options']) . '' : '
[ ' . $user->lang['FIRST_OPTION'] . ' ]
[ ' . $user->lang['SECOND_OPTION'] . ' ]
'; ?>
-
- - - 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"' : ''); ?> /> - - - lang['EXCLUDE_FROM_VIEW']; ?>
lang['EXCLUDE_FROM_VIEW_EXPLAIN']; ?> - vars['field_no_view']) ? ' checked="checked"' : ''); ?> /> - - -profile_types[$field_type] . '_options'; - $options = $cp->$function(); - foreach ($options as $num => $option_ary) - { -?> - - : ' . $option_ary['EXPLAIN'] . '' : ''; ?> - - - - -
 
- - - - -

- - - - -lang[$user_error], $cp->vars['lang_name']); - break; - case 'FIELD_TOO_SHORT': - case 'FIELD_TOO_SMALL': - $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name'], $cp->vars['field_minlen']); - break; - case 'FIELD_TOO_LONG': - case 'FIELD_TOO_LARGE': - $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name'], $cp->vars['field_maxlen']); - break; - case 'FIELD_INVALID_CHARS': - switch ($cp->vars['field_validation']) - { - case '[0-9]+': - $user_error = sprintf($user->lang[$user_error . '_NUMBERS_ONLY'], $cp->vars['lang_name']); - break; - case '[\w]+': - $user_error = sprintf($user->lang[$user_error . '_ALPHA_ONLY'], $cp->vars['lang_name']); - break; - case '[\w_\+\. \-\[\]]+': - $user_error = sprintf($user->lang[$user_error . '_SPACERS_ONLY'], $cp->vars['lang_name']); - break; - } - - default: - $user_error = ''; - } - -?> - - - $cp->vars['lang_name'], - 'lang_explain' => $cp->vars['lang_explain'], - 'lang_id' => $lang_defs['iso'][$config['default_lang']], - '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['PREVIEW_PROFILE_FIELD']; ?>
' . $user_error . '' : '' . $user->lang['EVERYTHING_OK'] . ''; ?>
- - $lang_ary) - { -?> - - lang['DEFAULT_ISO_LANGUAGE'], $config['default_lang']) : sprintf($user->lang['ISO_LANGUAGE'], $lang_ary['lang_iso']) ?> - - $field_ary) - { -?> - - : ' . $field_ary['EXPLAIN'] . '' : ''; ?> - - - - -
- - - - -sql_query($sql); - $field_ident = $db->sql_fetchfield('field_ident', 0, $result); - $db->sql_freeresult($result); - - $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"); - $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id"); - $db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id"); - $db->sql_query('ALTER TABLE ' . PROFILE_DATA_TABLE . " DROP $field_ident"); - - $order = 0; - - $sql = 'SELECT * - FROM ' . PROFILE_FIELDS_TABLE . ' - ORDER BY field_order'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $order++; - if ($row['field_order'] != $order) - { - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " - SET field_order = $order - WHERE field_id = {$row['field_id']}"; - $db->sql_query($sql); - } - } - - add_log('admin', 'LOG_REMOVED_PROFILE_FIELD', $field_ident); - trigger_error('REMOVED_PROFILE_FIELD'); - } - else if (!$cancel) - { - $l_message = '
' . $user->lang['CONFIRM_DELETE_PROFILE_FIELD'] . '

  
'; - - adm_page_message($user->lang['CONFIRM'], $l_message, false, false); - - adm_page_footer(); - } - - $mode = 'manage'; -} - -if ($mode == 'activate') -{ - $field_id = request_var('field_id', 0); - - if (!$field_id) - { - trigger_error('INVALID_MODE'); - } - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '{$config['default_lang']}'"; - $result = $db->sql_query($sql); - $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); - $db->sql_freeresult($result); - - if (!in_array($default_lang_id, $lang_defs['entry'][$field_id])) - { - trigger_error('DEFAULT_LANGUAGE_NOT_FILLED'); - } - - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " - SET field_active = 1 - WHERE field_id = $field_id"; - $db->sql_query($sql); - - $sql = 'SELECT field_ident - FROM ' . PROFILE_FIELDS_TABLE . " - WHERE field_id = $field_id"; - $result = $db->sql_query($sql); - $field_ident = $db->sql_fetchfield('field_ident', 0, $result); - $db->sql_freeresult($result); - - add_log('admin', 'LOG_ACTIVATE_PROFILE_FIELD', $field_ident); - trigger_error($user->lang['PROFILE_FIELD_ACTIVATED']); -} - -if ($mode == 'deactivate') -{ - $field_id = request_var('field_id', 0); - - if (!$field_id) - { - trigger_error('INVALID_MODE'); - } - - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " - SET field_active = 0 - WHERE field_id = $field_id"; - $db->sql_query($sql); - - $sql = 'SELECT field_ident - FROM ' . PROFILE_FIELDS_TABLE . " - WHERE field_id = $field_id"; - $result = $db->sql_query($sql); - $field_ident = $db->sql_fetchfield('field_ident', 0, $result); - $db->sql_freeresult($result); - - add_log('admin', 'LOG_DEACTIVATE_PROFILE_FIELD', $field_ident); - trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED']); -} - -if ($mode == 'move_up' || $mode == 'move_down') -{ - $field_order = request_var('order', 0); - $order_total = $field_order * 2 + (($mode == 'move_up') ? -1 : 1); - - $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); - - $mode = 'manage'; -} - -if ($mode == 'manage') -{ -?> -
"> - - - - - - - -sql_query($sql); - - $row_class = ''; - while ($row = $db->sql_fetchrow($result)) - { - $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; - - $active_lang = (!$row['field_active']) ? 'ACTIVATE' : 'DEACTIVATE'; - $active_value = (!$row['field_active']) ? 'activate' : 'deactivate'; - $id = $row['field_id']; -?> - - - - - - - - -sql_freeresult($result); - - $s_select_type = ''; - foreach ($cp->profile_types as $key => $value) - { - $s_select_type .= ''; - } -?> - - - -
lang['FIELD_IDENT']; ?>lang['FIELD_TYPE']; ?>lang['OPTIONS']; ?>lang['REORDER']; ?>
lang['FIELD_' . strtoupper($cp->profile_types[$row['field_type']])]; ?>lang[$active_lang]; ?>' . $user->lang['EDIT'] . '' : $user->lang['EDIT']) . '' . ((sizeof($lang_defs['diff'][$row['field_id']])) ? '' : ''); ?>lang['DELETE']; ?>lang['MOVE_UP']; ?> | lang['MOVE_DOWN']; ?>
-
-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(); - - foreach ($options as $field => $field_type) - { - $lang_options[1]['lang_iso'] = $config['default_lang']; - $lang_options[1]['fields'][$field] = array( - 'TITLE' => $user->lang['CP_' . strtoupper($field)], - 'FIELD' => '' . ((is_array($cp->vars[$field])) ? implode('
', $cp->vars[$field]) : str_replace("\n", '
', $cp->vars[$field])) . '
' - ); - - if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) - { - $lang_options[1]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN']; - } - } - - foreach ($languages as $lang_id => $lang_iso) - { - $lang_options[$lang_id]['lang_iso'] = $lang_iso; - foreach ($options as $field => $field_type) - { - $value = ($mode == 'create') ? request_var('l_' . $field, '') : $cp->vars['l_' . $field]; - - if ($field == 'lang_options') - { - - $var = ($mode == 'create' || !is_array($cp->vars['lang_options'][$lang_id])) ? $cp->vars['lang_options'] : $cp->vars['lang_options'][$lang_id]; - - switch ($field_type) - { - case 'two_options': - - $lang_options[$lang_id]['fields'][$field] = array( - 'TITLE' => $user->lang['CP_' . strtoupper($field)], - 'FIELD' => '
' . $user->lang['FIRST_OPTION'] . ':
' . $user->lang['SECOND_OPTION'] . ':
' - ); - break; - - case 'optionfield': - - $lang_options[$lang_id]['fields'][$field] = array( - 'TITLE' => $user->lang['CP_' . strtoupper($field)], - 'FIELD' => '' - ); - break; - } - - if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) - { - $lang_options[$lang_id]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN']; - } - } - else - { - $var = ($mode == 'create' || !is_array($cp->vars[$field])) ? $cp->vars[$field] : $cp->vars[$field][$lang_id]; - - $lang_options[$lang_id]['fields'][$field] = array( - 'TITLE' => $user->lang['CP_' . strtoupper($field)], - 'FIELD' => ($field_type == 'string') ? '' : '' - ); - - if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) - { - $lang_options[$lang_id]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN']; - } - } - } - } - - return $lang_options; -} - -function save_profile_field($field_type, $mode = 'create') -{ - global $cp, $db, $config, $user, $lang_defs; - - $field_id = request_var('field_id', 0); - - // Collect all informations, if something is going wrong, abort the operation - $profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array(); - - $default_lang_id = $lang_defs['iso'][$config['default_lang']]; - - if ($mode == 'create') - { - $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE); - $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result); - $db->sql_freeresult($result); - - $field_ident = $cp->vars['field_ident']; - } - - // Save the field - $profile_fields = array( - '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_no_view' => $cp->vars['field_no_view'] - ); - - if ($mode == 'create') - { - $profile_fields += array( - 'field_type' => $field_type, - 'field_ident' => $field_ident, - 'field_order' => $new_field_order + 1, - 'field_active' => 1 - ); - - $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields)); - - $field_id = $db->sql_nextid(); - } - else - { - $db->sql_query('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $profile_fields) . " - WHERE field_id = $field_id"); - } - - if ($mode == 'create') - { - // We are defining the biggest common value, because of the possibility to edit the min/max values of each field. - $sql = 'ALTER TABLE ' . PROFILE_DATA_TABLE . " 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, - ADD {$field_ident}_bbcode_uid VARCHAR(5) NOT NULL, - ADD {$field_ident}_bbcode_bitfield INT(11) UNSIGNED"; - 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 .= 'BIGINT(20) DEFAULT NULL NULL'; - break; - } - $profile_sql[] = $sql; - } - - $sql_ary = array( - 'lang_name' => $cp->vars['lang_name'], - 'lang_explain' => $cp->vars['lang_explain'], - 'lang_default_value' => $cp->vars['lang_default_value'] - ); - - if ($mode == 'create') - { - $sql_ary['field_id'] = $field_id; - $sql_ary['lang_id'] = $default_lang_id; - - $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - } - else - { - update_insert(PROFILE_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => $default_lang_id)); - } - - 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' => (isset($cp->vars['l_lang_explain'][$lang_id])) ? $cp->vars['l_lang_explain'][$lang_id] : '', - 'lang_default_value' => (isset($cp->vars['l_lang_default_value'][$lang_id])) ? $cp->vars['l_lang_default_value'][$lang_id] : '' - ); - } - } - - foreach ($empty_lang as $lang_id => $NULL) - { - $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . " - WHERE field_id = $field_id - AND lang_id = " . (int) $lang_id; - $db->sql_query($sql); - } - } - - $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']); - } - - if ($mode != 'create') - { - $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " - WHERE field_id = $field_id - AND lang_id = " . (int) $default_lang_id; - $db->sql_query($sql); - } - - foreach ($cp->vars['lang_options'] as $option_id => $value) - { - $sql_ary = array( - 'field_type' => (int) $field_type, - 'value' => $value - ); - - if ($mode == 'create') - { - $sql_ary['field_id'] = $field_id; - $sql_ary['lang_id'] = $default_lang_id; - $sql_ary['option_id'] = (int) $option_id; - - $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); - } - else - { - update_insert(PROFILE_FIELDS_LANG_TABLE, $sql_ary, array( - 'field_id' => $field_id, - 'lang_id' => (int) $default_lang_id, - 'option_id' => (int) $option_id) - ); - } - } - } - - if (is_array($cp->vars['l_lang_options']) && sizeof($cp->vars['l_lang_options'])) - { - $empty_lang = array(); - - 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])) - { - if ($mode != 'create') - { - $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " - WHERE field_id = $field_id - AND lang_id = " . (int) $lang_id; - $db->sql_query($sql); - } - - foreach ($lang_ary as $option_id => $value) - { - $profile_lang_fields[] = array( - 'field_id' => (int) $field_id, - 'lang_id' => (int) $lang_id, - 'option_id' => (int) $option_id, - 'field_type' => (int) $field_type, - 'value' => $value - ); - } - } - } - - foreach ($empty_lang as $lang_id => $NULL) - { - $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " - WHERE field_id = $field_id - AND lang_id = " . (int) $lang_id; - $db->sql_query($sql); - } - } - - foreach ($profile_lang as $sql) - { - if ($mode == 'create') - { - $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); - } - else - { - $lang_id = $sql['lang_id']; - unset($sql['lang_id'], $sql['field_id']); - update_insert(PROFILE_LANG_TABLE, $sql, array('lang_id' => (int) $lang_id, 'field_id' => $field_id)); - } - } - - if (sizeof($profile_lang_fields)) - { - foreach ($profile_lang_fields as $sql) - { - if ($mode == 'create') - { - $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); - } - else - { - $lang_id = $sql['lang_id']; - $option_id = $sql['option_id']; - unset($sql['lang_id'], $sql['field_id'], $sql['option_id']); - update_insert(PROFILE_FIELDS_LANG_TABLE, $sql, array( - 'lang_id' => $lang_id, - 'field_id' => $field_id, - 'option_id' => $option_id) - ); - } - } - } - - $db->sql_transaction(); - if ($mode == 'create') - { - foreach ($profile_sql as $sql) - { - $db->sql_query($sql); - } - } - $db->sql_transaction('commit'); - - if ($mode == 'edit') - { - add_log('admin', 'LOG_EDIT_PROFILE_FIELD', $cp->vars['field_ident'] . ':' . $cp->vars['lang_name']); - trigger_error($user->lang['CHANGED_PROFILE_FIELD']); - } - else - { - add_log('admin', 'LOG_CREATE_PROFILE_FIELD', $field_ident . ':' . $cp->vars['lang_name']); - trigger_error($user->lang['ADDED_PROFILE_FIELD']); - } -} - -// Update, then insert if not successfull -function update_insert($table, $sql_ary, $where_fields) -{ - global $db; - - $where_sql = array(); - $check_key = ''; - foreach ($where_fields as $key => $value) - { - $check_key = (!$check_key) ? $key : $check_key; - $where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : $value); - } - - $sql = "SELECT $check_key - FROM $table - WHERE " . implode(' AND ', $where_sql); - $result = $db->sql_query($sql); - - if (!$db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - - $sql_ary = array_merge($where_fields, $sql_ary); - $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary)); - } - else - { - $db->sql_freeresult($result); - - $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE ' . implode(' AND ', $where_sql); - $db->sql_query($sql); - } -} - -function build_hidden_keys($key_ary) -{ - $hidden_fields = ''; - - foreach ($key_ary as $key) - { - $var = isset($_REQUEST[$key]) ? $_REQUEST[$key] : false; - - if ($var === false) - { - continue; - } - - if (is_array($var)) - { - foreach ($var as $num => $__var) - { - if (is_array($__var)) - { - foreach ($__var as $_num => $___var) - { - $hidden_fields .= '' . "\n"; - } - } - else - { - $hidden_fields .= '' . "\n"; - } - } - } - else - { - $hidden_fields .= '' . "\n"; - } - } - return $hidden_fields; -} - -?> \ No newline at end of file diff --git a/phpBB/adm/admin_prune.php b/phpBB/adm/admin_prune.php deleted file mode 100644 index 223ec44095..0000000000 --- a/phpBB/adm/admin_prune.php +++ /dev/null @@ -1,254 +0,0 @@ -acl_get('a_prune')) - { - return; - } - - $module['FORUM']['PRUNE'] = basename(__FILE__) . $SID . '&mode=forums'; - - return; -} - -define('IN_PHPBB', 1); -// Include files -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); - -// Do we have permission? -if (!$auth->acl_get('a_prune')) -{ - trigger_error($user->lang['NO_ADMIN']); -} - -// Get the forum ID for pruning -$forum_id = (isset($_REQUEST['f'])) ? array_map('intval', $_REQUEST['f']) : array(); - -// Check for submit to be equal to Prune. If so then proceed with the pruning. -if (isset($_POST['submit'])) -{ - $prune_posted = (isset($_POST['prune_days'])) ? intval($_POST['prune_days']) : 0; - $prune_viewed = (isset($_POST['prune_vieweddays'])) ? intval($_POST['prune_vieweddays']) : 0; - $prune_all = !$prune_posted && !$prune_viewed; - - $prune_flags = 0; - $prune_flags += (!empty($_POST['prune_old_polls'])) ? 2 : 0; - $prune_flags += (!empty($_POST['prune_announce'])) ? 4 : 0; - $prune_flags += (!empty($_POST['prune_sticky'])) ? 8 : 0; - - // Convert days to seconds for timestamp functions... - $prunedate_posted = time() - ($prune_posted * 86400); - $prunedate_viewed = time() - ($prune_viewed * 86400); - - adm_page_header($user->lang['PRUNE']); - -?> - -

lang['PRUNE']; ?>

- -

lang['PRUNE_SUCCESS']; ?>

- - - - - - - -sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $prune_ids = array(); - $p_result['topics'] = 0; - $p_result['posts'] = 0; - $log_data = ''; - do - { - if ($auth->acl_get('f_list', $row['forum_id'])) - { - if ($prune_all) - { - $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false); - } - else - { - if ($prune_posted) - { - $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false); - $p_result['topics'] += $return['topics']; - $p_result['posts'] += $return['posts']; - } - if ($prune_viewed) - { - $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false); - $p_result['topics'] += $return['topics']; - $p_result['posts'] += $return['posts']; - } - } - - - $prune_ids[] = $row['forum_id']; - - $row_class = ($row_class == 'row1') ? 'row2' : 'row1'; - -?> - - - - - -sql_fetchrow($result)); - - // Sync all pruned forums at once - sync('forum', 'forum_id', $prune_ids, TRUE); - - add_log('admin', 'LOG_PRUNE', $log_data); - } - else - { - -?> - - - -sql_freeresult($result); - -?> -
lang['FORUM']; ?>lang['TOPICS_PRUNED']; ?>lang['POSTS_PRUNED']; ?>
lang['NO_PRUNE']; ?>
- -
- -lang['PRUNE']); - -?> - -

lang['PRUNE']; ?>

- -

lang['FORUM_PRUNE_EXPLAIN']; ?>

- - - -
"> - - - - - - - - - -
lang['SELECT_FORUM']; ?>
 
- -sql_query($sql); - - if (!($row = $db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_FORUM']); - } - - $forum_list = $s_hidden_fields = ''; - do - { - $forum_list .= (($forum_list != '') ? ', ' : '') . '' . $row['forum_name'] . ''; - $s_hidden_fields .= ''; - } - while ($row = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - $l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS'; - -?> - -

lang['FORUM']; ?>

- -

lang[$l_selected_forums] . ': ' . $forum_list; ?>

- -
"> - - - - - - - - - - - - - - - - - - - - - - - - - - -
lang['FORUM_PRUNE']; ?>
lang['PRUNE_NOT_POSTED']; ?>
lang['PRUNE_NOT_VIEWED']; ?>
lang['PRUNE_OLD_POLLS'] ?>:
lang['PRUNE_OLD_POLLS_EXPLAIN']; ?>
lang['YES']; ?>   lang['NO']; ?>
lang['PRUNE_ANNOUNCEMENTS'] ?>: lang['YES']; ?>   lang['NO']; ?>
lang['PRUNE_STICKY'] ?>: lang['YES']; ?>   lang['NO']; ?>
- - \ No newline at end of file diff --git a/phpBB/adm/admin_prune_users.php b/phpBB/adm/admin_prune_users.php deleted file mode 100644 index 55f2ca85f4..0000000000 --- a/phpBB/adm/admin_prune_users.php +++ /dev/null @@ -1,254 +0,0 @@ -acl_get('a_userdel')) - { - return; - } - - $module['USER']['PRUNE_USERS'] = basename(__FILE__) . $SID; - - return; -} - -define('IN_PHPBB', 1); -// Include files -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -require('pagestart.' . $phpEx); - -// Do we have forum admin permissions? -if (!$auth->acl_get('a_userdel')) -{ - trigger_error($user->lang['NO_ADMIN']); -} - -// Set mode -$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : ''; - -// Do prune -if (isset($_POST['prune'])) -{ - if (empty($_POST['confirm'])) - { - $values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'deleteposts'); - - $l_message = '
' . $user->lang['Confirm_prune_users'] . '

  '; - - foreach ($values as $field) - { - $l_message .= (!empty($_POST[$field])) ? '' : ''; - } - - $l_message .= '
'; - - adm_page_header($user->lang['Prune_users']); - -?> - -

lang['PRUNE_USERS']; ?>

- -

lang['PRUNE_USERS_EXPLAIN']; ?>

- -lang['CONFIRM'], $l_message, false); - adm_page_footer(); - - } - else if (isset($_POST['confirm'])) - { - if (!empty($_POST['users'])) - { - $users = explode("\n", urldecode($_POST['users'])); - - $where_sql = ''; - foreach ($users as $username) - { - $where_sql .= (($where_sql != '') ? ', ' : '') . '\'' . trim($username) . '\''; - } - $where_sql = " AND username IN ($where_sql)"; - } - else - { - $username = (!empty($_POST['username'])) ? urldecode($_POST['username']) : ''; - $email = (!empty($_POST['email'])) ? urldecode($_POST['email']) : ''; - - $joined_select = (!empty($_POST['joined_select'])) ? $_POST['joined_select'] : 'lt'; - $active_select = (!empty($_POST['active_select'])) ? $_POST['active_select'] :'lt'; - $count_select = (!empty($_POST['count_select'])) ? $_POST['count_select'] : 'eq'; - $joined = (!empty($_POST['joined'])) ? explode('-', $_POST['joined']) : array(); - $active = (!empty($_POST['active'])) ? explode('-', $_POST['active']) :array(); - $count = (!empty($_POST['count'])) ? intval($_POST['count']) : ''; - - $key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); - $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); - - $where_sql = ''; - $where_sql .= ($username) ? " AND username LIKE '" . str_replace('*', '%', $username) ."'" : ''; - $where_sql .= ($email) ? " AND user_email LIKE '" . str_replace('*', '%', $email) ."' " : ''; - $where_sql .= ($joined) ? " AND user_regdate " . $key_match[$joined_select] . " " . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : ''; - $where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . " $count " : ''; - $where_sql .= ($active) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : ''; - } - - $sql = 'SELECT username, user_id FROM ' . USERS_TABLE . ' - WHERE user_id <> ' . ANONYMOUS . " - $where_sql"; - $result = $db->sql_query($sql); - - $where_sql = ''; - $user_ids = array(); - $usernames = array(); - if ($row = $db->sql_fetchrow($result)) - { - do - { - $where_sql .= (($where_sql != '') ? ', ' : '') . $row['user_id']; - $user_ids[] = $row['user_id']; - $usernames[] = $row['username']; - } - while ($row = $db->sql_fetchrow($result)); - - $where_sql = " AND user_id IN ($where_sql)"; - } - $db->sql_freeresult($result); - - if ($where_sql != '') - { - $sql = ''; - if (!empty($_POST['delete'])) - { - if (!empty($_POST['deleteposts'])) - { - // Call unified post deletion routine? - - $l_log = 'LOG_PRUNE_USER_DEL_DEL'; - } - else - { - for($i = 0; $i < sizeof($user_ids); $i++) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET poster_id = ' . ANONYMOUS . ", post_username = '" . $usernames[$i] . "' - WHERE user_id = " . $userids[$i]; -// $db->sql_query($sql); - } - - $l_log = 'LOG_PRUNE_USER_DEL_ANON'; - } - - $sql = 'DELETE FROM ' . USERS_TABLE; - } - else if (!empty($_POST['deactivate'])) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_active = 0"; - - $l_log = 'LOG_PRUNE_USER_DEAC'; - } - - $sql .= ' WHERE user_id <> ' . ANONYMOUS . " - $where_sql"; -// $db->sql_query($sql); - - add_log('admin', $l_log, implode(', ', $usernames)); - - unset($user_ids); - unset($usernames); - } - - trigger_error($user->lang['SUCCESS_USER_PRUNE']); - } -} - - -// Front end -$find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); -$s_find_count = ''; -foreach ($find_count as $key => $value) -{ - $selected = ($key == 'eq') ? ' selected="selected"' : ''; - $s_find_count .= ''; -} - -$find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); -$s_find_join_time = ''; -foreach ($find_time as $key => $value) -{ - $s_find_join_time .= ''; -} -$s_find_active_time = ''; -foreach ($find_time as $key => $value) -{ - $s_find_active_time .= ''; -} - -// -// -// -adm_page_header($user->lang['PRUNE_USERS']); - -?> - -

lang['PRUNE_USERS']; ?>

- -

lang['PRUNE_USERS_EXPLAIN']; ?>

- -
"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lang['PRUNE_USERS']; ?>
lang['USERNAME']; ?>:
lang['EMAIL']; ?>:
lang['JOINED']; ?>:
lang['Joined_explain']; ?>
lang['LAST_ACTIVE']; ?>:
lang['Last_active_explain']; ?>
lang['POSTS']; ?>:
lang['PRUNE_USERS']; ?>:
lang['SELECT_USERS_EXPLAIN']; ?>
lang['DELETE_USER_POSTS']; ?>:
lang['DELETE_USER_POSTS_EXPLAIN']; ?>
lang['YES']; ?>   lang['NO']; ?>
lang['DEACTIVATE_DELETE']; ?>:
lang['DEACTIVATE_DELETE_EXPLAIN']; ?>
lang['DELETE_USERS']; ?>   lang['DEACTIVATE']; ?>
  ', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=650');return false;" />
- - \ No newline at end of file diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php new file mode 100644 index 0000000000..f7c3817c99 --- /dev/null +++ b/phpBB/includes/acp/acp_profile.php @@ -0,0 +1,1268 @@ +add_lang(array('ucp', 'acp/profile')); + $this->tpl_name = 'acp_profile'; + $this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS'; + + $action = (isset($_POST['create'])) ? 'create' : request_var('action', ''); + + $this->u_action = "{$phpbb_admin_path}index.$phpEx$SID&i=$id&mode=$mode"; + $error = array(); + $s_hidden_fields = ''; + + // Define some default values for each field type + $default_values = array( + FIELD_STRING => array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), + FIELD_TEXT => array('field_length' => '5|80', 'field_minlen' => 0, 'field_maxlen' => 1000, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), + 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' => 0, 'field_default_value' => 0), + ); + + $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_defs = array(); + + $sql = 'SELECT lang_id, lang_iso + FROM ' . LANG_TABLE; + $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']; + } + $db->sql_freeresult($result); + + $sql = 'SELECT field_id, lang_id + FROM ' . PROFILE_LANG_TABLE . ' + ORDER BY lang_id'; + $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); + } + } + + switch ($action) + { + case 'delete': + $field_id = request_var('field_id', 0); + + if (!$field_id) + { + trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action)); + } + + if (confirm_box(true)) + { + $sql = 'SELECT field_ident + FROM ' . PROFILE_FIELDS_TABLE . " + WHERE field_id = $field_id"; + $result = $db->sql_query($sql); + $field_ident = $db->sql_fetchfield('field_ident', 0, $result); + $db->sql_freeresult($result); + + $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id"); + $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id"); + $db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id"); + $db->sql_query('ALTER TABLE ' . PROFILE_DATA_TABLE . " DROP $field_ident"); + + $order = 0; + + $sql = 'SELECT * + FROM ' . PROFILE_FIELDS_TABLE . ' + ORDER BY field_order'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $order++; + if ($row['field_order'] != $order) + { + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " + SET field_order = $order + WHERE field_id = {$row['field_id']}"; + $db->sql_query($sql); + } + } + $db->sql_freeresult($result); + + add_log('admin', 'LOG_PROFILE_FIELD_REMOVED', $field_ident); + trigger_error($user->lang['REMOVED_PROFILE_FIELD'] . adm_back_link($this->u_action)); + } + else + { + confirm_box(false, 'DELETE_PROFILE_FIELD', build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'field_id' => $field_id, + ))); + } + + break; + + case 'activate': + $field_id = request_var('field_id', 0); + + if (!$field_id) + { + trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action)); + } + + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE . " + WHERE lang_iso = '{$config['default_lang']}'"; + $result = $db->sql_query($sql); + $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); + $db->sql_freeresult($result); + + if (!in_array($default_lang_id, $lang_defs['entry'][$field_id])) + { + trigger_error($user->lang['DEFAULT_LANGUAGE_NOT_FILLED'] . adm_back_link($this->u_action)); + } + + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " + SET field_active = 1 + WHERE field_id = $field_id"; + $db->sql_query($sql); + + $sql = 'SELECT field_ident + FROM ' . PROFILE_FIELDS_TABLE . " + WHERE field_id = $field_id"; + $result = $db->sql_query($sql); + $field_ident = $db->sql_fetchfield('field_ident', 0, $result); + $db->sql_freeresult($result); + + add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident); + trigger_error($user->lang['PROFILE_FIELD_ACTIVATED'] . adm_back_link($this->u_action)); + + break; + + case 'deactivate': + $field_id = request_var('field_id', 0); + + if (!$field_id) + { + trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action)); + } + + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " + SET field_active = 0 + WHERE field_id = $field_id"; + $db->sql_query($sql); + + $sql = 'SELECT field_ident + FROM ' . PROFILE_FIELDS_TABLE . " + WHERE field_id = $field_id"; + $result = $db->sql_query($sql); + $field_ident = $db->sql_fetchfield('field_ident', 0, $result); + $db->sql_freeresult($result); + + add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident); + trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action)); + + break; + + case 'move_up': + case 'move_down': + $field_order = request_var('order', 0); + $order_total = $field_order * 2 + (($action == 'move_up') ? -1 : 1); + + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " + SET field_order = $order_total - field_order + WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')'; + $db->sql_query($sql); + + break; + + case 'create': + case 'edit': + + $field_id = request_var('field_id', 0); + $step = request_var('step', 1); + + $submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; + $update = (isset($_REQUEST['update'])) ? true : false; + $save = (isset($_REQUEST['save'])) ? true : false; + + // We are editing... we need to grab basic things + if ($action == 'edit') + { + if (!$field_id) + { + trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action)); + } + + $sql = 'SELECT l.*, f.* + FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f + WHERE l.lang_id = ' . $lang_defs['iso'][$config['default_lang']] . " + AND f.field_id = $field_id + AND l.field_id = f.field_id"; + $result = $db->sql_query($sql); + $field_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$field_row) + { + trigger_error($user->lang['FIELD_NOT_FOUND'] . adm_back_link($this->u_action)); + } + $field_type = $field_row['field_type']; + + // Get language entries + $sql = 'SELECT * FROM ' . PROFILE_FIELDS_LANG_TABLE . ' + WHERE lang_id = ' . $lang_defs['iso'][$config['default_lang']] . " + AND field_id = $field_id + ORDER BY option_id ASC"; + $result = $db->sql_query($sql); + + $lang_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $lang_options[$row['option_id']] = $row['value']; + } + $db->sql_freeresult($result); + + $field_row['pf_preview'] = ''; + + $s_hidden_fields = ''; + } + else + { + // We are adding a new field, define basic params + $lang_options = $field_row = array(); + + $field_type = request_var('field_type', 0); + + if (!$field_type) + { + trigger_error($user->lang['NO_FIELD_TYPE'] . adm_back_link($this->u_action)); + } + + $field_row = array_merge($default_values[$field_type], array( + 'field_ident' => request_var('field_ident', ''), + 'field_required' => 0, + 'field_hide' => 0, + 'field_no_view' => 0, + 'field_show_on_reg' => 0, + 'lang_name' => '', + 'lang_explain' => '', + 'lang_default_value'=> '', + 'pf_preview' => '') + ); + + $s_hidden_fields = ''; + } + + // $exclude contains the data that 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'), + 3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options') + ); + + // 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'; + } + + // option-specific fields require lang_options to be excluded + if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN) + { + $exclude[1][] = 'lang_options'; + } + + $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 the user has submitted a form with options (i.e. dropdown field) + if ($options) + { + $exploded_options = explode("\n", $options); + + if (sizeof($exploded_options) == sizeof($lang_options) || $action == '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 if ($action == 'edit') + { + // Changing the number of options? (We remove and re-create the option fields) + $cp->vars['lang_options'] = explode("\n", $options); + } + } + else + { + $cp->vars['lang_options'] = $lang_options; + } + + // 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]); + } + + // 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', ''))); + } + + 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); + } + } + } + + $cp->vars[$key] = $var; + } + + // step 3 - all arrays + if ($action == 'edit') + { + // Get language entries + $sql = 'SELECT * FROM ' . PROFILE_FIELDS_LANG_TABLE . ' + WHERE lang_id <> ' . $lang_defs['iso'][$config['default_lang']] . " + AND field_id = $field_id + ORDER BY option_id ASC"; + $result = $db->sql_query($sql); + + $l_lang_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $l_lang_options[$row['lang_id']][$row['option_id']] = $row['value']; + } + $db->sql_freeresult($result); + + + $sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value FROM ' . PROFILE_LANG_TABLE . ' + WHERE lang_id <> ' . $lang_defs['iso'][$config['default_lang']] . " + AND field_id = $field_id + ORDER BY lang_id ASC"; + $result = $db->sql_query($sql); + + $l_lang_name = $l_lang_explain = $l_lang_default_value = array(); + while ($row = $db->sql_fetchrow($result)) + { + $l_lang_name[$row['lang_id']] = $row['lang_name']; + $l_lang_explain[$row['lang_id']] = $row['lang_explain']; + $l_lang_default_value[$row['lang_id']] = $row['lang_default_value']; + } + $db->sql_freeresult($result); + } + + foreach ($exclude[3] as $key) + { + $cp->vars[$key] = request_var($key, ''); + + if (!$cp->vars[$key] && $action == 'edit') + { + $cp->vars[$key] = $$key; + } + else if ($key == 'l_lang_options' && sizeof($cp->vars[$key]) > 1) + { + foreach ($cp->vars[$key] as $lang_id => $options) + { + $cp->vars[$key][$lang_id] = explode("\n", $options); + } + } + } + + if ($submit && $step == 1) + { + // Check values for step 1 + if ($cp->vars['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_IDENT']; + } + + if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN) + { + if (!sizeof($cp->vars['lang_options'])) + { + $error[] = $user->lang['NO_FIELD_ENTRIES']; + } + } + } + + $user_error = ''; + 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; + } + + $_new_key_ary = array(); + + foreach ($key_ary as $key) + { + $var = isset($_REQUEST[$key]) ? request_var($key, '') : false; + + if ($var !== false) + { + $_new_key_ary[$key] = $var; + } + } + + $s_hidden_fields .= build_hidden_fields($_new_key_ary); + } + + if (!sizeof($error)) + { + if ($step == 3 && (sizeof($lang_defs['iso']) == 1 || $save)) + { + $this->save_profile_field($cp, $field_type, $lang_defs, $action); + } + } + + $template->assign_vars(array( + 'S_EDIT' => true, + 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', + + 'L_TITLE' => $user->lang['STEP_' . $step . '_TITLE_' . strtoupper($action)], + 'L_EXPLAIN' => $user->lang['STEP_' . $step . '_EXPLAIN_' . strtoupper($action)], + + 'U_ACTION' => $this->u_action . "&action=$action&step=$step", + 'U_BACK' => $this->u_action) + ); + + // Now go through the steps + switch ($step) + { + // Create basic options - only small differences between field types + case 1: + + // Build common create options + $template->assign_vars(array( + 'S_STEP_ONE' => true, + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + + 'L_LANG_SPECIFIC' => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']), + 'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($cp->profile_types[$field_type])], + 'FIELD_IDENT' => $cp->vars['field_ident'], + 'LANG_NAME' => $cp->vars['lang_name'], + 'LANG_EXPLAIN' => $cp->vars['lang_explain']) + ); + + // String and Text needs to set default values here... + if ($field_type == FIELD_STRING || $field_type == FIELD_TEXT) + { + $template->assign_vars(array( + 'S_TEXT' => ($field_type == FIELD_TEXT) ? true : false, + 'S_STRING' => ($field_type == FIELD_STRING) ? true : false, + + 'L_DEFAULT_VALUE_EXPLAIN' => $user->lang[strtoupper($cp->profile_types[$field_type]) . '_DEFAULT_VALUE_EXPLAIN'], + 'LANG_DEFAULT_VALUE' => $cp->vars['lang_default_value']) + ); + } + + if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN) + { + // Initialize these array elements if we are creating a new field + if (!sizeof($cp->vars['lang_options'])) + { + 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(); + } + } + + $template->assign_vars(array( + 'S_BOOL' => ($field_type == FIELD_BOOL) ? true : false, + 'S_DROPDOWN' => ($field_type == FIELD_DROPDOWN) ? true : false, + + 'L_LANG_OPTIONS_EXPLAIN' => $user->lang[strtoupper($cp->profile_types[$field_type]) . '_ENTRIES_EXPLAIN'], + 'LANG_OPTIONS' => ($field_type == FIELD_DROPDOWN) ? implode("\n", $cp->vars['lang_options']) : '', + 'FIRST_LANG_OPTION' => ($field_type == FIELD_BOOL) ? $cp->vars['lang_options'][0] : '', + 'SECOND_LANG_OPTION' => ($field_type == FIELD_BOOL) ? $cp->vars['lang_options'][1] : '') + ); + } + + break; + + case 2: + + $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']) + ); + + // Build options based on profile type + $function = 'get_' . $cp->profile_types[$field_type] . '_options'; + $options = $cp->$function(); + + foreach ($options as $num => $option_ary) + { + $template->assign_block_vars('option', $option_ary); + } + + if ($user_error || $update) + { + // If not and only showing common error messages, use this one + switch ($user_error) + { + case 'FIELD_INVALID_DATE': + case 'FIELD_REQUIRED': + $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name']); + break; + + case 'FIELD_TOO_SHORT': + case 'FIELD_TOO_SMALL': + $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name'], $cp->vars['field_minlen']); + break; + + case 'FIELD_TOO_LONG': + case 'FIELD_TOO_LARGE': + $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name'], $cp->vars['field_maxlen']); + break; + + case 'FIELD_INVALID_CHARS': + switch ($cp->vars['field_validation']) + { + case '[0-9]+': + $user_error = sprintf($user->lang[$user_error . '_NUMBERS_ONLY'], $cp->vars['lang_name']); + break; + + case '[\w]+': + $user_error = sprintf($user->lang[$user_error . '_ALPHA_ONLY'], $cp->vars['lang_name']); + break; + + case '[\w_\+\. \-\[\]]+': + $user_error = sprintf($user->lang[$user_error . '_SPACERS_ONLY'], $cp->vars['lang_name']); + break; + } + break; + + default: + $user_error = ''; + } + + $template->assign_var('USER_ERROR', $user_error); + } + + $preview_field = $cp->process_field_row('preview', array( + 'lang_name' => $cp->vars['lang_name'], + 'lang_explain' => $cp->vars['lang_explain'], + 'lang_id' => $lang_defs['iso'][$config['default_lang']], + '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']) + ); + + $template->assign_vars(array( + 'PREVIEW_LANG_NAME' => $cp->vars['lang_name'], + 'PREVIEW_LANG_EXPLAIN' => $cp->vars['lang_explain'], + 'PREVIEW_FIELD' => $preview_field) + ); + + break; + + // Define remaining language variables + case 3: + + $template->assign_vars(array( + 'S_STEP_THREE' => true, + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + $options = $this->build_language_options($cp, $field_type, $action); + + foreach ($options as $lang_id => $lang_ary) + { + $template->assign_block_vars('options', array( + 'LANGUAGE' => ($lang_ary['lang_iso'] == $config['default_lang']) ? sprintf($user->lang['DEFAULT_ISO_LANGUAGE'], $config['default_lang']) : sprintf($user->lang['ISO_LANGUAGE'], $lang_ary['lang_iso'])) + ); + + foreach ($lang_ary['fields'] as $field_ident => $field_ary) + { + $template->assign_block_vars('options.field', array( + 'L_TITLE' => $field_ary['TITLE'], + 'L_EXPLAIN' => (isset($field_ary['EXPLAIN'])) ? $field_ary['EXPLAIN'] : '', + 'FIELD' => $field_ary['FIELD']) + ); + } + } + + break; + } + + return; + + break; + } + + $sql = 'SELECT * + FROM ' . PROFILE_FIELDS_TABLE . ' + ORDER BY field_order'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $active_lang = (!$row['field_active']) ? 'ACTIVATE' : 'DEACTIVATE'; + $active_value = (!$row['field_active']) ? 'activate' : 'deactivate'; + $id = $row['field_id']; + + $template->assign_block_vars('fields', array( + 'FIELD_IDENT' => $row['field_ident'], + 'FIELD_TYPE' => $user->lang['FIELD_' . strtoupper($cp->profile_types[$row['field_type']])], + + 'L_ACTIVATE_DEACTIVATE' => $user->lang[$active_lang], + 'U_ACTIVATE_DEACTIVATE' => $this->u_action . "&action=$active_value&field_id=$id", + 'U_EDIT' => $this->u_action . "&action=edit&field_id=$id", + 'U_DELETE' => $this->u_action . "&action=delete&field_id=$id", + 'U_MOVE_UP' => $this->u_action . "&action=move_up&order={$row['field_order']}", + 'U_MOVE_DOWN' => $this->u_action . "&action=move_down&order={$row['field_order']}", + + 'S_NEED_EDIT' => (sizeof($lang_defs['diff'][$row['field_id']])) ? true : false) + ); + } + $db->sql_freeresult($result); + + $s_select_type = ''; + foreach ($cp->profile_types as $key => $value) + { + $s_select_type .= ''; + } + + $template->assign_vars(array( + 'U_ACTION' => $this->u_action, + 'S_TYPE_OPTIONS' => $s_select_type) + ); + } + + /** + * Build all Language specific options + */ + function build_language_options(&$cp, $field_type, $action = 'create') + { + global $user, $config, $db; + + $sql = 'SELECT lang_id, lang_iso + FROM ' . LANG_TABLE . " + WHERE lang_iso <> '" . $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 ($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 ($cp->vars['lang_default_value']) + { + $options['lang_default_value'] = ($field_type == FIELD_STRING) ? 'string' : 'text'; + } + break; + } + + $lang_options = array(); + + foreach ($options as $field => $field_type) + { + $lang_options[1]['lang_iso'] = $config['default_lang']; + $lang_options[1]['fields'][$field] = array( + 'TITLE' => $user->lang['CP_' . strtoupper($field)], + 'FIELD' => '
' . ((is_array($cp->vars[$field])) ? implode('
', $cp->vars[$field]) : str_replace("\n", '
', $cp->vars[$field])) . '
' + ); + + if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) + { + $lang_options[1]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN']; + } + } + + foreach ($languages as $lang_id => $lang_iso) + { + $lang_options[$lang_id]['lang_iso'] = $lang_iso; + foreach ($options as $field => $field_type) + { + $value = ($action == 'create') ? request_var('l_' . $field, '') : $cp->vars['l_' . $field]; + + if ($field == 'lang_options') + { + + $var = ($action == 'create' || !is_array($cp->vars['lang_options'][$lang_id])) ? $cp->vars['lang_options'] : $cp->vars['lang_options'][$lang_id]; + + switch ($field_type) + { + case 'two_options': + + $lang_options[$lang_id]['fields'][$field] = array( + 'TITLE' => $user->lang['CP_' . strtoupper($field)], + 'FIELD' => ' +
' . $user->lang['FIRST_OPTION'] . '
+
' . $user->lang['SECOND_OPTION'] . '
' + ); + break; + + case 'optionfield': + + $lang_options[$lang_id]['fields'][$field] = array( + 'TITLE' => $user->lang['CP_' . strtoupper($field)], + 'FIELD' => '
' + ); + break; + } + + if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) + { + $lang_options[$lang_id]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN']; + } + } + else + { + $var = ($action == 'create' || !is_array($cp->vars[$field])) ? $cp->vars[$field] : $cp->vars[$field][$lang_id]; + + $lang_options[$lang_id]['fields'][$field] = array( + 'TITLE' => $user->lang['CP_' . strtoupper($field)], + 'FIELD' => ($field_type == 'string') ? '
' : '
' + ); + + if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN'])) + { + $lang_options[$lang_id]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN']; + } + } + } + } + + return $lang_options; + } + + /** + * Save Profile Field + */ + function save_profile_field(&$cp, $field_type, &$lang_defs, $action = 'create') + { + global $db, $config, $user; + + $field_id = request_var('field_id', 0); + + // Collect all informations, if something is going wrong, abort the operation + $profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array(); + + $default_lang_id = $lang_defs['iso'][$config['default_lang']]; + + if ($action == 'create') + { + $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE); + $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result); + $db->sql_freeresult($result); + + $field_ident = $cp->vars['field_ident']; + } + + // Save the field + $profile_fields = array( + '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_no_view' => $cp->vars['field_no_view'] + ); + + if ($action == 'create') + { + $profile_fields += array( + 'field_type' => $field_type, + 'field_ident' => $field_ident, + 'field_order' => $new_field_order + 1, + 'field_active' => 1 + ); + + $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields)); + + $field_id = $db->sql_nextid(); + } + else + { + $db->sql_query('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $profile_fields) . " + WHERE field_id = $field_id"); + } + + if ($action == 'create') + { + // We are defining the biggest common value, because of the possibility to edit the min/max values of each field. + $sql = 'ALTER TABLE ' . PROFILE_DATA_TABLE . " 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, + ADD {$field_ident}_bbcode_uid VARCHAR(5) NOT NULL, + ADD {$field_ident}_bbcode_bitfield INT(11) UNSIGNED"; + 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 .= 'BIGINT(20) DEFAULT NULL NULL'; + break; + } + + $profile_sql[] = $sql; + } + + $sql_ary = array( + 'lang_name' => $cp->vars['lang_name'], + 'lang_explain' => $cp->vars['lang_explain'], + 'lang_default_value' => $cp->vars['lang_default_value'] + ); + + if ($action == 'create') + { + $sql_ary['field_id'] = $field_id; + $sql_ary['lang_id'] = $default_lang_id; + + $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + } + else + { + $this->update_insert(PROFILE_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => $default_lang_id)); + } + + if (is_array($cp->vars['l_lang_name']) && 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' => (isset($cp->vars['l_lang_explain'][$lang_id])) ? $cp->vars['l_lang_explain'][$lang_id] : '', + 'lang_default_value' => (isset($cp->vars['l_lang_default_value'][$lang_id])) ? $cp->vars['l_lang_default_value'][$lang_id] : '' + ); + } + } + + foreach ($empty_lang as $lang_id => $NULL) + { + $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . " + WHERE field_id = $field_id + AND lang_id = " . (int) $lang_id; + $db->sql_query($sql); + } + } + + $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 ($cp->vars['lang_options']) + { + if (!is_array($cp->vars['lang_options'])) + { + $cp->vars['lang_options'] = explode("\n", $cp->vars['lang_options']); + } + + if ($action != 'create') + { + $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " + WHERE field_id = $field_id + AND lang_id = " . (int) $default_lang_id; + $db->sql_query($sql); + } + + foreach ($cp->vars['lang_options'] as $option_id => $value) + { + $sql_ary = array( + 'field_type' => (int) $field_type, + 'value' => $value + ); + + if ($action == 'create') + { + $sql_ary['field_id'] = $field_id; + $sql_ary['lang_id'] = $default_lang_id; + $sql_ary['option_id'] = (int) $option_id; + + $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); + } + else + { + $this->update_insert(PROFILE_FIELDS_LANG_TABLE, $sql_ary, array( + 'field_id' => $field_id, + 'lang_id' => (int) $default_lang_id, + 'option_id' => (int) $option_id) + ); + } + } + } + + if (is_array($cp->vars['l_lang_options']) && sizeof($cp->vars['l_lang_options'])) + { + $empty_lang = array(); + + 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])) + { + if ($action != 'create') + { + $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " + WHERE field_id = $field_id + AND lang_id = " . (int) $lang_id; + $db->sql_query($sql); + } + + foreach ($lang_ary as $option_id => $value) + { + $profile_lang_fields[] = array( + 'field_id' => (int) $field_id, + 'lang_id' => (int) $lang_id, + 'option_id' => (int) $option_id, + 'field_type' => (int) $field_type, + 'value' => $value + ); + } + } + } + + foreach ($empty_lang as $lang_id => $NULL) + { + $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " + WHERE field_id = $field_id + AND lang_id = " . (int) $lang_id; + $db->sql_query($sql); + } + } + + foreach ($profile_lang as $sql) + { + if ($action == 'create') + { + $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); + } + else + { + $lang_id = $sql['lang_id']; + unset($sql['lang_id'], $sql['field_id']); + + $this->update_insert(PROFILE_LANG_TABLE, $sql, array('lang_id' => (int) $lang_id, 'field_id' => $field_id)); + } + } + + if (sizeof($profile_lang_fields)) + { + foreach ($profile_lang_fields as $sql) + { + if ($action == 'create') + { + $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql); + } + else + { + $lang_id = $sql['lang_id']; + $option_id = $sql['option_id']; + unset($sql['lang_id'], $sql['field_id'], $sql['option_id']); + + $this->update_insert(PROFILE_FIELDS_LANG_TABLE, $sql, array( + 'lang_id' => $lang_id, + 'field_id' => $field_id, + 'option_id' => $option_id) + ); + } + } + } + + $db->sql_transaction(); + + if ($action == 'create') + { + foreach ($profile_sql as $sql) + { + $db->sql_query($sql); + } + } + + $db->sql_transaction('commit'); + + if ($action == 'edit') + { + add_log('admin', 'LOG_PROFILE_FIELD_EDIT', $cp->vars['field_ident'] . ':' . $cp->vars['lang_name']); + trigger_error($user->lang['CHANGED_PROFILE_FIELD'] . adm_back_link($this->u_action)); + } + else + { + add_log('admin', 'LOG_PROFILE_FIELD_CREATE', $field_ident . ':' . $cp->vars['lang_name']); + trigger_error($user->lang['ADDED_PROFILE_FIELD'] . adm_back_link($this->u_action)); + } + } + + /** + * Update, then insert if not successfull + */ + function update_insert($table, $sql_ary, $where_fields) + { + global $db; + + $where_sql = array(); + $check_key = ''; + + foreach ($where_fields as $key => $value) + { + $check_key = (!$check_key) ? $key : $check_key; + $where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : (int) $value); + } + + $sql = "SELECT $check_key + FROM $table + WHERE " . implode(' AND ', $where_sql); + $result = $db->sql_query($sql); + + if (!$db->sql_fetchrow($result)) + { + $db->sql_freeresult($result); + + $sql_ary = array_merge($where_fields, $sql_ary); + $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary)); + } + else + { + $db->sql_freeresult($result); + + $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE ' . implode(' AND ', $where_sql); + $db->sql_query($sql); + } + } +} + +/** +* @package module_install +*/ +class acp_profile_info +{ + function module() + { + return array( + 'filename' => 'acp_profile', + 'title' => 'ACP_CUSTOM_PROFILE_FIELDS', + 'version' => '1.0.0', + 'modes' => array( + 'profile' => array('title' => 'ACP_CUSTOM_PROFILE_FIELDS', 'auth' => 'acl_a_user'), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php new file mode 100644 index 0000000000..532380aa66 --- /dev/null +++ b/phpBB/includes/acp/acp_prune.php @@ -0,0 +1,409 @@ +add_lang('acp/prune'); + + $this->u_action = "{$phpbb_admin_path}index.$phpEx$SID&i=$id&mode=$mode"; + + switch ($mode) + { + case 'forums': + $this->tpl_name = 'acp_prune_forums'; + $this->page_header = 'ACP_PRUNE_FORUMS'; + $this->prune_forums($id, $mode); + break; + + case 'users': + $this->tpl_name = 'acp_prune_users'; + $this->page_header = 'ACP_PRUNE_USERS'; + $this->prune_users($id, $mode); + break; + } + } + + /** + * Prune forums + */ + function prune_forums($id, $mode) + { + global $db, $user, $auth, $template, $cache; + global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx; + + $forum_id = request_var('f', array(0)); + $submit = (isset($_POST['submit'])) ? true : false; + + if ($submit) + { + $prune_posted = request_var('prune_days', 0); + $prune_viewed = request_var('prune_vieweddays', 0); + $prune_all = !$prune_posted && !$prune_viewed; + + $prune_flags = 0; + $prune_flags += (request_var('prune_old_polls', 0)) ? 2 : 0; + $prune_flags += (request_var('prune_announce', 0)) ? 4 : 0; + $prune_flags += (request_var('prune_sticky', 0)) ? 8 : 0; + + // Convert days to seconds for timestamp functions... + $prunedate_posted = time() - ($prune_posted * 86400); + $prunedate_viewed = time() - ($prune_viewed * 86400); + + $template->assign_vars(array( + 'S_PRUNED' => true) + ); + + $sql_forum = (sizeof($forum_id)) ? ' AND forum_id IN (' . implode(', ', $forum_id) . ')' : ''; + + // Get a list of forum's or the data for the forum that we are pruning. + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_type = ' . FORUM_POST . " + $sql_forum + ORDER BY left_id ASC"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + $prune_ids = array(); + $p_result['topics'] = 0; + $p_result['posts'] = 0; + $log_data = ''; + + do + { + if (!$auth->acl_get('f_list', $row['forum_id'])) + { + continue; + } + + if ($prune_all) + { + $p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false); + } + else + { + if ($prune_posted) + { + $return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false); + $p_result['topics'] += $return['topics']; + $p_result['posts'] += $return['posts']; + } + + if ($prune_viewed) + { + $return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false); + $p_result['topics'] += $return['topics']; + $p_result['posts'] += $return['posts']; + } + } + + $prune_ids[] = $row['forum_id']; + + $template->assign_block_vars('pruned', array( + 'FORUM_NAME' => $row['forum_name'], + 'NUM_TOPICS' => $p_result['topics'], + 'NUM_POSTS' => $p_result['posts']) + ); + + $log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name']; + } + while ($row = $db->sql_fetchrow($result)); + + // Sync all pruned forums at once + sync('forum', 'forum_id', $prune_ids, true); + add_log('admin', 'LOG_PRUNE', $log_data); + } + $db->sql_freeresult($result); + + return; + } + + // If they haven't selected a forum for pruning yet then + // display a select box to use for pruning. + if (!sizeof($forum_id)) + { + $template->assign_vars(array( + 'U_ACTION' => $this->u_action, + 'S_SELECT_FORUM' => true, + 'S_FORUM_OPTIONS' => make_forum_select(false, false, false)) + ); + } + else + { + $sql = 'SELECT forum_id, forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id IN (' . implode(', ', $forum_id) . ')'; + $result = $db->sql_query($sql); + + if (!($row = $db->sql_fetchrow($result))) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action)); + } + + $forum_list = $s_hidden_fields = ''; + do + { + $forum_list .= (($forum_list != '') ? ', ' : '') . '' . $row['forum_name'] . ''; + $s_hidden_fields .= ''; + } + while ($row = $db->sql_fetchrow($result)); + + $db->sql_freeresult($result); + + $l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS'; + + $template->assign_vars(array( + 'L_SELECTED_FORUMS' => $user->lang[$l_selected_forums], + 'U_ACTION' => $this->u_action, + 'U_BACK' => $this->u_action, + 'FORUM_LIST' => $forum_list, + 'S_HIDDEN_FIELDS' => $s_hidden_fields) + ); + + } + + } + + /** + * Prune users + */ + function prune_users($id, $mode) + { + global $db, $user, $auth, $template, $cache; + global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx; + + $user->add_lang('memberlist'); + + $prune = (isset($_POST['prune'])) ? true : false; + + if ($prune) + { + if (confirm_box(true)) + { + $users = request_var('users', ''); + $action = request_var('action', 'deactivate'); + $deleteposts = request_var('deleteposts', 0); + + if ($users) + { + $users = explode("\n", $users); + + $where_sql = ''; + + foreach ($users as $username) + { + $where_sql .= (($where_sql != '') ? ', ' : '') . "'" . $db->sql_escape($username) . "'"; + } + $where_sql = " AND username IN ($where_sql)"; + } + else + { + $username = request_var('username', ''); + $email = request_var('email', ''); + + $joined_select = request_var('joined_select', 'lt'); + $active_select = request_var('active_select', 'lt'); + $count_select = request_var('count_select', 'eq'); + $joined = request_var('joined', ''); + $active = request_var('active', ''); + + $active = ($active) ? explode('-', $active) : array(); + $joined = ($joined) ? explode('-', $joined) : array(); + + $count = request_var('count', 0); + + $key_match = array('lt' => '<', 'gt' => '>', 'eq' => '='); + $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit'); + + $where_sql = ''; + $where_sql .= ($username) ? " AND username LIKE '" . $db->sql_escape(str_replace('*', '%', $username)) . "'" : ''; + $where_sql .= ($email) ? " AND user_email LIKE '" . $db->sql_escape(str_replace('*', '%', $email)) . "' " : ''; + $where_sql .= (sizeof($joined)) ? " AND user_regdate " . $key_match[$joined_select] . ' ' . gmmktime(0, 0, 0, (int) $joined[1], (int) $joined[2], (int) $joined[0]) : ''; + $where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . " $count " : ''; + $where_sql .= (sizeof($active)) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) : ''; + } + + // Get bot ids + $sql = 'SELECT user_id + FROM ' . BOTS_TABLE; + $result = $db->sql_query($sql); + + $bot_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $bot_ids[] = $row['user_id']; + } + $db->sql_freeresult($result); + + $sql = 'SELECT username, user_id FROM ' . USERS_TABLE . ' + WHERE user_id <> ' . ANONYMOUS . " + $where_sql"; + $result = $db->sql_query($sql); + + $where_sql = ''; + $user_ids = $usernames = array(); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + if (!in_array($row['user_id'], $bot_ids)) + { + $where_sql .= (($where_sql != '') ? ', ' : '') . $row['user_id']; + $user_ids[] = $row['user_id']; + $usernames[] = $row['username']; + } + } + while ($row = $db->sql_fetchrow($result)); + + if ($where_sql) + { + $where_sql = " AND user_id IN ($where_sql)"; + } + } + $db->sql_freeresult($result); + + if ($where_sql) + { + $sql = ''; + + if ($action == 'delete') + { + if ($deleteposts) + { + delete_posts('poster_id', $user_ids, true); + $l_log = 'LOG_PRUNE_USER_DEL_DEL'; + } + else + { + for ($i = 0, $size = sizeof($user_ids); $i < $size; $i++) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET poster_id = ' . ANONYMOUS . ", post_username = '" . $db->sql_escape($usernames[$i]) . "' + WHERE user_id = " . $userids[$i]; + $db->sql_query($sql); + } + + $l_log = 'LOG_PRUNE_USER_DEL_ANON'; + } + + $sql = 'DELETE FROM ' . USERS_TABLE; + } + else if ($action == 'deactivate') + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_active = 0"; + + $l_log = 'LOG_PRUNE_USER_DEAC'; + } + + $sql .= ' WHERE user_id <> ' . ANONYMOUS . " + $where_sql"; + $db->sql_query($sql); + + add_log('admin', $l_log, implode(', ', $usernames)); + } + + trigger_error($user->lang['USER_' . strtoupper($action) . '_SUCCESS'] . adm_back_link($this->u_action)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'i' => $id, + 'mode' => $mode, + 'prune' => 1, + + 'users' => request_var('users', ''), + 'username' => request_var('username', ''), + 'email' => request_var('email', ''), + 'joined_select' => request_var('joined_select', ''), + 'joined' => request_var('joined', ''), + 'active_select' => request_var('active_select', ''), + 'active' => request_var('active', ''), + 'count_select' => request_var('count_select', ''), + 'count' => request_var('count', 0), + 'deleteposts' => request_var('deleteposts', 0), + + 'action' => request_var('action', ''), + ))); + } + } + + $find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']); + $s_find_count = ''; + + foreach ($find_count as $key => $value) + { + $selected = ($key == 'eq') ? ' selected="selected"' : ''; + $s_find_count .= ''; + } + + $find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']); + $s_find_join_time = ''; + foreach ($find_time as $key => $value) + { + $s_find_join_time .= ''; + } + + $s_find_active_time = ''; + foreach ($find_time as $key => $value) + { + $s_find_active_time .= ''; + } + + $template->assign_vars(array( + 'U_ACTION' => $this->u_action, + 'S_JOINED_OPTIONS' => $s_find_join_time, + 'S_ACTIVE_OPTIONS' => $s_find_active_time, + 'S_COUNT_OPTIONS' => $s_find_count, + 'U_FIND_USER' => $phpbb_root_path . "memberlist.$phpEx$SID&mode=searchuser&form=acp_prune&field=users") + ); + + } +} + +/** +* @package module_install +*/ +class acp_prune_info +{ + function module() + { + return array( + 'filename' => 'acp_prune', + 'title' => 'ACP_PRUNING', + 'version' => '1.0.0', + 'modes' => array( + 'forums' => array('title' => 'ACP_PRUNE_FORUMS', 'auth' => 'acl_a_prune'), + 'users' => array('title' => 'ACP_PRUNE_USERS', 'auth' => 'acl_a_userdel'), + ), + ); + } + + function install() + { + } + + function uninstall() + { + } +} + +?> \ No newline at end of file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 431e4c7731..b90a4ca317 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1050,6 +1050,14 @@ function meta_refresh($time, $url) /** * Build Confirm box +* @param boolean $check True for checking if confirmed (without any additional parameters) and false for displaying the confirm box +* @param string $title Title/Message used for confirm box. +* message text is _CONFIRM appended to title. +* If title can not be found in user->lang a default one is displayed +* If title_CONFIRM can not be found in user->lang the text given is used. +* @param string $hidden Hidden variables +* @param string $html_body Template used for confirm box +* @param string $u_action Custom form action */ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '') { diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index cc39ecbdda..967f76d40e 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -1501,6 +1501,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync { $sql_and .= ' AND topic_type <> ' . POST_ANNOUNCE; } + if (!($prune_flags & 8)) { $sql_and .= ' AND topic_type <> ' . POST_STICKY; @@ -1510,6 +1511,7 @@ function prune($forum_id, $prune_mode, $prune_date, $prune_flags = 0, $auto_sync { $sql_and .= " AND topic_last_post_time < $prune_date"; } + if ($prune_mode == 'viewed') { $sql_and .= " AND topic_last_view_time < $prune_date"; diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 5c5f7e30e2..ae7e2d47f7 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -145,7 +145,9 @@ class p_master $right = $row['right_id']; - $url_func = $row['module_name'] . '_' . $row['module_mode'] . '_url'; + // We need to prefix the functions to not create a naming conflict + $url_func = '_module_' . $row['module_name'] . '_' . $row['module_mode'] . '_url'; + $lang_func = '_module_' . $row['module_name']; $this->module_ary[$i] = array( 'depth' => $depth, @@ -160,7 +162,7 @@ class p_master 'url_extra' => (function_exists($url_func)) ? $url_func() : '', - 'lang' => (function_exists($row['module_name'])) ? $row['module_name']($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), + 'lang' => ($row['module_name'] && function_exists($lang_func)) ? $lang_func($row['module_mode'], $row['module_langname']) : ((!empty($user->lang[$row['module_langname']])) ? $user->lang[$row['module_langname']] : $row['module_langname']), 'langname' => $row['module_langname'], 'left' => $row['left_id'], diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 1ba203bcd6..606976c99b 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -303,9 +303,9 @@ class custom_profile case FIELD_DATE: $field_validate = explode('-', $field_value); - $day = (int) $field_validate[0]; - $month = (int) $field_validate[1]; - $year = (int) $field_validate[2]; + $day = (isset($field_validate[0])) ? (int) $field_validate[0] : 0; + $month = (isset($field_validate[1])) ? (int) $field_validate[1] : 0; + $year = (isset($field_validate[2])) ? (int) $field_validate[2] : 0; if ((!$day || !$month || !$year) && !$field_data['field_required']) { @@ -587,7 +587,7 @@ class custom_profile $value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview); - if (!isset($this->options_lang[$profile_row['field_id']]) || !sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']])) + 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); } @@ -774,9 +774,9 @@ class custom_profile_admin extends custom_profile 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' => ''), + 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' => '') ); @@ -788,9 +788,9 @@ class custom_profile_admin extends custom_profile 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' => ''), + 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' => '') ); @@ -802,10 +802,10 @@ class custom_profile_admin extends custom_profile 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; @@ -888,7 +888,7 @@ class custom_profile_admin extends custom_profile ); $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->generate_date($profile_row, true) . '
vars['field_default_value'] == 'now') ? ' checked="checked"' : '') . ' />  ' . $user->lang['ALWAYS_TODAY']) ); return $options; diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index cad88b9c25..fdd3402ca0 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -59,6 +59,7 @@ $lang += array( 'ACP_CLIENT_COMMUNICATION' => 'Client Communication', 'ACP_COOKIE_SETTINGS' => 'Cookie Settings', 'ACP_CRITICAL_LOGS' => 'Error Log', + 'ACP_CUSTOM_PROFILE_FIELDS' => 'Custom Profile Fields', 'ACP_DISALLOW' => 'Disallow', 'ACP_DISALLOW_USERNAMES' => 'Disallow Usernames', 'ACP_EMAIL_SETTINGS' => 'Email Settings', @@ -88,6 +89,9 @@ $lang += array( 'ACP_ORPHAN_ATTACHMENTS' => 'Orphan Attachments', 'ACP_PERMISSION_SETTINGS' => 'Permission Settings', 'ACP_PHP_INFO' => 'PHP Information', + 'ACP_PRUNE_FORUMS' => 'Prune Forums', + 'ACP_PRUNE_USERS' => 'Prune Users', + 'ACP_PRUNING' => 'Pruning', 'ACP_RANKS' => 'Ranks', 'ACP_SERVER_CONFIGURATION' => 'Server Configuration', 'ACP_SERVER_SETTINGS' => 'Server Settings', @@ -132,6 +136,7 @@ $lang += array( 'LOGIN_ADMIN' => 'To administer the board you must be an authenticated user.', 'LOGIN_ADMIN_CONFIRM' => 'To administer the board you must re-authenticate yourself.', 'LOGIN_ADMIN_SUCCESS' => 'You have successfully authenticated and will now be redirected to the Administration Control Panel', + 'LOOK_UP_FORUM' => 'Select a Forum', 'MANAGE' => 'Manage', 'MOVE_DOWN' => 'Move Down', @@ -154,6 +159,8 @@ $lang += array( 'UCP' => 'User Control Panel', 'USERNAMES_EXPLAIN' => 'Place each username on a seperate line', 'USER_CONTROL_PANEL' => 'User Control Panel', + + 'WARNING' => 'Warning', ); // PHP info @@ -309,6 +316,18 @@ $lang += array( 'LOG_MODULE_ADD' => 'Module added
» %s', 'LOG_MODULE_EDIT' => 'Module edited
» %s', + 'LOG_PROFILE_FIELD_ACTIVATE' => 'Profile field activated
» %s', + 'LOG_PROFILE_FIELD_CREATE' => 'Profile field added
» %s', + 'LOG_PROFILE_FIELD_DEACTIVATE' => 'Profile field deactivated
» %s', + 'LOG_PROFILE_FIELD_EDIT' => 'Profile field changed
» %s', + 'LOG_PROFILE_FIELD_REMOVED' => 'Profile field removed
» %s', + + 'LOG_PRUNE' => 'Pruned forums
» %s', + 'LOG_AUTO_PRUNE' => 'Auto-pruned forums
» %s', + 'LOG_PRUNE_USER_DEAC' => 'Users deactivated
» %s', + 'LOG_PRUNE_USER_DEL_DEL' => 'Users pruned and posts deleted
» %s', + 'LOG_PRUNE_USER_DEL_ANON' => 'Users pruned and posts retained
» %s', + 'LOG_RESET_DATE' => 'Board start date reset', 'LOG_RESET_ONLINE' => 'Most users online reset', 'LOG_RESYNC_POSTCOUNTS' => 'User postcounts synced', diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php new file mode 100644 index 0000000000..67b26e080f --- /dev/null +++ b/phpBB/language/en/acp/profile.php @@ -0,0 +1,138 @@ + 'Successfully added custom profile field', + 'ALPHA_ONLY' => 'Alphanumeric only', + 'ALPHA_SPACERS' => 'Alphanumeric and spacers', + 'ALWAYS_TODAY' => 'Always the current date', + + 'BOOL_ENTRIES_EXPLAIN' => 'Enter your options now', + 'BOOL_TYPE_EXPLAIN' => 'Define the Type, either a checkbox or radio buttons', + + 'CHANGED_PROFILE_FIELD' => 'Successfully changed profile field', + 'CHARS_ANY' => 'Any character', + 'CHECKBOX' => 'Checkbox', + 'CP_LANG_DEFAULT_VALUE' => 'Default Value', + 'CP_LANG_EXPLAIN' => 'Field Description', + 'CP_LANG_EXPLAIN_EXPLAIN' => 'The Explanation for this field presented to the user', + 'CP_LANG_NAME' => 'Field Name presented to the user', + 'CP_LANG_OPTIONS' => 'Options', + 'CREATE_NEW_FIELD' => 'Create New Field', + 'COLUMNS' => 'Columns', + + 'DEFAULT_ISO_LANGUAGE' => 'Default Language [%s]', + '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', + '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', + 'FIELD_DESCRIPTION' => 'Field Description', + 'FIELD_DESCRIPTION_EXPLAIN' => 'The Explanation for this field presented to the user', + 'FIELD_DROPDOWN' => 'Dropdown Box', + 'FIELD_IDENT' => 'Field Name', + 'FIELD_IDENT_EXPLAIN' => 'The Field Name is a name for you to identify the profile field, it is not displayed to the user.', + 'FIELD_INT' => 'Numbers', + 'FIELD_LENGTH' => 'Length of input box', + 'FIELD_NOT_FOUND' => 'Profile field not found', + 'FIELD_STRING' => 'Single Textfield', + 'FIELD_TEXT' => 'Textarea', + 'FIELD_TYPE' => 'Field Type', + 'FIELD_TYPE_EXPLAIN' => 'You are not able to change the field type later.', + 'FIELD_VALIDATION' => 'Field Validation', + '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', + + 'INVALID_CHARS_FIELD_IDENT' => 'Field name can only contain lowercase a-z and _', + 'ISO_LANGUAGE' => 'Language [%s]', + + 'LANG_SPECIFIC_OPTIONS' => 'Language specific options [%s]', + + 'MAX_FIELD_CHARS' => 'Maximum number of characters', + 'MAX_FIELD_NUMBER' => 'Highest allowed number', + 'MIN_FIELD_CHARS' => 'Minimum number of characters', + 'MIN_FIELD_NUMBER' => 'Lowest allowed number', + + 'NO_FIELD_ENTRIES' => 'No Entries defined', + 'NO_FIELD_ID' => 'No field id specified', + 'NO_FIELD_TYPE' => 'No Field type specified', + 'NO_VALUE_OPTION' => 'Option equal to non entered value', + 'NO_VALUE_OPTION_EXPLAIN' => 'Value for a non-entry. If the field is required, the user gets an error if he choose the option selected here', + 'NUMBERS_ONLY' => 'Only numbers (0-9)', + + 'PREVIEW_PROFILE_FIELD' => 'Preview Profile Field', + 'PROFILE_BASIC_OPTIONS' => 'Basic Options', + 'PROFILE_FIELD_ACTIVATED' => 'Profile field successfully activated', + 'PROFILE_FIELD_DEACTIVATED' => 'Profile field successfully deactivated', + 'PROFILE_LANG_OPTIONS' => 'Language specific options', + 'PROFILE_TYPE_OPTIONS' => 'Profile type specific options', + + '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', + 'ROWS' => 'Rows', + + 'SAVE' => 'Save', + 'SECOND_OPTION' => 'Second Option', + 'STEP_1_EXPLAIN_CREATE' => 'Here you can enter the first basic parameters of your new profile field. These informations are needed for the second step where you are able to set remaining options and where you are able to preview and tweak your profile field further.', + 'STEP_1_EXPLAIN_EDIT' => 'Here you can change the basic parameters of your profile field. The relevant options are re-calculated within the second step, where you are able to preview and test the changed settings.', + 'STEP_1_TITLE_CREATE' => 'Add Profile Field', + 'STEP_1_TITLE_EDIT' => 'Edit Profile Field', + 'STEP_2_EXPLAIN_CREATE' => 'Here you are able to define some common options. Further you are able to preview the field you generated, as the user will see it. Play around with it until you are satisfied as how the field behaves.', + 'STEP_2_EXPLAIN_EDIT' => 'Here you are able to change some common options. Further you are able to preview the changed field, as the user will see it. Play around with it until you are satisfied as how the field behaves.
Please note that changes to profile fields will not affect existing profile fields entered by your users.', + 'STEP_2_TITLE_CREATE' => 'Profile type specific options', + 'STEP_2_TITLE_EDIT' => 'Profile type specific options', + 'STEP_3_EXPLAIN_CREATE' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. The profile field will work with the default language enabled, you are able to fill out the remaining language items later too.', + 'STEP_3_EXPLAIN_EDIT' => 'Since you have more than one board language installed, you now can change or add the remaining language items too. The profile field will work with the default language enabled.', + 'STEP_3_TITLE_CREATE' => 'Remaining Language Definitions', + 'STEP_3_TITLE_EDIT' => 'Language Definitions', + '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.', + + 'UPDATE_PREVIEW' => 'Update Preview', + 'USER_FIELD_NAME' => 'Field Name presented to the user', +); + +?> \ No newline at end of file diff --git a/phpBB/language/en/acp/prune.php b/phpBB/language/en/acp/prune.php new file mode 100644 index 0000000000..38ad6b75c6 --- /dev/null +++ b/phpBB/language/en/acp/prune.php @@ -0,0 +1,77 @@ + 'Here you can delete (or deactivate) users from you board. This can be done in a variety of ways; by post count, last activity, etc. Each of these criteria can be combined, i.e. you can prune users last active before 2002-01-01 with fewer than 10 posts. Alternatively you can enter a list of users directly into the text box, any criteria entered will be ignored. Take care with this facility! Once a user is deleted there is no way back.', + + 'DEACTIVATE' => 'Deactivate', + 'DEACTIVATE_DELETE' => 'Deactivate or delete', + 'DEACTIVATE_DELETE_EXPLAIN' => 'Choose whether to deactivate users or delete them entirely, note there is no undo!', + 'DELETE_USERS' => 'Delete', + 'DELETE_USER_POSTS' => 'Delete pruned user posts', + 'DELETE_USER_POSTS_EXPLAIN' => 'Removes posts made by deleted users, has no effect if users are deactivated.', + + 'JOINED_EXPLAIN' => 'Enter a date in YYYY-MM-DD format.', + + 'LAST_ACTIVE_EXPLAIN' => 'Enter a date in YYYY-MM-DD format.', + + 'SELECT_USERS_EXPLAIN' => 'Enter specific usernames here, they will be used in preference to the criteria above.', + + 'USER_DEACTIVATE_SUCCESS' => 'The selected users have been deactivated successfully', + 'USER_DELETE_SUCCESS' => 'The selected users have been deleted successfully', +); + +// Forum Pruning +$lang += array( + 'ACP_PRUNE_FORUMS_EXPLAIN' => 'This will delete any topic which has not been posted to within the number of days you select. If you do not enter a number then all topics will be deleted. It will not remove topics in which polls are still running nor will it remove announcements. You will need to remove these topics manually.', + + 'FORUM_PRUNE' => 'Forum Prune', + + 'NO_PRUNE' => 'No forums pruned', + + 'SELECTED_FORUM' => 'Selected Forum', + 'SELECTED_FORUMS' => 'Selected Forums', + + 'POSTS_PRUNED' => 'Posts pruned', + 'PRUNE_ANNOUNCEMENTS' => 'Prune Announcements', + 'PRUNE_FINISHED_POLLS' => 'Prune Closed Polls', + 'PRUNE_FINISHED_POLLS_EXPLAIN' => 'Removes topics with polls which have ended.', + 'PRUNE_NOT_POSTED' => 'Days since last posted', + 'PRUNE_NOT_VIEWED' => 'Days since last viewed', + 'PRUNE_OLD_POLLS' => 'Prune Old Polls', + 'PRUNE_OLD_POLLS_EXPLAIN' => 'Removes topics with polls not voted in for post age days.', + 'PRUNE_STICKY' => 'Prune Stickies', + 'PRUNE_SUCCESS' => 'Pruning of forums was successful', + + 'TOPICS_PRUNED' => 'Topics pruned', +); + +?> \ No newline at end of file diff --git a/phpBB/mcp.php b/phpBB/mcp.php index ab6cfc38b8..e1f1b0662f 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -214,18 +214,21 @@ switch ($mode) /** * Functions used to generate additional URL paramters */ -function main_forum_view_url() +function _module_main_forum_view_url() { return extra_url(); } -function main_topic_view_url() + +function _module_main_topic_view_url() { return extra_url(); } -function main_post_details_url() + +function _module_main_post_details_url() { return extra_url(); } + function extra_url() { global $forum_id, $topic_id, $post_id; @@ -236,9 +239,6 @@ function extra_url() return $url_extra; } -// -// LITTLE HELPER - /** * Get simple topic data */