3 final class PhamePostMoveController
extends PhamePostController
{
5 public function handleRequest(AphrontRequest
$request) {
6 $viewer = $request->getViewer();
7 $id = $request->getURIData('id');
9 $post = id(new PhamePostQuery())
12 ->requireCapabilities(
14 PhabricatorPolicyCapability
::CAN_EDIT
,
15 PhabricatorPolicyCapability
::CAN_VIEW
,
20 return new Aphront404Response();
23 $view_uri = $post->getViewURI();
24 $v_blog = $post->getBlog()->getPHID();
26 if ($request->isFormPost()) {
27 $v_blog = $request->getStr('blogPHID');
30 $xactions[] = id(new PhamePostTransaction())
31 ->setTransactionType(PhamePostBlogTransaction
::TRANSACTIONTYPE
)
32 ->setNewValue($v_blog);
34 $editor = id(new PhamePostEditor())
36 ->setContentSourceFromRequest($request)
37 ->setContinueOnMissingFields(true)
38 ->setContinueOnNoEffect(true);
40 $editor->applyTransactions($post, $xactions);
42 $view_uri = $post->getViewURI();
44 return id(new AphrontRedirectResponse())
45 ->setURI($view_uri.'?moved=1');
48 $blogs = id(new PhameBlogQuery())
50 ->requireCapabilities(
52 PhabricatorPolicyCapability
::CAN_VIEW
,
53 PhabricatorPolicyCapability
::CAN_EDIT
,
57 $options = mpull($blogs, 'getName', 'getPHID');
60 $form = id(new PHUIFormLayoutView())
63 id(new AphrontFormSelectControl())
64 ->setLabel(pht('Blog'))
66 ->setOptions($options)
69 return $this->newDialog()
70 ->setTitle(pht('Move Post'))
72 ->addSubmitButton(pht('Move Post'))
73 ->addCancelButton($view_uri);