Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91513697
PhabricatorFileDeleteController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 11, 19:45
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Nov 13, 19:45 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22274015
Attached To
rPH Phabricator
PhabricatorFileDeleteController.php
View Options
<?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/'
);
}
$dialog
=
new
AphrontDialogView
();
$dialog
->
setUser
(
$viewer
);
$dialog
->
setTitle
(
pht
(
'Really delete file?'
));
$dialog
->
appendChild
(
hsprintf
(
'<p>%s</p>'
,
pht
(
"Permanently delete '%s'? This action can not be undone."
,
$file
->
getName
())));
$dialog
->
addSubmitButton
(
pht
(
'Delete'
));
$dialog
->
addCancelButton
(
$file
->
getInfoURI
());
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment