Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93608197
PhameBlogArchiveController.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
Sat, Nov 30, 03:17
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 03:17 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22675237
Attached To
rPH Phabricator
PhameBlogArchiveController.php
View Options
<?php
final
class
PhameBlogArchiveController
extends
PhameBlogController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$blog
=
id
(
new
PhameBlogQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$blog
)
{
return
new
Aphront404Response
();
}
$view_uri
=
$this
->
getApplicationURI
(
'blog/view/'
.
$blog
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
if
(
$blog
->
isArchived
())
{
$new_status
=
PhameBlog
::
STATUS_ACTIVE
;
}
else
{
$new_status
=
PhameBlog
::
STATUS_ARCHIVED
;
}
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhameBlogTransaction
())
->
setTransactionType
(
PhameBlogTransaction
::
TYPE_STATUS
)
->
setNewValue
(
$new_status
);
id
(
new
PhameBlogEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$blog
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$view_uri
);
}
if
(
$blog
->
isArchived
())
{
$title
=
pht
(
'Activate Blog'
);
$body
=
pht
(
'This blog will become active again.'
);
$button
=
pht
(
'Activate Blog'
);
}
else
{
$title
=
pht
(
'Archive Blog'
);
$body
=
pht
(
'This blog will be marked as archived.'
);
$button
=
pht
(
'Archive Blog'
);
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
$title
)
->
appendChild
(
$body
)
->
addCancelButton
(
$view_uri
)
->
addSubmitButton
(
$button
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment