Skip to content

Commit

Permalink
Feature 1533: admincan activate/deactivate user customization.
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@5328 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed Mar 24, 2010
1 parent 7682ed5 commit f9b339c
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 42 deletions.
1 change: 1 addition & 0 deletions admin/configuration.php
Expand Up @@ -51,6 +51,7 @@
'rate',
'rate_anonymous',
'email_admin_on_new_user',
'allow_user_customization',
);

$history_checkboxes = array(
Expand Down
7 changes: 7 additions & 0 deletions admin/themes/default/template/configuration.tpl
Expand Up @@ -67,6 +67,13 @@
</label>
</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>
<label>
<span class="property">{'Mail address is obligatory for all users'|@translate}</span>
Expand Down
1 change: 1 addition & 0 deletions install/config.sql
Expand Up @@ -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_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_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_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');
Expand Down
44 changes: 44 additions & 0 deletions install/db/89-database.php
@@ -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 change: 1 addition & 0 deletions language/en_UK/admin.lang.php
Expand Up @@ -749,4 +749,5 @@
$lang['Activate icon "%s"'] = 'Activate icon "%s"';
$lang['Activate field "%s"'] = 'Activate field "%s"';
$lang['Photo Properties'] = 'Photo Properties';
$lang['Allow user customization'] = 'Allow user customization';
?>
1 change: 1 addition & 0 deletions language/fr_FR/common.lang.php
Expand Up @@ -387,4 +387,5 @@
$lang['delete this comment'] = "supprimer ce commentaire";
$lang['validate this comment'] = 'valider ce commentaire';
$lang['(!) This comment requires validation'] = '(!) Ce commentaire requiert une validation';
$lang['Allow user customization'] = "Permettre la personnalisation de l'affichage";
?>
90 changes: 48 additions & 42 deletions profile.php
Expand Up @@ -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']))
Expand Down Expand Up @@ -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']))
Expand All @@ -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'],
Expand Down
2 changes: 2 additions & 0 deletions themes/default/template/profile_content.tpl
Expand Up @@ -39,6 +39,7 @@
{/if}
</fieldset>

{if $ALLOW_USER_CUSTOMIZATION}
<fieldset>
<legend>{'Preferences'|@translate}</legend>

Expand Down Expand Up @@ -99,6 +100,7 @@
</li>
</ul>
</fieldset>
{/if}

<p class="bottomButtons">
<input class="submit" type="submit" name="validate" value="{'Submit'|@translate}">
Expand Down

0 comments on commit f9b339c

Please sign in to comment.