Page MenuHomePhorge

PhamePostDeleteController.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

PhamePostDeleteController.php

<?php
/**
* @group phame
*/
final class PhamePostDeleteController extends PhameController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$post = id(new PhamePostQuery())
->setViewer($user)
->withIDs(array($this->id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
if ($request->isFormPost()) {
$post->delete();
return id(new AphrontRedirectResponse())
->setURI('/phame/post/');
}
$cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Delete Post?'))
->appendChild(
pht(
'Really delete the post "%s"? It will be gone forever.',
$post->getTitle()))
->addSubmitButton(pht('Delete'))
->addCancelButton($cancel_uri);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, May 3, 7:00 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
59246
Default Alt Text
PhamePostDeleteController.php (1 KB)

Event Timeline