Restored JobArgs approach. Previous introduction of hierarchic argument definitions has backfired: it was confusing what class to take arguments from, the concept of sharing arguments between different jobs was unintelligible and one never knew where given argument was actually defined. This appraoch makes it easier to maintain the arguments list and simplifies the code a lot.
25 lines
474 B
PHP
25 lines
474 B
PHP
<?php
|
|
class ScorePostJob extends AbstractPostJob
|
|
{
|
|
public function execute()
|
|
{
|
|
$post = $this->post;
|
|
$score = intval($this->getArgument(JobArgs::ARG_NEW_POST_SCORE));
|
|
|
|
UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score);
|
|
|
|
return $post;
|
|
}
|
|
|
|
public function requiresPrivilege()
|
|
{
|
|
return new Privilege(
|
|
Privilege::ScorePost,
|
|
Access::getIdentity($this->post->getUploader()));
|
|
}
|
|
|
|
public function requiresAuthentication()
|
|
{
|
|
return true;
|
|
}
|
|
}
|