szurubooru/src/Api/Jobs/EditPostThumbJob.php

30 lines
639 B
PHP
Raw Normal View History

2014-05-03 18:09:31 +02:00
<?php
class EditPostThumbJob extends AbstractPostEditJob
2014-05-03 18:09:31 +02:00
{
const THUMB_CONTENT = 'thumb-content';
public function execute()
{
$post = $this->post;
$file = $this->getArgument(self::THUMB_CONTENT);
$post->setCustomThumbnailFromPath($file->filePath);
if (!$this->skipSaving)
PostModel::save($post);
2014-05-03 18:09:31 +02:00
2014-05-04 19:23:09 +02:00
Logger::log('{user} changed thumb of {post}', [
2014-05-03 18:09:31 +02:00
'user' => TextHelper::reprUser(Auth::getCurrentUser()),
'post' => TextHelper::reprPost($post)]);
return $post;
}
public function requiresPrivilege()
{
2014-05-04 16:27:15 +02:00
return new Privilege(
2014-05-03 18:09:31 +02:00
Privilege::EditPostThumb,
2014-05-04 16:27:15 +02:00
Access::getIdentity($this->post->getUploader()));
2014-05-03 18:09:31 +02:00
}
}