Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phame / editor / PhamePostEditor.php
blobd95389e549049c62187ce4d35d9e31a95dd88324
1 <?php
3 final class PhamePostEditor
4 extends PhabricatorApplicationTransactionEditor {
6 public function getEditorApplicationClass() {
7 return 'PhabricatorPhameApplication';
10 public function getEditorObjectsDescription() {
11 return pht('Phame Posts');
14 public function getCreateObjectTitle($author, $object) {
15 return pht('%s created this post.', $author);
18 public function getCreateObjectTitleForFeed($author, $object) {
19 return pht('%s created %s.', $author, $object);
22 public function getTransactionTypes() {
23 $types = parent::getTransactionTypes();
24 $types[] = PhabricatorTransactions::TYPE_COMMENT;
26 return $types;
29 protected function shouldSendMail(
30 PhabricatorLiskDAO $object,
31 array $xactions) {
32 if ($object->isDraft() || ($object->isArchived())) {
33 return false;
35 return true;
38 protected function shouldPublishFeedStory(
39 PhabricatorLiskDAO $object,
40 array $xactions) {
41 if ($object->isDraft() || $object->isArchived()) {
42 return false;
44 return true;
47 protected function getMailTo(PhabricatorLiskDAO $object) {
48 $phids = array();
49 $phids[] = $object->getBloggerPHID();
50 $phids[] = $this->requireActor()->getPHID();
52 $blog_phid = $object->getBlogPHID();
53 if ($blog_phid) {
54 $cc_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID(
55 $blog_phid);
56 foreach ($cc_phids as $cc) {
57 $phids[] = $cc;
60 return $phids;
63 protected function buildMailTemplate(PhabricatorLiskDAO $object) {
64 $title = $object->getTitle();
66 return id(new PhabricatorMetaMTAMail())
67 ->setSubject($title);
70 protected function buildReplyHandler(PhabricatorLiskDAO $object) {
71 return id(new PhamePostReplyHandler())
72 ->setMailReceiver($object);
75 protected function buildMailBody(
76 PhabricatorLiskDAO $object,
77 array $xactions) {
79 $body = parent::buildMailBody($object, $xactions);
81 // We don't send mail if the object is a draft, and we only want
82 // to include the full body of the post on the either the
83 // first creation or if it was created as a draft, once it goes live.
84 if ($this->getIsNewObject()) {
85 $body->addRemarkupSection(null, $object->getBody());
86 } else {
87 foreach ($xactions as $xaction) {
88 switch ($xaction->getTransactionType()) {
89 case PhamePostVisibilityTransaction::TRANSACTIONTYPE:
90 if (!$object->isDraft() && !$object->isArchived()) {
91 $body->addRemarkupSection(null, $object->getBody());
93 break;
98 $body->addLinkSection(
99 pht('POST DETAIL'),
100 PhabricatorEnv::getProductionURI($object->getViewURI()));
102 return $body;
105 public function getMailTagsMap() {
106 return array(
107 PhamePostTransaction::MAILTAG_CONTENT =>
108 pht("A post's content changes."),
109 PhamePostTransaction::MAILTAG_SUBSCRIBERS =>
110 pht("A post's subscribers change."),
111 PhamePostTransaction::MAILTAG_COMMENT =>
112 pht('Someone comments on a post.'),
113 PhamePostTransaction::MAILTAG_OTHER =>
114 pht('Other post activity not listed above occurs.'),
118 protected function getMailSubjectPrefix() {
119 return '[Phame]';
122 protected function supportsSearch() {
123 return true;
126 protected function shouldApplyHeraldRules(
127 PhabricatorLiskDAO $object,
128 array $xactions) {
129 return true;
132 protected function buildHeraldAdapter(
133 PhabricatorLiskDAO $object,
134 array $xactions) {
136 return id(new HeraldPhamePostAdapter())
137 ->setPost($object);