mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #64 from catcherdev/master
NEW Add require_moderation_nonmembers for non-members only
This commit is contained in:
commit
df64d7d098
@ -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
|
||||
@ -80,7 +81,7 @@ class Commenting {
|
||||
* @return bool
|
||||
*/
|
||||
public static function has_commenting($class) {
|
||||
return (isset(self::$enabled_classes[$class]));
|
||||
return (isset(self::$enabled_classes[$class]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,13 +345,17 @@ 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) {
|
||||
$form->loadDataFrom($member);
|
||||
$form->loadDataFrom($member);
|
||||
}
|
||||
|
||||
// hook to allow further extensions to alter the comments form
|
||||
@ -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) {
|
||||
|
@ -58,13 +58,13 @@ class CommentsExtension extends DataExtension {
|
||||
// Filter content for unauthorised users
|
||||
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')) {
|
||||
$list = $list->filter('Moderated', 1);
|
||||
} else {
|
||||
// Filter spam comments for non-administrators if auto-moderted
|
||||
$list = $list->filter('IsSpam', 0);
|
||||
}
|
||||
// Filter unmoderated comments for non-administrators if moderation is enabled
|
||||
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
|
||||
$list = $list->filter('IsSpam', 0);
|
||||
}
|
||||
}
|
||||
|
||||
$list = new PaginatedList($list);
|
||||
|
Loading…
Reference in New Issue
Block a user