3 final class PhameBlogArchiveController
4 extends PhameBlogController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
8 $id = $request->getURIData('id');
10 $blog = id(new PhameBlogQuery())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $view_uri = $this->getApplicationURI('blog/manage/'.$blog->getID().'/');
25 if ($request->isFormPost()) {
26 if ($blog->isArchived()) {
27 $new_status = PhameBlog
::STATUS_ACTIVE
;
29 $new_status = PhameBlog
::STATUS_ARCHIVED
;
34 $xactions[] = id(new PhameBlogTransaction())
35 ->setTransactionType(PhameBlogStatusTransaction
::TRANSACTIONTYPE
)
36 ->setNewValue($new_status);
38 id(new PhameBlogEditor())
40 ->setContentSourceFromRequest($request)
41 ->setContinueOnNoEffect(true)
42 ->setContinueOnMissingFields(true)
43 ->applyTransactions($blog, $xactions);
45 return id(new AphrontRedirectResponse())->setURI($view_uri);
48 if ($blog->isArchived()) {
49 $title = pht('Activate Blog');
50 $body = pht('This blog will become active again.');
51 $button = pht('Activate Blog');
53 $title = pht('Archive Blog');
54 $body = pht('This blog will be marked as archived.');
55 $button = pht('Archive Blog');
58 $dialog = id(new AphrontDialogView())
62 ->addCancelButton($view_uri)
63 ->addSubmitButton($button);
65 return id(new AphrontDialogResponse())->setDialog($dialog);