2012-04-02 21:12:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ManiphestSubpriorityController extends ManiphestController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
2013-03-23 22:38:01 +01:00
|
|
|
$user = $request->getUser();
|
2012-04-02 21:12:04 +02:00
|
|
|
|
|
|
|
if (!$request->validateCSRF()) {
|
|
|
|
return new Aphront403Response();
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:44:14 +02:00
|
|
|
$task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($request->getInt('task')))
|
2014-12-18 22:53:45 +01:00
|
|
|
->needProjectPHIDs(true)
|
2013-09-25 22:44:14 +02:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
2012-04-02 21:12:04 +02:00
|
|
|
if (!$task) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->getInt('after')) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$after_task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($request->getInt('after')))
|
|
|
|
->executeOne();
|
2012-04-02 21:12:04 +02:00
|
|
|
if (!$after_task) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
$after_pri = $after_task->getPriority();
|
|
|
|
$after_sub = $after_task->getSubpriority();
|
|
|
|
} else {
|
|
|
|
$after_pri = $request->getInt('priority');
|
|
|
|
$after_sub = null;
|
|
|
|
}
|
|
|
|
|
2014-02-27 18:39:59 +01:00
|
|
|
$xactions = array(id(new ManiphestTransaction())
|
|
|
|
->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY)
|
|
|
|
->setNewValue(array(
|
|
|
|
'newPriority' => $after_pri,
|
2014-03-27 18:50:54 +01:00
|
|
|
'newSubpriorityBase' => $after_sub,
|
2014-10-07 15:01:04 +02:00
|
|
|
'direction' => '>',
|
|
|
|
)),
|
|
|
|
);
|
2014-02-27 18:39:59 +01:00
|
|
|
$editor = id(new ManiphestTransactionEditor())
|
|
|
|
->setActor($user)
|
|
|
|
->setContinueOnMissingFields(true)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContentSourceFromRequest($request);
|
|
|
|
|
|
|
|
$editor->applyTransactions($task, $xactions);
|
2012-04-02 21:12:04 +02:00
|
|
|
|
2013-03-23 22:38:01 +01:00
|
|
|
return id(new AphrontAjaxResponse())->setContent(
|
|
|
|
array(
|
2013-05-31 03:55:25 +02:00
|
|
|
'tasks' => $this->renderSingleTask($task),
|
2013-03-23 22:38:01 +01:00
|
|
|
));
|
2012-04-02 21:12:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|