szurubooru/src/Api/Jobs/PostJobs/ScorePostJob.php

40 lines
795 B
PHP
Raw Normal View History

2014-05-03 19:50:35 +02:00
<?php
class ScorePostJob extends AbstractJob
2014-05-03 19:50:35 +02:00
{
protected $postRetriever;
public function __construct()
{
$this->postRetriever = new PostRetriever($this);
}
2014-05-03 19:50:35 +02:00
public function execute()
{
$post = $this->postRetriever->retrieve();
$score = intval($this->getArgument(JobArgs::ARG_NEW_POST_SCORE));
2014-05-03 19:50:35 +02:00
UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score);
return $post;
2014-05-03 19:50:35 +02:00
}
public function getRequiredArguments()
2014-05-12 10:31:34 +02:00
{
return JobArgs::Conjunction(
$this->postRetriever->getRequiredArguments(),
JobArgs::ARG_NEW_POST_SCORE);
2014-05-12 10:31:34 +02:00
}
public function getRequiredPrivileges()
2014-05-03 19:50:35 +02:00
{
2014-05-04 16:27:15 +02:00
return new Privilege(
2014-05-03 19:50:35 +02:00
Privilege::ScorePost,
Access::getIdentity($this->postRetriever->retrieve()->getUploader()));
2014-05-03 19:50:35 +02:00
}
2014-05-06 18:36:11 +02:00
2014-05-12 10:31:34 +02:00
public function isAuthenticationRequired()
2014-05-06 18:36:11 +02:00
{
return true;
}
2014-05-03 19:50:35 +02:00
}