szurubooru/src/Api/Jobs/DeleteCommentJob.php
2014-05-07 17:58:23 +02:00

38 lines
742 B
PHP

<?php
class DeleteCommentJob extends AbstractJob
{
protected $comment;
public function prepare()
{
$this->comment = CommentModel::findById($this->getArgument(self::COMMENT_ID));
}
public function execute()
{
$post = $this->comment->getPost();
CommentModel::remove($this->comment);
Logger::log('{user} removed comment from {post}', [
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
'post' => TextHelper::reprPost($post)]);
}
public function requiresPrivilege()
{
return new Privilege(
Privilege::DeleteComment,
Access::getIdentity($this->comment->getCommenter()));
}
public function requiresAuthentication()
{
return true;
}
public function requiresConfirmedEmail()
{
return false;
}
}