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=anonymous
listPosts.sketchy=registered listPosts.sketchy=registered
listPosts.unsafe=registered listPosts.unsafe=registered
listPosts.hidden=nobody listPosts.hidden=admin
viewPost=anonymous viewPost=anonymous
viewPost.sketchy=registered viewPost.sketchy=registered
viewPost.unsafe=registered viewPost.unsafe=registered

View file

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