1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 19:32:40 +01:00
phorge-phorge/src/applications/files/controller/PhabricatorFileDeleteController.php
Chad Little 1914ea28eb Update Files to new UI
Summary: Modernize Files a bit, use newPage

Test Plan: New file, drag and drop file, view file, edit file

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15631
2016-04-05 15:58:27 -07:00

42 lines
1.1 KiB
PHP

<?php
final class PhabricatorFileDeleteController extends PhabricatorFileController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$file) {
return new Aphront404Response();
}
if (($viewer->getPHID() != $file->getAuthorPHID()) &&
(!$viewer->getIsAdmin())) {
return new Aphront403Response();
}
if ($request->isFormPost()) {
$file->delete();
return id(new AphrontRedirectResponse())->setURI('/file/');
}
return $this->newDialog()
->setTitle(pht('Really delete file?'))
->appendChild(hsprintf(
'<p>%s</p>',
pht(
'Permanently delete "%s"? This action can not be undone.',
$file->getName())))
->addSubmitButton(pht('Delete'))
->addCancelButton($file->getInfoURI());
}
}