aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2009-10-09 08:52:20 +0000
committerpatdenice <patdenice@piwigo.org>2009-10-09 08:52:20 +0000
commit6de7f6179c80b5ec15ab249c3fc20a30ad899b41 (patch)
tree9938286720addf52ab746435f12112faa04b37f6
parent74a8594c4252c15a7c6ba2f45f2fc54b06f53ed5 (diff)
merge r4001-4003 from trunk to branch 2.0
Issue 1079: re-refactoring of code ;-) git-svn-id: http://piwigo.org/svn/branches/2.0@4004 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--profile.php91
1 files changed, 23 insertions, 68 deletions
diff --git a/profile.php b/profile.php
index e84ace65b..f5cc440f9 100644
--- a/profile.php
+++ b/profile.php
@@ -43,76 +43,31 @@ if (!defined('PHPWG_ROOT_PATH'))
// Reset to default (Guest) custom settings
if (isset($_POST['reset_to_default']))
{
- global $conf;
- // Get the Guest custom settings
- $query = 'SELECT * FROM '.USER_INFOS_TABLE.
- ' WHERE user_id = '.$conf['default_user_id'].';';
+ // 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 '.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
- foreach ($userdata as $key => $valeur)
- {
- if ($key == 'nb_image_line')
- {
- $userdata[$key] = $default_user['nb_image_line'];
- $_POST['nb_image_line'] = $userdata['nb_image_line'];
- }
- if ($key == 'nb_line_page')
- {
- $userdata[$key] = $default_user['nb_line_page'];
- $_POST['nb_line_page'] = $userdata['nb_line_page'];
- }
- if ($key == 'maxwidth')
- {
- $userdata[$key] = $default_user['maxwidth'];
- $_POST['maxwidth'] = $userdata['maxheight'];
- }
- if ($key == 'maxheight')
- {
- $userdata[$key] = $default_user['maxheight'];
- $_POST['maxheight'] = $userdata['maxheight'];
- }
- if ($key == 'expand')
- {
- $userdata[$key] = $default_user['expand'];
- $_POST['expand'] = $userdata['expand'];
- }
- if ($key == 'show_nb_comments')
- {
- $userdata[$key] = $default_user['show_nb_comments'];
- $_POST['show_nb_comments'] = $userdata['show_nb_comments'];
- }
- if ($key == 'recent_period')
- {
- $userdata[$key] = $default_user['recent_period'];
- $_POST['recent_period'] = $userdata['recent_period'];
- }
- if ($key == 'show_nb_hits')
- {
- $userdata[$key] = $default_user['show_nb_hits'];
- $_POST['show_nb_hits'] = $userdata['show_nb_hits'];
- }
- }
- }
-
+ $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');