Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104482506
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
Sun, Mar 9, 19:54
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Mar 11, 19:54 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24795549
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
))
->
withIsDeleted
(
false
)
->
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
())
{
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorFileTransaction
())
->
setTransactionType
(
PhabricatorFileDeleteTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
true
);
id
(
new
PhabricatorFileEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$file
,
$xactions
);
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
());
}
}
Event Timeline
Log In to Comment