feature:2549 Allow to disable comments for everybody

git-svn-id: http://piwigo.org/svn/trunk@12887 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
mistic100 2012-01-14 22:29:10 +00:00
parent a412558492
commit c501688dbc
23 changed files with 172 additions and 51 deletions

View file

@ -189,11 +189,15 @@ $template->assign(
'U_PLUGINS'=> $link_start.'plugins',
'U_ADD_PHOTOS' => $link_start.'photos_add',
'U_CHANGE_THEME' => $change_theme_url,
'U_PENDING_COMMENTS' => $link_start.'comments',
'U_UPDATES' => $link_start.'updates',
)
);
if ($conf['activate_comments'])
{
$template->assign('U_PENDING_COMMENTS', $link_start.'comments');
}
// +-----------------------------------------------------------------------+
// | Plugin menu |
// +-----------------------------------------------------------------------+

View file

@ -48,12 +48,16 @@ if (isset($_POST['submit']))
array(
'id' => $_GET['cat_id'],
'name' => @$_POST['name'],
'commentable' => isset($_POST['commentable'])?$_POST['commentable']:'false',
'comment' =>
$conf['allow_html_descriptions'] ?
@$_POST['comment'] : strip_tags(@$_POST['comment']),
);
if ($conf['activate_comments'])
{
$data['commentable'] = isset($_POST['commentable'])?$_POST['commentable']:'false';
}
mass_updates(
CATEGORIES_TABLE,
array(
@ -222,7 +226,6 @@ $template->assign(
'CAT_STATUS' => $category['status'],
'CAT_VISIBLE' => boolean_to_string($category['visible']),
'CAT_COMMENTABLE' => boolean_to_string($category['commentable']),
'U_JUMPTO' => make_index_url(
array(
@ -239,6 +242,11 @@ $template->assign(
)
);
if ($conf['activate_comments'])
{
$template->assign('CAT_COMMENTABLE', boolean_to_string($category['commentable']));
}
if ('private' == $category['status'])
{

View file

@ -142,7 +142,10 @@ $tabsheet = new tabsheet();
$opt_link = $link_start.'cat_options&section=';
$tabsheet->add('status', l10n('Public / Private'), $opt_link.'status');
$tabsheet->add('visible', l10n('Lock'), $opt_link.'visible');
if ($conf['activate_comments'])
{
$tabsheet->add('comments', l10n('Comments'), $opt_link.'comments');
}
if ($conf['allow_random_representative'])
{
$tabsheet->add('representative', l10n('Representative'), $opt_link.'representative');

View file

@ -66,6 +66,7 @@ $history_checkboxes = array(
);
$comments_checkboxes = array(
'activate_comments',
'comments_forall',
'comments_validation',
'email_admin_on_comment',

View file

@ -185,12 +185,6 @@ SELECT COUNT(*)
;';
list($nb_groups) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.COMMENTS_TABLE.'
;';
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
$query = '
SELECT COUNT(*)
FROM '.RATE_TABLE.'
@ -218,7 +212,6 @@ $template->assign(
'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
'DB_RATES' => sprintf('%d rates', $nb_rates),
'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
@ -227,6 +220,35 @@ $template->assign(
)
);
if ($conf['activate_comments'])
{
$query = '
SELECT COUNT(*)
FROM '.COMMENTS_TABLE.'
;';
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
$template->assign('DB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments));
// unvalidated comments
$query = '
SELECT COUNT(*)
FROM '.COMMENTS_TABLE.'
WHERE validated=\'false\'
;';
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
if ($nb_comments > 0)
{
$template->assign(
'unvalidated',
array(
'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
)
);
}
}
if ($nb_elements > 0)
{
$query = '
@ -247,25 +269,6 @@ SELECT MIN(date_available)
);
}
// unvalidated comments
$query = '
SELECT COUNT(*)
FROM '.COMMENTS_TABLE.'
WHERE validated=\'false\'
;';
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
if ($nb_comments > 0)
{
$template->assign(
'unvalidated',
array(
'URL' => PHPWG_ROOT_PATH.'admin.php?page=comments',
'INFO' => sprintf(l10n('%d waiting for validation'), $nb_comments)
)
);
}
// graphics library
switch (pwg_image::get_library())
{

View file

@ -74,7 +74,9 @@ jQuery(document).ready(function(){ldelim}
<li><a href="{$U_THUMBNAILS}">{'Thumbnails'|@translate}</a></li>
{/if}
<li><a href="{$U_MAINTENANCE}">{'Maintenance'|@translate}</a></li>
{if isset($U_PENDING_COMMENTS)}
<li><a href="{$U_PENDING_COMMENTS}">{'Pending Comments'|@translate}</a></li>
{/if}
<li><a href="{$U_UPDATES}">{'Updates'|@translate}</a></li>
</ul>
</dd>

View file

@ -82,12 +82,14 @@
{html_radios name='visible' values='true,false'|@explode output='No,Yes'|@explode|translate selected=$CAT_VISIBLE}
</td>
</tr>
{if isset($CAT_COMMENTABLE)}
<tr>
<td><strong>{'Comments'|@translate}</strong>
<td>
{html_radios name='commentable' values='false,true'|@explode output='No,Yes'|@explode|translate selected=$CAT_COMMENTABLE}
</td>
</tr>
{/if}
</table>
</fieldset>

View file

@ -181,6 +181,15 @@ jQuery(document).ready(function () {
<fieldset id="commentsConf">
<legend></legend>
<ul>
<li>
<label>
<span class="property">{'Activate comments'|@translate}</span>
<input type="checkbox" name="activate_comments" id="activate_comments"{if ($comments.activate_comments)}checked="checked"{/if}>
</label>
</li>
</ul>
<ul id="comments_param_warp"{if not ($comments.activate_comments)} style="display:none;"{/if}>
<li>
<label>
<span class="property">{'Comments for all'|@translate}</span>
@ -243,6 +252,17 @@ jQuery(document).ready(function () {
</ul>
</fieldset>
{footer_script}{literal}
$(document).ready(function(){
$("#activate_comments").change(function(){
if ($(this).attr('checked')) {
$("#comments_param_warp").css('display', '');
} else {
$("#comments_param_warp").css('display', 'none');
}
});
});
{/literal}{/footer_script}
{/if}
</div> <!-- configContent -->

View file

@ -72,12 +72,14 @@ jQuery().ready(function(){
<li>{$DB_TAGS} ({$DB_IMAGE_TAG})</li>
<li>{$DB_USERS}</li>
<li>{$DB_GROUPS}</li>
{if isset($DB_COMMENTS)}
<li>
{$DB_COMMENTS}
{if isset($unvalidated)}
(<a href="{$unvalidated.URL}">{$unvalidated.INFO}</a>)
{/if}
</li>
{/if}
<li>{$DB_RATES}</li>
</ul>
</dd>

View file

@ -71,10 +71,12 @@
<span class="property">{'Expand all albums'|@translate}</span>
{html_radios name='expand' options=$radio_options selected=$EXPAND}
</li>
{if $ACTIVATE_COMMENTS}
<li>
<span class="property">{'Show number of comments'|@translate}</span>
{html_radios name='show_nb_comments' options=$radio_options selected=$NB_COMMENTS}
</li>
{/if}
<li>
<span class="property">{'Show number of hits'|@translate}</span>
{html_radios name='show_nb_hits' options=$radio_options selected=$NB_HITS}

View file

@ -235,6 +235,7 @@
</td>
</tr>
{if $ACTIVATE_COMMENTS}
<tr>
<td>{'Show number of comments'|@translate}</td>
<td>
@ -244,6 +245,7 @@
<label><input type="radio" name="show_nb_comments" value="false">{'No'|@translate}</label>
</td>
</tr>
{/if}
<tr>
<td>{'Show number of hits'|@translate}</td>

View file

@ -415,14 +415,19 @@ DELETE FROM '.USER_GROUP_TABLE.'
$datas = array();
$dbfields = array('primary' => array('user_id'), 'update' => array());
$formfields =
array('nb_image_page', 'theme', 'language',
'recent_period', 'expand', 'show_nb_comments',
'show_nb_hits', 'status', 'enabled_high',
'level');
$formfields = array(
'nb_image_page', 'theme', 'language',
'recent_period', 'expand', 'show_nb_hits',
'status', 'enabled_high', 'level'
);
$true_false_fields = array('expand', 'show_nb_comments',
'show_nb_hits', 'enabled_high');
$true_false_fields = array('expand', 'show_nb_hits', 'enabled_high');
if ($conf['activate_comments'])
{
array_push($formfields, 'show_nb_comments');
array_push($true_false_fields, 'show_nb_comments');
}
foreach ($formfields as $formfield)
{
@ -555,7 +560,9 @@ $template->assign(
'F_ADD_ACTION' => $base_url,
'F_USERNAME' => @htmlentities($_GET['username'], ENT_COMPAT, 'UTF-8'),
'F_FILTER_ACTION' => get_root_url().'admin.php'
'F_FILTER_ACTION' => get_root_url().'admin.php',
'ACTIVATE_COMMENTS' => $conf['activate_comments'],
));
// Display or Hide double password type

View file

@ -28,6 +28,11 @@ define('PHPWG_ROOT_PATH','./');
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
if (!$conf['activate_comments'])
{
page_not_found(null);
}
// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok |
// +-----------------------------------------------------------------------+

View file

@ -74,7 +74,7 @@ if (count($pictures) > 0)
: '' ))
);
if ($user['show_nb_comments'])
if ($conf['activate_comments'] and $user['show_nb_comments'])
{
$query = '
SELECT image_id, COUNT(*) AS nb_comments

View file

@ -257,6 +257,8 @@ function initialize_menu()
'REL'=> 'rel="search"'
);
if ($conf['activate_comments'])
{
// comments link
$block->data['comments'] =
array(
@ -264,6 +266,7 @@ function initialize_menu()
'NAME'=>l10n('Comments'),
'URL'=> get_root_url().'comments.php',
);
}
// about link
$block->data['about'] =

View file

@ -1,5 +1,6 @@
-- initial configuration for Piwigo
INSERT INTO piwigo_config (param,value,comment) VALUES ('activate_comments','true','Global parameter for usage of comments system');
INSERT INTO piwigo_config (param,value,comment) VALUES ('nb_comment_page','10','number of comments to display on each page');
INSERT INTO piwigo_config (param,value,comment) VALUES ('log','true','keep an history of visits on your website');
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_validation','false','administrators validate users comments before becoming visible');

View file

@ -0,0 +1,42 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 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 = 'new parameter: Activate comments';
$query = '
INSERT INTO piwigo_config (param,value,comment)
VALUES (\'activate_comments\',\'true\',\'Global parameter for usage of comments system\')
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>

View file

@ -101,6 +101,7 @@ $lang['Activate icon "%s"'] = 'Activate icon "%s"';
$lang['Activate icon "new" next to albums and pictures'] = 'Activate icon "new" next to albums and pictures';
$lang['Activate Navigation Bar'] = 'Activate navigation bar';
$lang['Activate Navigation Thumbnails'] = 'Activate navigation thumbnails';
$lang['Activate comments'] = 'Activate comments';
$lang['Activate'] = "Activate";
$lang['Active Languages'] = 'Active Languages';
$lang['Active Plugins'] = 'Active Plugins';

View file

@ -845,5 +845,6 @@ $lang['An error has occured during upgrade.'] = 'Une erreur est survenue pendant
$lang['An error has occured during extract. Please check files permissions of your piwigo installation.<br><a href="%s">Click here to show log error</a>.'] = 'Impossible d\'extraire les fichiers. Veuillez vérifier les permissions des fichiers de votre installation.<br><a href="%s">Cliquez ici pour voir le rapport d\'erreur</a>.';
$lang['Piwigo cannot retrieve upgrade file from server'] = 'Piwigo ne peut pas récupérer le fichier de mise à jour depuis le serveur';
$lang['Send connection settings by email'] = 'Envoyer les identifiants par email';
$lang['Activate comments'] = 'Activate comments';
?>

View file

@ -844,5 +844,6 @@ $lang['Resize after upload'] = 'Redimensionner après transfert';
$lang['Photo Sizes'] = 'Tailles de photo';
$lang['Original Size'] = 'Taille originale';
$lang['Send connection settings by email'] = 'Envoyer les identifiants par email';
$lang['Activate comments'] = 'Activate comments';
?>

View file

@ -965,7 +965,10 @@ if (isset($picture['next'])
// +-----------------------------------------------------------------------+
include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php');
if ($conf['activate_comments'])
{
include(PHPWG_ROOT_PATH.'include/picture_comment.inc.php');
}
if ($metadata_showable and pwg_get_session_var('show_metadata') <> null )
{
include(PHPWG_ROOT_PATH.'include/picture_metadata.inc.php');

View file

@ -256,9 +256,14 @@ function save_profile_from_post($userdata, &$errors)
// update user "additional" informations (specific to Piwigo)
$fields = array(
'nb_image_page', 'language',
'expand', 'show_nb_comments', 'show_nb_hits', 'recent_period', 'theme'
'expand', 'show_nb_hits', 'recent_period', 'theme'
);
if ($conf['activate_comments'])
{
array_push($fields, 'show_nb_comments');
}
$data = array();
$data['user_id'] = $userdata['id'];
@ -300,6 +305,7 @@ function load_profile_in_template($url_action, $url_redirect, $userdata)
'USERNAME'=>stripslashes($userdata['username']),
'EMAIL'=>get_email_address_as_display_text(@$userdata['email']),
'ALLOW_USER_CUSTOMIZATION'=>$conf['allow_user_customization'],
'ACTIVATE_COMMENTS'=>$conf['activate_comments'],
'NB_IMAGE_PAGE'=>$userdata['nb_image_page'],
'RECENT_PERIOD'=>$userdata['recent_period'],
'EXPAND' =>$userdata['expand'] ? 'true' : 'false',

View file

@ -70,10 +70,12 @@
<span class="property">{'Expand all albums'|@translate}</span>
{html_radios name='expand' options=$radio_options selected=$EXPAND}
</li>
{if $ACTIVATE_COMMENTS}
<li>
<span class="property">{'Show number of comments'|@translate}</span>
{html_radios name='show_nb_comments' options=$radio_options selected=$NB_COMMENTS}
</li>
{/if}
<li>
<span class="property">{'Show number of hits'|@translate}</span>
{html_radios name='show_nb_hits' options=$radio_options selected=$NB_HITS}