Page MenuHomePhabricator

D14698.diff
No OneTemporary

D14698.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3338,6 +3338,7 @@
'PhamePostListController' => 'applications/phame/controller/post/PhamePostListController.php',
'PhamePostListView' => 'applications/phame/view/PhamePostListView.php',
'PhamePostMailReceiver' => 'applications/phame/mail/PhamePostMailReceiver.php',
+ 'PhamePostMoveController' => 'applications/phame/controller/post/PhamePostMoveController.php',
'PhamePostNewController' => 'applications/phame/controller/post/PhamePostNewController.php',
'PhamePostNotLiveController' => 'applications/phame/controller/post/PhamePostNotLiveController.php',
'PhamePostPreviewController' => 'applications/phame/controller/post/PhamePostPreviewController.php',
@@ -7687,6 +7688,7 @@
'PhamePostListController' => 'PhamePostController',
'PhamePostListView' => 'AphrontTagView',
'PhamePostMailReceiver' => 'PhabricatorObjectMailReceiver',
+ 'PhamePostMoveController' => 'PhamePostController',
'PhamePostNewController' => 'PhamePostController',
'PhamePostNotLiveController' => 'PhamePostController',
'PhamePostPreviewController' => 'PhamePostController',
diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php
--- a/src/applications/phame/application/PhabricatorPhameApplication.php
+++ b/src/applications/phame/application/PhabricatorPhameApplication.php
@@ -54,7 +54,7 @@
'preview/' => 'PhabricatorMarkupPreviewController',
'framed/(?P<id>\d+)/' => 'PhamePostFramedController',
'new/' => 'PhamePostNewController',
- 'move/(?P<id>\d+)/' => 'PhamePostNewController',
+ 'move/(?P<id>\d+)/' => 'PhamePostMoveController',
'comment/(?P<id>[1-9]\d*)/' => 'PhamePostCommentController',
),
'blog/' => array(
diff --git a/src/applications/phame/controller/PhameHomeController.php b/src/applications/phame/controller/PhameHomeController.php
--- a/src/applications/phame/controller/PhameHomeController.php
+++ b/src/applications/phame/controller/PhameHomeController.php
@@ -86,6 +86,13 @@
$crumbs->addAction(
id(new PHUIListItemView())
+ ->setName(pht('New Post'))
+ ->setHref($this->getApplicationURI('/post/new/'))
+ ->setIcon('fa-plus-square')
+ ->setWorkflow(true));
+
+ $crumbs->addAction(
+ id(new PHUIListItemView())
->setName(pht('New Blog'))
->setHref($this->getApplicationURI('/blog/new/'))
->setIcon('fa-plus-square')
diff --git a/src/applications/phame/controller/post/PhamePostMoveController.php b/src/applications/phame/controller/post/PhamePostMoveController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/controller/post/PhamePostMoveController.php
@@ -0,0 +1,78 @@
+<?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);
+
+ }
+
+}
diff --git a/src/applications/phame/controller/post/PhamePostNewController.php b/src/applications/phame/controller/post/PhamePostNewController.php
--- a/src/applications/phame/controller/post/PhamePostNewController.php
+++ b/src/applications/phame/controller/post/PhamePostNewController.php
@@ -4,12 +4,10 @@
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
- $id = $request->getURIData('id');
+ $id = $request->getInt('blog');
- $post = null;
- $view_uri = null;
if ($id) {
- $post = id(new PhamePostQuery())
+ $blog = id(new PhameBlogQuery())
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
@@ -17,35 +15,14 @@
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
- if (!$post) {
+ if (!$blog) {
return new Aphront404Response();
}
- $view_uri = '/post/view/'.$post->getID().'/';
+ $view_uri = '/post/edit/?blog='.$blog->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);
- }
- }
-
- $title = pht('Move Post');
- } else {
- $title = pht('Create Post');
- $view_uri = $this->getApplicationURI('/post/new');
+ return id(new AphrontRedirectResponse())->setURI($view_uri);
}
$blogs = id(new PhameBlogQuery())
@@ -56,13 +33,8 @@
))
->execute();
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $view_uri);
-
- $notification = null;
- $form_box = null;
if (!$blogs) {
- $notification = id(new PHUIInfoView())
+ $form = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild(
pht('You do not have permission to post to any blogs. Create a blog '.
@@ -72,48 +44,19 @@
$options = mpull($blogs, 'getName', 'getID');
asort($options);
- $selected_value = null;
- if ($post && $post->getBlog()) {
- $selected_value = $post->getBlog()->getID();
- }
-
- $form = id(new AphrontFormView())
+ $form = id(new PHUIFormLayoutView())
->setUser($viewer)
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Blog'))
->setName('blog')
- ->setOptions($options)
- ->setValue($selected_value));
-
- if ($post) {
- $form
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->setValue(pht('Move Post'))
- ->addCancelButton($view_uri));
- } else {
- $form
- ->setAction($this->getApplicationURI('post/edit/'))
- ->setMethod('GET')
- ->appendChild(
- id(new AphrontFormSubmitControl())
- ->setValue(pht('Continue')));
- }
-
- $form_box = id(new PHUIObjectBoxView())
- ->setHeaderText($title)
- ->setForm($form);
+ ->setOptions($options));
}
- return $this->newPage()
- ->setTitle($title)
- ->setCrumbs($crumbs)
- ->appendChild(
- array(
- $notification,
- $form_box,
- ));
+ return $this->newDialog()
+ ->setTitle(pht('New Post'))
+ ->appendChild($form)
+ ->addSubmitButton(pht('Continue'));
}
diff --git a/src/applications/phame/controller/post/PhamePostViewController.php b/src/applications/phame/controller/post/PhamePostViewController.php
--- a/src/applications/phame/controller/post/PhamePostViewController.php
+++ b/src/applications/phame/controller/post/PhamePostViewController.php
@@ -8,6 +8,7 @@
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
+ $moved = $request->getStr('moved');
$post = id(new PhamePostQuery())
->setViewer($viewer)
@@ -57,6 +58,13 @@
$document = id(new PHUIDocumentViewPro())
->setHeader($header);
+ if ($moved) {
+ $document->appendChild(
+ id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->appendChild(pht('Post moved successfully.')));
+ }
+
if ($post->isDraft()) {
$document->appendChild(
id(new PHUIInfoView())
@@ -169,8 +177,7 @@
->setIcon('fa-pencil')
->setHref($this->getApplicationURI('post/edit/'.$id.'/'))
->setName(pht('Edit Post'))
- ->setDisabled(!$can_edit)
- ->setWorkflow(!$can_edit));
+ ->setDisabled(!$can_edit));
$actions->addAction(
id(new PhabricatorActionView())
@@ -178,7 +185,7 @@
->setHref($this->getApplicationURI('post/move/'.$id.'/'))
->setName(pht('Move Post'))
->setDisabled(!$can_edit)
- ->setWorkflow(!$can_edit));
+ ->setWorkflow(true));
$actions->addAction(
id(new PhabricatorActionView())

File Metadata

Mime Type
text/plain
Expires
Sun, May 12, 5:53 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6290371
Default Alt Text
D14698.diff (10 KB)

Event Timeline