2012-04-02 21:12:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ManiphestSubpriorityController extends ManiphestController {
|
|
|
|
|
2015-08-02 02:06:57 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
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())
|
2015-08-02 02:06:57 +02:00
|
|
|
->setViewer($viewer)
|
2013-09-25 22:44:14 +02:00
|
|
|
->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())
|
2015-08-02 02:06:57 +02:00
|
|
|
->setViewer($viewer)
|
2013-09-25 22:44:14 +02:00
|
|
|
->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())
|
2017-05-15 19:23:20 +02:00
|
|
|
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
|
2015-03-21 01:38:25 +01:00
|
|
|
->setNewValue($pri);
|
|
|
|
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
2017-05-15 19:23:20 +02:00
|
|
|
->setTransactionType(ManiphestTaskSubpriorityTransaction::TRANSACTIONTYPE)
|
2015-03-21 01:38:25 +01:00
|
|
|
->setNewValue($sub);
|
|
|
|
|
2014-02-27 18:39:59 +01:00
|
|
|
$editor = id(new ManiphestTransactionEditor())
|
2015-08-02 02:06:57 +02:00
|
|
|
->setActor($viewer)
|
2014-02-27 18:39:59 +01:00
|
|
|
->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
|
|
|
}
|
|
|
|
|
|
|
|
}
|