szurubooru/src/Jobs/EditPostContentJob.php

40 lines
746 B
PHP
Raw Normal View History

2014-05-03 14:20:48 +02:00
<?php
class EditPostContentJob extends AbstractPostEditJob
{
2014-05-03 18:09:31 +02:00
const POST_CONTENT = 'post-content';
2014-05-03 14:20:48 +02:00
public function execute()
{
2014-05-03 18:09:31 +02:00
$post = $this->post;
$file = $this->getArgument(self::POST_CONTENT);
2014-05-03 14:20:48 +02:00
2014-05-03 18:09:31 +02:00
$post->setContentFromPath($file->filePath, $file->fileName);
2014-05-03 14:20:48 +02:00
2014-05-03 18:09:31 +02:00
PostModel::save($post);
2014-05-03 14:20:48 +02:00
LogHelper::log('{user} changed contents of {post}', [
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
2014-05-03 18:09:31 +02:00
'post' => TextHelper::reprPost($post)]);
2014-05-03 14:20:48 +02:00
2014-05-03 18:09:31 +02:00
return $post;
2014-05-03 14:20:48 +02:00
}
public function requiresPrivilege()
{
return
[
Privilege::EditPostFile,
Access::getIdentity($this->post->getUploader())
];
}
public function requiresAuthentication()
{
return false;
}
public function requiresConfirmedEmail()
{
return false;
}
}