2014-05-03 14:20:48 +02:00
|
|
|
<?php
|
2014-05-04 17:53:40 +02:00
|
|
|
class EditPostContentJob extends AbstractPostEditJob
|
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-04 17:53:40 +02:00
|
|
|
if (!$this->skipSaving)
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|