Permalink
Browse files

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.
  • Loading branch information...
1 parent 1637723 commit 9e0631ab0d222f7e4e438f8add0e900334852857 @bharat bharat committed May 28, 2014
@@ -34,6 +34,8 @@ public function save() {
$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 @@ private function _get_admin_form() {
->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"),
@@ -43,3 +43,7 @@
padding: .2em .6em;
}
+.g-comment-state-unpublished {
+ font-style: italic;
+ color: #999;
+}
@@ -49,6 +49,7 @@ static function install() {
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 @@ static function upgrade($version) {
}
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() {
@@ -81,7 +81,7 @@ public function save() {
// 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
@@ -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"
@@ -1,5 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<li id="g-comment-<?= $comment->id; ?>">
+<li id="g-comment-<?= $comment->id; ?>" class="g-comment-state-<?= $comment->state ?>">
<p class="g-author">
<a href="#">
<img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
@@ -22,4 +22,7 @@ class="g-avatar"
<div>
<?= nl2br(html::purify($comment->text)) ?>
</div>
+ <? if ($comment->state == "unpublished"): ?>
+ <b> <?= t("Your comment is held for moderation. The site moderator will review and publish it.") ?> </b>
+ <? endif ?>
</li>
@@ -25,7 +25,7 @@ class="g-button ui-corner-all ui-icon-left ui-state-default">
<? if ($comments->count()): ?>
<ul>
<? foreach ($comments as $comment): ?>
- <li id="g-comment-<?= $comment->id ?>">
+ <li id="g-comment-<?= $comment->id ?>" class="g-comment-state-<?= $comment->state ?>">
<p class="g-author">
<a href="#">
<img src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
@@ -48,6 +48,9 @@ class="g-avatar"
<div>
<?= nl2br(html::purify($comment->text)) ?>
</div>
+ <? if ($comment->state == "unpublished"): ?>
+ <b> <?= t("Your comment is held for moderation. The site moderator will review and publish it.") ?> </b>
+ <? endif ?>
</li>
<? endforeach ?>
</ul>

1 comment on commit 9e0631a

This is a realy great change, wich helps me and hopfully others a lot.
It also shows me how some things that i didn't understand in the documentation works.
Thank You really much.

Please sign in to comment.