szurubooru/src/Api/Jobs/PreviewCommentJob.php
2014-05-05 17:47:30 +02:00

30 lines
604 B
PHP

<?php
class PreviewCommentJob extends AbstractJob
{
public function execute()
{
$user = Auth::getCurrentUser();
$text = CommentModel::validateText($this->getArgument(self::TEXT));
$comment = CommentModel::spawn();
$comment->setCommenter($user);
$comment->commentDate = time();
$comment->text = $text;
return $comment;
}
public function requiresPrivilege()
{
return new Privilege(Privilege::AddComment);
}
public function requiresAuthentication()
{
return true;
}
public function requiresConfirmedEmail()
{
return getConfig()->registration->needEmailForCommenting;
}
}