mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-11 08:06:13 +01:00
51acc22962
Summary: Ref T4426. This moves "Edit Details", "Edit Picture", and "Archive" to a separate "Edit" interface. "History" becomes part of this UI. Test Plan: {F114417} {F114418} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T4426 Differential Revision: https://secure.phabricator.com/D8248
74 lines
2.1 KiB
PHP
74 lines
2.1 KiB
PHP
<?php
|
|
|
|
final class PhabricatorProjectArchiveController
|
|
extends PhabricatorProjectController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($this->id))
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$project) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
|
|
|
|
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);
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
|
}
|
|
|
|
if ($project->isArchived()) {
|
|
$title = pht('Really unarchive project?');
|
|
$body = pht('This project will become active again.');
|
|
$button = pht('Unarchive Project');
|
|
} else {
|
|
$title = pht('Really archive project?');
|
|
$body = pht('This project will moved to the archive.');
|
|
$button = pht('Archive Project');
|
|
}
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($viewer)
|
|
->setTitle($title)
|
|
->appendChild($body)
|
|
->addCancelButton($edit_uri)
|
|
->addSubmitButton($button);
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
}
|