From b4992926a1ee7bd4da9e4d75e57fa5cfefc8ec06 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 3 Oct 2014 21:14:58 +0200 Subject: [PATCH] Added autohiding disliked posts to post searching --- TODO | 1 - src/Controllers/PostController.php | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 9de4a115..928eb5bd 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ everything related to posts: - post listing - better thumbnail loading - comment count - - regard disliked settings - search filters - comment:rr- - comment_count: 3..5 diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index c9c60be7..77060985 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -158,11 +158,12 @@ final class PostController extends AbstractController private function decorateFilterFromBrowsingSettings($filter) { - $userSettings = $this->authService->getLoggedInUser()->getBrowsingSettings(); + $currentUser = $this->authService->getLoggedInUser(); + $userSettings = $currentUser->getBrowsingSettings(); if (!$userSettings) return; - if ($userSettings->listPosts and !count($filter->getRequirementsByType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_SAFETY))) + if (!empty($userSettings->listPosts) and !count($filter->getRequirementsByType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_SAFETY))) { $values = []; if (!\Szurubooru\Helpers\TypeHelper::toBool($userSettings->listPosts->safe)) @@ -182,5 +183,16 @@ final class PostController extends AbstractController $filter->addRequirement($requirement); } } + + if (!empty($userSettings->hideDownvoted) and !count($filter->getRequirementsByType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_USER_SCORE))) + { + $requirementValue = new \Szurubooru\SearchServices\Requirements\RequirementCompositeValue(); + $requirementValue->setValues([$currentUser->getName(), -1]); + $requirement = new \Szurubooru\SearchServices\Requirements\Requirement(); + $requirement->setType(\Szurubooru\SearchServices\Filters\PostFilter::REQUIREMENT_USER_SCORE); + $requirement->setValue($requirementValue); + $requirement->setNegated(true); + $filter->addRequirement($requirement); + } } }