More capable privilege system
Following privileges for post actions can now understand different settings for everyone and for uploader: * Scoring posts * Featuring posts * Flagging posts * Favoriting posts Additionally, privilege for flagging users can now understand different settings for everyone and for the user that is currently logged in. In other words: with this update admin can configure privileges so that scoring own posts or flagging oneself will be prohibited, while scoring other people's posts or flagging others will be okay.
This commit is contained in:
parent
28037af029
commit
2bac28a553
5 changed files with 14 additions and 17 deletions
|
@ -86,14 +86,11 @@ editPostThumb=moderator
|
|||
editPostSource=moderator
|
||||
editPostRelations.own=registered
|
||||
editPostRelations.all=moderator
|
||||
editPostFile.all=moderator
|
||||
editPostFile.own=moderator
|
||||
editPostFile=moderator
|
||||
massTag.own=registered
|
||||
massTag.all=power-user
|
||||
hidePost.own=moderator
|
||||
hidePost.all=moderator
|
||||
deletePost.own=moderator
|
||||
deletePost.all=moderator
|
||||
hidePost=moderator
|
||||
deletePost=moderator
|
||||
featurePost=moderator
|
||||
scorePost=registered
|
||||
flagPost=registered
|
||||
|
|
|
@ -254,7 +254,7 @@ class PostController
|
|||
public function flagAction($id)
|
||||
{
|
||||
$post = PostModel::findByIdOrName($id);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FlagPost);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FlagPost, PrivilegesHelper::getIdentitySubPrivilege($post->getUploader()));
|
||||
|
||||
if (InputHelper::get('submit'))
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ class PostController
|
|||
public function addFavoriteAction($id)
|
||||
{
|
||||
$post = PostModel::findByIdOrName($id);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FavoritePost);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FavoritePost, PrivilegesHelper::getIdentitySubPrivilege($post->getUploader()));
|
||||
|
||||
if (InputHelper::get('submit'))
|
||||
{
|
||||
|
@ -358,7 +358,7 @@ class PostController
|
|||
public function remFavoriteAction($id)
|
||||
{
|
||||
$post = PostModel::findByIdOrName($id);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FavoritePost);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FavoritePost, PrivilegesHelper::getIdentitySubPrivilege($post->getUploader()));
|
||||
|
||||
if (InputHelper::get('submit'))
|
||||
{
|
||||
|
@ -379,7 +379,7 @@ class PostController
|
|||
public function scoreAction($id, $score)
|
||||
{
|
||||
$post = PostModel::findByIdOrName($id);
|
||||
PrivilegesHelper::confirmWithException(Privilege::ScorePost);
|
||||
PrivilegesHelper::confirmWithException(Privilege::ScorePost, PrivilegesHelper::getIdentitySubPrivilege($post->getUploader()));
|
||||
|
||||
if (InputHelper::get('submit'))
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ class PostController
|
|||
public function featureAction($id)
|
||||
{
|
||||
$post = PostModel::findByIdOrName($id);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FeaturePost);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FeaturePost, PrivilegesHelper::getIdentitySubPrivilege($post->getUploader()));
|
||||
PropertyModel::set(PropertyModel::FeaturedPostId, $post->id);
|
||||
PropertyModel::set(PropertyModel::FeaturedPostDate, time());
|
||||
PropertyModel::set(PropertyModel::FeaturedPostUserName, $this->context->user->name);
|
||||
|
|
|
@ -140,7 +140,7 @@ class UserController
|
|||
public function flagAction($name)
|
||||
{
|
||||
$user = UserModel::findByNameOrEmail($name);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FlagUser);
|
||||
PrivilegesHelper::confirmWithException(Privilege::FlagUser, PrivilegesHelper::getIdentitySubPrivilege($user));
|
||||
|
||||
if (InputHelper::get('submit'))
|
||||
{
|
||||
|
|
|
@ -130,7 +130,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<span class="value">
|
||||
<?php echo $this->context->transport->post->score ?>
|
||||
|
||||
<?php if (PrivilegesHelper::confirm(Privilege::ScorePost)): ?>
|
||||
<?php if (PrivilegesHelper::confirm(Privilege::ScorePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader()))): ?>
|
||||
[
|
||||
<?php $scoreLink = function($score) { return \Chibi\UrlHelper::route('post', 'score', ['id' => $this->context->transport->post->id, 'score' => $score]); } ?>
|
||||
|
||||
|
@ -173,7 +173,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (PrivilegesHelper::confirm(Privilege::FavoritePost)): ?>
|
||||
<?php if (PrivilegesHelper::confirm(Privilege::FavoritePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader()))): ?>
|
||||
<div class="hl-option">
|
||||
<?php if (!$this->context->favorite): ?>
|
||||
<a class="add-fav icon simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'add-favorite', ['id' => $this->context->transport->post->id]) ?>">
|
||||
|
@ -232,7 +232,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<?php
|
||||
$options = [];
|
||||
|
||||
if (PrivilegesHelper::confirm(Privilege::FeaturePost))
|
||||
if (PrivilegesHelper::confirm(Privilege::FeaturePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
|
||||
{
|
||||
$options []=
|
||||
[
|
||||
|
@ -244,7 +244,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
];
|
||||
}
|
||||
|
||||
if (PrivilegesHelper::confirm(Privilege::FlagPost))
|
||||
if (PrivilegesHelper::confirm(Privilege::FlagPost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->getUploader())))
|
||||
{
|
||||
if ($this->context->flagged)
|
||||
{
|
||||
|
|
|
@ -86,7 +86,7 @@ LayoutHelper::addStylesheet('user-view.css');
|
|||
];
|
||||
}
|
||||
|
||||
if (PrivilegesHelper::confirm(Privilege::FlagUser))
|
||||
if (PrivilegesHelper::confirm(Privilege::FlagUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user)))
|
||||
{
|
||||
if ($this->context->flagged)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue