szurubooru/src/Jobs/DeleteCommentJob.php

41 lines
784 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::findById($this->getArgument(JobArgs::COMMENT_ID));
}
public function execute()
{
$post = $this->comment->getPost();
CommentModel::remove($this->comment);
LogHelper::log('{user} removed comment from {post}', [
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
'post' => TextHelper::reprPost($post)]);
}
public function requiresPrivilege()
{
return
[
Privilege::DeleteComment,
Access::getIdentity($this->comment->getCommenter())
];
}
public function requiresAuthentication()
{
return true;
}
public function requiresConfirmedEmail()
{
return getConfig()->registration->needEmailForCommenting;
}
}