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(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$v_projects = array_reverse($v_projects);
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$blog->getPHID());
} else {
$this->requireApplicationCapability(
@ -39,28 +41,30 @@ final class PhameBlogEditController
$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 @@ final class PhameBlogEditController
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 @@ final class PhameBlogEditController
->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)

View file

@ -27,6 +27,8 @@ final class PhamePostEditController extends PhamePostController {
$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 @@ final class PhamePostEditController extends PhamePostController {
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 @@ final class PhamePostEditController extends PhamePostController {
$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 @@ final class PhamePostEditController extends PhamePostController {
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;
@ -154,6 +162,13 @@ final class PhamePostEditController extends PhamePostController {
->setID('post-body')
->setUser($viewer)
->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'))

View file

@ -22,12 +22,6 @@ final class PhamePostPublishController extends PhamePostController {
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);

View file

@ -20,12 +20,6 @@ final class PhamePostUnpublishController extends PhamePostController {
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);

View file

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

View file

@ -121,6 +121,9 @@ final class PhamePostEditor
}
break;
case PhamePostTransaction::TYPE_PHAME_TITLE:
if (!$xactions) {
continue;
}
$missing = $this->validateIsEmptyTextField(
$object->getPhameTitle(),
$xactions);
@ -183,8 +186,11 @@ final class PhamePostEditor
$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;
}