1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-31 08:58:20 +01:00

Add Subscribers to Phame Blogs / Posts

Summary: Fixes T9051, adds ability to edit blogs and posts and manually add subscribers. Also fixed bug granting tokens to posts.

Test Plan: Create a new blog, subcribe chad and notchad. Write a post, both are notified. Award token for hard work.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9051

Differential Revision: https://secure.phabricator.com/D14432
This commit is contained in:
Chad Little 2015-11-07 11:29:20 -08:00
parent 152ddf5709
commit c86a514f84
6 changed files with 53 additions and 26 deletions

View file

@ -28,6 +28,8 @@ final class PhameBlogEditController
$blog->getPHID(), $blog->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$v_projects = array_reverse($v_projects); $v_projects = array_reverse($v_projects);
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$blog->getPHID());
} else { } else {
$this->requireApplicationCapability( $this->requireApplicationCapability(
@ -39,28 +41,30 @@ final class PhameBlogEditController
$page_title = pht('Create Blog'); $page_title = pht('Create Blog');
$cancel_uri = $this->getApplicationURI(); $cancel_uri = $this->getApplicationURI();
$v_projects = array(); $v_projects = array();
$v_cc = array();
} }
$name = $blog->getName(); $name = $blog->getName();
$description = $blog->getDescription(); $description = $blog->getDescription();
$custom_domain = $blog->getDomain(); $custom_domain = $blog->getDomain();
$skin = $blog->getSkin(); $skin = $blog->getSkin();
$can_view = $blog->getViewPolicy(); $can_view = $blog->getViewPolicy();
$can_edit = $blog->getEditPolicy(); $can_edit = $blog->getEditPolicy();
$can_join = $blog->getJoinPolicy(); $can_join = $blog->getJoinPolicy();
$e_name = true; $e_name = true;
$e_custom_domain = null; $e_custom_domain = null;
$e_view_policy = null; $e_view_policy = null;
$validation_exception = null; $validation_exception = null;
if ($request->isFormPost()) { if ($request->isFormPost()) {
$name = $request->getStr('name'); $name = $request->getStr('name');
$description = $request->getStr('description'); $description = $request->getStr('description');
$custom_domain = nonempty($request->getStr('custom_domain'), null); $custom_domain = nonempty($request->getStr('custom_domain'), null);
$skin = $request->getStr('skin'); $skin = $request->getStr('skin');
$can_view = $request->getStr('can_view'); $can_view = $request->getStr('can_view');
$can_edit = $request->getStr('can_edit'); $can_edit = $request->getStr('can_edit');
$can_join = $request->getStr('can_join'); $can_join = $request->getStr('can_join');
$v_projects = $request->getArr('projects'); $v_projects = $request->getArr('projects');
$v_cc = $request->getArr('cc');
$xactions = array( $xactions = array(
id(new PhameBlogTransaction()) id(new PhameBlogTransaction())
@ -84,6 +88,9 @@ final class PhameBlogEditController
id(new PhameBlogTransaction()) id(new PhameBlogTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY) ->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
->setNewValue($can_join), ->setNewValue($can_join),
id(new PhameBlogTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => $v_cc)),
); );
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
@ -139,6 +146,13 @@ final class PhameBlogEditController
->setID('blog-description') ->setID('blog-description')
->setUser($viewer) ->setUser($viewer)
->setDisableMacros(true)) ->setDisableMacros(true))
->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Subscribers'))
->setName('cc')
->setValue($v_cc)
->setUser($viewer)
->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
->appendChild( ->appendChild(
id(new AphrontFormPolicyControl()) id(new AphrontFormPolicyControl())
->setUser($viewer) ->setUser($viewer)

View file

@ -27,6 +27,8 @@ final class PhamePostEditController extends PhamePostController {
$post->getPHID(), $post->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$v_projects = array_reverse($v_projects); $v_projects = array_reverse($v_projects);
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$post->getPHID());
} else { } else {
$blog = id(new PhameBlogQuery()) $blog = id(new PhameBlogQuery())
->setViewer($viewer) ->setViewer($viewer)
@ -41,6 +43,7 @@ final class PhamePostEditController extends PhamePostController {
return new Aphront404Response(); return new Aphront404Response();
} }
$v_projects = array(); $v_projects = array();
$v_cc = array();
$post = PhamePost::initializePost($viewer, $blog); $post = PhamePost::initializePost($viewer, $blog);
$cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/'); $cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/');
@ -65,6 +68,7 @@ final class PhamePostEditController extends PhamePostController {
$body = $request->getStr('body'); $body = $request->getStr('body');
$comments_widget = $request->getStr('comments_widget'); $comments_widget = $request->getStr('comments_widget');
$v_projects = $request->getArr('projects'); $v_projects = $request->getArr('projects');
$v_cc = $request->getArr('cc');
$visibility = $request->getInt('visibility'); $visibility = $request->getInt('visibility');
$xactions = array( $xactions = array(
@ -83,6 +87,10 @@ final class PhamePostEditController extends PhamePostController {
id(new PhamePostTransaction()) id(new PhamePostTransaction())
->setTransactionType(PhamePostTransaction::TYPE_COMMENTS_WIDGET) ->setTransactionType(PhamePostTransaction::TYPE_COMMENTS_WIDGET)
->setNewValue($comments_widget), ->setNewValue($comments_widget),
id(new PhamePostTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => $v_cc)),
); );
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
@ -154,6 +162,13 @@ final class PhamePostEditController extends PhamePostController {
->setID('post-body') ->setID('post-body')
->setUser($viewer) ->setUser($viewer)
->setDisableMacros(true)) ->setDisableMacros(true))
->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Subscribers'))
->setName('cc')
->setValue($v_cc)
->setUser($viewer)
->setDatasource(new PhabricatorMetaMTAMailableDatasource()))
->appendControl( ->appendControl(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects')) ->setLabel(pht('Projects'))

View file

@ -22,12 +22,6 @@ final class PhamePostPublishController extends PhamePostController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
$xactions = array(); $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()) $xactions[] = id(new PhamePostTransaction())
->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY)
->setNewValue(PhameConstants::VISIBILITY_PUBLISHED); ->setNewValue(PhameConstants::VISIBILITY_PUBLISHED);

