Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93128985
PhamePostMoveController.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
Tue, Nov 26, 10:22
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 10:22 (2 d)
Engine
blob
Format
Raw Data
Handle
22580792
Attached To
rPH Phabricator
PhamePostMoveController.php
View Options
<?php
final
class
PhamePostMoveController
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_EDIT
,
PhabricatorPolicyCapability
::
CAN_VIEW
,
))
->
executeOne
();
if
(!
$post
)
{
return
new
Aphront404Response
();
}
$view_uri
=
'/post/view/'
.
$post
->
getID
().
'/'
;
$view_uri
=
$this
->
getApplicationURI
(
$view_uri
);
if
(
$request
->
isFormPost
())
{
$blog
=
id
(
new
PhameBlogQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$request
->
getInt
(
'blog'
)))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(
$blog
)
{
$post
->
setBlogPHID
(
$blog
->
getPHID
());
$post
->
save
();
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
$view_uri
.
'?moved=1'
);
}
}
$blogs
=
id
(
new
PhameBlogQuery
())
->
setViewer
(
$viewer
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
execute
();
$options
=
mpull
(
$blogs
,
'getName'
,
'getID'
);
asort
(
$options
);
$selected_value
=
null
;
if
(
$post
&&
$post
->
getBlog
())
{
$selected_value
=
$post
->
getBlog
()->
getID
();
}
$form
=
id
(
new
PHUIFormLayoutView
())
->
setUser
(
$viewer
)
->
appendChild
(
id
(
new
AphrontFormSelectControl
())
->
setLabel
(
pht
(
'Blog'
))
->
setName
(
'blog'
)
->
setOptions
(
$options
)
->
setValue
(
$selected_value
));
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Move Post'
))
->
appendChild
(
$form
)
->
addSubmitButton
(
pht
(
'Move Post'
))
->
addCancelButton
(
$view_uri
);
}
}
Event Timeline
Log In to Comment