aboutsummaryrefslogtreecommitdiffstats
path: root/profile.php
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2010-03-24 23:24:01 +0000
committerpatdenice <patdenice@piwigo.org>2010-03-24 23:24:01 +0000
commitf9b339cf796e1b78e2a3416f594897c0b808c156 (patch)
tree8db694d7e84410212fd72a63d3312baad0e286dc /profile.php
parent7682ed5e13e88d01cc0e05b083d49b6d8552a2b3 (diff)
Feature 1533: admincan activate/deactivate user customization.
git-svn-id: http://piwigo.org/svn/trunk@5328 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'profile.php')
-rw-r--r--profile.php90
1 files changed, 48 insertions, 42 deletions
diff --git a/profile.php b/profile.php
index 4b3d03138..ddc7a3452 100644
--- a/profile.php
+++ b/profile.php
@@ -104,36 +104,39 @@ function save_profile_from_post($userdata, &$errors)
);
}
- $int_pattern = '/^\d+$/';
- if (empty($_POST['nb_image_line'])
- or (!preg_match($int_pattern, $_POST['nb_image_line'])))
+ if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
{
- $errors[] = l10n('The number of images per row must be a not null scalar');
- }
+ $int_pattern = '/^\d+$/';
+ if (empty($_POST['nb_image_line'])
+ or (!preg_match($int_pattern, $_POST['nb_image_line'])))
+ {
+ $errors[] = l10n('The number of images per row must be a not null scalar');
+ }
- if (empty($_POST['nb_line_page'])
- or (!preg_match($int_pattern, $_POST['nb_line_page'])))
- {
- $errors[] = l10n('The number of rows per page must be a not null scalar');
- }
+ if (empty($_POST['nb_line_page'])
+ or (!preg_match($int_pattern, $_POST['nb_line_page'])))
+ {
+ $errors[] = l10n('The number of rows per page must be a not null scalar');
+ }
- if ($_POST['maxwidth'] != ''
- and (!preg_match($int_pattern, $_POST['maxwidth'])
- or $_POST['maxwidth'] < 50))
- {
- $errors[] = l10n('Maximum width must be a number superior to 50');
- }
- if ($_POST['maxheight']
- and (!preg_match($int_pattern, $_POST['maxheight'])
- or $_POST['maxheight'] < 50))
- {
- $errors[] = l10n('Maximum height must be a number superior to 50');
- }
- // periods must be integer values, they represents number of days
- if (!preg_match($int_pattern, $_POST['recent_period'])
- or $_POST['recent_period'] <= 0)
- {
- $errors[] = l10n('Recent period must be a positive integer value') ;
+ if ($_POST['maxwidth'] != ''
+ and (!preg_match($int_pattern, $_POST['maxwidth'])
+ or $_POST['maxwidth'] < 50))
+ {
+ $errors[] = l10n('Maximum width must be a number superior to 50');
+ }
+ if ($_POST['maxheight']
+ and (!preg_match($int_pattern, $_POST['maxheight'])
+ or $_POST['maxheight'] < 50))
+ {
+ $errors[] = l10n('Maximum height must be a number superior to 50');
+ }
+ // periods must be integer values, they represents number of days
+ if (!preg_match($int_pattern, $_POST['recent_period'])
+ or $_POST['recent_period'] <= 0)
+ {
+ $errors[] = l10n('Recent period must be a positive integer value') ;
+ }
}
if (isset($_POST['mail_address']))
@@ -199,26 +202,28 @@ function save_profile_from_post($userdata, &$errors)
array($data));
}
- // update user "additional" informations (specific to Piwigo)
- $fields = array(
- 'nb_image_line', 'nb_line_page', 'language', 'maxwidth', 'maxheight',
- 'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'theme'
- );
+ if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
+ {
+ // update user "additional" informations (specific to Piwigo)
+ $fields = array(
+ 'nb_image_line', 'nb_line_page', 'language', 'maxwidth', 'maxheight',
+ 'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'theme'
+ );
- $data = array();
- $data['user_id'] = $userdata['id'];
+ $data = array();
+ $data['user_id'] = $userdata['id'];
- foreach ($fields as $field)
- {
- if (isset($_POST[$field]))
+ foreach ($fields as $field)
{
- $data[$field] = $_POST[$field];
+ if (isset($_POST[$field]))
+ {
+ $data[$field] = $_POST[$field];
+ }
}
+ mass_updates(USER_INFOS_TABLE,
+ array('primary' => array('user_id'), 'update' => $fields),
+ array($data));
}
- mass_updates(USER_INFOS_TABLE,
- array('primary' => array('user_id'), 'update' => $fields),
- array($data));
-
trigger_action( 'save_profile_from_post', $userdata['id'] );
if (!empty($_POST['redirect']))
@@ -245,6 +250,7 @@ function load_profile_in_template($url_action, $url_redirect, $userdata)
array(
'USERNAME'=>stripslashes($userdata['username']),
'EMAIL'=>get_email_address_as_display_text(@$userdata['email']),
+ 'ALLOW_USER_CUSTOMIZATION'=>$conf['allow_user_customization'],
'NB_IMAGE_LINE'=>$userdata['nb_image_line'],
'NB_ROW_PAGE'=>$userdata['nb_line_page'],
'RECENT_PERIOD'=>$userdata['recent_period'],