Differential D15174 Diff 36642 src/applications/project/controller/PhabricatorProjectMoveController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/controller/PhabricatorProjectMoveController.php
| Show All 20 Lines | $project = id(new PhabricatorProjectQuery()) | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| )) | )) | ||||
| ->withIDs(array($id)) | ->withIDs(array($id)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$project) { | if (!$project) { | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $board_phid = $project->getPHID(); | |||||
| $object = id(new ManiphestTaskQuery()) | $object = id(new ManiphestTaskQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withPHIDs(array($object_phid)) | ->withPHIDs(array($object_phid)) | ||||
| ->needProjectPHIDs(true) | ->needProjectPHIDs(true) | ||||
| ->requireCapabilities( | ->requireCapabilities( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| Show All 12 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $columns = mpull($columns, null, 'getPHID'); | $columns = mpull($columns, null, 'getPHID'); | ||||
| $column = idx($columns, $column_phid); | $column = idx($columns, $column_phid); | ||||
| if (!$column) { | if (!$column) { | ||||
| // User is trying to drop this object into a nonexistent column, just kick | // User is trying to drop this object into a nonexistent column, just kick | ||||
| // them out. | // them out. | ||||
| return new Aphront404Response(); | return new Aphront404Response(); | ||||
| } | } | ||||
| $positions = id(new PhabricatorProjectColumnPositionQuery()) | $engine = id(new PhabricatorBoardLayoutEngine()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withColumns($columns) | ->setBoardPHIDs(array($board_phid)) | ||||
| ->withObjectPHIDs(array($object_phid)) | ->setObjectPHIDs(array($object_phid)) | ||||
| ->execute(); | ->executeLayout(); | ||||
| $columns = $engine->getObjectColumns($board_phid, $object_phid); | |||||
| $old_column_phids = mpull($columns, 'getPHID'); | |||||
| $xactions = array(); | $xactions = array(); | ||||
| if ($order == PhabricatorProjectColumn::ORDER_NATURAL) { | if ($order == PhabricatorProjectColumn::ORDER_NATURAL) { | ||||
| $order_params = array( | $order_params = array( | ||||
| 'afterPHID' => $after_phid, | 'afterPHID' => $after_phid, | ||||
| 'beforePHID' => $before_phid, | 'beforePHID' => $before_phid, | ||||
| ); | ); | ||||
| } else { | } else { | ||||
| $order_params = array(); | $order_params = array(); | ||||
| } | } | ||||
| $xactions[] = id(new ManiphestTransaction()) | $xactions[] = id(new ManiphestTransaction()) | ||||
| ->setTransactionType(ManiphestTransaction::TYPE_PROJECT_COLUMN) | ->setTransactionType(ManiphestTransaction::TYPE_PROJECT_COLUMN) | ||||
| ->setNewValue( | ->setNewValue( | ||||
| array( | array( | ||||
| 'columnPHIDs' => array($column->getPHID()), | 'columnPHIDs' => array($column->getPHID()), | ||||
| 'projectPHID' => $column->getProjectPHID(), | 'projectPHID' => $column->getProjectPHID(), | ||||
| ) + $order_params) | ) + $order_params) | ||||
| ->setOldValue( | ->setOldValue( | ||||
| array( | array( | ||||
| 'columnPHIDs' => mpull($positions, 'getColumnPHID'), | 'columnPHIDs' => $old_column_phids, | ||||
| 'projectPHID' => $column->getProjectPHID(), | 'projectPHID' => $column->getProjectPHID(), | ||||
| )); | )); | ||||
| $task_phids = array(); | $task_phids = array(); | ||||
| if ($after_phid) { | if ($after_phid) { | ||||
| $task_phids[] = $after_phid; | $task_phids[] = $after_phid; | ||||
| } | } | ||||
| if ($before_phid) { | if ($before_phid) { | ||||
| ▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines | |||||