mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
Issue 1079: re-refactoring of code ;-)
git-svn-id: http://piwigo.org/svn/trunk@4003 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
57
profile.php
57
profile.php
@@ -40,45 +40,34 @@ if (!defined('PHPWG_ROOT_PATH'))
|
||||
|
||||
trigger_action('loc_begin_profile');
|
||||
|
||||
// Reset to default (Guest) custom settings
|
||||
// Reset to default (Guest) custom settings
|
||||
if (isset($_POST['reset_to_default']))
|
||||
{
|
||||
global $conf;
|
||||
// mass_updates function
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
||||
$fields = array(
|
||||
'nb_image_line', 'nb_line_page', 'maxwidth', 'maxheight', 'expand',
|
||||
'show_nb_comments', 'show_nb_hits', 'recent_period', 'show_nb_hits'
|
||||
);
|
||||
|
||||
// Get the Guest custom settings
|
||||
$query = '
|
||||
SELECT * FROM '.USER_INFOS_TABLE.'
|
||||
WHERE user_id = '.$conf['default_user_id'].
|
||||
';';
|
||||
|
||||
SELECT '.implode(',', $fields).'
|
||||
FROM '.USER_INFOS_TABLE.'
|
||||
WHERE user_id = '.$conf['default_user_id'].'
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
$cache['default_user'] = mysql_fetch_assoc($result);
|
||||
|
||||
$default_user = array();
|
||||
|
||||
foreach ($cache['default_user'] as $name => $value)
|
||||
{
|
||||
// If the field is true or false, the variable is transformed into a
|
||||
// boolean value.
|
||||
if ($value == 'true' or $value == 'false')
|
||||
{
|
||||
$default_user[$name] = get_boolean($value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$default_user[$name] = $value;
|
||||
}
|
||||
}
|
||||
// Changing $userdata array values with default ones
|
||||
$userdata_params = array('nb_image_line', 'nb_line_page',
|
||||
'maxwidth', 'maxheight', 'expand',
|
||||
'show_nb_comments', 'show_nb_hits');
|
||||
foreach ($userdata_params as $key)
|
||||
{
|
||||
$userdata[$key] = $default_user[$key];
|
||||
$_POST[$key] = $userdata[$key];
|
||||
}
|
||||
}
|
||||
$default_user = mysql_fetch_assoc($result);
|
||||
$userdata = array_merge($userdata, $default_user);
|
||||
|
||||
mass_updates(
|
||||
USER_INFOS_TABLE,
|
||||
array('primary' => array('user_id'), 'update' => $fields),
|
||||
array($userdata)
|
||||
);
|
||||
}
|
||||
|
||||
save_profile_from_post($userdata, $errors);
|
||||
|
||||
$title= l10n('customize_page_title');
|
||||
|
||||
Reference in New Issue
Block a user