2014-03-18 18:40:31 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorProjectBoardDeleteController
|
2014-03-26 22:40:47 +01:00
|
|
|
extends PhabricatorProjectBoardController {
|
2014-03-18 18:40:31 +01:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
private $projectID;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->projectID = $data['projectID'];
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->withIDs(array($this->projectID))
|
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$project) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2014-03-26 22:40:47 +01:00
|
|
|
$this->setProject($project);
|
2014-03-18 18:40:31 +01:00
|
|
|
|
2014-03-26 22:40:47 +01:00
|
|
|
$column = id(new PhabricatorProjectColumnQuery())
|
2014-03-18 18:40:31 +01:00
|
|
|
->setViewer($viewer)
|
2014-03-26 22:40:47 +01:00
|
|
|
->withIDs(array($this->id))
|
2014-03-18 18:40:31 +01:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT))
|
2014-03-26 22:40:47 +01:00
|
|
|
->executeOne();
|
|
|
|
if (!$column) {
|
2014-03-18 18:40:31 +01:00
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2014-03-26 22:40:47 +01:00
|
|
|
$column_phid = $column->getPHID();
|
|
|
|
$view_uri = $this->getApplicationURI(
|
|
|
|
'/board/'.$this->projectID.'/column/'.$this->id.'/');
|
2014-03-18 18:40:31 +01:00
|
|
|
|
2014-06-25 21:30:43 +02:00
|
|
|
if ($column->isDefaultColumn()) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Can Not Hide Default Column'))
|
|
|
|
->appendParagraph(
|
|
|
|
pht('You can not hide the default/backlog column on a board.'))
|
|
|
|
->addCancelButton($view_uri, pht('Okay'));
|
|
|
|
}
|
|
|
|
|
2014-06-25 21:30:20 +02:00
|
|
|
if ($request->isFormPost()) {
|
|
|
|
if ($column->isHidden()) {
|
2014-03-26 22:40:47 +01:00
|
|
|
$new_status = PhabricatorProjectColumn::STATUS_ACTIVE;
|
|
|
|
} else {
|
2014-06-25 21:30:20 +02:00
|
|
|
$new_status = PhabricatorProjectColumn::STATUS_HIDDEN;
|
2014-03-18 18:40:31 +01:00
|
|
|
}
|
2014-03-26 22:40:47 +01:00
|
|
|
|
|
|
|
$type_status = PhabricatorProjectColumnTransaction::TYPE_STATUS;
|
|
|
|
$xactions = array(id(new PhabricatorProjectColumnTransaction())
|
|
|
|
->setTransactionType($type_status)
|
|
|
|
->setNewValue($new_status));
|
|
|
|
|
|
|
|
$editor = id(new PhabricatorProjectColumnTransactionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->applyTransactions($column, $xactions);
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
2014-03-18 18:40:31 +01:00
|
|
|
}
|
|
|
|
|
2014-06-25 21:30:20 +02:00
|
|
|
if ($column->isHidden()) {
|
|
|
|
$title = pht('Show Column');
|
2014-03-26 22:40:47 +01:00
|
|
|
} else {
|
2014-06-25 21:30:20 +02:00
|
|
|
$title = pht('Hide Column');
|
2014-03-26 22:40:47 +01:00
|
|
|
}
|
2014-06-25 21:30:20 +02:00
|
|
|
|
|
|
|
if ($column->isHidden()) {
|
|
|
|
$body = pht(
|
|
|
|
'Are you sure you want to show this column?');
|
2014-03-26 22:40:47 +01:00
|
|
|
} else {
|
2014-06-25 21:30:20 +02:00
|
|
|
$body = pht(
|
|
|
|
'Are you sure you want to hide this column? It will no longer '.
|
|
|
|
'appear on the workboard.');
|
2014-03-26 22:40:47 +01:00
|
|
|
}
|
|
|
|
|
2014-06-25 21:30:20 +02:00
|
|
|
$dialog = $this->newDialog()
|
2014-03-26 22:40:47 +01:00
|
|
|
->setWidth(AphrontDialogView::WIDTH_FORM)
|
|
|
|
->setTitle($title)
|
|
|
|
->appendChild($body)
|
|
|
|
->setDisableWorkflowOnCancel(true)
|
2014-06-25 21:30:20 +02:00
|
|
|
->addCancelButton($view_uri)
|
|
|
|
->addSubmitButton($title);
|
2014-03-18 18:40:31 +01:00
|
|
|
|
2014-06-25 21:30:20 +02:00
|
|
|
return $dialog;
|
2014-03-18 18:40:31 +01:00
|
|
|
}
|
|
|
|
}
|