aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin.php6
-rw-r--r--admin/cat_modify.php12
-rw-r--r--admin/cat_options.php5
-rw-r--r--admin/configuration.php1
-rw-r--r--admin/intro.php55
-rw-r--r--admin/themes/default/template/admin.tpl2
-rw-r--r--admin/themes/default/template/cat_modify.tpl2
-rw-r--r--admin/themes/default/template/configuration.tpl20
-rw-r--r--admin/themes/default/template/intro.tpl2
-rw-r--r--admin/themes/default/template/profile_content.tpl6
-rw-r--r--admin/themes/default/template/user_list.tpl2
-rw-r--r--admin/user_list.php25
-rw-r--r--comments.php5
-rw-r--r--include/category_default.inc.php2
-rw-r--r--include/menubar.inc.php17
-rw-r--r--install/config.sql1
-rw-r--r--install/db/114-database.php42
-rw-r--r--language/en_UK/admin.lang.php1
-rw-r--r--language/fr_CA/admin.lang.php1
-rw-r--r--language/fr_FR/admin.lang.php1
-rw-r--r--picture.php5
-rw-r--r--profile.php8
-rw-r--r--themes/default/template/profile_content.tpl2
23 files changed, 172 insertions, 51 deletions
diff --git a/admin.php b/admin.php
index 411dcb9e2..1fb7ebc45 100644
--- a/admin.php
+++ b/admin.php
@@ -189,10 +189,14 @@ $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 |
diff --git a/admin/cat_modify.php b/admin/cat_modify.php
index 8c4d59ae9..5137e73b5 100644
--- a/admin/cat_modify.php
+++ b/admin/cat_modify.php
@@ -48,11 +48,15 @@ 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,
@@ -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(
@@ -238,6 +241,11 @@ $template->assign(
'F_ACTION' => $form_action,
)
);
+
+if ($conf['activate_comments'])
+{
+ $template->assign('CAT_COMMENTABLE', boolean_to_string($category['commentable']));
+}
if ('private' == $category['status'])
diff --git a/admin/cat_options.php b/admin/cat_options.php
index 8ab02272d..ec5842886 100644
--- a/admin/cat_options.php
+++ b/admin/cat_options.php
@@ -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');
-$tabsheet->add('comments', l10n('Comments'), $opt_link.'comments');
+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');
diff --git a/admin/configuration.php b/admin/configuration.php
index bc6f3634d..b7a06aa74 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -66,6 +66,7 @@ $history_checkboxes = array(
);
$comments_checkboxes = array(
+ 'activate_comments',
'comments_forall',
'comments_validation',
'email_admin_on_comment',
diff --git a/admin/intro.php b/admin/intro.php
index 63d5b9805..72406dee6 100644
--- a/admin/intro.php
+++ b/admin/intro.php
@@ -187,12 +187,6 @@ 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.'
;';
list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
@@ -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',
@@ -226,6 +219,35 @@ $template->assign(
'DB_DATATIME' => $db_current_date,
)
);
+
+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)
{
@@ -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())
{
diff --git a/admin/themes/default/template/admin.tpl b/admin/themes/default/template/admin.tpl
index 5bc11c92a..393cf7157 100644
--- a/admin/themes/default/template/admin.tpl
+++ b/admin/themes/default/template/admin.tpl
@@ -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>
diff --git a/admin/themes/default/template/cat_modify.tpl b/admin/themes/default/template/cat_modify.tpl
index 23c68fe97..91b580998 100644
--- a/admin/themes/default/template/cat_modify.tpl
+++ b/admin/themes/default/template/cat_modify.tpl
@@ -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>
diff --git a/admin/themes/default/template/configuration.tpl b/admin/themes/default/template/configuration.tpl
index 008dfe4e0..bc64a14ff 100644
--- a/admin/themes/default/template/configuration.tpl
+++ b/admin/themes/default/template/configuration.tpl
@@ -183,6 +183,15 @@ jQuery(document).ready(function () {
<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>
<input type="checkbox" name="comments_forall" {if ($comments.comments_forall)}checked="checked"{/if}>
</label>
@@ -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 -->
diff --git a/admin/themes/default/template/intro.tpl b/admin/themes/default/template/intro.tpl
index 7afbd6ab4..679a3565f 100644
--- a/admin/themes/default/template/intro.tpl
+++ b/admin/themes/default/template/intro.tpl
@@ -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>
diff --git a/admin/themes/default/template/profile_content.tpl b/admin/themes/default/template/profile_content.tpl
index 24cf53abe..33727f7aa 100644
--- a/admin/themes/default/template/profile_content.tpl
+++ b/admin/themes/default/template/profile_content.tpl
@@ -47,7 +47,7 @@
</span>
<input type="text" size="4" maxlength="3" name="nb_image_page" id="nb_image_page" value="{$NB_IMAGE_PAGE}">
</li>
-{if not $SPECIAL_USER}
+ {if not $SPECIAL_USER}
<li>
<span class="property">
<label for="template">{'Interface theme'|@translate}</label>
@@ -60,7 +60,7 @@
</span>
{html_options id=language name=language options=$language_options selected=$language_selection}
</li>
-{/if}
+ {/if}
<li>
<span class="property">
<label for="recent_period">{'Recent period'|@translate}</label>
@@ -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}
diff --git a/admin/themes/default/template/user_list.tpl b/admin/themes/default/template/user_list.tpl
index 4458f9792..5bb3f18ed 100644
--- a/admin/themes/default/template/user_list.tpl
+++ b/admin/themes/default/template/user_list.tpl
@@ -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>
diff --git a/admin/user_list.php b/admin/user_list.php
index 425c3c698..8a8396792 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -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');
-
- $true_false_fields = array('expand', 'show_nb_comments',
- 'show_nb_hits', 'enabled_high');
+ $formfields = array(
+ 'nb_image_page', 'theme', 'language',
+ 'recent_period', 'expand', 'show_nb_hits',
+ 'status', 'enabled_high', 'level'
+ );
+
+ $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
diff --git a/comments.php b/comments.php
index b75dc190b..5520e7933 100644
--- a/comments.php
+++ b/comments.php
@@ -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 |
// +-----------------------------------------------------------------------+
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 61c81aa9e..8d2cd050b 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -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
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index 14a96ff9e..c017a5d64 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -257,13 +257,16 @@ function initialize_menu()
'REL'=> 'rel="search"'
);
- // comments link
- $block->data['comments'] =
- array(
- 'TITLE'=>l10n('display last user comments'),
- 'NAME'=>l10n('Comments'),
- 'URL'=> get_root_url().'comments.php',
- );
+ if ($conf['activate_comments'])
+ {
+ // comments link
+ $block->data['comments'] =
+ array(
+ 'TITLE'=>l10n('display last user comments'),
+ 'NAME'=>l10n('Comments'),
+ 'URL'=> get_root_url().'comments.php',
+ );
+ }
// about link
$block->data['about'] =
diff --git a/install/config.sql b/install/config.sql
index 5fdf38fe8..a973bb107 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -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');
diff --git a/install/db/114-database.php b/install/db/114-database.php
new file mode 100644
index 000000000..495e6354f
--- /dev/null
+++ b/install/db/114-database.php
@@ -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"
+;
+?> \ No newline at end of file
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index 250476327..a76c27488 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -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';
diff --git a/language/fr_CA/admin.lang.php b/language/fr_CA/admin.lang.php
index 4da56dc8e..57c054d91 100644
--- a/language/fr_CA/admin.lang.php
+++ b/language/fr_CA/admin.lang.php
@@ -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';
?> \ No newline at end of file
diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php
index 676a7e207..17902f5f1 100644
--- a/language/fr_FR/admin.lang.php
+++ b/language/fr_FR/admin.lang.php
@@ -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';
?> \ No newline at end of file
diff --git a/picture.php b/picture.php
index 7f5878e60..1d35b9613 100644
--- a/picture.php
+++ b/picture.php
@@ -965,7 +965,10 @@ if (isset($picture['next'])
// +-----------------------------------------------------------------------+
include(PHPWG_ROOT_PATH.'include/picture_rate.inc.php');
-include(PHPWG_ROOT_PATH.'include/picture_comment.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');
diff --git a/profile.php b/profile.php
index 01e5c8308..82b4421c8 100644
--- a/profile.php
+++ b/profile.php
@@ -256,8 +256,13 @@ 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',
diff --git a/themes/default/template/profile_content.tpl b/themes/default/template/profile_content.tpl
index 161203362..3f2245523 100644
--- a/themes/default/template/profile_content.tpl
+++ b/themes/default/template/profile_content.tpl
@@ -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}