From 28037af029b3b5d53d88bba0c8aa20830dabfecb Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 20 Feb 2014 18:44:51 +0100 Subject: [PATCH] Registered users can mass tag their own posts --- data/config.ini | 3 ++- src/Controllers/PostController.php | 5 ++++- src/Helpers/PrivilegesHelper.php | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/data/config.ini b/data/config.ini index dfcb0387..04af9432 100644 --- a/data/config.ini +++ b/data/config.ini @@ -88,6 +88,8 @@ editPostRelations.own=registered editPostRelations.all=moderator editPostFile.all=moderator editPostFile.own=moderator +massTag.own=registered +massTag.all=power-user hidePost.own=moderator hidePost.all=moderator deletePost.own=moderator @@ -125,7 +127,6 @@ editComment.all=admin listTags=anonymous mergeTags=moderator renameTags=moderator -massTag=moderator listLogs=moderator viewLog=moderator diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 93b7be2b..f0b28a37 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -73,6 +73,9 @@ class PostController PrivilegesHelper::confirmWithException(Privilege::MassTag); $this->context->massTagTag = $additionalInfo; $this->context->massTagQuery = $query; + + if (!PrivilegesHelper::confirm(Privilege::MassTag, 'all')) + $query = trim($query . ' submit:' . $this->context->user->name); } $posts = PostSearchService::getEntities($query, $postsPerPage, $page); @@ -104,7 +107,7 @@ class PostController if (InputHelper::get('submit')) { - PrivilegesHelper::confirmWithException(Privilege::MassTag); + PrivilegesHelper::confirmWithException(Privilege::MassTag, PrivilegesHelper::getIdentitySubPrivilege($post->getUploader())); $tags = $post->getTags(); diff --git a/src/Helpers/PrivilegesHelper.php b/src/Helpers/PrivilegesHelper.php index 19a48f62..2e2a7654 100644 --- a/src/Helpers/PrivilegesHelper.php +++ b/src/Helpers/PrivilegesHelper.php @@ -17,6 +17,12 @@ class PrivilegesHelper $minAccessRank = TextHelper::resolveConstant($minAccessRankName, 'AccessRank'); self::$privileges[$key] = $minAccessRank; + + if (!isset(self::$privileges[$privilegeName]) or + self::$privileges[$privilegeName] > $minAccessRank) + { + self::$privileges[$privilegeName] = $minAccessRank; + } } } @@ -48,9 +54,7 @@ class PrivilegesHelper public static function confirmWithException($privilege, $subPrivilege = null) { if (!self::confirm($privilege, $subPrivilege)) - { throw new SimpleException('Insufficient privileges'); - } } public static function getIdentitySubPrivilege($user)