szurubooru/src/Api/Jobs/EditPostContentJob.php

28 lines
620 B
PHP
Raw Normal View History

2014-05-03 14:20:48 +02:00
<?php
2014-05-03 22:18:41 +02:00
class EditPostContentJob extends AbstractPostJob
2014-05-03 14:20:48 +02:00
{
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()
{
2014-05-04 16:27:15 +02:00
return new Privilege(
2014-05-03 14:20:48 +02:00
Privilege::EditPostFile,
2014-05-04 16:27:15 +02:00
Access::getIdentity($this->post->getUploader()));
2014-05-03 14:20:48 +02:00
}
}