Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/post/PhamePostNewController.php
| Show All 24 Lines | if ($id) { | ||||
| $view_uri = $this->getApplicationURI($view_uri); | $view_uri = $this->getApplicationURI($view_uri); | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $blog = id(new PhameBlogQuery()) | $blog = id(new PhameBlogQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withIDs(array($request->getInt('blog'))) | ->withIDs(array($request->getInt('blog'))) | ||||
| ->requireCapabilities( | ->requireCapabilities( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_JOIN, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| )) | )) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if ($blog) { | if ($blog) { | ||||
| $post->setBlogPHID($blog->getPHID()); | $post->setBlogPHID($blog->getPHID()); | ||||
| $post->save(); | $post->save(); | ||||
| return id(new AphrontRedirectResponse())->setURI($view_uri); | return id(new AphrontRedirectResponse())->setURI($view_uri); | ||||
| } | } | ||||
| } | } | ||||
| $title = pht('Move Post'); | $title = pht('Move Post'); | ||||
| } else { | } else { | ||||
| $title = pht('Create Post'); | $title = pht('Create Post'); | ||||
| $view_uri = $this->getApplicationURI('/post/new'); | $view_uri = $this->getApplicationURI('/post/new'); | ||||
| } | } | ||||
| $blogs = id(new PhameBlogQuery()) | $blogs = id(new PhameBlogQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->requireCapabilities( | ->requireCapabilities( | ||||
| array( | array( | ||||
| PhabricatorPolicyCapability::CAN_JOIN, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| )) | )) | ||||
| ->execute(); | ->execute(); | ||||
| $crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
| $crumbs->addTextCrumb($title, $view_uri); | $crumbs->addTextCrumb($title, $view_uri); | ||||
| $notification = null; | $notification = null; | ||||
| $form_box = null; | $form_box = null; | ||||
| if (!$blogs) { | if (!$blogs) { | ||||
| $notification = id(new PHUIInfoView()) | $notification = id(new PHUIInfoView()) | ||||
| ->setSeverity(PHUIInfoView::SEVERITY_NODATA) | ->setSeverity(PHUIInfoView::SEVERITY_NODATA) | ||||
| ->appendChild( | ->appendChild( | ||||
| pht('You do not have permission to join any blogs. Create a blog '. | pht('You do not have permission to post to any blogs. Create a blog '. | ||||
| 'first, then you can post to it.')); | 'first, then you can post to it.')); | ||||
| } else { | } else { | ||||
| $options = mpull($blogs, 'getName', 'getID'); | $options = mpull($blogs, 'getName', 'getID'); | ||||
| asort($options); | asort($options); | ||||
| $selected_value = null; | $selected_value = null; | ||||
| if ($post && $post->getBlog()) { | if ($post && $post->getBlog()) { | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||