3 final class PhabricatorOwnersArchiveController
4 extends PhabricatorOwnersController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $package = id(new PhabricatorOwnersPackageQuery())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $view_uri = $this->getApplicationURI('package/'.$package->getID().'/');
25 if ($request->isFormPost()) {
26 if ($package->isArchived()) {
27 $new_status = PhabricatorOwnersPackage
::STATUS_ACTIVE
;
29 $new_status = PhabricatorOwnersPackage
::STATUS_ARCHIVED
;
34 $type = PhabricatorOwnersPackageStatusTransaction
::TRANSACTIONTYPE
;
35 $xactions[] = id(new PhabricatorOwnersPackageTransaction())
36 ->setTransactionType($type)
37 ->setNewValue($new_status);
39 id(new PhabricatorOwnersPackageTransactionEditor())
41 ->setContentSourceFromRequest($request)
42 ->setContinueOnNoEffect(true)
43 ->setContinueOnMissingFields(true)
44 ->applyTransactions($package, $xactions);
46 return id(new AphrontRedirectResponse())->setURI($view_uri);
49 if ($package->isArchived()) {
50 $title = pht('Activate Package');
51 $body = pht('This package will become active again.');
52 $button = pht('Activate Package');
54 $title = pht('Archive Package');
55 $body = pht('This package will be marked as archived.');
56 $button = pht('Archive Package');
59 return $this->newDialog()
62 ->addCancelButton($view_uri)
63 ->addSubmitButton($button);