Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93550655
PhamePostUnpublishController.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
Fri, Nov 29, 16:10
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Dec 1, 16:10 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22572539
Attached To
rPH Phabricator
PhamePostUnpublishController.php
View Options
<?php
/**
* @group phame
*/
final
class
PhamePostUnpublishController
extends
PhameController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$post
=
id
(
new
PhamePostQuery
())
->
setViewer
(
$user
)
->
withIDs
(
array
(
$this
->
id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$post
)
{
return
new
Aphront404Response
();
}
if
(
$request
->
isFormPost
())
{
$post
->
setVisibility
(
PhamePost
::
VISIBILITY_DRAFT
);
$post
->
setDatePublished
(
0
);
$post
->
save
();
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
$this
->
getApplicationURI
(
'/post/view/'
.
$post
->
getID
().
'/'
));
}
$cancel_uri
=
$this
->
getApplicationURI
(
'/post/view/'
.
$post
->
getID
().
'/'
);
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$user
)
->
setTitle
(
pht
(
'Unpublish Post?'
))
->
appendChild
(
pht
(
'The post "%s" will no longer be visible to other users until you '
.
'republish it.'
,
$post
->
getTitle
()))
->
addSubmitButton
(
pht
(
'Unpublish'
))
->
addCancelButton
(
$cancel_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment