Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893205
PhamePostPublishController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
PhamePostPublishController.php
View Options
<?php
final
class
PhamePostPublishController
extends
PhamePostController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
(
)
;
$id
=
$request
->
getURIData
(
'id'
)
;
$post
=
id
(
new
PhamePostQuery
(
)
)
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
)
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
)
)
->
executeOne
(
)
;
if
(
!
$post
)
{
return
new
Aphront404Response
(
)
;
}
$cancel_uri
=
$post
->
getViewURI
(
)
;
$action
=
$request
->
getURIData
(
'action'
)
;
$is_publish
=
(
$action
==
'publish'
)
;
if
(
$request
->
isFormPost
(
)
)
{
$xactions
=
array
(
)
;
if
(
$is_publish
)
{
$new_value
=
PhameConstants
::
VISIBILITY_PUBLISHED
;
}
else
{
$new_value
=
PhameConstants
::
VISIBILITY_DRAFT
;
}
$xactions
[
]
=
id
(
new
PhamePostTransaction
(
)
)
->
setTransactionType
(
PhamePostVisibilityTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$new_value
)
;
id
(
new
PhamePostEditor
(
)
)
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$post
,
$xactions
)
;
return
id
(
new
AphrontRedirectResponse
(
)
)
->
setURI
(
$cancel_uri
)
;
}
if
(
$is_publish
)
{
$title
=
pht
(
'Publish Post'
)
;
$body
=
pht
(
'This post will go live once you publish it.'
)
;
$button
=
pht
(
'Publish'
)
;
}
else
{
$title
=
pht
(
'Unpublish Post'
)
;
$body
=
pht
(
'This post will revert to draft status and no longer be visible '
.
'to other users.'
)
;
$button
=
pht
(
'Unpublish'
)
;
}
return
$this
->
newDialog
(
)
->
setTitle
(
$title
)
->
appendParagraph
(
$body
)
->
addSubmitButton
(
$button
)
->
addCancelButton
(
$cancel_uri
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 18:03 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127230
Default Alt Text
PhamePostPublishController.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment