1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 17:32:41 +01:00
phorge-phorge/src/applications/project/controller/PhabricatorProjectBoardDeleteController.php
epriestley f1c638d231 Allow the Default/Backlog column to be renamed
Summary: Fixes T5101. There's no technical reason not to allow this, it just took a little extra work so I didn't do it originally.

Test Plan: Renamed "Backlog", un-renamed it. Tried to hide it.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5101

Differential Revision: https://secure.phabricator.com/D9721
2014-06-25 12:30:43 -07:00

102 lines
2.9 KiB
PHP

<?php
final class PhabricatorProjectBoardDeleteController
extends PhabricatorProjectBoardController {
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();
}
$this->setProject($project);
$column = id(new PhabricatorProjectColumnQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT))
->executeOne();
if (!$column) {
return new Aphront404Response();
}
$column_phid = $column->getPHID();
$view_uri = $this->getApplicationURI(
'/board/'.$this->projectID.'/column/'.$this->id.'/');
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'));
}
if ($request->isFormPost()) {
if ($column->isHidden()) {
$new_status = PhabricatorProjectColumn::STATUS_ACTIVE;
} else {
$new_status = PhabricatorProjectColumn::STATUS_HIDDEN;
}
$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);
}
if ($column->isHidden()) {
$title = pht('Show Column');
} else {
$title = pht('Hide Column');
}
if ($column->isHidden()) {
$body = pht(
'Are you sure you want to show this column?');
} else {
$body = pht(
'Are you sure you want to hide this column? It will no longer '.
'appear on the workboard.');
}
$dialog = $this->newDialog()
->setWidth(AphrontDialogView::WIDTH_FORM)
->setTitle($title)
->appendChild($body)
->setDisableWorkflowOnCancel(true)
->addCancelButton($view_uri)
->addSubmitButton($title);
return $dialog;
}
}