View file

@ -20,12 +20,6 @@ final class PhamePostUnpublishController extends PhamePostController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
$xactions = array(); $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()) $xactions[] = id(new PhamePostTransaction())
->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY) ->setTransactionType(PhamePostTransaction::TYPE_VISIBILITY)
->setNewValue(PhameConstants::VISIBILITY_DRAFT); ->setNewValue(PhameConstants::VISIBILITY_DRAFT);

View file

@ -94,6 +94,7 @@ final class PhameBlogEditor
$errors = parent::validateTransaction($object, $type, $xactions); $errors = parent::validateTransaction($object, $type, $xactions);
switch ($type) { switch ($type) {
case PhameBlogTransaction::TYPE_NAME: case PhameBlogTransaction::TYPE_NAME:
$missing = $this->validateIsEmptyTextField( $missing = $this->validateIsEmptyTextField(
@ -112,6 +113,9 @@ final class PhameBlogEditor
} }
break; break;
case PhameBlogTransaction::TYPE_DOMAIN: case PhameBlogTransaction::TYPE_DOMAIN:
if (!$xactions) {
continue;
}
$custom_domain = last($xactions)->getNewValue(); $custom_domain = last($xactions)->getNewValue();
if (empty($custom_domain)) { if (empty($custom_domain)) {
continue; continue;

View file

@ -121,6 +121,9 @@ final class PhamePostEditor
} }
break; break;
case PhamePostTransaction::TYPE_PHAME_TITLE: case PhamePostTransaction::TYPE_PHAME_TITLE:
if (!$xactions) {
continue;
}
$missing = $this->validateIsEmptyTextField( $missing = $this->validateIsEmptyTextField(
$object->getPhameTitle(), $object->getPhameTitle(),
$xactions); $xactions);
@ -183,8 +186,11 @@ final class PhamePostEditor
$blog_phid = $object->getBlogPHID(); $blog_phid = $object->getBlogPHID();
if ($blog_phid) { if ($blog_phid) {
$phids[] = PhabricatorSubscribersQuery::loadSubscribersForPHID( $cc_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$blog_phid); $blog_phid);
foreach ($cc_phids as $cc) {
$phids[] = $cc;
}
} }
return $phids; return $phids;
} }