From 56622b8e9d5d859a0a9a022c7da871e8d7fc676a Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 4 Jan 2014 12:55:59 +0100 Subject: [PATCH] Last comments respect safety choice --- src/Models/SearchServices/CommentSearchService.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Models/SearchServices/CommentSearchService.php b/src/Models/SearchServices/CommentSearchService.php index f4a606ee..ac6a7e48 100644 --- a/src/Models/SearchServices/CommentSearchService.php +++ b/src/Models/SearchServices/CommentSearchService.php @@ -5,9 +5,17 @@ class CommentSearchService extends AbstractSearchService { $sqlQuery ->from('comment') - ->where('post_id') - ->is()->not('NULL') - ->orderBy('id') + ->innerJoin('post') + ->on('post_id = post.id'); + + $allowedSafety = PrivilegesHelper::getAllowedSafety(); + if (empty($allowedSafety)) + $sqlQuery->where('0'); + else + $sqlQuery->where('post.safety')->in()->genSlots($allowedSafety)->put($allowedSafety); + + $sqlQuery + ->orderBy('comment.id') ->desc(); } }