@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update Fund for modular transactions

Summary: Fixes T12627. Updates FundInitiative and FundBacker with modular transactions.

Test Plan: Create an Initiative, back it with fake monies, close initiative, reopen, edit various fields.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12627

Differential Revision: https://secure.phabricator.com/D17782

+609 -489
+24 -2
src/__phutil_library_map__.php
··· 1124 1124 'FundBackerPHIDType' => 'applications/fund/phid/FundBackerPHIDType.php', 1125 1125 'FundBackerProduct' => 'applications/fund/phortune/FundBackerProduct.php', 1126 1126 'FundBackerQuery' => 'applications/fund/query/FundBackerQuery.php', 1127 + 'FundBackerRefundTransaction' => 'applications/fund/xaction/FundBackerRefundTransaction.php', 1127 1128 'FundBackerSearchEngine' => 'applications/fund/query/FundBackerSearchEngine.php', 1129 + 'FundBackerStatusTransaction' => 'applications/fund/xaction/FundBackerStatusTransaction.php', 1128 1130 'FundBackerTransaction' => 'applications/fund/storage/FundBackerTransaction.php', 1129 1131 'FundBackerTransactionQuery' => 'applications/fund/query/FundBackerTransactionQuery.php', 1132 + 'FundBackerTransactionType' => 'applications/fund/xaction/FundBackerTransactionType.php', 1130 1133 'FundController' => 'applications/fund/controller/FundController.php', 1131 1134 'FundCreateInitiativesCapability' => 'applications/fund/capability/FundCreateInitiativesCapability.php', 1132 1135 'FundDAO' => 'applications/fund/storage/FundDAO.php', 1133 1136 'FundDefaultViewCapability' => 'applications/fund/capability/FundDefaultViewCapability.php', 1134 1137 'FundInitiative' => 'applications/fund/storage/FundInitiative.php', 1135 1138 'FundInitiativeBackController' => 'applications/fund/controller/FundInitiativeBackController.php', 1139 + 'FundInitiativeBackerTransaction' => 'applications/fund/xaction/FundInitiativeBackerTransaction.php', 1136 1140 'FundInitiativeCloseController' => 'applications/fund/controller/FundInitiativeCloseController.php', 1137 1141 'FundInitiativeCommentController' => 'applications/fund/controller/FundInitiativeCommentController.php', 1142 + 'FundInitiativeDescriptionTransaction' => 'applications/fund/xaction/FundInitiativeDescriptionTransaction.php', 1138 1143 'FundInitiativeEditController' => 'applications/fund/controller/FundInitiativeEditController.php', 1139 1144 'FundInitiativeEditor' => 'applications/fund/editor/FundInitiativeEditor.php', 1140 1145 'FundInitiativeFulltextEngine' => 'applications/fund/search/FundInitiativeFulltextEngine.php', 1141 1146 'FundInitiativeListController' => 'applications/fund/controller/FundInitiativeListController.php', 1147 + 'FundInitiativeMerchantTransaction' => 'applications/fund/xaction/FundInitiativeMerchantTransaction.php', 1148 + 'FundInitiativeNameTransaction' => 'applications/fund/xaction/FundInitiativeNameTransaction.php', 1142 1149 'FundInitiativePHIDType' => 'applications/fund/phid/FundInitiativePHIDType.php', 1143 1150 'FundInitiativeQuery' => 'applications/fund/query/FundInitiativeQuery.php', 1151 + 'FundInitiativeRefundTransaction' => 'applications/fund/xaction/FundInitiativeRefundTransaction.php', 1144 1152 'FundInitiativeRemarkupRule' => 'applications/fund/remarkup/FundInitiativeRemarkupRule.php', 1145 1153 'FundInitiativeReplyHandler' => 'applications/fund/mail/FundInitiativeReplyHandler.php', 1154 + 'FundInitiativeRisksTransaction' => 'applications/fund/xaction/FundInitiativeRisksTransaction.php', 1146 1155 'FundInitiativeSearchEngine' => 'applications/fund/query/FundInitiativeSearchEngine.php', 1156 + 'FundInitiativeStatusTransaction' => 'applications/fund/xaction/FundInitiativeStatusTransaction.php', 1147 1157 'FundInitiativeTransaction' => 'applications/fund/storage/FundInitiativeTransaction.php', 1148 1158 'FundInitiativeTransactionComment' => 'applications/fund/storage/FundInitiativeTransactionComment.php', 1149 1159 'FundInitiativeTransactionQuery' => 'applications/fund/query/FundInitiativeTransactionQuery.php', 1160 + 'FundInitiativeTransactionType' => 'applications/fund/xaction/FundInitiativeTransactionType.php', 1150 1161 'FundInitiativeViewController' => 'applications/fund/controller/FundInitiativeViewController.php', 1151 1162 'FundSchemaSpec' => 'applications/fund/storage/FundSchemaSpec.php', 1152 1163 'HarbormasterArcLintBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterArcLintBuildStepImplementation.php', ··· 6066 6077 'FundBackerPHIDType' => 'PhabricatorPHIDType', 6067 6078 'FundBackerProduct' => 'PhortuneProductImplementation', 6068 6079 'FundBackerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6080 + 'FundBackerRefundTransaction' => 'FundBackerTransactionType', 6069 6081 'FundBackerSearchEngine' => 'PhabricatorApplicationSearchEngine', 6070 - 'FundBackerTransaction' => 'PhabricatorApplicationTransaction', 6082 + 'FundBackerStatusTransaction' => 'FundBackerTransactionType', 6083 + 'FundBackerTransaction' => 'PhabricatorModularTransaction', 6071 6084 'FundBackerTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6085 + 'FundBackerTransactionType' => 'PhabricatorModularTransactionType', 6072 6086 'FundController' => 'PhabricatorController', 6073 6087 'FundCreateInitiativesCapability' => 'PhabricatorPolicyCapability', 6074 6088 'FundDAO' => 'PhabricatorLiskDAO', ··· 6086 6100 'PhabricatorFulltextInterface', 6087 6101 ), 6088 6102 'FundInitiativeBackController' => 'FundController', 6103 + 'FundInitiativeBackerTransaction' => 'FundInitiativeTransactionType', 6089 6104 'FundInitiativeCloseController' => 'FundController', 6090 6105 'FundInitiativeCommentController' => 'FundController', 6106 + 'FundInitiativeDescriptionTransaction' => 'FundInitiativeTransactionType', 6091 6107 'FundInitiativeEditController' => 'FundController', 6092 6108 'FundInitiativeEditor' => 'PhabricatorApplicationTransactionEditor', 6093 6109 'FundInitiativeFulltextEngine' => 'PhabricatorFulltextEngine', 6094 6110 'FundInitiativeListController' => 'FundController', 6111 + 'FundInitiativeMerchantTransaction' => 'FundInitiativeTransactionType', 6112 + 'FundInitiativeNameTransaction' => 'FundInitiativeTransactionType', 6095 6113 'FundInitiativePHIDType' => 'PhabricatorPHIDType', 6096 6114 'FundInitiativeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6115 + 'FundInitiativeRefundTransaction' => 'FundInitiativeTransactionType', 6097 6116 'FundInitiativeRemarkupRule' => 'PhabricatorObjectRemarkupRule', 6098 6117 'FundInitiativeReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 6118 + 'FundInitiativeRisksTransaction' => 'FundInitiativeTransactionType', 6099 6119 'FundInitiativeSearchEngine' => 'PhabricatorApplicationSearchEngine', 6100 - 'FundInitiativeTransaction' => 'PhabricatorApplicationTransaction', 6120 + 'FundInitiativeStatusTransaction' => 'FundInitiativeTransactionType', 6121 + 'FundInitiativeTransaction' => 'PhabricatorModularTransaction', 6101 6122 'FundInitiativeTransactionComment' => 'PhabricatorApplicationTransactionComment', 6102 6123 'FundInitiativeTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6124 + 'FundInitiativeTransactionType' => 'PhabricatorModularTransactionType', 6103 6125 'FundInitiativeViewController' => 'FundController', 6104 6126 'FundSchemaSpec' => 'PhabricatorConfigSchemaSpec', 6105 6127 'HarbormasterArcLintBuildStepImplementation' => 'HarbormasterBuildStepImplementation',
+1 -1
src/applications/fund/controller/FundInitiativeBackController.php
··· 96 96 $xactions = array(); 97 97 98 98 $xactions[] = id(new FundBackerTransaction()) 99 - ->setTransactionType(FundBackerTransaction::TYPE_STATUS) 99 + ->setTransactionType(FundBackerStatusTransaction::TRANSACTIONTYPE) 100 100 ->setNewValue(FundBacker::STATUS_IN_CART); 101 101 102 102 $editor = id(new FundBackerEditor())
+1 -1
src/applications/fund/controller/FundInitiativeCloseController.php
··· 25 25 $is_close = !$initiative->isClosed(); 26 26 27 27 if ($request->isFormPost()) { 28 - $type_status = FundInitiativeTransaction::TYPE_STATUS; 28 + $type_status = FundInitiativeStatusTransaction::TRANSACTIONTYPE; 29 29 30 30 if ($is_close) { 31 31 $new_status = FundInitiative::STATUS_CLOSED;
+4 -4
src/applications/fund/controller/FundInitiativeEditController.php
··· 68 68 $v_merchant = $request->getStr('merchantPHID'); 69 69 $v_projects = $request->getArr('projects'); 70 70 71 - $type_name = FundInitiativeTransaction::TYPE_NAME; 72 - $type_desc = FundInitiativeTransaction::TYPE_DESCRIPTION; 73 - $type_risk = FundInitiativeTransaction::TYPE_RISKS; 74 - $type_merchant = FundInitiativeTransaction::TYPE_MERCHANT; 71 + $type_name = FundInitiativeNameTransaction::TRANSACTIONTYPE; 72 + $type_desc = FundInitiativeDescriptionTransaction::TRANSACTIONTYPE; 73 + $type_risk = FundInitiativeRisksTransaction::TRANSACTIONTYPE; 74 + $type_merchant = FundInitiativeMerchantTransaction::TRANSACTIONTYPE; 75 75 $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; 76 76 $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; 77 77
+2 -2
src/applications/fund/controller/FundInitiativeViewController.php
··· 29 29 $initiative->getName()); 30 30 31 31 if ($initiative->isClosed()) { 32 - $status_icon = 'fa-times'; 33 - $status_color = 'bluegrey'; 32 + $status_icon = 'fa-ban'; 33 + $status_color = 'indigo'; 34 34 } else { 35 35 $status_icon = 'fa-check'; 36 36 $status_color = 'bluegrey';
-63
src/applications/fund/editor/FundBackerEditor.php
··· 11 11 return pht('Fund Backing'); 12 12 } 13 13 14 - public function getTransactionTypes() { 15 - $types = parent::getTransactionTypes(); 16 - 17 - $types[] = FundBackerTransaction::TYPE_STATUS; 18 - $types[] = FundBackerTransaction::TYPE_REFUND; 19 - 20 - return $types; 21 - } 22 - 23 - protected function getCustomTransactionOldValue( 24 - PhabricatorLiskDAO $object, 25 - PhabricatorApplicationTransaction $xaction) { 26 - switch ($xaction->getTransactionType()) { 27 - case FundBackerTransaction::TYPE_STATUS: 28 - return $object->getStatus(); 29 - case FundBackerTransaction::TYPE_REFUND: 30 - return null; 31 - } 32 - 33 - return parent::getCustomTransactionOldValue($object, $xaction); 34 - } 35 - 36 - protected function getCustomTransactionNewValue( 37 - PhabricatorLiskDAO $object, 38 - PhabricatorApplicationTransaction $xaction) { 39 - 40 - switch ($xaction->getTransactionType()) { 41 - case FundBackerTransaction::TYPE_STATUS: 42 - case FundBackerTransaction::TYPE_REFUND: 43 - return $xaction->getNewValue(); 44 - } 45 - 46 - return parent::getCustomTransactionNewValue($object, $xaction); 47 - } 48 - 49 - protected function applyCustomInternalTransaction( 50 - PhabricatorLiskDAO $object, 51 - PhabricatorApplicationTransaction $xaction) { 52 - 53 - switch ($xaction->getTransactionType()) { 54 - case FundBackerTransaction::TYPE_STATUS: 55 - $object->setStatus($xaction->getNewValue()); 56 - return; 57 - case FundBackerTransaction::TYPE_REFUND: 58 - return; 59 - } 60 - 61 - return parent::applyCustomInternalTransaction($object, $xaction); 62 - } 63 - 64 - protected function applyCustomExternalTransaction( 65 - PhabricatorLiskDAO $object, 66 - PhabricatorApplicationTransaction $xaction) { 67 - 68 - switch ($xaction->getTransactionType()) { 69 - case FundBackerTransaction::TYPE_STATUS: 70 - case FundBackerTransaction::TYPE_REFUND: 71 - return; 72 - } 73 - 74 - return parent::applyCustomExternalTransaction($object, $xaction); 75 - } 76 - 77 14 }
+8 -206
src/applications/fund/editor/FundInitiativeEditor.php
··· 11 11 return pht('Fund Initiatives'); 12 12 } 13 13 14 + public function getCreateObjectTitle($author, $object) { 15 + return pht('%s created this initiative.', $author); 16 + } 17 + 18 + public function getCreateObjectTitleForFeed($author, $object) { 19 + return pht('%s created %s.', $author, $object); 20 + } 21 + 14 22 public function getTransactionTypes() { 15 23 $types = parent::getTransactionTypes(); 16 - 17 - $types[] = FundInitiativeTransaction::TYPE_NAME; 18 - $types[] = FundInitiativeTransaction::TYPE_DESCRIPTION; 19 - $types[] = FundInitiativeTransaction::TYPE_RISKS; 20 - $types[] = FundInitiativeTransaction::TYPE_STATUS; 21 - $types[] = FundInitiativeTransaction::TYPE_BACKER; 22 - $types[] = FundInitiativeTransaction::TYPE_REFUND; 23 - $types[] = FundInitiativeTransaction::TYPE_MERCHANT; 24 24 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 25 25 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 26 26 $types[] = PhabricatorTransactions::TYPE_COMMENT; 27 27 28 28 return $types; 29 - } 30 - 31 - protected function getCustomTransactionOldValue( 32 - PhabricatorLiskDAO $object, 33 - PhabricatorApplicationTransaction $xaction) { 34 - switch ($xaction->getTransactionType()) { 35 - case FundInitiativeTransaction::TYPE_NAME: 36 - return $object->getName(); 37 - case FundInitiativeTransaction::TYPE_DESCRIPTION: 38 - return $object->getDescription(); 39 - case FundInitiativeTransaction::TYPE_RISKS: 40 - return $object->getRisks(); 41 - case FundInitiativeTransaction::TYPE_STATUS: 42 - return $object->getStatus(); 43 - case FundInitiativeTransaction::TYPE_BACKER: 44 - case FundInitiativeTransaction::TYPE_REFUND: 45 - return null; 46 - case FundInitiativeTransaction::TYPE_MERCHANT: 47 - return $object->getMerchantPHID(); 48 - } 49 - 50 - return parent::getCustomTransactionOldValue($object, $xaction); 51 - } 52 - 53 - protected function getCustomTransactionNewValue( 54 - PhabricatorLiskDAO $object, 55 - PhabricatorApplicationTransaction $xaction) { 56 - 57 - switch ($xaction->getTransactionType()) { 58 - case FundInitiativeTransaction::TYPE_NAME: 59 - case FundInitiativeTransaction::TYPE_DESCRIPTION: 60 - case FundInitiativeTransaction::TYPE_RISKS: 61 - case FundInitiativeTransaction::TYPE_STATUS: 62 - case FundInitiativeTransaction::TYPE_BACKER: 63 - case FundInitiativeTransaction::TYPE_REFUND: 64 - case FundInitiativeTransaction::TYPE_MERCHANT: 65 - return $xaction->getNewValue(); 66 - } 67 - 68 - return parent::getCustomTransactionNewValue($object, $xaction); 69 - } 70 - 71 - protected function applyCustomInternalTransaction( 72 - PhabricatorLiskDAO $object, 73 - PhabricatorApplicationTransaction $xaction) { 74 - 75 - $type = $xaction->getTransactionType(); 76 - switch ($type) { 77 - case FundInitiativeTransaction::TYPE_NAME: 78 - $object->setName($xaction->getNewValue()); 79 - return; 80 - case FundInitiativeTransaction::TYPE_DESCRIPTION: 81 - $object->setDescription($xaction->getNewValue()); 82 - return; 83 - case FundInitiativeTransaction::TYPE_RISKS: 84 - $object->setRisks($xaction->getNewValue()); 85 - return; 86 - case FundInitiativeTransaction::TYPE_MERCHANT: 87 - $object->setMerchantPHID($xaction->getNewValue()); 88 - return; 89 - case FundInitiativeTransaction::TYPE_STATUS: 90 - $object->setStatus($xaction->getNewValue()); 91 - return; 92 - case FundInitiativeTransaction::TYPE_BACKER: 93 - case FundInitiativeTransaction::TYPE_REFUND: 94 - $amount = $xaction->getMetadataValue( 95 - FundInitiativeTransaction::PROPERTY_AMOUNT); 96 - $amount = PhortuneCurrency::newFromString($amount); 97 - 98 - if ($type == FundInitiativeTransaction::TYPE_REFUND) { 99 - $total = $object->getTotalAsCurrency()->subtract($amount); 100 - } else { 101 - $total = $object->getTotalAsCurrency()->add($amount); 102 - } 103 - 104 - $object->setTotalAsCurrency($total); 105 - return; 106 - } 107 - 108 - return parent::applyCustomInternalTransaction($object, $xaction); 109 - } 110 - 111 - protected function applyCustomExternalTransaction( 112 - PhabricatorLiskDAO $object, 113 - PhabricatorApplicationTransaction $xaction) { 114 - 115 - $type = $xaction->getTransactionType(); 116 - switch ($type) { 117 - case FundInitiativeTransaction::TYPE_NAME: 118 - case FundInitiativeTransaction::TYPE_DESCRIPTION: 119 - case FundInitiativeTransaction::TYPE_RISKS: 120 - case FundInitiativeTransaction::TYPE_STATUS: 121 - case FundInitiativeTransaction::TYPE_MERCHANT: 122 - return; 123 - case FundInitiativeTransaction::TYPE_BACKER: 124 - case FundInitiativeTransaction::TYPE_REFUND: 125 - $backer = id(new FundBackerQuery()) 126 - ->setViewer($this->requireActor()) 127 - ->withPHIDs(array($xaction->getNewValue())) 128 - ->executeOne(); 129 - if (!$backer) { 130 - throw new Exception(pht('Unable to load %s!', 'FundBacker')); 131 - } 132 - 133 - $subx = array(); 134 - 135 - if ($type == FundInitiativeTransaction::TYPE_BACKER) { 136 - $subx[] = id(new FundBackerTransaction()) 137 - ->setTransactionType(FundBackerTransaction::TYPE_STATUS) 138 - ->setNewValue(FundBacker::STATUS_PURCHASED); 139 - } else { 140 - $amount = $xaction->getMetadataValue( 141 - FundInitiativeTransaction::PROPERTY_AMOUNT); 142 - $subx[] = id(new FundBackerTransaction()) 143 - ->setTransactionType(FundBackerTransaction::TYPE_STATUS) 144 - ->setNewValue($amount); 145 - } 146 - 147 - $editor = id(new FundBackerEditor()) 148 - ->setActor($this->requireActor()) 149 - ->setContentSource($this->getContentSource()) 150 - ->setContinueOnMissingFields(true) 151 - ->setContinueOnNoEffect(true); 152 - 153 - $editor->applyTransactions($backer, $subx); 154 - return; 155 - } 156 - 157 - return parent::applyCustomExternalTransaction($object, $xaction); 158 - } 159 - 160 - protected function validateTransaction( 161 - PhabricatorLiskDAO $object, 162 - $type, 163 - array $xactions) { 164 - 165 - $errors = parent::validateTransaction($object, $type, $xactions); 166 - 167 - switch ($type) { 168 - case FundInitiativeTransaction::TYPE_NAME: 169 - $missing = $this->validateIsEmptyTextField( 170 - $object->getName(), 171 - $xactions); 172 - 173 - if ($missing) { 174 - $error = new PhabricatorApplicationTransactionValidationError( 175 - $type, 176 - pht('Required'), 177 - pht('Initiative name is required.'), 178 - nonempty(last($xactions), null)); 179 - 180 - $error->setIsMissingFieldError(true); 181 - $errors[] = $error; 182 - } 183 - break; 184 - case FundInitiativeTransaction::TYPE_MERCHANT: 185 - $missing = $this->validateIsEmptyTextField( 186 - $object->getName(), 187 - $xactions); 188 - if ($missing) { 189 - $error = new PhabricatorApplicationTransactionValidationError( 190 - $type, 191 - pht('Required'), 192 - pht('Payable merchant is required.'), 193 - nonempty(last($xactions), null)); 194 - 195 - $error->setIsMissingFieldError(true); 196 - $errors[] = $error; 197 - } else if ($xactions) { 198 - $merchant_phid = last($xactions)->getNewValue(); 199 - 200 - // Make sure the actor has permission to edit the merchant they're 201 - // selecting. You aren't allowed to send payments to an account you 202 - // do not control. 203 - $merchants = id(new PhortuneMerchantQuery()) 204 - ->setViewer($this->requireActor()) 205 - ->withPHIDs(array($merchant_phid)) 206 - ->requireCapabilities( 207 - array( 208 - PhabricatorPolicyCapability::CAN_VIEW, 209 - PhabricatorPolicyCapability::CAN_EDIT, 210 - )) 211 - ->execute(); 212 - if (!$merchants) { 213 - $error = new PhabricatorApplicationTransactionValidationError( 214 - $type, 215 - pht('Invalid'), 216 - pht( 217 - 'You must specify a merchant account you control as the '. 218 - 'recipient of funds from this initiative.'), 219 - last($xactions)); 220 - $errors[] = $error; 221 - } 222 - } 223 - break; 224 - } 225 - 226 - return $errors; 227 29 } 228 30 229 31 protected function shouldSendMail(
+2 -2
src/applications/fund/phortune/FundBackerProduct.php
··· 105 105 106 106 $xactions = array(); 107 107 $xactions[] = id(new FundInitiativeTransaction()) 108 - ->setTransactionType(FundInitiativeTransaction::TYPE_BACKER) 108 + ->setTransactionType(FundInitiativeBackerTransaction::TRANSACTIONTYPE) 109 109 ->setMetadataValue( 110 110 FundInitiativeTransaction::PROPERTY_AMOUNT, 111 111 $backer->getAmountAsCurrency()->serializeForStorage()) ··· 134 134 135 135 $xactions = array(); 136 136 $xactions[] = id(new FundInitiativeTransaction()) 137 - ->setTransactionType(FundInitiativeTransaction::TYPE_REFUND) 137 + ->setTransactionType(FundInitiativeRefundTransaction::TRANSACTIONTYPE) 138 138 ->setMetadataValue( 139 139 FundInitiativeTransaction::PROPERTY_AMOUNT, 140 140 $amount->serializeForStorage())
+5 -4
src/applications/fund/storage/FundBackerTransaction.php
··· 1 1 <?php 2 2 3 3 final class FundBackerTransaction 4 - extends PhabricatorApplicationTransaction { 5 - 6 - const TYPE_STATUS = 'fund:backer:status'; 7 - const TYPE_REFUND = 'fund:backer:refund'; 4 + extends PhabricatorModularTransaction { 8 5 9 6 public function getApplicationName() { 10 7 return 'fund'; ··· 16 13 17 14 public function getApplicationTransactionCommentObject() { 18 15 return null; 16 + } 17 + 18 + public function getBaseTransactionClass() { 19 + return 'FundBackerTransactionType'; 19 20 } 20 21 21 22 }
+3 -204
src/applications/fund/storage/FundInitiativeTransaction.php
··· 1 1 <?php 2 2 3 3 final class FundInitiativeTransaction 4 - extends PhabricatorApplicationTransaction { 5 - 6 - const TYPE_NAME = 'fund:name'; 7 - const TYPE_DESCRIPTION = 'fund:description'; 8 - const TYPE_RISKS = 'fund:risks'; 9 - const TYPE_STATUS = 'fund:status'; 10 - const TYPE_BACKER = 'fund:backer'; 11 - const TYPE_REFUND = 'fund:refund'; 12 - const TYPE_MERCHANT = 'fund:merchant'; 4 + extends PhabricatorModularTransaction { 13 5 14 6 const MAILTAG_BACKER = 'fund.backer'; 15 7 const MAILTAG_STATUS = 'fund.status'; ··· 30 22 return new FundInitiativeTransactionComment(); 31 23 } 32 24 33 - public function getRequiredHandlePHIDs() { 34 - $phids = parent::getRequiredHandlePHIDs(); 35 - 36 - $old = $this->getOldValue(); 37 - $new = $this->getNewValue(); 38 - 39 - $type = $this->getTransactionType(); 40 - switch ($type) { 41 - case self::TYPE_MERCHANT: 42 - if ($old) { 43 - $phids[] = $old; 44 - } 45 - if ($new) { 46 - $phids[] = $new; 47 - } 48 - break; 49 - case self::TYPE_REFUND: 50 - $phids[] = $this->getMetadataValue(self::PROPERTY_BACKER); 51 - break; 52 - } 53 - 54 - return $phids; 55 - } 56 - 57 - public function getTitle() { 58 - $author_phid = $this->getAuthorPHID(); 59 - $object_phid = $this->getObjectPHID(); 60 - 61 - $old = $this->getOldValue(); 62 - $new = $this->getNewValue(); 63 - 64 - $type = $this->getTransactionType(); 65 - switch ($type) { 66 - case self::TYPE_NAME: 67 - if ($old === null) { 68 - return pht( 69 - '%s created this initiative.', 70 - $this->renderHandleLink($author_phid)); 71 - } else { 72 - return pht( 73 - '%s renamed this initiative from "%s" to "%s".', 74 - $this->renderHandleLink($author_phid), 75 - $old, 76 - $new); 77 - } 78 - break; 79 - case self::TYPE_RISKS: 80 - return pht( 81 - '%s edited the risks for this initiative.', 82 - $this->renderHandleLink($author_phid)); 83 - case self::TYPE_DESCRIPTION: 84 - return pht( 85 - '%s edited the description of this initiative.', 86 - $this->renderHandleLink($author_phid)); 87 - case self::TYPE_STATUS: 88 - switch ($new) { 89 - case FundInitiative::STATUS_OPEN: 90 - return pht( 91 - '%s reopened this initiative.', 92 - $this->renderHandleLink($author_phid)); 93 - case FundInitiative::STATUS_CLOSED: 94 - return pht( 95 - '%s closed this initiative.', 96 - $this->renderHandleLink($author_phid)); 97 - } 98 - break; 99 - case self::TYPE_BACKER: 100 - $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); 101 - $amount = PhortuneCurrency::newFromString($amount); 102 - return pht( 103 - '%s backed this initiative with %s.', 104 - $this->renderHandleLink($author_phid), 105 - $amount->formatForDisplay()); 106 - case self::TYPE_REFUND: 107 - $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); 108 - $amount = PhortuneCurrency::newFromString($amount); 109 - 110 - $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); 111 - 112 - return pht( 113 - '%s refunded %s to %s.', 114 - $this->renderHandleLink($author_phid), 115 - $amount->formatForDisplay(), 116 - $this->renderHandleLink($backer_phid)); 117 - case self::TYPE_MERCHANT: 118 - if ($old === null) { 119 - return pht( 120 - '%s set this initiative to pay to %s.', 121 - $this->renderHandleLink($author_phid), 122 - $this->renderHandleLink($new)); 123 - } else { 124 - return pht( 125 - '%s changed the merchant receiving funds from this '. 126 - 'initiative from %s to %s.', 127 - $this->renderHandleLink($author_phid), 128 - $this->renderHandleLink($old), 129 - $this->renderHandleLink($new)); 130 - } 131 - } 132 - 133 - return parent::getTitle(); 134 - } 135 - 136 - public function getTitleForFeed() { 137 - $author_phid = $this->getAuthorPHID(); 138 - $object_phid = $this->getObjectPHID(); 139 - 140 - $old = $this->getOldValue(); 141 - $new = $this->getNewValue(); 142 - 143 - $type = $this->getTransactionType(); 144 - switch ($type) { 145 - case self::TYPE_NAME: 146 - if ($old === null) { 147 - return pht( 148 - '%s created %s.', 149 - $this->renderHandleLink($author_phid), 150 - $this->renderHandleLink($object_phid)); 151 - 152 - } else { 153 - return pht( 154 - '%s renamed %s.', 155 - $this->renderHandleLink($author_phid), 156 - $this->renderHandleLink($object_phid)); 157 - } 158 - break; 159 - case self::TYPE_DESCRIPTION: 160 - return pht( 161 - '%s updated the description for %s.', 162 - $this->renderHandleLink($author_phid), 163 - $this->renderHandleLink($object_phid)); 164 - case self::TYPE_STATUS: 165 - switch ($new) { 166 - case FundInitiative::STATUS_OPEN: 167 - return pht( 168 - '%s reopened %s.', 169 - $this->renderHandleLink($author_phid), 170 - $this->renderHandleLink($object_phid)); 171 - case FundInitiative::STATUS_CLOSED: 172 - return pht( 173 - '%s closed %s.', 174 - $this->renderHandleLink($author_phid), 175 - $this->renderHandleLink($object_phid)); 176 - } 177 - break; 178 - case self::TYPE_BACKER: 179 - $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); 180 - $amount = PhortuneCurrency::newFromString($amount); 181 - return pht( 182 - '%s backed %s with %s.', 183 - $this->renderHandleLink($author_phid), 184 - $this->renderHandleLink($object_phid), 185 - $amount->formatForDisplay()); 186 - case self::TYPE_REFUND: 187 - $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); 188 - $amount = PhortuneCurrency::newFromString($amount); 189 - 190 - $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); 191 - 192 - return pht( 193 - '%s refunded %s to %s for %s.', 194 - $this->renderHandleLink($author_phid), 195 - $amount->formatForDisplay(), 196 - $this->renderHandleLink($backer_phid), 197 - $this->renderHandleLink($object_phid)); 198 - } 199 - 200 - return parent::getTitleForFeed(); 25 + public function getBaseTransactionClass() { 26 + return 'FundInitiativeTransactionType'; 201 27 } 202 28 203 29 public function getMailTags() { ··· 219 45 return $tags; 220 46 } 221 47 222 - 223 - public function shouldHide() { 224 - $old = $this->getOldValue(); 225 - switch ($this->getTransactionType()) { 226 - case self::TYPE_DESCRIPTION: 227 - case self::TYPE_RISKS: 228 - return ($old === null); 229 - } 230 - return parent::shouldHide(); 231 - } 232 - 233 - public function hasChangeDetails() { 234 - switch ($this->getTransactionType()) { 235 - case self::TYPE_DESCRIPTION: 236 - case self::TYPE_RISKS: 237 - return ($this->getOldValue() !== null); 238 - } 239 - 240 - return parent::hasChangeDetails(); 241 - } 242 - 243 - public function renderChangeDetails(PhabricatorUser $viewer) { 244 - return $this->renderTextCorpusChangeDetails( 245 - $viewer, 246 - $this->getOldValue(), 247 - $this->getNewValue()); 248 - } 249 48 }
+13
src/applications/fund/xaction/FundBackerRefundTransaction.php
··· 1 + <?php 2 + 3 + final class FundBackerRefundTransaction 4 + extends FundBackerTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:backer:refund'; 7 + 8 + public function generateOldValue($object) { 9 + return null; 10 + } 11 + 12 + 13 + }
+17
src/applications/fund/xaction/FundBackerStatusTransaction.php
··· 1 + <?php 2 + 3 + final class FundBackerStatusTransaction 4 + extends FundBackerTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:backer:status'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getStatus(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setStatus($value); 14 + } 15 + 16 + 17 + }
+4
src/applications/fund/xaction/FundBackerTransactionType.php
··· 1 + <?php 2 + 3 + abstract class FundBackerTransactionType 4 + extends PhabricatorModularTransactionType {}
+74
src/applications/fund/xaction/FundInitiativeBackerTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeBackerTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:backer'; 7 + 8 + public function generateOldValue($object) { 9 + return null; 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $amount = $this->getMetadataValue( 14 + FundInitiativeTransaction::PROPERTY_AMOUNT); 15 + $amount = PhortuneCurrency::newFromString($amount); 16 + $total = $object->getTotalAsCurrency()->add($amount); 17 + $object->setTotalAsCurrency($total); 18 + } 19 + 20 + public function applyExternalEffects($object, $value) { 21 + $backer = id(new FundBackerQuery()) 22 + ->setViewer($this->getActor()) 23 + ->withPHIDs(array($value)) 24 + ->executeOne(); 25 + if (!$backer) { 26 + throw new Exception(pht('Unable to load %s!', 'FundBacker')); 27 + } 28 + 29 + $subx = array(); 30 + $subx[] = id(new FundBackerTransaction()) 31 + ->setTransactionType(FundBackerStatusTransaction::TRANSACTIONTYPE) 32 + ->setNewValue(FundBacker::STATUS_PURCHASED); 33 + 34 + $content_source = $this->getEditor()->getContentSource(); 35 + 36 + $editor = id(new FundBackerEditor()) 37 + ->setActor($this->getActor()) 38 + ->setContentSource($content_source) 39 + ->setContinueOnMissingFields(true) 40 + ->setContinueOnNoEffect(true); 41 + 42 + $editor->applyTransactions($backer, $subx); 43 + } 44 + 45 + public function getTitle() { 46 + $amount = $this->getMetadataValue( 47 + FundInitiativeTransaction::PROPERTY_AMOUNT); 48 + $amount = PhortuneCurrency::newFromString($amount); 49 + return pht( 50 + '%s backed this initiative with %s.', 51 + $this->renderAuthor(), 52 + $amount->formatForDisplay()); 53 + } 54 + 55 + public function getTitleForFeed() { 56 + $amount = $this->getMetadataValue( 57 + FundInitiativeTransaction::PROPERTY_AMOUNT); 58 + $amount = PhortuneCurrency::newFromString($amount); 59 + return pht( 60 + '%s backed %s.', 61 + $this->renderAuthor(), 62 + $this->renderObject()); 63 + } 64 + 65 + public function getIcon() { 66 + return 'fa-heart'; 67 + } 68 + 69 + public function getColor() { 70 + return 'red'; 71 + } 72 + 73 + 74 + }
+75
src/applications/fund/xaction/FundInitiativeDescriptionTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeDescriptionTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:description'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getDescription(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setDescription($value); 14 + } 15 + 16 + public function shouldHide() { 17 + $old = $this->getOldValue(); 18 + $new = $this->getNewValue(); 19 + if (!strlen($old) && !strlen($new)) { 20 + return true; 21 + } 22 + return false; 23 + } 24 + 25 + public function getTitle() { 26 + $old = $this->getOldValue(); 27 + $new = $this->getNewValue(); 28 + 29 + if ($old === null) { 30 + return pht( 31 + '%s set the initiative description.', 32 + $this->renderAuthor()); 33 + } else { 34 + return pht( 35 + '%s updated the initiative description.', 36 + $this->renderAuthor()); 37 + } 38 + } 39 + 40 + public function getTitleForFeed() { 41 + return pht( 42 + '%s updated the initiative description for %s.', 43 + $this->renderAuthor(), 44 + $this->renderObject()); 45 + } 46 + 47 + public function hasChangeDetailView() { 48 + return true; 49 + } 50 + 51 + public function getMailDiffSectionHeader() { 52 + return pht('CHANGES TO INITIATIVE DESCRIPTION'); 53 + } 54 + 55 + public function newChangeDetailView() { 56 + $viewer = $this->getViewer(); 57 + 58 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 59 + ->setViewer($viewer) 60 + ->setOldText($this->getOldValue()) 61 + ->setNewText($this->getNewValue()); 62 + } 63 + 64 + public function newRemarkupChanges() { 65 + $changes = array(); 66 + 67 + $changes[] = $this->newRemarkupChange() 68 + ->setOldValue($this->getOldValue()) 69 + ->setNewValue($this->getNewValue()); 70 + 71 + return $changes; 72 + } 73 + 74 + 75 + }
+93
src/applications/fund/xaction/FundInitiativeMerchantTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeMerchantTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:merchant'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getMerchantPHID(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setMerchantPHID($value); 14 + } 15 + 16 + public function getTitle() { 17 + $new = $this->getNewValue(); 18 + $new_merchant = $this->renderHandleList(array($new)); 19 + 20 + $old = $this->getOldValue(); 21 + $old_merchant = $this->renderHandleList(array($old)); 22 + 23 + if ($old) { 24 + return pht( 25 + '%s changed the merchant receiving funds from this '. 26 + 'initiative from %s to %s.', 27 + $this->renderAuthor(), 28 + $old_merchant, 29 + $new_merchant); 30 + } else { 31 + return pht( 32 + '%s set the merchant receiving funds from this '. 33 + 'initiative to %s.', 34 + $this->renderAuthor(), 35 + $new_merchant); 36 + } 37 + } 38 + 39 + public function getTitleForFeed() { 40 + $new = $this->getNewValue(); 41 + $new_merchant = $this->renderHandleList(array($new)); 42 + 43 + $old = $this->getOldValue(); 44 + $old_merchant = $this->renderHandleList(array($old)); 45 + 46 + return pht( 47 + '%s changed the merchant receiving funds from %s '. 48 + 'initiative from %s to %s.', 49 + $this->renderAuthor(), 50 + $this->renderObject(), 51 + $old_merchant, 52 + $new_merchant); 53 + } 54 + 55 + public function validateTransactions($object, array $xactions) { 56 + $errors = array(); 57 + 58 + if ($this->isEmptyTextTransaction($object->getMerchantPHID(), $xactions)) { 59 + $errors[] = $this->newRequiredError( 60 + pht('Initiatives must have a payable merchant.')); 61 + } 62 + 63 + foreach ($xactions as $xaction) { 64 + $merchant_phid = $xaction->getNewValue(); 65 + 66 + // Make sure the actor has permission to edit the merchant they're 67 + // selecting. You aren't allowed to send payments to an account you 68 + // do not control. 69 + $merchants = id(new PhortuneMerchantQuery()) 70 + ->setViewer($this->getActor()) 71 + ->withPHIDs(array($merchant_phid)) 72 + ->requireCapabilities( 73 + array( 74 + PhabricatorPolicyCapability::CAN_VIEW, 75 + PhabricatorPolicyCapability::CAN_EDIT, 76 + )) 77 + ->execute(); 78 + if (!$merchants) { 79 + $errors[] = $this->newInvalidError( 80 + pht('You must specify a merchant account you control as the '. 81 + 'recipient of funds from this initiative.')); 82 + } 83 + } 84 + 85 + return $errors; 86 + } 87 + 88 + public function getIcon() { 89 + return 'fa-bank'; 90 + } 91 + 92 + 93 + }
+71
src/applications/fund/xaction/FundInitiativeNameTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeNameTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:name'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getName(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setName($value); 14 + } 15 + 16 + public function getTitle() { 17 + $old = $this->getOldValue(); 18 + if (!strlen($old)) { 19 + return pht( 20 + '%s created this initiative.', 21 + $this->renderAuthor()); 22 + } else { 23 + return pht( 24 + '%s renamed this initiative from %s to %s.', 25 + $this->renderAuthor(), 26 + $this->renderOldValue(), 27 + $this->renderNewValue()); 28 + } 29 + } 30 + 31 + public function getTitleForFeed() { 32 + $old = $this->getOldValue(); 33 + if (!strlen($old)) { 34 + return pht( 35 + '%s created initiative %s.', 36 + $this->renderAuthor(), 37 + $this->renderObject()); 38 + } else { 39 + return pht( 40 + '%s renamed %s initiative from %s to %s.', 41 + $this->renderAuthor(), 42 + $this->renderObject(), 43 + $this->renderOldValue(), 44 + $this->renderNewValue()); 45 + } 46 + } 47 + 48 + public function validateTransactions($object, array $xactions) { 49 + $errors = array(); 50 + 51 + if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { 52 + $errors[] = $this->newRequiredError( 53 + pht('Initiatives must have a name.')); 54 + } 55 + 56 + $max_length = $object->getColumnMaximumByteLength('name'); 57 + foreach ($xactions as $xaction) { 58 + $new_value = $xaction->getNewValue(); 59 + $new_length = strlen($new_value); 60 + if ($new_length > $max_length) { 61 + $errors[] = $this->newInvalidError( 62 + pht('The name can be no longer than %s characters.', 63 + new PhutilNumber($max_length))); 64 + } 65 + } 66 + 67 + return $errors; 68 + } 69 + 70 + 71 + }
+77
src/applications/fund/xaction/FundInitiativeRefundTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeRefundTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:refund'; 7 + 8 + public function generateOldValue($object) { 9 + return null; 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $amount = $this->getMetadataValue( 14 + FundInitiativeTransaction::PROPERTY_AMOUNT); 15 + $amount = PhortuneCurrency::newFromString($amount); 16 + $total = $object->getTotalAsCurrency()->subtract($amount); 17 + $object->setTotalAsCurrency($total); 18 + } 19 + 20 + public function applyExternalEffects($object, $value) { 21 + $backer = id(new FundBackerQuery()) 22 + ->setViewer($this->getActor()) 23 + ->withPHIDs(array($value)) 24 + ->executeOne(); 25 + if (!$backer) { 26 + throw new Exception(pht('Unable to load %s!', 'FundBacker')); 27 + } 28 + 29 + $subx = array(); 30 + $amount = $this->getMetadataValue( 31 + FundInitiativeTransaction::PROPERTY_AMOUNT); 32 + $subx[] = id(new FundBackerTransaction()) 33 + ->setTransactionType(FundBackerStatusTransaction::TRANSACTIONTYPE) 34 + ->setNewValue($amount); 35 + 36 + $content_source = $this->getEditor()->getContentSource(); 37 + 38 + $editor = id(new FundBackerEditor()) 39 + ->setActor($this->getActor()) 40 + ->setContentSource($content_source) 41 + ->setContinueOnMissingFields(true) 42 + ->setContinueOnNoEffect(true); 43 + 44 + $editor->applyTransactions($backer, $subx); 45 + } 46 + 47 + public function getTitle() { 48 + $amount = $this->getMetadataValue( 49 + FundInitiativeTransaction::PROPERTY_AMOUNT); 50 + $amount = PhortuneCurrency::newFromString($amount); 51 + $backer_phid = $this->getMetadataValue( 52 + FundInitiativeTransaction::PROPERTY_BACKER); 53 + 54 + return pht( 55 + '%s refunded %s to %s.', 56 + $this->renderAuthor(), 57 + $amount->formatForDisplay(), 58 + $this->renderHandleLink($backer_phid)); 59 + } 60 + 61 + public function getTitleForFeed() { 62 + $amount = $this->getMetadataValue( 63 + FundInitiativeTransaction::PROPERTY_AMOUNT); 64 + $amount = PhortuneCurrency::newFromString($amount); 65 + $backer_phid = $this->getMetadataValue( 66 + FundInitiativeTransaction::PROPERTY_BACKER); 67 + 68 + return pht( 69 + '%s refunded %s to %s for %s.', 70 + $this->renderAuthor(), 71 + $amount->formatForDisplay(), 72 + $this->renderHandleLink($backer_phid), 73 + $this->renderObject()); 74 + } 75 + 76 + 77 + }
+80
src/applications/fund/xaction/FundInitiativeRisksTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeRisksTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:risks'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getRisks(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setRisks($value); 14 + } 15 + 16 + public function shouldHide() { 17 + $old = $this->getOldValue(); 18 + $new = $this->getNewValue(); 19 + if (!strlen($old) && !strlen($new)) { 20 + return true; 21 + } 22 + return false; 23 + } 24 + 25 + public function getTitle() { 26 + $old = $this->getOldValue(); 27 + $new = $this->getNewValue(); 28 + 29 + if ($old === null) { 30 + return pht( 31 + '%s set the initiative risks/challenges.', 32 + $this->renderAuthor()); 33 + } else { 34 + return pht( 35 + '%s updated the initiative risks/challenges.', 36 + $this->renderAuthor()); 37 + } 38 + 39 + } 40 + 41 + public function getTitleForFeed() { 42 + return pht( 43 + '%s updated the initiative risks/challenges for %s.', 44 + $this->renderAuthor(), 45 + $this->renderObject()); 46 + } 47 + 48 + public function hasChangeDetailView() { 49 + return true; 50 + } 51 + 52 + public function getMailDiffSectionHeader() { 53 + return pht('CHANGES TO INITIATIVE RISKS/CHALLENGES'); 54 + } 55 + 56 + public function newChangeDetailView() { 57 + $viewer = $this->getViewer(); 58 + 59 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 60 + ->setViewer($viewer) 61 + ->setOldText($this->getOldValue()) 62 + ->setNewText($this->getNewValue()); 63 + } 64 + 65 + public function newRemarkupChanges() { 66 + $changes = array(); 67 + 68 + $changes[] = $this->newRemarkupChange() 69 + ->setOldValue($this->getOldValue()) 70 + ->setNewValue($this->getNewValue()); 71 + 72 + return $changes; 73 + } 74 + 75 + public function getIcon() { 76 + return 'fa-ambulance'; 77 + } 78 + 79 + 80 + }
+51
src/applications/fund/xaction/FundInitiativeStatusTransaction.php
··· 1 + <?php 2 + 3 + final class FundInitiativeStatusTransaction 4 + extends FundInitiativeTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'fund:status'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getStatus(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setStatus($value); 14 + } 15 + 16 + public function getTitle() { 17 + if ($this->getNewValue() == FundInitiative::STATUS_CLOSED) { 18 + return pht( 19 + '%s closed this initiative.', 20 + $this->renderAuthor()); 21 + } else { 22 + return pht( 23 + '%s reopened this initiative.', 24 + $this->renderAuthor()); 25 + } 26 + } 27 + 28 + public function getTitleForFeed() { 29 + if ($this->getNewValue() == FundInitiative::STATUS_CLOSED) { 30 + return pht( 31 + '%s closed the initiative %s.', 32 + $this->renderAuthor(), 33 + $this->renderObject()); 34 + } else { 35 + return pht( 36 + '%s reopened the initiative %s.', 37 + $this->renderAuthor(), 38 + $this->renderObject()); 39 + } 40 + } 41 + 42 + public function getIcon() { 43 + if ($this->getNewValue() == FundInitiative::STATUS_CLOSED) { 44 + return 'fa-ban'; 45 + } else { 46 + return 'fa-check'; 47 + } 48 + } 49 + 50 + 51 + }
+4
src/applications/fund/xaction/FundInitiativeTransactionType.php
··· 1 + <?php 2 + 3 + abstract class FundInitiativeTransactionType 4 + extends PhabricatorModularTransactionType {}