mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 19:32:40 +01:00
1914ea28eb
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
42 lines
1.1 KiB
PHP
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());
|
|
}
|
|
}
|