Feature 1533: admincan activate/deactivate user customization.

git-svn-id: http://piwigo.org/svn/trunk@5328 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
patdenice
2010-03-24 23:24:01 +00:00
parent 7682ed5e13
commit f9b339cf79
8 changed files with 108 additions and 45 deletions
+1
View File
@@ -51,6 +51,7 @@ $main_checkboxes = array(
'rate', 'rate',
'rate_anonymous', 'rate_anonymous',
'email_admin_on_new_user', 'email_admin_on_new_user',
'allow_user_customization',
); );
$history_checkboxes = array( $history_checkboxes = array(
@@ -67,6 +67,13 @@
</label> </label>
</li> </li>
<li>
<label>
<span class="property">{'Allow user customization'|@translate}</span>
<input type="checkbox" name="allow_user_customization" {if ($main.allow_user_customization)}checked="checked"{/if}>
</label>
</li>
<li> <li>
<label> <label>
<span class="property">{'Mail address is obligatory for all users'|@translate}</span> <span class="property">{'Mail address is obligatory for all users'|@translate}</span>
+1
View File
@@ -17,6 +17,7 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('page_banner','<h1>Piwig
INSERT INTO piwigo_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website'); INSERT INTO piwigo_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website');
INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website'); INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?'); INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?');
INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_customization','true','allow users to customize their gallery?');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail'); INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail'); INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail'); INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
+44
View File
@@ -0,0 +1,44 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based picture gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
if (!defined("PHPWG_ROOT_PATH"))
{
die('Hacking attempt!');
}
$upgrade_description = 'Admins can activate/deactivate user customization.';
$query = '
INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
VALUES
("allow_user_customization","true","allow users to customize their gallery?")
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
+1
View File
@@ -749,4 +749,5 @@ $lang['Activate Navigation Thumbnails'] = 'Activate Navigation Thumbnails';
$lang['Activate icon "%s"'] = 'Activate icon "%s"'; $lang['Activate icon "%s"'] = 'Activate icon "%s"';
$lang['Activate field "%s"'] = 'Activate field "%s"'; $lang['Activate field "%s"'] = 'Activate field "%s"';
$lang['Photo Properties'] = 'Photo Properties'; $lang['Photo Properties'] = 'Photo Properties';
$lang['Allow user customization'] = 'Allow user customization';
?> ?>
+1
View File
@@ -387,4 +387,5 @@ $lang['This author removed the comment with id %d'] = 'Cet auteur a supprimé le
$lang['delete this comment'] = "supprimer ce commentaire"; $lang['delete this comment'] = "supprimer ce commentaire";
$lang['validate this comment'] = 'valider ce commentaire'; $lang['validate this comment'] = 'valider ce commentaire';
$lang['(!) This comment requires validation'] = '(!) Ce commentaire requiert une validation'; $lang['(!) This comment requires validation'] = '(!) Ce commentaire requiert une validation';
$lang['Allow user customization'] = "Permettre la personnalisation de l'affichage";
?> ?>
+51 -45
View File
@@ -104,36 +104,39 @@ function save_profile_from_post($userdata, &$errors)
); );
} }
$int_pattern = '/^\d+$/'; if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
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'); $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']) if (empty($_POST['nb_line_page'])
or (!preg_match($int_pattern, $_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'); $errors[] = l10n('The number of rows per page must be a not null scalar');
} }
if ($_POST['maxwidth'] != '' if ($_POST['maxwidth'] != ''
and (!preg_match($int_pattern, $_POST['maxwidth']) and (!preg_match($int_pattern, $_POST['maxwidth'])
or $_POST['maxwidth'] < 50)) or $_POST['maxwidth'] < 50))
{ {
$errors[] = l10n('Maximum width must be a number superior to 50'); $errors[] = l10n('Maximum width must be a number superior to 50');
} }
if ($_POST['maxheight'] if ($_POST['maxheight']
and (!preg_match($int_pattern, $_POST['maxheight']) and (!preg_match($int_pattern, $_POST['maxheight'])
or $_POST['maxheight'] < 50)) or $_POST['maxheight'] < 50))
{ {
$errors[] = l10n('Maximum height must be a number superior to 50'); $errors[] = l10n('Maximum height must be a number superior to 50');
} }
// periods must be integer values, they represents number of days // periods must be integer values, they represents number of days
if (!preg_match($int_pattern, $_POST['recent_period']) if (!preg_match($int_pattern, $_POST['recent_period'])
or $_POST['recent_period'] <= 0) or $_POST['recent_period'] <= 0)
{ {
$errors[] = l10n('Recent period must be a positive integer value') ; $errors[] = l10n('Recent period must be a positive integer value') ;
}
} }
if (isset($_POST['mail_address'])) if (isset($_POST['mail_address']))
@@ -199,26 +202,28 @@ function save_profile_from_post($userdata, &$errors)
array($data)); array($data));
} }
// update user "additional" informations (specific to Piwigo) if ($conf['allow_user_customization'] or defined('IN_ADMIN'))
$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'];
foreach ($fields as $field)
{ {
if (isset($_POST[$field])) // update user "additional" informations (specific to Piwigo)
{ $fields = array(
$data[$field] = $_POST[$field]; 'nb_image_line', 'nb_line_page', 'language', 'maxwidth', 'maxheight',
} 'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'theme'
} );
mass_updates(USER_INFOS_TABLE,
array('primary' => array('user_id'), 'update' => $fields),
array($data));
$data = array();
$data['user_id'] = $userdata['id'];
foreach ($fields as $field)
{
if (isset($_POST[$field]))
{
$data[$field] = $_POST[$field];
}
}
mass_updates(USER_INFOS_TABLE,
array('primary' => array('user_id'), 'update' => $fields),
array($data));
}
trigger_action( 'save_profile_from_post', $userdata['id'] ); trigger_action( 'save_profile_from_post', $userdata['id'] );
if (!empty($_POST['redirect'])) if (!empty($_POST['redirect']))
@@ -245,6 +250,7 @@ function load_profile_in_template($url_action, $url_redirect, $userdata)
array( array(
'USERNAME'=>stripslashes($userdata['username']), 'USERNAME'=>stripslashes($userdata['username']),
'EMAIL'=>get_email_address_as_display_text(@$userdata['email']), 'EMAIL'=>get_email_address_as_display_text(@$userdata['email']),
'ALLOW_USER_CUSTOMIZATION'=>$conf['allow_user_customization'],
'NB_IMAGE_LINE'=>$userdata['nb_image_line'], 'NB_IMAGE_LINE'=>$userdata['nb_image_line'],
'NB_ROW_PAGE'=>$userdata['nb_line_page'], 'NB_ROW_PAGE'=>$userdata['nb_line_page'],
'RECENT_PERIOD'=>$userdata['recent_period'], 'RECENT_PERIOD'=>$userdata['recent_period'],
@@ -39,6 +39,7 @@
{/if} {/if}
</fieldset> </fieldset>
{if $ALLOW_USER_CUSTOMIZATION}
<fieldset> <fieldset>
<legend>{'Preferences'|@translate}</legend> <legend>{'Preferences'|@translate}</legend>
@@ -99,6 +100,7 @@
</li> </li>
</ul> </ul>
</fieldset> </fieldset>
{/if}
<p class="bottomButtons"> <p class="bottomButtons">
<input class="submit" type="submit" name="validate" value="{'Submit'|@translate}"> <input class="submit" type="submit" name="validate" value="{'Submit'|@translate}">