3 final class PhabricatorFileDeleteController
extends PhabricatorFileController
{
5 public function handleRequest(AphrontRequest
$request) {
6 $viewer = $request->getViewer();
7 $id = $request->getURIData('id');
9 $file = id(new PhabricatorFileQuery())
12 ->withIsDeleted(false)
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 if (($viewer->getPHID() != $file->getAuthorPHID()) &&
24 (!$viewer->getIsAdmin())) {
25 return new Aphront403Response();
28 if ($request->isFormPost()) {
31 $xactions[] = id(new PhabricatorFileTransaction())
32 ->setTransactionType(PhabricatorFileDeleteTransaction
::TRANSACTIONTYPE
)
35 id(new PhabricatorFileEditor())
37 ->setContentSourceFromRequest($request)
38 ->setContinueOnNoEffect(true)
39 ->setContinueOnMissingFields(true)
40 ->applyTransactions($file, $xactions);
42 return id(new AphrontRedirectResponse())->setURI('/file/');
45 return $this->newDialog()
46 ->setTitle(pht('Really delete file?'))
47 ->appendChild(hsprintf(
50 'Permanently delete "%s"? This action can not be undone.',
52 ->addSubmitButton(pht('Delete'))
53 ->addCancelButton($file->getInfoURI());