diff --git a/data/config.ini b/data/config.ini index bbbda47d..a9daccd9 100644 --- a/data/config.ini +++ b/data/config.ini @@ -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 diff --git a/src/Models/SearchServices/PostSearchService.php b/src/Models/SearchServices/PostSearchService.php index d5e2c0d0..40e03741 100644 --- a/src/Models/SearchServices/PostSearchService.php +++ b/src/Models/SearchServices/PostSearchService.php @@ -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';