2014-05-03 19:50:35 +02:00
|
|
|
<?php
|
2014-05-12 16:46:14 +02:00
|
|
|
class ScorePostJob extends AbstractJob
|
2014-05-03 19:50:35 +02:00
|
|
|
{
|
2014-05-12 16:46:14 +02:00
|
|
|
protected $postRetriever;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->postRetriever = new PostRetriever($this);
|
|
|
|
}
|
|
|
|
|
2014-05-03 19:50:35 +02:00
|
|
|
public function execute()
|
|
|
|
{
|
2014-05-12 16:46:14 +02:00
|
|
|
$post = $this->postRetriever->retrieve();
|
2014-05-12 00:13:18 +02:00
|
|
|
$score = intval($this->getArgument(JobArgs::ARG_NEW_POST_SCORE));
|
2014-05-03 19:50:35 +02:00
|
|
|
|
|
|
|
UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score);
|
2014-05-09 13:46:29 +02:00
|
|
|
|
|
|
|
return $post;
|
2014-05-03 19:50:35 +02:00
|
|
|
}
|
|
|
|
|
2014-05-12 16:46:14 +02:00
|
|
|
public function getRequiredArguments()
|
2014-05-12 10:31:34 +02:00
|
|
|
{
|
2014-05-12 16:46:14 +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,
|
2014-05-12 16:46:14 +02:00
|
|
|
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
|
|
|
}
|