This commit is contained in:
Marcin Kurczewski 2014-02-01 09:51:37 +01:00
parent d2946e0148
commit d085ffe39a
2 changed files with 7 additions and 11 deletions

View file

@ -71,7 +71,7 @@ uploadPost=registered
listPosts=anonymous
listPosts.sketchy=registered
listPosts.unsafe=registered
listPosts.hidden=nobody
listPosts.hidden=admin
viewPost=anonymous
viewPost.sketchy=registered
viewPost.unsafe=registered

View file

@ -17,14 +17,6 @@ class PostSearchService extends AbstractSearchService
$sqlQuery->raw('safety')->in()->genSlots($allowedSafety)->put($allowedSafety);
}
protected static function filterUserHidden(SqlQuery $sqlQuery)
{
if (!PrivilegesHelper::confirm(Privilege::ListPosts, 'hidden'))
$sqlQuery->not('hidden');
else
$sqlQuery->raw('1');
}
protected static function filterChain(SqlQuery $sqlQuery)
{
if (isset($sqlQuery->__chained))
@ -144,6 +136,10 @@ class PostSearchService extends AbstractSearchService
->close();
break;
case 'hidden':
$sqlQuery->raw('hidden');
break;
default:
throw new SimpleException('Unknown special "' . $val . '"');
}
@ -415,8 +411,6 @@ class PostSearchService extends AbstractSearchService
self::filterChain($sqlQuery);
self::filterUserSafety($sqlQuery);
self::filterChain($sqlQuery);
self::filterUserHidden($sqlQuery);
/* query tokens */
$tokens = array_filter(array_unique(explode(' ', $searchQuery)), function($x) { return $x != ''; });
@ -425,6 +419,8 @@ class PostSearchService extends AbstractSearchService
if (\Chibi\Registry::getContext()->user->hasEnabledHidingDislikedPosts())
$tokens []= '-special:disliked';
if (!PrivilegesHelper::confirm(Privilege::ListPosts, 'hidden') or !in_array('special:hidden', $tokens))
$tokens []= '-special:hidden';
$searchContext = new StdClass;
$searchContext->orderColumn = 'id';