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();
|
|
|
|
}
|
2015-03-21 01:38:25 +01:00
|
|
|
list($pri, $sub) = ManiphestTransactionEditor::getAdjacentSubpriority(
|
|
|
|
$after_task,
|
|
|
|
$is_after = true);
|
2012-04-02 21:12:04 +02:00
|
|
|
} else {
|
2015-03-21 01:38:25 +01:00
|
|
|
list($pri, $sub) = ManiphestTransactionEditor::getEdgeSubpriority(
|
|
|
|
$request->getInt('priority'),
|
|
|
|
$is_end = false);
|
2012-04-02 21:12:04 +02:00
|
|
|
}
|
|
|
|
|
2015-03-21 01:38:25 +01:00
|
|
|
$xactions = array();
|
|
|
|
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
|
|
|
->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)
|
|
|
|
->setNewValue($pri);
|
|
|
|
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
2014-02-27 18:39:59 +01:00
|
|
|
->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY)
|
2015-03-21 01:38:25 +01:00
|
|
|
->setNewValue($sub);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|