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