mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #45 from tractorcow/3.1-fix-hide-spam
BUG Hide spam comments
This commit is contained in:
commit
0401c57973
@ -52,8 +52,6 @@ class CommentsExtension extends DataExtension {
|
|||||||
* @return PaginatedList
|
* @return PaginatedList
|
||||||
*/
|
*/
|
||||||
public function Comments() {
|
public function Comments() {
|
||||||
$controller = Controller::curr();
|
|
||||||
|
|
||||||
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
|
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
|
||||||
|
|
||||||
$list = Comment::get()->filter(array(
|
$list = Comment::get()->filter(array(
|
||||||
@ -61,11 +59,15 @@ class CommentsExtension extends DataExtension {
|
|||||||
'BaseClass' => $this->ownerBaseClass
|
'BaseClass' => $this->ownerBaseClass
|
||||||
))->sort($order);
|
))->sort($order);
|
||||||
|
|
||||||
// has moderation been turned on if it has amend the DataList
|
// Filter content for unauthorised users
|
||||||
if (Commenting::get_config_value($this->ownerBaseClass, 'require_moderation')) {
|
if (!($member = Member::currentUser()) || !Permission::checkMember($member, 'CMS_ACCESS_CommentAdmin')) {
|
||||||
|
|
||||||
if (Member::currentUser() == false) {
|
// Filter unmoderated comments for non-administrators if moderation is enabled
|
||||||
|
if (Commenting::get_config_value($this->ownerBaseClass, 'require_moderation')) {
|
||||||
$list = $list->filter('Moderated', 1);
|
$list = $list->filter('Moderated', 1);
|
||||||
|
} else {
|
||||||
|
// Filter spam comments for non-administrators if auto-moderted
|
||||||
|
$list = $list->filter('IsSpam', 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user