2014-05-02 09:40:23 +02:00
|
|
|
<?php
|
|
|
|
class DeleteCommentJob extends AbstractJob
|
|
|
|
{
|
|
|
|
protected $comment;
|
|
|
|
|
|
|
|
public function prepare()
|
|
|
|
{
|
2014-05-03 11:43:29 +02:00
|
|
|
$this->comment = CommentModel::findById($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()
|
|
|
|
{
|
|
|
|
return getConfig()->registration->needEmailForCommenting;
|
|
|
|
}
|
|
|
|
}
|