Added autohiding disliked posts to post searching

This commit is contained in:
Marcin Kurczewski 2014-10-03 21:14:58 +02:00
parent 0e59147423
commit b4992926a1
2 changed files with 14 additions and 3 deletions

1
TODO
View file

@ -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

View file

@ -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);
}
}
}