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§ion=';
$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
@@ -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',
@@ -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}
{'Thumbnails'|@translate}
{/if}
{'Maintenance'|@translate}
+{if isset($U_PENDING_COMMENTS)}
{'Pending Comments'|@translate}
+{/if}
{'Updates'|@translate}
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}
+ {if isset($CAT_COMMENTABLE)}
{'Comments'|@translate}
|
{html_radios name='commentable' values='false,true'|@explode output='No,Yes'|@explode|translate selected=$CAT_COMMENTABLE}
|
+ {/if}
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
@@ -181,6 +181,15 @@ jQuery(document).ready(function () {
+{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}
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(){
{$DB_TAGS} ({$DB_IMAGE_TAG})
{$DB_USERS}
{$DB_GROUPS}
+ {if isset($DB_COMMENTS)}
{$DB_COMMENTS}
{if isset($unvalidated)}
({$unvalidated.INFO})
{/if}
+ {/if}
{$DB_RATES}
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 @@
-{if not $SPECIAL_USER}
+ {if not $SPECIAL_USER}
@@ -60,7 +60,7 @@
{html_options id=language name=language options=$language_options selected=$language_selection}
-{/if}
+ {/if}
@@ -71,10 +71,12 @@
{'Expand all albums'|@translate}
{html_radios name='expand' options=$radio_options selected=$EXPAND}
+ {if $ACTIVATE_COMMENTS}
{'Show number of comments'|@translate}
{html_radios name='show_nb_comments' options=$radio_options selected=$NB_COMMENTS}
+ {/if}
{'Show number of hits'|@translate}
{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 @@
+{if $ACTIVATE_COMMENTS}
{'Show number of comments'|@translate} |
@@ -244,6 +245,7 @@
|
+{/if}
{'Show number of hits'|@translate} |
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 @@
+
\ 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.
Click here to show log error.'] = 'Impossible d\'extraire les fichiers. Veuillez vérifier les permissions des fichiers de votre installation.
Cliquez ici pour voir le rapport d\'erreur.';
$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 @@
{'Expand all albums'|@translate}
{html_radios name='expand' options=$radio_options selected=$EXPAND}
+ {if $ACTIVATE_COMMENTS}
{'Show number of comments'|@translate}
{html_radios name='show_nb_comments' options=$radio_options selected=$NB_COMMENTS}
+ {/if}
{'Show number of hits'|@translate}
{html_radios name='show_nb_hits' options=$radio_options selected=$NB_HITS}