-added config option 'require_moderation_nonmembers' - when set, only comments posted by non-members will require moderation

-comment bodies now populate with previous value after validation errors (i.e. spam protection)
This commit is contained in:
catcher 2013-06-04 14:12:16 -06:00
parent 07123cfcfc
commit a5e00eccd7
3 changed files with 25 additions and 16 deletions

View File

@ -36,6 +36,7 @@ class Commenting {
'comments_holder_id' => "comments-holder", // id for the comments holder
'comment_permalink_prefix' => "comment-", // id prefix for each comment. If needed make this different
'require_moderation' => false,
'require_moderation_nonmembers' => false, // requires moderation for comments posted by non-members. 'require_moderation' overrides this if set.
'html_allowed' => false, // allow for sanitized HTML in comments
'html_allowed_elements' => array('a', 'img', 'i', 'b'),
'use_preview' => false, // preview formatted comment (when allowing HTML). Requires include_js=true

View File

@ -345,9 +345,13 @@ class CommentingController extends Controller {
$form->loadDataFrom(array(
"Name" => isset($data['Name']) ? $data['Name'] : '',
"URL" => isset($data['URL']) ? $data['URL'] : '',
"Email" => isset($data['Email']) ? $data['Email'] : '',
"Comment" => Cookie::get('CommentsForm_Comment')
"Email" => isset($data['Email']) ? $data['Email'] : ''
));
// allow previous value to fill if comment not stored in cookie (i.e. validation error)
$prevComment = Cookie::get('CommentsForm_Comment');
if($prevComment && $prevComment != ''){
$form->loadDataFrom(array("Comment" => $prevComment));
}
}
if($member) {
@ -397,6 +401,10 @@ class CommentingController extends Controller {
// is moderation turned on
$moderated = Commenting::get_config_value($class, 'require_moderation');
if(!$moderated){
$moderated_nonmembers = Commenting::get_config_value($class, 'require_moderation_nonmembers');
$moderated = $moderated_nonmembers ? !Member::currentUser() : false;
}
// we want to show a notification if comments are moderated
if ($moderated) {

View File

@ -59,7 +59,7 @@ class CommentsExtension extends DataExtension {
if (!($member = Member::currentUser()) || !Permission::checkMember($member, 'CMS_ACCESS_CommentAdmin')) {
// Filter unmoderated comments for non-administrators if moderation is enabled
if (Commenting::get_config_value($this->ownerBaseClass, 'require_moderation')) {
if (Commenting::get_config_value($this->ownerBaseClass, 'require_moderation') || Commenting::get_config_value($this->ownerBaseClass, 'require_moderation_nonmembers')) {
$list = $list->filter('Moderated', 1);
} else {
// Filter spam comments for non-administrators if auto-moderted