- fix smiley emotion

- some language pack updates
- profile field updates


git-svn-id: file:///svn/phpbb/trunk@5132 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2005-04-30 14:12:21 +00:00
parent 20fda3315f
commit f6df4a9993
5 changed files with 212 additions and 185 deletions

View file

@ -225,6 +225,8 @@ if ($submit && $mode == 'extensions')
{
$notify[] = $user->lang['EXTENSIONS_UPDATED'];
}
$cache->destroy('extensions');
}

View file

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

View file

@ -220,7 +220,7 @@ switch ($action)
?>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" name="code[<?php echo $img; ?>]" value="<?php echo (!empty($img_row['code'])) ? $img_row['code'] : '' ?>" size="10" /></td>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" name="emotion[<?php echo $img; ?>]" value="<?php echo (!empty($img_row['smiley'])) ? $img_row['smiley'] : '' ?>" size="10" /></td>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" name="emotion[<?php echo $img; ?>]" value="<?php echo (!empty($img_row['emotion'])) ? $img_row['emotion'] : '' ?>" size="10" /></td>
<?php
}
@ -308,7 +308,7 @@ switch ($action)
if ($mode == 'smilies')
{
$img_sql = array_merge($img_sql, array(
'smiley' => $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)
{
?>
<td class="<?php echo $row_class; ?>" align="center"><?php echo htmlspecialchars($row['code']); ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['smiley']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['emotion']; ?></td>
<?php
}
?>

View file

@ -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 = '<?php
/**
*
* {FILENAME} [{LANG_NAME}]
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @author {CHANGED} - {AUTHOR}
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine
/**
*/
';
if (!$mode)
{
trigger_error('NO_MODE');
}
$user->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.<br />If you want to remove this language pack, change your boards default language first.',
'LANGUAGE_PACK_DELETED' => 'The language pack <b>%s</b> 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 <b>%s</b> 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: <span style="color:red">%s</span>',
'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 <b>%s</b> 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 = '<?php
// -------------------------------------------------------------
//
// FILENAME : ' . $cur_file . ' [ ' . $row['lang_english_name'] . ' ]
// CHANGED : ' . date('Y-m-d', time()) . '
// COPYRIGHT : ' . $row['lang_author'] . '
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine
$help = array(
';
$header = str_replace(array('{FILENAME}', '{LANG_NAME}', '{CHANGED}', '{AUTHOR}'), array($cur_file, $row['lang_english_name'], date('Y-m-d', time()), $row['lang_author']), $language_file_header);
$header .= '$help = array(' . "\n";
fwrite($fp, $header);
foreach ($_POST['entry'] as $key => $value)
@ -250,33 +199,16 @@ $help = array(
}
else
{
$header = '<?php
// -------------------------------------------------------------
//
// FILENAME : ' . $cur_file . ' [ ' . $row['lang_english_name'] . ' ]
// CHANGED : ' . date('Y-m-d', time()) . '
// COPYRIGHT : ' . $row['lang_author'] . '
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
// DO NOT CHANGE
$header = str_replace(array('{FILENAME}', '{LANG_NAME}', '{CHANGED}', '{AUTHOR}'), array($cur_file, $row['lang_english_name'], date('Y-m-d', time()), $row['lang_author']), $language_file_header);
$header .= '
/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// Placeholders can now contain order information, e.g. instead of
// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine
$lang += array(
';
fwrite($fp, $header);
@ -428,9 +360,9 @@ $lang += array(
// More missing files... for example email templates?
foreach ($email_templates as $file)
{
if (!file_exists(get_filename($lang_iso, "email/$file.$phpEx")))
if (!file_exists(get_filename($lang_iso, "email/$file")))
{
$missing_files[] = get_filename("email/$file.$phpEx");
$missing_files[] = get_filename($lang_iso, "email/$file");
}
}
@ -593,17 +525,18 @@ $lang += array(
<?php
if (!$is_email_file)
{
$function = ($is_help_file) ? 'print_help_entries' : 'print_language_entries';
if (isset($missing_vars[$cur_file]) && sizeof($missing_vars[$cur_file]))
{
print_language_entries($missing_vars[$cur_file], '* ');
$function($missing_vars[$cur_file], '* ');
}
print_language_entries($lang);
$function($lang);
}
else
{
?>
<tr>
<td class="row1" colspan="2" align="center"><textarea name="entry" cols="80" rows="20" class="text" style="width:90%"><?php echo $lang; ?></textarea></td>
<td class="row1" colspan="2" align="center"><textarea name="entry" cols="80" rows="20" class="post" style="width:90%"><?php echo $lang; ?></textarea></td>
</tr>
<?php
}
@ -835,7 +768,7 @@ $lang += array(
break;
default:
// Output list of themes
// Output list of language packs
adm_page_header($user->lang['LANGUAGE_PACKS']);
?>
<h1><?php echo $user->lang['LANGUAGE_PACKS']; ?></h1>
@ -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
{
?>
<?php if ($input_field) { ?><input type="text" class="text" name="entry[<?php echo $key; ?>]" value="<?php echo htmlspecialchars($value); ?>" style="width:99%" /><?php } else { ?><b><?php echo htmlspecialchars($value); ?></b><?php } ?></td>
<?php if ($input_field) { ?><input type="text" class="post" name="entry[<?php echo $key; ?>]" value="<?php echo htmlspecialchars($value); ?>" style="width:99%" /><?php } else { ?><b><?php echo htmlspecialchars($value); ?></b><?php } ?></td>
</tr>
<?php
}
}
}
/**
* Print help entries
*/
function print_help_entries(&$lang_ary, $key_prefix = '', $text_field = true)
{
foreach ($lang_ary as $key => $value)
{
?>
<tr>
<td class="row1" width="10%" nowrap="nowrap"><?php echo $key_prefix; ?><b><?php echo $key; ?></b></td>
<td class="row2">
<?php
if (is_array($value))
{
?>
&nbsp;</td>
</tr>
<?php
foreach ($value as $_key => $_value)
{
?>
<tr>
<td class="row1" width="10%" nowrap="nowrap"><?php echo $key_prefix; ?><b><?php echo $key . ' :: ' . $_key; ?></b></td>
<td class="row2"><?php if ($text_field) { ?><textarea class="post" name="entry[<?php echo $key; ?>][<?php echo $_key; ?>]" cols="80" rows="5" class="post" style="width:90%"><?php echo htmlspecialchars($_value); ?></textarea><?php } else { ?><b><?php echo htmlspecialchars($_value); ?></b><?php } ?></td>
</tr>
<?php
}
}
else
{
?>
<?php if ($text_field) { ?><textarea type="text" class="post" name="entry[<?php echo $key; ?>]" cols="80" rows="5" style="width:90%"><?php echo htmlspecialchars($value); ?></textarea><?php } else { ?><b><?php echo htmlspecialchars($value); ?></b><?php } ?></td>
</tr>
<?php
}
}
}
/**
* Get filename/location of language/help/email file
*/
function get_filename($lang_iso, $file, $check_store = false)
{
global $phpbb_root_path, $safe_mode;

View file

@ -11,30 +11,6 @@
/**
*/
/*
Remind if...
... one or more language entries are missing
Taking into consideration
... admin is NOT able to change the field type later
... admin can NOT change field name after creation
Admin is able to preview/test the input and output of a profile field at any time.
If the admin adds a field, he needs to enter at least the default board language params. Without doing so, he
is not able to activate the field.
If the default board language is changed a check has to be made if the profile field language entries are
still valid.
TODO:
* Show at profile view (yes/no)
* Viewtopic Integration (Load Switch, Able to show fields with additional template vars populated if enabled)
* Custom Validation (Regex) - not in 2.2
* Fix novalue/default for dropdown boxes. These fields seem to get saved +1 in the database
*/
if (!empty($setmodules))
{
$filename = basename(__FILE__);
@ -54,14 +30,14 @@ include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
if (!$auth->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 = '<input type="hidden" name="field_type" value="' . $field_type . '" />';
}
// $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')
);
@ -224,6 +200,7 @@ if ($mode == 'create' || $mode == 'edit')
$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')
<td class="row1"><b><?php echo $user->lang['HIDE_PROFILE_FIELD']; ?></b><br /><span class="gensmall"><?php echo $user->lang['HIDE_PROFILE_FIELD_EXPLAIN']; ?></span></td>
<td class="row2"><input type="checkbox" name="field_hide" value="1"<?php echo (($cp->vars['field_hide']) ? ' checked="checked"' : ''); ?> /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['EXCLUDE_FROM_VIEW']; ?></b><br /><span class="gensmall"><?php echo $user->lang['EXCLUDE_FROM_VIEW_EXPLAIN']; ?></span></td>
<td class="row2"><input type="checkbox" name="field_no_view" value="1"<?php echo (($cp->vars['field_no_view']) ? ' checked="checked"' : ''); ?> /></td>
</tr>
<?php
// Build options based on profile type
@ -710,16 +690,15 @@ if ($mode == 'delete')
$order++;
if ($row['field_order'] != $order)
{
$sql = 'UPDATE ' .
PROFILE_FIELDS_TABLE . "
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
SET field_order = $order
WHERE field_id = {$row['field_id']}";
$db->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')
<form name="profile_fields" method="post" action="admin_profile.<?php echo "$phpEx$SID"; ?>">
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%">
<tr>
<th nowrap="nowrap">Name</th>
<th nowrap="nowrap">Type</th>
<th colspan="3" nowrap="nowrap">Options</th>
<th nowrap="nowrap">Reorder</th>
<th nowrap="nowrap"><?php echo $user->lang['FIELD_IDENT']; ?></th>
<th nowrap="nowrap"><?php echo $user->lang['FIELD_TYPE']; ?></th>
<th colspan="3" nowrap="nowrap"><?php echo $user->lang['OPTIONS']; ?></th>
<th nowrap="nowrap"><?php echo $user->lang['REORDER']; ?></th>
</tr>
<?php
$sql = 'SELECT *
@ -928,7 +921,8 @@ function build_language_options($field_type, $mode = 'create')
if ($field == 'lang_options')
{
$var = ($mode == 'create') ? $cp->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')
@ -1097,11 +1092,19 @@ function save_profile_field($field_type, $mode = 'create')
'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
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)