Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class FundInitiativeTransaction
|
|
|
|
extends PhabricatorApplicationTransaction {
|
|
|
|
|
|
|
|
const TYPE_NAME = 'fund:name';
|
|
|
|
const TYPE_DESCRIPTION = 'fund:description';
|
2014-10-08 14:32:42 +02:00
|
|
|
const TYPE_RISKS = 'fund:risks';
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
const TYPE_STATUS = 'fund:status';
|
2014-10-06 19:36:43 +02:00
|
|
|
const TYPE_BACKER = 'fund:backer';
|
2014-10-10 20:29:31 +02:00
|
|
|
const TYPE_REFUND = 'fund:refund';
|
2014-10-07 23:41:59 +02:00
|
|
|
const TYPE_MERCHANT = 'fund:merchant';
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
|
2014-10-10 20:29:42 +02:00
|
|
|
const MAILTAG_BACKER = 'fund.backer';
|
|
|
|
const MAILTAG_STATUS = 'fund.status';
|
|
|
|
const MAILTAG_OTHER = 'fund.other';
|
|
|
|
|
2014-10-10 20:29:31 +02:00
|
|
|
const PROPERTY_AMOUNT = 'fund.amount';
|
|
|
|
const PROPERTY_BACKER = 'fund.backer';
|
|
|
|
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
public function getApplicationName() {
|
|
|
|
return 'fund';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionType() {
|
|
|
|
return FundInitiativePHIDType::TYPECONST;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-10-07 23:41:59 +02:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = parent::getRequiredHandlePHIDs();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$type = $this->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case FundInitiativeTransaction::TYPE_MERCHANT:
|
|
|
|
if ($old) {
|
|
|
|
$phids[] = $old;
|
|
|
|
}
|
|
|
|
if ($new) {
|
|
|
|
$phids[] = $new;
|
|
|
|
}
|
|
|
|
break;
|
2014-10-10 20:29:31 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_REFUND:
|
|
|
|
$phids[] = $this->getMetadataValue(self::PROPERTY_BACKER);
|
|
|
|
break;
|
2014-10-07 23:41:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$type = $this->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case FundInitiativeTransaction::TYPE_NAME:
|
|
|
|
if ($old === null) {
|
|
|
|
return pht(
|
|
|
|
'%s created this initiative.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s renamed this initiative from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$old,
|
|
|
|
$new);
|
|
|
|
}
|
|
|
|
break;
|
2014-10-08 14:32:42 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_RISKS:
|
|
|
|
return pht(
|
|
|
|
'%s edited the risks for this initiative.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_DESCRIPTION:
|
|
|
|
return pht(
|
|
|
|
'%s edited the description of this initiative.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
case FundInitiativeTransaction::TYPE_STATUS:
|
|
|
|
switch ($new) {
|
|
|
|
case FundInitiative::STATUS_OPEN:
|
|
|
|
return pht(
|
|
|
|
'%s reopened this initiative.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
case FundInitiative::STATUS_CLOSED:
|
|
|
|
return pht(
|
|
|
|
'%s closed this initiative.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
break;
|
2014-10-06 19:36:43 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_BACKER:
|
2014-10-10 20:29:31 +02:00
|
|
|
$amount = $this->getMetadataValue(self::PROPERTY_AMOUNT);
|
|
|
|
$amount = PhortuneCurrency::newFromString($amount);
|
2014-10-06 19:36:43 +02:00
|
|
|
return pht(
|
2014-10-10 20:29:31 +02:00
|
|
|
'%s backed this initiative with %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$amount->formatForDisplay());
|
|
|
|
case FundInitiativeTransaction::TYPE_REFUND:
|
|
|
|
$amount = $this->getMetadataValue(self::PROPERTY_AMOUNT);
|
|
|
|
$amount = PhortuneCurrency::newFromString($amount);
|
|
|
|
|
|
|
|
$backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER);
|
|
|
|
|
|
|
|
return pht(
|
|
|
|
'%s refunded %s to %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$amount->formatForDisplay(),
|
|
|
|
$this->renderHandleLink($backer_phid));
|
2014-10-07 23:41:59 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_MERCHANT:
|
|
|
|
if ($old === null) {
|
|
|
|
return pht(
|
|
|
|
'%s set this initiative to pay to %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($new));
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s changed the merchant receiving funds from this '.
|
|
|
|
'initiative from %s to %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($old),
|
|
|
|
$this->renderHandleLink($new));
|
|
|
|
}
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitleForFeed(PhabricatorFeedStory $story) {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$type = $this->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case FundInitiativeTransaction::TYPE_NAME:
|
|
|
|
if ($old === null) {
|
|
|
|
return pht(
|
|
|
|
'%s created %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s renamed %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FundInitiativeTransaction::TYPE_DESCRIPTION:
|
|
|
|
return pht(
|
|
|
|
'%s updated the description for %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
case FundInitiativeTransaction::TYPE_STATUS:
|
|
|
|
switch ($new) {
|
|
|
|
case FundInitiative::STATUS_OPEN:
|
|
|
|
return pht(
|
|
|
|
'%s reopened %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
case FundInitiative::STATUS_CLOSED:
|
|
|
|
return pht(
|
|
|
|
'%s closed %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
}
|
|
|
|
break;
|
2014-10-06 19:36:43 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_BACKER:
|
2014-10-10 20:29:42 +02:00
|
|
|
$amount = $this->getMetadataValue(self::PROPERTY_AMOUNT);
|
|
|
|
$amount = PhortuneCurrency::newFromString($amount);
|
|
|
|
return pht(
|
|
|
|
'%s backed %s with %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid),
|
|
|
|
$amount->formatForDisplay());
|
|
|
|
case FundInitiativeTransaction::TYPE_REFUND:
|
|
|
|
$amount = $this->getMetadataValue(self::PROPERTY_AMOUNT);
|
|
|
|
$amount = PhortuneCurrency::newFromString($amount);
|
|
|
|
|
|
|
|
$backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER);
|
|
|
|
|
2014-10-06 19:36:43 +02:00
|
|
|
return pht(
|
2014-10-10 20:29:42 +02:00
|
|
|
'%s refunded %s to %s for %s.',
|
2014-10-06 19:36:43 +02:00
|
|
|
$this->renderHandleLink($author_phid),
|
2014-10-10 20:29:42 +02:00
|
|
|
$amount->formatForDisplay(),
|
|
|
|
$this->renderHandleLink($backer_phid),
|
2014-10-06 19:36:43 +02:00
|
|
|
$this->renderHandleLink($object_phid));
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getTitleForFeed($story);
|
|
|
|
}
|
|
|
|
|
2014-10-10 20:29:42 +02:00
|
|
|
public function getMailTags() {
|
|
|
|
$tags = parent::getMailTags();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case self::TYPE_STATUS:
|
|
|
|
$tags[] = self::MAILTAG_STATUS;
|
|
|
|
break;
|
|
|
|
case self::TYPE_BACKER:
|
|
|
|
case self::TYPE_REFUND:
|
|
|
|
$tags[] = self::MAILTAG_BACKER;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$tags[] = self::MAILTAG_OTHER;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
public function shouldHide() {
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case FundInitiativeTransaction::TYPE_DESCRIPTION:
|
2014-10-08 14:32:42 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_RISKS:
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
return ($old === null);
|
|
|
|
}
|
|
|
|
return parent::shouldHide();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasChangeDetails() {
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case FundInitiativeTransaction::TYPE_DESCRIPTION:
|
2014-10-08 14:32:42 +02:00
|
|
|
case FundInitiativeTransaction::TYPE_RISKS:
|
Scaffolding for Fund
Summary:
Ref T5835. This is all pretty boilerplate, and does not interact with Phortune at all yet.
You can create "Initiatives", which have a title and description, and support most of the expected infrastructure (policies, transactions, mentions, edges, appsearch, remakrup, etc).
Only notable decisions:
- Initiatives have an explicit owner. I think it's good to have a single clearly-responsible user behind an initiative.
- I think that's it?
Test Plan:
- Created an initiative.
- Edited an initiative.
- Changed application policy defaults.
- Searched for initiatives.
- Subscribed to an initiative.
- Opened/closed an initiative.
- Used `I123` and `{I123}` in remarkup.
- Destroyed an initiative.
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5835
Differential Revision: https://secure.phabricator.com/D10481
2014-09-11 22:38:58 +02:00
|
|
|
return ($this->getOldValue() !== null);
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::hasChangeDetails();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
|
|
|
return $this->renderTextCorpusChangeDetails(
|
|
|
|
$viewer,
|
|
|
|
$this->getOldValue(),
|
|
|
|
$this->getNewValue());
|
|
|
|
}
|
|
|
|
}
|