diff options
author | patdenice <patdenice@piwigo.org> | 2010-03-24 23:24:01 +0000 |
---|---|---|
committer | patdenice <patdenice@piwigo.org> | 2010-03-24 23:24:01 +0000 |
commit | f9b339cf796e1b78e2a3416f594897c0b808c156 (patch) | |
tree | 8db694d7e84410212fd72a63d3312baad0e286dc | |
parent | 7682ed5e13e88d01cc0e05b083d49b6d8552a2b3 (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 '')
-rw-r--r-- | admin/configuration.php | 1 | ||||
-rw-r--r-- | admin/themes/default/template/configuration.tpl | 7 | ||||
-rw-r--r-- | install/config.sql | 1 | ||||
-rw-r--r-- | install/db/89-database.php | 44 | ||||
-rw-r--r-- | language/en_UK/admin.lang.php | 1 | ||||
-rw-r--r-- | language/fr_FR/common.lang.php | 1 | ||||
-rw-r--r-- | profile.php | 90 | ||||
-rw-r--r-- | themes/default/template/profile_content.tpl | 2 |
8 files changed, 105 insertions, 42 deletions
diff --git a/admin/configuration.php b/admin/configuration.php index 9ec7ed805..436661803 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -51,6 +51,7 @@ $main_checkboxes = array( 'rate', 'rate_anonymous', 'email_admin_on_new_user', + 'allow_user_customization', ); $history_checkboxes = array( diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl index c31374148..d0cb9b4bd 100644 --- a/admin/themes/default/template/configuration.tpl +++ b/admin/themes/default/template/configuration.tpl @@ -69,6 +69,13 @@ <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> <input type="checkbox" name="obligatory_user_mail_address" {if ($main.obligatory_user_mail_address)}checked="checked"{/if}> </label> diff --git a/install/config.sql b/install/config.sql index 97b8ad53a..5bd5df4a9 100644 --- a/install/config.sql +++ b/install/config.sql @@ -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'); diff --git a/install/db/89-database.php b/install/db/89-database.php new file mode 100644 index 000000000..848d5897b --- /dev/null +++ b/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" +; +?>
\ No newline at end of file diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index 270972422..4803cbd86 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -749,4 +749,5 @@ $lang['Activate Navigation Thumbnails'] = 'Activate Navigation Thumbnails'; $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'; ?> diff --git a/language/fr_FR/common.lang.php b/language/fr_FR/common.lang.php index 877031f8e..86d6a512a 100644 --- a/language/fr_FR/common.lang.php +++ b/language/fr_FR/common.lang.php @@ -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['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"; ?> 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'], diff --git a/themes/default/template/profile_content.tpl b/themes/default/template/profile_content.tpl index 876a2a8a8..fa43adde6 100644 --- a/themes/default/template/profile_content.tpl +++ b/themes/default/template/profile_content.tpl @@ -39,6 +39,7 @@ {/if} </fieldset> +{if $ALLOW_USER_CUSTOMIZATION} <fieldset> <legend>{'Preferences'|@translate}</legend> @@ -99,6 +100,7 @@ </li> </ul> </fieldset> +{/if} <p class="bottomButtons"> <input class="submit" type="submit" name="validate" value="{'Submit'|@translate}"> |