Closed #57
This commit is contained in:
parent
da63c0fd19
commit
3c41940142
6 changed files with 79 additions and 0 deletions
|
@ -86,6 +86,7 @@ deletePost.own=moderator
|
||||||
deletePost.all=moderator
|
deletePost.all=moderator
|
||||||
featurePost=moderator
|
featurePost=moderator
|
||||||
scorePost=registered
|
scorePost=registered
|
||||||
|
flagPost=registered
|
||||||
|
|
||||||
listUsers=registered
|
listUsers=registered
|
||||||
viewUser=registered
|
viewUser=registered
|
||||||
|
@ -104,6 +105,7 @@ banUser.own=nobody
|
||||||
banUser.all=admin
|
banUser.all=admin
|
||||||
deleteUser.own=registered
|
deleteUser.own=registered
|
||||||
deleteUser.all=nobody
|
deleteUser.all=nobody
|
||||||
|
flagUser=registered
|
||||||
|
|
||||||
listComments=anonymous
|
listComments=anonymous
|
||||||
addComment=registered
|
addComment=registered
|
||||||
|
|
|
@ -474,6 +474,31 @@ class PostController
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @route /post/{id}/flag
|
||||||
|
*/
|
||||||
|
public function flagAction($id)
|
||||||
|
{
|
||||||
|
$post = Model_Post::locate($id);
|
||||||
|
PrivilegesHelper::confirmWithException(Privilege::FlagPost);
|
||||||
|
|
||||||
|
if (InputHelper::get('submit'))
|
||||||
|
{
|
||||||
|
$key = '@' . $post->id;
|
||||||
|
|
||||||
|
if (!isset($_SESSION['flagged']))
|
||||||
|
$_SESSION['flagged'] = [];
|
||||||
|
if (in_array($key, $_SESSION['flagged']))
|
||||||
|
throw new SimpleException('You already flagged this post');
|
||||||
|
$_SESSION['flagged'] []= $key;
|
||||||
|
|
||||||
|
LogHelper::logEvent('post-flag', '**+{user} flagged @{post} for moderator attention**', ['post' => $post->id]);
|
||||||
|
StatusHelper::success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route /post/{id}/hide
|
* @route /post/{id}/hide
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -137,6 +137,32 @@ class UserController
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @route /user/{name}/flag
|
||||||
|
* @validate name [^\/]+
|
||||||
|
*/
|
||||||
|
public function flagAction($name)
|
||||||
|
{
|
||||||
|
$user = Model_User::locate($name);
|
||||||
|
PrivilegesHelper::confirmWithException(Privilege::FlagUser);
|
||||||
|
|
||||||
|
if (InputHelper::get('submit'))
|
||||||
|
{
|
||||||
|
$key = '+' . $user->name;
|
||||||
|
|
||||||
|
if (!isset($_SESSION['flagged']))
|
||||||
|
$_SESSION['flagged'] = [];
|
||||||
|
if (in_array($key, $_SESSION['flagged']))
|
||||||
|
throw new SimpleException('You already flagged this user');
|
||||||
|
$_SESSION['flagged'] []= $key;
|
||||||
|
|
||||||
|
LogHelper::logEvent('user-flag', '**+{user} flagged +{subject} for moderator attention**', ['subject' => $user->name]);
|
||||||
|
StatusHelper::success();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route /user/{name}/ban
|
* @route /user/{name}/ban
|
||||||
* @validate name [^\/]+
|
* @validate name [^\/]+
|
||||||
|
@ -145,15 +171,19 @@ class UserController
|
||||||
{
|
{
|
||||||
$user = Model_User::locate($name);
|
$user = Model_User::locate($name);
|
||||||
PrivilegesHelper::confirmWithException(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($user));
|
PrivilegesHelper::confirmWithException(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($user));
|
||||||
|
|
||||||
if (InputHelper::get('submit'))
|
if (InputHelper::get('submit'))
|
||||||
{
|
{
|
||||||
$user->banned = true;
|
$user->banned = true;
|
||||||
R::store($user);
|
R::store($user);
|
||||||
|
|
||||||
LogHelper::logEvent('ban', '+{user} banned +{subject}', ['subject' => $user->name]);
|
LogHelper::logEvent('ban', '+{user} banned +{subject}', ['subject' => $user->name]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route /post/{name}/unban
|
* @route /post/{name}/unban
|
||||||
* @validate name [^\/]+
|
* @validate name [^\/]+
|
||||||
|
@ -162,15 +192,19 @@ class UserController
|
||||||
{
|
{
|
||||||
$user = Model_User::locate($name);
|
$user = Model_User::locate($name);
|
||||||
PrivilegesHelper::confirmWithException(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($user));
|
PrivilegesHelper::confirmWithException(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($user));
|
||||||
|
|
||||||
if (InputHelper::get('submit'))
|
if (InputHelper::get('submit'))
|
||||||
{
|
{
|
||||||
$user->banned = false;
|
$user->banned = false;
|
||||||
R::store($user);
|
R::store($user);
|
||||||
|
|
||||||
LogHelper::logEvent('unban', '+{user} unbanned +{subject}', ['subject' => $user->name]);
|
LogHelper::logEvent('unban', '+{user} unbanned +{subject}', ['subject' => $user->name]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @route /post/{name}/accept-registration
|
* @route /post/{name}/accept-registration
|
||||||
* @validate name [^\/]+
|
* @validate name [^\/]+
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Privilege extends Enum
|
||||||
const DeletePost = 10;
|
const DeletePost = 10;
|
||||||
const FeaturePost = 25;
|
const FeaturePost = 25;
|
||||||
const ScorePost = 31;
|
const ScorePost = 31;
|
||||||
|
const FlagPost = 34;
|
||||||
|
|
||||||
const ListUsers = 11;
|
const ListUsers = 11;
|
||||||
const ViewUser = 12;
|
const ViewUser = 12;
|
||||||
|
@ -27,6 +28,7 @@ class Privilege extends Enum
|
||||||
const ChangeUserName = 18;
|
const ChangeUserName = 18;
|
||||||
const ChangeUserSettings = 28;
|
const ChangeUserSettings = 28;
|
||||||
const DeleteUser = 19;
|
const DeleteUser = 19;
|
||||||
|
const FlagUser = 35;
|
||||||
|
|
||||||
const ListComments = 20;
|
const ListComments = 20;
|
||||||
const AddComment = 23;
|
const AddComment = 23;
|
||||||
|
|
|
@ -247,6 +247,14 @@
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if (PrivilegesHelper::confirm(Privilege::FlagPost)): ?>
|
||||||
|
<li class="flag">
|
||||||
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'flag', ['id' => $this->context->transport->post->id]) ?>" data-confirm-text="Are you sure you want to flag this post?">
|
||||||
|
Flag for moderator attention
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (PrivilegesHelper::confirm(Privilege::DeletePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->uploader))): ?>
|
<?php if (PrivilegesHelper::confirm(Privilege::DeletePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->uploader))): ?>
|
||||||
<li class="delete">
|
<li class="delete">
|
||||||
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'delete', ['id' => $this->context->transport->post->id]) ?>" data-confirm-text="Are you sure you want to delete this post?" data-redirect-url="<?php echo \Chibi\UrlHelper::route('post', 'list') ?>">
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'delete', ['id' => $this->context->transport->post->id]) ?>" data-confirm-text="Are you sure you want to delete this post?" data-redirect-url="<?php echo \Chibi\UrlHelper::route('post', 'list') ?>">
|
||||||
|
|
|
@ -65,6 +65,14 @@
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if (PrivilegesHelper::confirm(Privilege::FlagUser)): ?>
|
||||||
|
<li class="flag">
|
||||||
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('user', 'flag', ['name' => $this->context->transport->user->name]) ?>" data-confirm-text="Are you sure you want to flag this user?">
|
||||||
|
Flag for moderator attention
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (PrivilegesHelper::confirm(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
|
<?php if (PrivilegesHelper::confirm(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
|
||||||
<?php if (!$this->context->transport->user->banned): ?>
|
<?php if (!$this->context->transport->user->banned): ?>
|
||||||
<li class="ban">
|
<li class="ban">
|
||||||
|
|
Loading…
Reference in a new issue