Merge pull request #64 from catcherdev/master

NEW Add require_moderation_nonmembers for non-members only
This commit is contained in:
Will Rossiter 2013-06-05 01:22:38 -07:00
commit df64d7d098
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 'comments_holder_id' => "comments-holder", // id for the comments holder
'comment_permalink_prefix' => "comment-", // id prefix for each comment. If needed make this different 'comment_permalink_prefix' => "comment-", // id prefix for each comment. If needed make this different
'require_moderation' => false, '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' => false, // allow for sanitized HTML in comments
'html_allowed_elements' => array('a', 'img', 'i', 'b'), 'html_allowed_elements' => array('a', 'img', 'i', 'b'),
'use_preview' => false, // preview formatted comment (when allowing HTML). Requires include_js=true '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( $form->loadDataFrom(array(
"Name" => isset($data['Name']) ? $data['Name'] : '', "Name" => isset($data['Name']) ? $data['Name'] : '',
"URL" => isset($data['URL']) ? $data['URL'] : '', "URL" => isset($data['URL']) ? $data['URL'] : '',
"Email" => isset($data['Email']) ? $data['Email'] : '', "Email" => isset($data['Email']) ? $data['Email'] : ''
"Comment" => Cookie::get('CommentsForm_Comment')
)); ));
// 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) { if($member) {
@ -397,6 +401,10 @@ class CommentingController extends Controller {
// is moderation turned on // is moderation turned on
$moderated = Commenting::get_config_value($class, 'require_moderation'); $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 // we want to show a notification if comments are moderated
if ($moderated) { if ($moderated) {

View File

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