Differential D15171 Diff 36648 src/applications/project/controller/PhabricatorProjectMoveController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectMoveController.php
| Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | if ($task_phids && ($order == PhabricatorProjectColumn::ORDER_PRIORITY)) { | ||||
| if ($pri !== null) { | if ($pri !== null) { | ||||
| $xactions[] = id(new ManiphestTransaction()) | $xactions[] = id(new ManiphestTransaction()) | ||||
| ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY) | ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY) | ||||
| ->setNewValue($pri); | ->setNewValue($pri); | ||||
| $xactions[] = id(new ManiphestTransaction()) | $xactions[] = id(new ManiphestTransaction()) | ||||
| ->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY) | ->setTransactionType(ManiphestTransaction::TYPE_SUBPRIORITY) | ||||
| ->setNewValue($sub); | ->setNewValue($sub); | ||||
| } | } | ||||
| } | } | ||||
| $proxy = $column->getProxy(); | |||||
| if ($proxy) { | |||||
| // We're moving the task into a subproject or milestone column, so add | |||||
| // the subproject or milestone. | |||||
| $add_projects = array($proxy->getPHID()); | |||||
| } else if ($project->getHasSubprojects() || $project->getHasMilestones()) { | |||||
| // We're moving the task into the "Backlog" column on the parent project, | |||||
| // so add the parent explicitly. This gets rid of any subproject or | |||||
| // milestone tags. | |||||
| $add_projects = array($project->getPHID()); | |||||
| } else { | |||||
| $add_projects = array(); | |||||
| } | |||||
| if ($add_projects) { | |||||
| $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; | |||||
| $xactions[] = id(new ManiphestTransaction()) | |||||
| ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | |||||
| ->setMetadataValue('edge:type', $project_type) | |||||
| ->setNewValue( | |||||
| array( | |||||
| '+' => array_fuse($add_projects), | |||||
| )); | |||||
| } | |||||
| $editor = id(new ManiphestTransactionEditor()) | $editor = id(new ManiphestTransactionEditor()) | ||||
| ->setActor($viewer) | ->setActor($viewer) | ||||
| ->setContinueOnMissingFields(true) | ->setContinueOnMissingFields(true) | ||||
| ->setContinueOnNoEffect(true) | ->setContinueOnNoEffect(true) | ||||
| ->setContentSourceFromRequest($request); | ->setContentSourceFromRequest($request); | ||||
| $editor->applyTransactions($object, $xactions); | $editor->applyTransactions($object, $xactions); | ||||
| $owner = null; | $owner = null; | ||||
| if ($object->getOwnerPHID()) { | if ($object->getOwnerPHID()) { | ||||
| $owner = id(new PhabricatorHandleQuery()) | $owner = id(new PhabricatorHandleQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs(array($object->getOwnerPHID())) | ->withPHIDs(array($object->getOwnerPHID())) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| } | } | ||||
| // Reload the object so it reflects edits which have been applied. | |||||
| $object = id(new ManiphestTaskQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($object_phid)) | |||||
| ->needProjectPHIDs(true) | |||||
| ->requireCapabilities( | |||||
| array( | |||||
| PhabricatorPolicyCapability::CAN_VIEW, | |||||
| PhabricatorPolicyCapability::CAN_EDIT, | |||||
| )) | |||||
| ->executeOne(); | |||||
| $card = id(new ProjectBoardTaskCard()) | $card = id(new ProjectBoardTaskCard()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->setTask($object) | ->setTask($object) | ||||
| ->setOwner($owner) | ->setOwner($owner) | ||||
| ->setCanEdit(true) | ->setCanEdit(true) | ||||
| ->setProject($project) | ->setProject($project) | ||||
| ->getItem(); | ->getItem(); | ||||
| $card->addClass('phui-workcard'); | $card->addClass('phui-workcard'); | ||||
| return id(new AphrontAjaxResponse())->setContent( | return id(new AphrontAjaxResponse())->setContent( | ||||
| array('task' => $card)); | array('task' => $card)); | ||||
| } | } | ||||
| } | } | ||||