From f6df4a9993ac5a78b2e00c8f72e15469060e3f2b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 30 Apr 2005 14:12:21 +0000 Subject: [PATCH] - fix smiley emotion - some language pack updates - profile field updates git-svn-id: file:///svn/phpbb/trunk@5132 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/admin_attachments.php | 2 + phpBB/adm/admin_forums.php | 1 + phpBB/adm/admin_icons.php | 12 +- phpBB/adm/admin_language.php | 200 ++++++++++++++------------------ phpBB/adm/admin_profile.php | 182 ++++++++++++++++++----------- 5 files changed, 212 insertions(+), 185 deletions(-) diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php index a438b16f65..74e2a76417 100644 --- a/phpBB/adm/admin_attachments.php +++ b/phpBB/adm/admin_attachments.php @@ -225,6 +225,8 @@ if ($submit && $mode == 'extensions') { $notify[] = $user->lang['EXTENSIONS_UPDATED']; } + + $cache->destroy('extensions'); } diff --git a/phpBB/adm/admin_forums.php b/phpBB/adm/admin_forums.php index 5ec50c9832..0a6180499a 100644 --- a/phpBB/adm/admin_forums.php +++ b/phpBB/adm/admin_forums.php @@ -1420,6 +1420,7 @@ function delete_forum_content($forum_id) switch (SQL_LAYER) { case 'mysql4': + case 'mysqli': // Select then delete all attachments $sql = 'SELECT a.topic_id FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a diff --git a/phpBB/adm/admin_icons.php b/phpBB/adm/admin_icons.php index be4c18a617..bc400e8a18 100644 --- a/phpBB/adm/admin_icons.php +++ b/phpBB/adm/admin_icons.php @@ -220,7 +220,7 @@ switch ($action) ?> - + $image_emotion[$image], + 'emotion' => $image_emotion[$image], 'code' => $image_code[$image]) ); } @@ -467,7 +467,7 @@ switch ($action) if ($mode == 'smilies') { $sql = array_merge($sql, array( - 'smiley' => $emotion + 'emotion' => $emotion )); } @@ -489,7 +489,7 @@ switch ($action) { $sql = array_merge($sql, array( 'code' => $code, - 'smiley' => $emotion + 'emotion' => $emotion )); } $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql)); @@ -582,7 +582,7 @@ switch ($action) $pak .= "'" . addslashes($row[$fields . '_width']) . "', "; if ($mode == 'smilies') { - $pak .= "'" . addslashes($row['smiley']) . "', "; + $pak .= "'" . addslashes($row['emotion']) . "', "; $pak .= "'" . addslashes($row['code']) . "', "; } $pak .= "\n"; @@ -745,7 +745,7 @@ switch ($action) { ?> - + diff --git a/phpBB/adm/admin_language.php b/phpBB/adm/admin_language.php index 50f810d98e..725472a440 100644 --- a/phpBB/adm/admin_language.php +++ b/phpBB/adm/admin_language.php @@ -10,18 +10,8 @@ /** */ - -// TODO: -// * new auth? -// * add ability to change uninstalled language packs -// * add ability to create new language pack from existing one -// * add documentation/help -// * Ability to add/remove entries to/from help files? -// * Extend help entries to textarea - if (!empty($setmodules)) { - // New auth for language dependent settings? if (!$auth->acl_get('a_server')) { return; @@ -42,7 +32,7 @@ include($phpbb_root_path . 'includes/functions_user.'.$phpEx); // Do we have general permissions? if (!$auth->acl_get('a_server')) { - trigger_error($user->lang['NO_ADMIN']); + trigger_error('NO_ADMIN'); } // Check and set some common vars @@ -69,58 +59,38 @@ $safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on' $language_files = array('common', 'groups', 'mcp', 'memberlist', 'posting', 'search', 'ucp', 'viewforum', 'viewtopic', 'admin', 'help_bbcode', 'help_faq'); +$language_file_header = 'lang += array( - 'LANGUAGE_PACKS_EXPLAIN' => 'Here you are able to install/remove language packs', - 'LANGUAGE_PACK_NAME' => 'Name', - 'LANGUAGE_PACK_LOCALNAME' => 'Local name', - 'LANGUAGE_PACK_ISO' => 'ISO', - 'LANGUAGE_PACK_USED_BY' => 'Used by', - 'INSTALLED_LANGUAGE_PACKS' => 'Installed language packs', - 'UNINSTALLED_LANGUAGE_PACKS'=> 'Uninstalled language packs', - 'NO_UNINSTALLED_LANGUAGE_PACKS' => 'No uninstalled language packs', - 'NO_LANG_ID' => 'You haven\'t specified a language pack', - 'NO_REMOVE_DEFAULT_LANG' => 'You are not able to remove the default language pack.
If you want to remove this language pack, change your boards default language first.', - 'LANGUAGE_PACK_DELETED' => 'The language pack %s has been removed successfully. All users using this language have been resetted to the boards default language.', - 'LANGUAGE_PACK_NOT_EXIST' => 'The selected language pack does not exist.', - 'LANGUAGE_PACK_ALREADY_INSTALLED' => 'This language pack is already installed.', - 'INVALID_LANGUAGE_PACK' => 'The selected language pack seems to be not valid. Please verify the language pack and upload it again if necessary.', - 'LANGUAGE_PACK_INSTALLED' => 'The language pack %s has been successfully installed.', - 'LANGUAGE_PACK_DETAILS' => 'Language Pack Details', - 'WRONG_LANGUAGE_FILE' => 'Selected language file is invalid', - 'LANGUAGE_DETAILS_UPDATED' => 'Language details successfully updated', - - 'LANG_ENGLISH_NAME' => 'English name', - 'LANG_LOCAL_NAME' => 'Local name', - 'LANG_ISO_CODE' => 'ISO Code', - 'LANG_AUTHOR' => 'Language Pack Author', - - 'MISSING_LANGUAGE_FILE' => 'Missing Language File: %s', - 'THOSE_MISSING_LANG_FILES' => 'The following language files are missing from the %s language folder', - 'MISSING_LANG_VARIABLES' => 'Missing Language Variables', - 'THOSE_MISSING_LANG_VARIABLES' => 'The following language variables are missing from the %s language pack', - - 'LANGUAGE_KEY' => 'Language Key', - 'LANGUAGE_VARIABLE' => 'Language Variable', - 'LANGUAGE_FILES' => 'Language Files', - 'HELP_FILES' => 'Help Files', - 'EMAIL_TEMPLATES' => 'Email Templates', - - 'LANGUAGE_ENTRIES' => 'Language Entries', - 'LANGUAGE_ENTRIES_EXPLAIN' => 'Here you are able to change existing language pack entries or not already translated ones.', - 'REMOVE_FROM_STORAGE_FOLDER'=> 'Remove from storage folder', - 'FILE_CONTENTS' => 'File Contents', - 'FILE_FROM_STORAGE' => 'File from storage folder', - 'SUBMIT_AND_DOWNLOAD' => 'Submit and Download File', - 'SELECT_DOWNLOAD_FORMAT' => 'Select download format', - 'DOWNLOAD_AS' => 'Download as', - 'DOWNLOAD' => 'Download', -); - switch ($action) { case 'update_details': @@ -199,29 +169,8 @@ switch ($action) } else if (strpos($cur_file, 'help_') === 0) { - $header = ' $value) @@ -250,33 +199,16 @@ $help = array( } else { - $header = ' - + lang['LANGUAGE_PACKS']); ?>

lang['LANGUAGE_PACKS']; ?>

@@ -967,6 +900,9 @@ exit; // // FUNCTIONS +/** +* Compare two language files +*/ function compare_language_files($source_lang, $dest_lang, $file_var) { global $phpbb_root_path, $phpEx; @@ -1003,6 +939,9 @@ function compare_language_files($source_lang, $dest_lang, $file_var) return $return_ary; } +/** +* Print language entries +*/ function print_language_entries(&$lang_ary, $key_prefix = '', $input_field = true) { foreach ($lang_ary as $key => $value) @@ -1031,13 +970,54 @@ function print_language_entries(&$lang_ary, $key_prefix = '', $input_field = tru else { ?> - + $value) + { +?> + + + + +   + + $_value) + { +?> + + + + + + + +acl_get('a_user')) { - trigger_error($user->lang['NO_ADMIN']); + 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; +$submit = (isset($_POST['submit'])) ? true : false; +$create = (isset($_POST['create'])) ? true : false; $error = $notify = array(); adm_page_header($user->lang['CUSTOM_PROFILE_FIELDS']); @@ -136,7 +112,7 @@ if ($mode == 'create' || $mode == 'edit') { if (!$field_id) { - trigger_error('No field id specified'); + trigger_error('NO_FIELD_ID'); } $sql = 'SELECT l.*, f.* @@ -150,7 +126,7 @@ if ($mode == 'create' || $mode == 'edit') if (!$field_row) { - trigger_error('Profile field not found'); + trigger_error('FIELD_NOT_FOUND'); } $field_type = $field_row['field_type']; @@ -175,8 +151,7 @@ if ($mode == 'create' || $mode == 'edit') else { // We are adding a new field, define basic params - $lang_options = array(); - $field_row = array(); + $lang_options = $field_row = array(); $field_type = request_var('field_type', 0); @@ -189,6 +164,7 @@ if ($mode == 'create' || $mode == 'edit') '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' => '', @@ -199,10 +175,10 @@ if ($mode == 'create' || $mode == 'edit') $s_hidden_fields = ''; } - // $exclude contains the data that we gather in each ste + // $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'), + 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') ); @@ -218,12 +194,13 @@ if ($mode == 'create' || $mode == 'edit') $exclude[1][] = 'lang_options'; } - $cp->vars['field_ident'] = request_var('field_ident', $field_row['field_ident']); + $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)) { @@ -235,8 +212,8 @@ if ($mode == 'create' || $mode == 'edit') } else if ($mode == 'edit') { - $cp->vars['lang_options'] = $lang_options; - $error[] = 'You are not allowed to remove or add options within already existing profile fields'; + // Changing the number of options? (We remove and re-create the option fields) + $cp->vars['lang_options'] = explode("\n", $options); } } else @@ -247,7 +224,7 @@ if ($mode == 'create' || $mode == 'edit') // step 2 foreach ($exclude[2] as $key) { - if ($key == 'field_required' || $key == 'field_show_on_reg' || $key == 'field_hide') + 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); @@ -372,7 +349,6 @@ if ($mode == 'create' || $mode == 'edit') // Check values for step 1 if ($cp->vars['field_ident'] == '') { - // Rename $user->lang['EMPTY_FIELD_NAME'] to $user->lang['EMPTY_FIELD_IDENT'] $error[] = $user->lang['EMPTY_FIELD_IDENT']; } @@ -390,7 +366,7 @@ if ($mode == 'create' || $mode == 'edit') { if (!sizeof($cp->vars['lang_options'])) { - $error[] = 'No Entries defined'; + $error[] = $user->lang['NO_FIELD_ENTRIES']; } } } @@ -545,6 +521,10 @@ if ($mode == 'create' || $mode == 'edit') 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"' : ''); ?> /> + sql_query($sql); } } - // TODO: add_log - trigger_error($user->lang['DELETED_PROFILE_FIELD']); + add_log('admin', 'LOG_REMOVED_PROFILE_FIELD', $field_ident); + trigger_error('REMOVED_PROFILE_FIELD'); } else if (!$cancel) { @@ -759,7 +738,14 @@ if ($mode == 'activate') WHERE field_id = $field_id"; $db->sql_query($sql); - // TODO: add_log + $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']); } @@ -777,7 +763,14 @@ if ($mode == 'deactivate') WHERE field_id = $field_id"; $db->sql_query($sql); - // TODO: add_log + $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']); } @@ -800,10 +793,10 @@ if ($mode == 'manage')
"> - - - - + + + + vars['lang_options'] : $cp->vars['lang_options'][$lang_id]; + + $var = ($mode == 'create' || !is_array($cp->vars['lang_options'][$lang_id])) ? $cp->vars['lang_options'] : $cp->vars['lang_options'][$lang_id]; switch ($field_type) { @@ -956,7 +950,7 @@ function build_language_options($field_type, $mode = 'create') } else { - $var = ($mode == 'create') ? $cp->vars[$field] : $cp->vars[$field][$lang_id]; + $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)], @@ -1004,7 +998,8 @@ function save_profile_field($field_type, $mode = 'create') '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_hide' => $cp->vars['field_hide'], + 'field_no_view' => $cp->vars['field_no_view'] ); if ($mode == 'create') @@ -1090,18 +1085,26 @@ function save_profile_field($field_type, $mode = 'create') $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' => $cp->vars['l_lang_explain'][$lang_id], - 'lang_default_value' => $cp->vars['l_lang_default_value'][$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', ''); @@ -1116,6 +1119,14 @@ function save_profile_field($field_type, $mode = 'create') $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( @@ -1142,9 +1153,10 @@ function save_profile_field($field_type, $mode = 'create') } } - // TODO: sizeof() returns 1 if it's argument is something else than an array. It also seems to do that on empty array elements :? - if (sizeof($cp->vars['l_lang_options'])) + 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)) @@ -1159,6 +1171,14 @@ function save_profile_field($field_type, $mode = 'create') 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( @@ -1171,6 +1191,14 @@ function save_profile_field($field_type, $mode = 'create') } } } + + 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) @@ -1209,7 +1237,7 @@ function save_profile_field($field_type, $mode = 'create') } } -// $db->sql_transaction(); + $db->sql_transaction(); if ($mode == 'create') { foreach ($profile_sql as $sql) @@ -1217,10 +1245,18 @@ function save_profile_field($field_type, $mode = 'create') $db->sql_query($sql); } } -// $db->sql_transaction('commit'); + $db->sql_transaction('commit'); - // TODO: add_log - trigger_error($user->lang['ADDED_PROFILE_FIELD']); + 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 @@ -1229,25 +1265,33 @@ 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); } - $db->sql_return_on_error(true); - - $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE ' . implode(' AND ', $where_sql); + $sql = "SELECT $check_key + FROM $table + WHERE " . implode(' AND ', $where_sql); $result = $db->sql_query($sql); - - $db->sql_return_on_error(false); - if (!$result) + 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_fields($key_ary)
NameTypeOptionsReorderlang['FIELD_IDENT']; ?>lang['FIELD_TYPE']; ?>lang['OPTIONS']; ?>lang['REORDER']; ?>