2014-02-10 23:30:47 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorProjectArchiveController
|
|
|
|
extends PhabricatorProjectController {
|
|
|
|
|
2015-08-08 19:34:55 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
2014-02-10 23:30:47 +01:00
|
|
|
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($viewer)
|
2015-08-08 19:34:55 +02:00
|
|
|
->withIDs(array($id))
|
2014-02-10 23:30:47 +01:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
|
|
|
if (!$project) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2016-01-24 01:02:29 +01:00
|
|
|
$edit_uri = $this->getApplicationURI('manage/'.$project->getID().'/');
|
2014-02-10 23:30:47 +01:00
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
if ($project->isArchived()) {
|
|
|
|
$new_status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
|
|
|
} else {
|
|
|
|
$new_status = PhabricatorProjectStatus::STATUS_ARCHIVED;
|
|
|
|
}
|
|
|
|
|
|
|
|
$xactions = array();
|
|
|
|
|
|
|
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
|
|
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
|
|
|
|
->setNewValue($new_status);
|
|
|
|
|
|
|
|
id(new PhabricatorProjectTransactionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContinueOnMissingFields(true)
|
|
|
|
->applyTransactions($project, $xactions);
|
|
|
|
|
2014-02-17 05:17:52 +01:00
|
|
|
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
2014-02-10 23:30:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($project->isArchived()) {
|
2015-01-06 20:13:04 +01:00
|
|
|
$title = pht('Really activate project?');
|
2014-02-10 23:30:47 +01:00
|
|
|
$body = pht('This project will become active again.');
|
2015-01-06 20:13:04 +01:00
|
|
|
$button = pht('Activate Project');
|
2014-02-10 23:30:47 +01:00
|
|
|
} else {
|
|
|
|
$title = pht('Really archive project?');
|
2014-06-23 16:07:50 +02:00
|
|
|
$body = pht('This project will be moved to the archive.');
|
2014-02-10 23:30:47 +01:00
|
|
|
$button = pht('Archive Project');
|
|
|
|
}
|
|
|
|
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setTitle($title)
|
|
|
|
->appendChild($body)
|
2014-02-17 05:17:52 +01:00
|
|
|
->addCancelButton($edit_uri)
|
2014-02-10 23:30:47 +01:00
|
|
|
->addSubmitButton($button);
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|