This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Api/Jobs/EditPostContentJob.php

39 lines
862 B
PHP
Raw Normal View History

2014-05-03 14:20:48 +02:00
<?php
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';
const POST_CONTENT_URL = 'post-content-url';
2014-05-03 14:20:48 +02:00
public function execute()
{
2014-05-03 18:09:31 +02:00
$post = $this->post;
2014-05-03 14:20:48 +02:00
if ($this->hasArgument(self::POST_CONTENT_URL))
{
$url = $this->getArgument(self::POST_CONTENT_URL);
$post->setContentFromUrl($url);
}
else
{
$file = $this->getArgument(self::POST_CONTENT);
$post->setContentFromPath($file->filePath, $file->fileName);
}
2014-05-03 14:20:48 +02:00
if (!$this->skipSaving)
PostModel::save($post);
2014-05-04 19:23:09 +02:00
Logger::log('{user} changed contents of {post}', [
2014-05-03 14:20:48 +02:00
'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(
Privilege::EditPostContent,
2014-05-04 16:27:15 +02:00
Access::getIdentity($this->post->getUploader()));
2014-05-03 14:20:48 +02:00
}
}