From 9e0631ab0d222f7e4e438f8add0e900334852857 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 28 May 2014 14:54:02 -0400 Subject: [PATCH] Provide a "default moderate" option for comments. The default behavior is unchanged, but you now have the option to set all new comments to be unpublished and then moderate them through the Admin > Content > Comments interface. Fixes #2126. --- modules/comment/controllers/admin_comments.php | 7 +++++++ modules/comment/css/comment.css | 4 ++++ modules/comment/helpers/comment_installer.php | 6 ++++++ modules/comment/models/comment.php | 2 +- modules/comment/module.info | 2 +- modules/comment/views/comment.html.php | 5 ++++- modules/comment/views/comments.html.php | 5 ++++- 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php index 30183402..a397221a 100644 --- a/modules/comment/controllers/admin_comments.php +++ b/modules/comment/controllers/admin_comments.php @@ -34,6 +34,8 @@ class Admin_Comments_Controller extends Admin_Controller { $form->comment_settings->access_permissions->value); module::set_var("comment", "rss_visible", $form->comment_settings->rss_visible->value); + module::set_var("comment", "initial_state", + $form->comment_settings->initial_state->value); message::success(t("Comment settings updated")); url::redirect("admin/comments"); } @@ -47,6 +49,11 @@ class Admin_Comments_Controller extends Admin_Controller { ->options(array("everybody" => t("Everybody"), "registered_users" => t("Only registered users"))) ->selected(module::get_var("comment", "access_permissions")); + $comment_settings->dropdown("initial_state") + ->label(t("Are new comments published or unpublished by default?")) + ->options(array("published" => t("Published"), + "unpublished" => t("Unpublished"))) + ->selected(module::get_var("comment", "initial_state")); $comment_settings->dropdown("rss_visible") ->label(t("Which RSS feeds can users see?")) ->options(array("all" => t("All comment feeds"), diff --git a/modules/comment/css/comment.css b/modules/comment/css/comment.css index db096f2d..0bbd471f 100644 --- a/modules/comment/css/comment.css +++ b/modules/comment/css/comment.css @@ -43,3 +43,7 @@ padding: .2em .6em; } +.g-comment-state-unpublished { + font-style: italic; + color: #999; +} diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 136f96ef..476c4a1a 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -49,6 +49,7 @@ class comment_installer { module::set_var("comment", "spam_caught", 0); module::set_var("comment", "access_permissions", "everybody"); module::set_var("comment", "rss_visible", "all"); + module::set_var("comment", "initial_state", "published"); } static function upgrade($version) { @@ -99,6 +100,11 @@ class comment_installer { } module::set_version("comment", $version = 7); } + + if ($version == 7) { + module::set_var("comment", "initial_state", "published"); + module::set_version("comment", $version = 8); + } } static function uninstall() { diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index 62ab8bc9..5507f8af 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -81,7 +81,7 @@ class Comment_Model_Core extends ORM { // New comment $this->created = $this->updated; if (empty($this->state)) { - $this->state = "published"; + $this->state = module::get_var("comment", "initial_state"); } // These values are useful for spam fighting, so save them with the comment. It's painful to diff --git a/modules/comment/module.info b/modules/comment/module.info index b69379fa..c7242d7d 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,6 +1,6 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." -version = 7 +version = 8 author_name = "Gallery Team" author_url = "http://codex.galleryproject.org/Gallery:Team" info_url = "http://codex.galleryproject.org/Gallery3:Modules:comment" diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php index 263e5f97..505bfb2f 100644 --- a/modules/comment/views/comment.html.php +++ b/modules/comment/views/comment.html.php @@ -1,5 +1,5 @@ -
  • +
  • " @@ -22,4 +22,7 @@

    text)) ?>
    + state == "unpublished"): ?> + +
  • diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php index b524f5da..80072a33 100644 --- a/modules/comment/views/comments.html.php +++ b/modules/comment/views/comments.html.php @@ -25,7 +25,7 @@ count()): ?>