Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99872615
PhamePostNotLiveController.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, Jan 27, 01:45
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Jan 29, 01:45 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23839846
Attached To
rPH Phabricator
PhamePostNotLiveController.php
View Options
<?php
/**
* @group phame
*/
final
class
PhamePostNotLiveController
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
))
->
executeOne
();
if
(!
$post
)
{
return
new
Aphront404Response
();
}
$reasons
=
array
();
if
(!
$post
->
getBlog
())
{
$reasons
[]
=
phutil_tag
(
'p'
,
array
(),
pht
(
'You can not view the live version of this post because it '
.
'is not associated with a blog. Move the post to a blog in order to '
.
'view it live.'
));
}
if
(
$post
->
isDraft
())
{
$reasons
[]
=
phutil_tag
(
'p'
,
array
(),
pht
(
'You can not view the live version of this post because it '
.
'is still a draft. Use "Preview/Publish" to publish the post.'
));
}
if
(
$reasons
)
{
$cancel_uri
=
$this
->
getApplicationURI
(
'/post/view/'
.
$post
->
getID
().
'/'
);
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$user
)
->
setTitle
(
pht
(
'Post Not Live'
))
->
addCancelButton
(
$cancel_uri
);
foreach
(
$reasons
as
$reason
)
{
$dialog
->
appendChild
(
$reason
);
}
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
// No reason this can't go live, maybe an old link. Kick them live and see
// what happens.
$live_uri
=
$post
->
getViewURI
();
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$live_uri
);
}
}
Event Timeline
Log In to Comment