szurubooru/src/Api/Jobs/CommentJobs/DeleteCommentJob.php

45 lines
903 B
PHP
Raw Normal View History

2014-05-02 09:40:23 +02:00
<?php
class DeleteCommentJob extends AbstractJob
2014-05-02 09:40:23 +02:00
{
protected $commentRetriever;
public function __construct()
{
$this->commentRetriever = new CommentRetriever($this);
}
2014-05-02 09:40:23 +02:00
public function execute()
{
$comment = $this->commentRetriever->retrieve();
$post = $comment->getPost();
2014-05-02 09:40:23 +02:00
CommentModel::remove($comment);
2014-05-02 09:40:23 +02:00
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 getRequiredArguments()
2014-05-12 10:31:34 +02:00
{
return $this->commentRetriever->getRequiredArguments();
2014-05-12 10:31:34 +02:00
}
public function getRequiredPrivileges()
2014-05-02 09:40:23 +02:00
{
2014-05-04 16:27:15 +02:00
return new Privilege(
2014-05-02 09:40:23 +02:00
Privilege::DeleteComment,
Access::getIdentity($this->commentRetriever->retrieve()->getCommenter()));
2014-05-02 09:40:23 +02:00
}
2014-05-12 10:31:34 +02:00
public function isAuthenticationRequired()
2014-05-02 09:40:23 +02:00
{
return true;
}
2014-05-12 10:31:34 +02:00
public function isConfirmedEmailRequired()
2014-05-02 09:40:23 +02:00
{
2014-05-06 13:06:42 +02:00
return false;
2014-05-02 09:40:23 +02:00
}
}