BUG Unless moderation has been explicitly done on a comment, spam comments should not be shown to those who cannot authorise comments

This commit is contained in:
Damian Mooyman 2013-01-17 14:45:47 +13:00
parent dda00c5452
commit fc03b89d0f

View File

@ -52,8 +52,6 @@ class CommentsExtension extends DataExtension {
* @return PaginatedList
*/
public function Comments() {
$controller = Controller::curr();
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
$list = Comment::get()->filter(array(
@ -61,11 +59,15 @@ class CommentsExtension extends DataExtension {
'BaseClass' => $this->ownerBaseClass
))->sort($order);
// has moderation been turned on if it has amend the DataList
if (Commenting::get_config_value($this->ownerBaseClass, 'require_moderation')) {
// Filter content for unauthorised users
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);
} else {
// Filter spam comments for non-administrators if auto-moderted
$list = $list->filter('IsSpam', 0);
}
}