szurubooru/src/Api/Jobs/DeleteCommentJob.php

39 lines
741 B
PHP
Raw Normal View History

2014-05-02 09:40:23 +02:00
<?php
class DeleteCommentJob extends AbstractJob
{
protected $comment;
public function prepare()
{
$this->comment = CommentModel::getById($this->getArgument(self::COMMENT_ID));
2014-05-02 09:40:23 +02:00
}
public function execute()
{
$post = $this->comment->getPost();
CommentModel::remove($this->comment);
2014-05-04 19:23:09 +02:00
Logger::log('{user} removed comment from {post}', [
2014-05-02 09:40:23 +02:00
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
'post' => TextHelper::reprPost($post)]);
}
public function requiresPrivilege()
{
2014-05-04 16:27:15 +02:00
return new Privilege(
2014-05-02 09:40:23 +02:00
Privilege::DeleteComment,
2014-05-04 16:27:15 +02:00
Access::getIdentity($this->comment->getCommenter()));
2014-05-02 09:40:23 +02:00
}
public function requiresAuthentication()
{
return true;
}
public function requiresConfirmedEmail()
{
2014-05-06 13:06:42 +02:00
return false;
2014-05-02 09:40:23 +02:00
}
}