diff --git a/src/applications/phame/controller/blog/PhameBlogEditController.php b/src/applications/phame/controller/blog/PhameBlogEditController.php --- a/src/applications/phame/controller/blog/PhameBlogEditController.php +++ b/src/applications/phame/controller/blog/PhameBlogEditController.php @@ -28,6 +28,8 @@ $blog->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $v_projects = array_reverse($v_projects); + $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( + $blog->getPHID()); } else { $this->requireApplicationCapability( @@ -39,28 +41,30 @@ $page_title = pht('Create Blog'); $cancel_uri = $this->getApplicationURI(); $v_projects = array(); + $v_cc = array(); } - $name = $blog->getName(); - $description = $blog->getDescription(); + $name = $blog->getName(); + $description = $blog->getDescription(); $custom_domain = $blog->getDomain(); - $skin = $blog->getSkin(); - $can_view = $blog->getViewPolicy(); - $can_edit = $blog->getEditPolicy(); - $can_join = $blog->getJoinPolicy(); + $skin = $blog->getSkin(); + $can_view = $blog->getViewPolicy(); + $can_edit = $blog->getEditPolicy(); + $can_join = $blog->getJoinPolicy(); $e_name = true; $e_custom_domain = null; $e_view_policy = null; $validation_exception = null; if ($request->isFormPost()) { - $name = $request->getStr('name'); - $description = $request->getStr('description'); + $name = $request->getStr('name'); + $description = $request->getStr('description'); $custom_domain = nonempty($request->getStr('custom_domain'), null); - $skin = $request->getStr('skin'); - $can_view = $request->getStr('can_view'); - $can_edit = $request->getStr('can_edit'); - $can_join = $request->getStr('can_join'); - $v_projects = $request->getArr('projects'); + $skin = $request->getStr('skin'); + $can_view = $request->getStr('can_view'); + $can_edit = $request->getStr('can_edit'); + $can_join = $request->getStr('can_join'); + $v_projects = $request->getArr('projects'); + $v_cc = $request->getArr('cc'); $xactions = array( id(new PhameBlogTransaction()) @@ -84,6 +88,9 @@ id(new PhameBlogTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY) ->setNewValue($can_join), + id(new PhameBlogTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) + ->setNewValue(array('=' => $v_cc)), ); $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; @@ -139,6 +146,13 @@ ->setID('blog-description') ->setUser($viewer) ->setDisableMacros(true)) + ->appendControl( + id(new AphrontFormTokenizerControl()) + ->setLabel(pht('Subscribers')) + ->setName('cc') + ->setValue($v_cc) + ->setUser($viewer) + ->setDatasource(new PhabricatorMetaMTAMailableDatasource())) ->appendChild( id(new AphrontFormPolicyControl()) ->setUser($viewer) diff --git a/src/applications/phame/controller/post/PhamePostEditController.php b/src/applications/phame/controller/post/PhamePostEditController.php --- a/src/applications/phame/controller/post/PhamePostEditController.php +++ b/src/applications/phame/controller/post/PhamePostEditController.php @@ -27,6 +27,8 @@ $post->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $v_projects = array_reverse($v_projects); + $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( + $post->getPHID()); } else { $blog = id(new PhameBlogQuery()) ->setViewer($viewer) @@ -41,6 +43,7 @@ return new Aphront404Response(); } $v_projects = array(); + $v_cc = array(); $post = PhamePost::initializePost($viewer, $blog); $cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/'); @@ -65,6 +68,7 @@ $body = $request->getStr('body'); $comments_widget = $request->getStr('comments_widget'); $v_projects = $request->getArr('projects'); + $v_cc = $request->getArr('cc'); $visibility = $request->getInt('visibility'); $xactions = array( @@ -83,6 +87,10 @@ id(new PhamePostTransaction()) ->setTransactionType(PhamePostTransaction::TYPE_COMMENTS_WIDGET) ->setNewValue($comments_widget), + id(new PhamePostTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) + ->setNewValue(array('=' => $v_cc)), + ); $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; @@ -156,6 +164,13 @@ ->setDisableMacros(true)) ->appendControl( id(new AphrontFormTokenizerControl()) + ->setLabel(pht('Subscribers')) + ->setName('cc') + ->setValue($v_cc) + ->setUser($viewer) + ->setDatasource(new PhabricatorMetaMTAMailableDatasource())) + ->appendControl( + id(new AphrontFormTokenizerControl()) ->setLabel(pht('Projects')) ->setName('projects') ->setValue($v_projects) diff --git a/src/applications/phame/controller/post/PhamePostPublishController.php b/src/applications/phame/controller/post/PhamePostPublishController.php --- a/src/applications/phame/controller/post/PhamePostPublishController.php +++ b/src/applications/phame/controller/post/PhamePostPublishController.php @@ -23,12 +23,6 @@ if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhamePostTransaction()) - ->setTransactionType(PhamePostTransaction::TYPE_TITLE) - ->setNewValue($post->getTitle()); - $xactions[] = id(new PhamePostTransaction()) - ->setTransactionType(PhamePostTransaction::TYPE_PHAME_TITLE) - ->setNewValue($post->getPhameTitle()); - $xactions[] = id(new PhamePostTransaction()) ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) ->setNewValue(PhameConstants::VISIBILITY_PUBLISHED); diff --git a/src/applications/phame/controller/post/PhamePostUnpublishController.php b/src/applications/phame/controller/post/PhamePostUnpublishController.php --- a/src/applications/phame/controller/post/PhamePostUnpublishController.php +++ b/src/applications/phame/controller/post/PhamePostUnpublishController.php @@ -21,12 +21,6 @@ if ($request->isFormPost()) { $xactions = array(); $xactions[] = id(new PhamePostTransaction()) - ->setTransactionType(PhamePostTransaction::TYPE_TITLE) - ->setNewValue($post->getTitle()); - $xactions[] = id(new PhamePostTransaction()) - ->setTransactionType(PhamePostTransaction::TYPE_PHAME_TITLE) - ->setNewValue($post->getPhameTitle()); - $xactions[] = id(new PhamePostTransaction()) ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) ->setNewValue(PhameConstants::VISIBILITY_DRAFT); diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php --- a/src/applications/phame/editor/PhameBlogEditor.php +++ b/src/applications/phame/editor/PhameBlogEditor.php @@ -94,6 +94,7 @@ $errors = parent::validateTransaction($object, $type, $xactions); + switch ($type) { case PhameBlogTransaction::TYPE_NAME: $missing = $this->validateIsEmptyTextField( @@ -112,6 +113,9 @@ } break; case PhameBlogTransaction::TYPE_DOMAIN: + if (!$xactions) { + continue; + } $custom_domain = last($xactions)->getNewValue(); if (empty($custom_domain)) { continue; diff --git a/src/applications/phame/editor/PhamePostEditor.php b/src/applications/phame/editor/PhamePostEditor.php --- a/src/applications/phame/editor/PhamePostEditor.php +++ b/src/applications/phame/editor/PhamePostEditor.php @@ -121,6 +121,9 @@ } break; case PhamePostTransaction::TYPE_PHAME_TITLE: + if (!$xactions) { + continue; + } $missing = $this->validateIsEmptyTextField( $object->getPhameTitle(), $xactions); @@ -183,8 +186,11 @@ $blog_phid = $object->getBlogPHID(); if ($blog_phid) { - $phids[] = PhabricatorSubscribersQuery::loadSubscribersForPHID( + $cc_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID( $blog_phid); + foreach ($cc_phids as $cc) { + $phids[] = $cc; + } } return $phids; }