@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 PhortuneMerchant to Modular Transactions

Summary: Modernize PhortuneMerchant for Modular Transactions. Also changed the language of "Members" to "Managers", which I think fits better given the power/capability.

Test Plan:
- Create a new Merchant
- Test not filling in a name, see error
- Test removing myself, see error
- Edit an existing Merchant
- Add new managers
- Test removing myself, see error
- Replace Picture
- Update various fields, contact info, email, footer
- Verify transactions are now nice and pretty

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+431 -226
+15 -1
src/__phutil_library_map__.php
··· 4367 4367 'PhortuneMemberHasMerchantEdgeType' => 'applications/phortune/edge/PhortuneMemberHasMerchantEdgeType.php', 4368 4368 'PhortuneMerchant' => 'applications/phortune/storage/PhortuneMerchant.php', 4369 4369 'PhortuneMerchantCapability' => 'applications/phortune/capability/PhortuneMerchantCapability.php', 4370 + 'PhortuneMerchantContactInfoTransaction' => 'applications/phortune/xaction/PhortuneMerchantContactInfoTransaction.php', 4370 4371 'PhortuneMerchantController' => 'applications/phortune/controller/merchant/PhortuneMerchantController.php', 4372 + 'PhortuneMerchantDescriptionTransaction' => 'applications/phortune/xaction/PhortuneMerchantDescriptionTransaction.php', 4371 4373 'PhortuneMerchantEditController' => 'applications/phortune/controller/merchant/PhortuneMerchantEditController.php', 4372 4374 'PhortuneMerchantEditEngine' => 'applications/phortune/editor/PhortuneMerchantEditEngine.php', 4373 4375 'PhortuneMerchantEditor' => 'applications/phortune/editor/PhortuneMerchantEditor.php', 4374 4376 'PhortuneMerchantHasMemberEdgeType' => 'applications/phortune/edge/PhortuneMerchantHasMemberEdgeType.php', 4375 4377 'PhortuneMerchantInvoiceCreateController' => 'applications/phortune/controller/merchant/PhortuneMerchantInvoiceCreateController.php', 4378 + 'PhortuneMerchantInvoiceEmailTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceEmailTransaction.php', 4379 + 'PhortuneMerchantInvoiceFooterTransaction' => 'applications/phortune/xaction/PhortuneMerchantInvoiceFooterTransaction.php', 4376 4380 'PhortuneMerchantListController' => 'applications/phortune/controller/merchant/PhortuneMerchantListController.php', 4381 + 'PhortuneMerchantNameTransaction' => 'applications/phortune/xaction/PhortuneMerchantNameTransaction.php', 4377 4382 'PhortuneMerchantPHIDType' => 'applications/phortune/phid/PhortuneMerchantPHIDType.php', 4378 4383 'PhortuneMerchantPictureController' => 'applications/phortune/controller/merchant/PhortuneMerchantPictureController.php', 4384 + 'PhortuneMerchantPictureTransaction' => 'applications/phortune/xaction/PhortuneMerchantPictureTransaction.php', 4379 4385 'PhortuneMerchantQuery' => 'applications/phortune/query/PhortuneMerchantQuery.php', 4380 4386 'PhortuneMerchantSearchEngine' => 'applications/phortune/query/PhortuneMerchantSearchEngine.php', 4381 4387 'PhortuneMerchantTransaction' => 'applications/phortune/storage/PhortuneMerchantTransaction.php', 4382 4388 'PhortuneMerchantTransactionQuery' => 'applications/phortune/query/PhortuneMerchantTransactionQuery.php', 4389 + 'PhortuneMerchantTransactionType' => 'applications/phortune/xaction/PhortuneMerchantTransactionType.php', 4383 4390 'PhortuneMerchantViewController' => 'applications/phortune/controller/merchant/PhortuneMerchantViewController.php', 4384 4391 'PhortuneMonthYearExpiryControl' => 'applications/phortune/control/PhortuneMonthYearExpiryControl.php', 4385 4392 'PhortuneOrderTableView' => 'applications/phortune/view/PhortuneOrderTableView.php', ··· 9820 9827 'PhabricatorPolicyInterface', 9821 9828 ), 9822 9829 'PhortuneMerchantCapability' => 'PhabricatorPolicyCapability', 9830 + 'PhortuneMerchantContactInfoTransaction' => 'PhortuneMerchantTransactionType', 9823 9831 'PhortuneMerchantController' => 'PhortuneController', 9832 + 'PhortuneMerchantDescriptionTransaction' => 'PhortuneMerchantTransactionType', 9824 9833 'PhortuneMerchantEditController' => 'PhortuneMerchantController', 9825 9834 'PhortuneMerchantEditEngine' => 'PhabricatorEditEngine', 9826 9835 'PhortuneMerchantEditor' => 'PhabricatorApplicationTransactionEditor', 9827 9836 'PhortuneMerchantHasMemberEdgeType' => 'PhabricatorEdgeType', 9828 9837 'PhortuneMerchantInvoiceCreateController' => 'PhortuneMerchantController', 9838 + 'PhortuneMerchantInvoiceEmailTransaction' => 'PhortuneMerchantTransactionType', 9839 + 'PhortuneMerchantInvoiceFooterTransaction' => 'PhortuneMerchantTransactionType', 9829 9840 'PhortuneMerchantListController' => 'PhortuneMerchantController', 9841 + 'PhortuneMerchantNameTransaction' => 'PhortuneMerchantTransactionType', 9830 9842 'PhortuneMerchantPHIDType' => 'PhabricatorPHIDType', 9831 9843 'PhortuneMerchantPictureController' => 'PhortuneMerchantController', 9844 + 'PhortuneMerchantPictureTransaction' => 'PhortuneMerchantTransactionType', 9832 9845 'PhortuneMerchantQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 9833 9846 'PhortuneMerchantSearchEngine' => 'PhabricatorApplicationSearchEngine', 9834 - 'PhortuneMerchantTransaction' => 'PhabricatorApplicationTransaction', 9847 + 'PhortuneMerchantTransaction' => 'PhabricatorModularTransaction', 9835 9848 'PhortuneMerchantTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 9849 + 'PhortuneMerchantTransactionType' => 'PhabricatorModularTransactionType', 9836 9850 'PhortuneMerchantViewController' => 'PhortuneMerchantController', 9837 9851 'PhortuneMonthYearExpiryControl' => 'AphrontFormControl', 9838 9852 'PhortuneOrderTableView' => 'AphrontView',
+2 -1
src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
··· 76 76 77 77 $xactions = array(); 78 78 $xactions[] = id(new PhortuneMerchantTransaction()) 79 - ->setTransactionType(PhortuneMerchantTransaction::TYPE_PICTURE) 79 + ->setTransactionType( 80 + PhortuneMerchantPictureTransaction::TRANSACTIONTYPE) 80 81 ->setNewValue($new_value); 81 82 82 83 $editor = id(new PhortuneMerchantEditor())
+1 -1
src/applications/phortune/controller/merchant/PhortuneMerchantViewController.php
··· 240 240 } 241 241 242 242 $curtain->newPanel() 243 - ->setHeaderText(pht('Members')) 243 + ->setHeaderText(pht('Managers')) 244 244 ->appendChild($member_list); 245 245 246 246 return $curtain;
+6 -6
src/applications/phortune/edge/PhortuneMerchantHasMemberEdgeType.php
··· 14 14 $add_edges) { 15 15 16 16 return pht( 17 - '%s added %s merchant member(s): %s.', 17 + '%s added %s merchant manager(s): %s.', 18 18 $actor, 19 19 $add_count, 20 20 $add_edges); ··· 26 26 $rem_edges) { 27 27 28 28 return pht( 29 - '%s removed %s merchant member(s): %s.', 29 + '%s removed %s merchant manager(s): %s.', 30 30 $actor, 31 31 $rem_count, 32 32 $rem_edges); ··· 41 41 $rem_edges) { 42 42 43 43 return pht( 44 - '%s edited %s merchant member(s), added %s: %s; removed %s: %s.', 44 + '%s edited %s merchant manager(s), added %s: %s; removed %s: %s.', 45 45 $actor, 46 46 $total_count, 47 47 $add_count, ··· 57 57 $add_edges) { 58 58 59 59 return pht( 60 - '%s added %s merchant member(s) to %s: %s.', 60 + '%s added %s merchant manager(s) to %s: %s.', 61 61 $actor, 62 62 $add_count, 63 63 $object, ··· 71 71 $rem_edges) { 72 72 73 73 return pht( 74 - '%s removed %s merchant member(s) from %s: %s.', 74 + '%s removed %s merchant manager(s) from %s: %s.', 75 75 $actor, 76 76 $rem_count, 77 77 $object, ··· 88 88 $rem_edges) { 89 89 90 90 return pht( 91 - '%s edited %s merchant member(s) for %s, added %s: %s; removed %s: %s.', 91 + '%s edited %s merchant manager(s) for %s, added %s: %s; removed %s: %s.', 92 92 $actor, 93 93 $total_count, 94 94 $object,
+15 -10
src/applications/phortune/editor/PhortuneMerchantEditEngine.php
··· 81 81 ->setDescription(pht('Merchant name.')) 82 82 ->setConduitTypeDescription(pht('New Merchant name.')) 83 83 ->setIsRequired(true) 84 - ->setTransactionType(PhortuneMerchantTransaction::TYPE_NAME) 84 + ->setTransactionType( 85 + PhortuneMerchantNameTransaction::TRANSACTIONTYPE) 85 86 ->setValue($object->getName()), 86 87 87 88 id(new PhabricatorUsersEditField()) 88 89 ->setKey('members') 89 - ->setAliases(array('memberPHIDs')) 90 - ->setLabel(pht('Members')) 90 + ->setAliases(array('memberPHIDs', 'managerPHIDs')) 91 + ->setLabel(pht('Managers')) 91 92 ->setUseEdgeTransactions(true) 92 93 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 93 94 ->setMetadataValue( 94 95 'edge:type', 95 96 PhortuneMerchantHasMemberEdgeType::EDGECONST) 96 - ->setDescription(pht('Initial merchant members.')) 97 - ->setConduitDescription(pht('Set merchant members.')) 98 - ->setConduitTypeDescription(pht('New list of members.')) 97 + ->setDescription(pht('Initial merchant managers.')) 98 + ->setConduitDescription(pht('Set merchant managers.')) 99 + ->setConduitTypeDescription(pht('New list of managers.')) 99 100 ->setInitialValue($object->getMemberPHIDs()) 100 101 ->setValue($member_phids), 101 102 ··· 104 105 ->setLabel(pht('Description')) 105 106 ->setDescription(pht('Merchant description.')) 106 107 ->setConduitTypeDescription(pht('New merchant description.')) 107 - ->setTransactionType(PhortuneMerchantTransaction::TYPE_DESCRIPTION) 108 + ->setTransactionType( 109 + PhortuneMerchantDescriptionTransaction::TRANSACTIONTYPE) 108 110 ->setValue($object->getDescription()), 109 111 110 112 id(new PhabricatorRemarkupEditField()) ··· 112 114 ->setLabel(pht('Contact Info')) 113 115 ->setDescription(pht('Merchant contact information.')) 114 116 ->setConduitTypeDescription(pht('Merchant contact information.')) 115 - ->setTransactionType(PhortuneMerchantTransaction::TYPE_CONTACTINFO) 117 + ->setTransactionType( 118 + PhortuneMerchantContactInfoTransaction::TRANSACTIONTYPE) 116 119 ->setValue($object->getContactInfo()), 117 120 118 121 id(new PhabricatorTextEditField()) ··· 121 124 ->setDescription(pht('Email address invoices are sent from.')) 122 125 ->setConduitTypeDescription( 123 126 pht('Email address invoices are sent from.')) 124 - ->setTransactionType(PhortuneMerchantTransaction::TYPE_INVOICEEMAIL) 127 + ->setTransactionType( 128 + PhortuneMerchantInvoiceEmailTransaction::TRANSACTIONTYPE) 125 129 ->setValue($object->getInvoiceEmail()), 126 130 127 131 id(new PhabricatorRemarkupEditField()) ··· 129 133 ->setLabel(pht('Invoice Footer')) 130 134 ->setDescription(pht('Footer on invoice forms.')) 131 135 ->setConduitTypeDescription(pht('Footer on invoice forms.')) 132 - ->setTransactionType(PhortuneMerchantTransaction::TYPE_INVOICEFOOTER) 136 + ->setTransactionType( 137 + PhortuneMerchantInvoiceFooterTransaction::TRANSACTIONTYPE) 133 138 ->setValue($object->getInvoiceFooter()), 134 139 135 140 );
+21 -126
src/applications/phortune/editor/PhortuneMerchantEditor.php
··· 11 11 return pht('Phortune Merchants'); 12 12 } 13 13 14 + public function getCreateObjectTitle($author, $object) { 15 + return pht('%s created this merchant.', $author); 16 + } 17 + 14 18 public function getTransactionTypes() { 15 19 $types = parent::getTransactionTypes(); 16 20 17 - $types[] = PhortuneMerchantTransaction::TYPE_NAME; 18 - $types[] = PhortuneMerchantTransaction::TYPE_DESCRIPTION; 19 - $types[] = PhortuneMerchantTransaction::TYPE_CONTACTINFO; 20 - $types[] = PhortuneMerchantTransaction::TYPE_PICTURE; 21 - $types[] = PhortuneMerchantTransaction::TYPE_INVOICEEMAIL; 22 - $types[] = PhortuneMerchantTransaction::TYPE_INVOICEFOOTER; 23 21 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 24 22 $types[] = PhabricatorTransactions::TYPE_EDGE; 25 23 26 24 return $types; 27 25 } 28 26 29 - protected function getCustomTransactionOldValue( 30 - PhabricatorLiskDAO $object, 31 - PhabricatorApplicationTransaction $xaction) { 32 - switch ($xaction->getTransactionType()) { 33 - case PhortuneMerchantTransaction::TYPE_NAME: 34 - return $object->getName(); 35 - case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 36 - return $object->getDescription(); 37 - case PhortuneMerchantTransaction::TYPE_CONTACTINFO: 38 - return $object->getContactInfo(); 39 - case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: 40 - return $object->getInvoiceEmail(); 41 - case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER: 42 - return $object->getInvoiceFooter(); 43 - case PhortuneMerchantTransaction::TYPE_PICTURE: 44 - return $object->getProfileImagePHID(); 45 - } 46 - 47 - return parent::getCustomTransactionOldValue($object, $xaction); 48 - } 49 - 50 - protected function getCustomTransactionNewValue( 51 - PhabricatorLiskDAO $object, 52 - PhabricatorApplicationTransaction $xaction) { 53 - 54 - switch ($xaction->getTransactionType()) { 55 - case PhortuneMerchantTransaction::TYPE_NAME: 56 - case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 57 - case PhortuneMerchantTransaction::TYPE_CONTACTINFO: 58 - case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: 59 - case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER: 60 - case PhortuneMerchantTransaction::TYPE_PICTURE: 61 - return $xaction->getNewValue(); 62 - } 63 - 64 - return parent::getCustomTransactionNewValue($object, $xaction); 65 - } 66 - 67 - protected function applyCustomInternalTransaction( 68 - PhabricatorLiskDAO $object, 69 - PhabricatorApplicationTransaction $xaction) { 70 - 71 - switch ($xaction->getTransactionType()) { 72 - case PhortuneMerchantTransaction::TYPE_NAME: 73 - $object->setName($xaction->getNewValue()); 74 - return; 75 - case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 76 - $object->setDescription($xaction->getNewValue()); 77 - return; 78 - case PhortuneMerchantTransaction::TYPE_CONTACTINFO: 79 - $object->setContactInfo($xaction->getNewValue()); 80 - return; 81 - case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: 82 - $object->setInvoiceEmail($xaction->getNewValue()); 83 - return; 84 - case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER: 85 - $object->setInvoiceFooter($xaction->getNewValue()); 86 - return; 87 - case PhortuneMerchantTransaction::TYPE_PICTURE: 88 - $object->setProfileImagePHID($xaction->getNewValue()); 89 - return; 90 - } 91 - 92 - return parent::applyCustomInternalTransaction($object, $xaction); 93 - } 94 - 95 - protected function applyCustomExternalTransaction( 96 - PhabricatorLiskDAO $object, 97 - PhabricatorApplicationTransaction $xaction) { 98 - 99 - switch ($xaction->getTransactionType()) { 100 - case PhortuneMerchantTransaction::TYPE_NAME: 101 - case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 102 - case PhortuneMerchantTransaction::TYPE_CONTACTINFO: 103 - case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: 104 - case PhortuneMerchantTransaction::TYPE_INVOICEFOOTER: 105 - case PhortuneMerchantTransaction::TYPE_PICTURE: 106 - return; 107 - } 108 - 109 - return parent::applyCustomExternalTransaction($object, $xaction); 110 - } 111 - 112 27 protected function validateTransaction( 113 28 PhabricatorLiskDAO $object, 114 29 $type, ··· 117 32 $errors = parent::validateTransaction($object, $type, $xactions); 118 33 119 34 switch ($type) { 120 - case PhortuneMerchantTransaction::TYPE_NAME: 121 - $missing = $this->validateIsEmptyTextField( 122 - $object->getName(), 123 - $xactions); 124 - 125 - if ($missing) { 126 - $error = new PhabricatorApplicationTransactionValidationError( 127 - $type, 128 - pht('Required'), 129 - pht('Merchant name is required.'), 130 - nonempty(last($xactions), null)); 131 - 132 - $error->setIsMissingFieldError(true); 133 - $errors[] = $error; 134 - } 135 - break; 136 - case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: 137 - $new_email = null; 35 + case PhabricatorTransactions::TYPE_EDGE: 138 36 foreach ($xactions as $xaction) { 139 - switch ($xaction->getTransactionType()) { 140 - case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: 141 - $new_email = $xaction->getNewValue(); 142 - break; 143 - } 144 - } 145 - if (strlen($new_email)) { 146 - $email = new PhutilEmailAddress($new_email); 147 - $domain = $email->getDomainName(); 148 - 149 - if (!$domain) { 150 - $error = new PhabricatorApplicationTransactionValidationError( 151 - $type, 152 - pht('Invalid'), 153 - pht('%s is not a valid email.', $new_email), 154 - nonempty(last($xactions), null)); 155 - 156 - $errors[] = $error; 37 + switch ($xaction->getMetadataValue('edge:type')) { 38 + case PhortuneMerchantHasMemberEdgeType::EDGECONST: 39 + $new = $xaction->getNewValue(); 40 + $set = idx($new, '-', array()); 41 + $actor_phid = $this->requireActor()->getPHID(); 42 + foreach ($set as $phid) { 43 + if ($actor_phid == $phid) { 44 + $error = new PhabricatorApplicationTransactionValidationError( 45 + $type, 46 + pht('Invalid'), 47 + pht('You can not remove yourself as an merchant manager.'), 48 + $xaction); 49 + $errors[] = $error; 50 + } 51 + } 52 + break; 157 53 } 158 54 } 159 55 break; 160 56 } 161 - 162 57 return $errors; 163 58 } 164 59
+3 -81
src/applications/phortune/storage/PhortuneMerchantTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhortuneMerchantTransaction 4 - extends PhabricatorApplicationTransaction { 5 - 6 - const TYPE_NAME = 'merchant:name'; 7 - const TYPE_DESCRIPTION = 'merchant:description'; 8 - const TYPE_CONTACTINFO = 'merchant:contactinfo'; 9 - const TYPE_INVOICEEMAIL = 'merchant:invoiceemail'; 10 - const TYPE_INVOICEFOOTER = 'merchant:invoicefooter'; 11 - const TYPE_PICTURE = 'merchant:picture'; 4 + extends PhabricatorModularTransaction { 12 5 13 6 public function getApplicationName() { 14 7 return 'phortune'; ··· 22 15 return null; 23 16 } 24 17 25 - public function getTitle() { 26 - $author_phid = $this->getAuthorPHID(); 27 - 28 - $old = $this->getOldValue(); 29 - $new = $this->getNewValue(); 30 - 31 - switch ($this->getTransactionType()) { 32 - case self::TYPE_NAME: 33 - if ($old === null) { 34 - return pht( 35 - '%s created this merchant.', 36 - $this->renderHandleLink($author_phid)); 37 - } else { 38 - return pht( 39 - '%s renamed this merchant from "%s" to "%s".', 40 - $this->renderHandleLink($author_phid), 41 - $old, 42 - $new); 43 - } 44 - break; 45 - case self::TYPE_DESCRIPTION: 46 - return pht( 47 - '%s updated the description for this merchant.', 48 - $this->renderHandleLink($author_phid)); 49 - case self::TYPE_CONTACTINFO: 50 - return pht( 51 - '%s updated the contact information for this merchant.', 52 - $this->renderHandleLink($author_phid)); 53 - case self::TYPE_INVOICEEMAIL: 54 - return pht( 55 - '%s updated the invoice email for this merchant.', 56 - $this->renderHandleLink($author_phid)); 57 - case self::TYPE_INVOICEFOOTER: 58 - return pht( 59 - '%s updated the invoice footer for this merchant.', 60 - $this->renderHandleLink($author_phid)); 61 - } 62 - 63 - return parent::getTitle(); 64 - } 65 - 66 - public function shouldHide() { 67 - $old = $this->getOldValue(); 68 - switch ($this->getTransactionType()) { 69 - case self::TYPE_DESCRIPTION: 70 - case self::TYPE_CONTACTINFO: 71 - case self::TYPE_INVOICEEMAIL: 72 - case self::TYPE_INVOICEFOOTER: 73 - return ($old === null); 74 - } 75 - return parent::shouldHide(); 76 - } 77 - 78 - public function hasChangeDetails() { 79 - switch ($this->getTransactionType()) { 80 - case self::TYPE_DESCRIPTION: 81 - return ($this->getOldValue() !== null); 82 - case self::TYPE_CONTACTINFO: 83 - return ($this->getOldValue() !== null); 84 - case self::TYPE_INVOICEEMAIL: 85 - return ($this->getOldValue() !== null); 86 - case self::TYPE_INVOICEFOOTER: 87 - return ($this->getOldValue() !== null); 88 - } 89 - 90 - return parent::hasChangeDetails(); 91 - } 92 - 93 - public function renderChangeDetails(PhabricatorUser $viewer) { 94 - return $this->renderTextCorpusChangeDetails( 95 - $viewer, 96 - $this->getOldValue(), 97 - $this->getNewValue()); 18 + public function getBaseTransactionClass() { 19 + return 'PhortuneMerchantTransactionType'; 98 20 } 99 21 100 22 }
+56
src/applications/phortune/xaction/PhortuneMerchantContactInfoTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneMerchantContactInfoTransaction 4 + extends PhortuneMerchantTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'merchant:contactinfo'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getContactInfo(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setContactInfo($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s updated the merchant contact info.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s updated the merchant contact info for %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + public function hasChangeDetailView() { 30 + return true; 31 + } 32 + 33 + public function getMailDiffSectionHeader() { 34 + return pht('CHANGES TO MERCHANT CONTACT INFO'); 35 + } 36 + 37 + public function newChangeDetailView() { 38 + $viewer = $this->getViewer(); 39 + 40 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 41 + ->setViewer($viewer) 42 + ->setOldText($this->getOldValue()) 43 + ->setNewText($this->getNewValue()); 44 + } 45 + 46 + public function newRemarkupChanges() { 47 + $changes = array(); 48 + 49 + $changes[] = $this->newRemarkupChange() 50 + ->setOldValue($this->getOldValue()) 51 + ->setNewValue($this->getNewValue()); 52 + 53 + return $changes; 54 + } 55 + 56 + }
+56
src/applications/phortune/xaction/PhortuneMerchantDescriptionTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneMerchantDescriptionTransaction 4 + extends PhortuneMerchantTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'merchant: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 getTitle() { 17 + return pht( 18 + '%s updated the merchant description.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s updated the merchant description for %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + public function hasChangeDetailView() { 30 + return true; 31 + } 32 + 33 + public function getMailDiffSectionHeader() { 34 + return pht('CHANGES TO MERCHANT DESCRIPTION'); 35 + } 36 + 37 + public function newChangeDetailView() { 38 + $viewer = $this->getViewer(); 39 + 40 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 41 + ->setViewer($viewer) 42 + ->setOldText($this->getOldValue()) 43 + ->setNewText($this->getNewValue()); 44 + } 45 + 46 + public function newRemarkupChanges() { 47 + $changes = array(); 48 + 49 + $changes[] = $this->newRemarkupChange() 50 + ->setOldValue($this->getOldValue()) 51 + ->setNewValue($this->getNewValue()); 52 + 53 + return $changes; 54 + } 55 + 56 + }
+94
src/applications/phortune/xaction/PhortuneMerchantInvoiceEmailTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneMerchantInvoiceEmailTransaction 4 + extends PhortuneMerchantTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'merchant:invoiceemail'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getInvoiceEmail(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setInvoiceEmail($value); 14 + } 15 + 16 + public function getTitle() { 17 + $old = $this->getOldValue(); 18 + $new = $this->getNewValue(); 19 + 20 + if (strlen($old) && strlen($new)) { 21 + return pht( 22 + '%s updated the invoice email from %s to %s.', 23 + $this->renderAuthor(), 24 + $this->renderOldValue(), 25 + $this->renderNewValue()); 26 + } else if (strlen($old)) { 27 + return pht( 28 + '%s removed the invoice email.', 29 + $this->renderAuthor()); 30 + } else { 31 + return pht( 32 + '%s set the invoice email to %s.', 33 + $this->renderAuthor(), 34 + $this->renderNewValue()); 35 + } 36 + } 37 + 38 + public function getTitleForFeed() { 39 + $old = $this->getOldValue(); 40 + $new = $this->getNewValue(); 41 + 42 + if (strlen($old) && strlen($new)) { 43 + return pht( 44 + '%s updated %s invoice email from %s to %s.', 45 + $this->renderAuthor(), 46 + $this->renderObject(), 47 + $this->renderOldValue(), 48 + $this->renderNewValue()); 49 + } else if (strlen($old)) { 50 + return pht( 51 + '%s removed the invoice email for %s.', 52 + $this->renderAuthor(), 53 + $this->renderObject()); 54 + } else { 55 + return pht( 56 + '%s set the invoice email for %s to %s.', 57 + $this->renderAuthor(), 58 + $this->renderObject(), 59 + $this->renderNewValue()); 60 + } 61 + } 62 + 63 + public function getIcon() { 64 + return 'fa-envelope'; 65 + } 66 + 67 + public function validateTransactions($object, array $xactions) { 68 + $errors = array(); 69 + 70 + $max_length = $object->getColumnMaximumByteLength('invoiceEmail'); 71 + foreach ($xactions as $xaction) { 72 + if (strlen($xaction->getNewValue())) { 73 + $email = new PhutilEmailAddress($xaction->getNewValue()); 74 + $domain = $email->getDomainName(); 75 + if (!strlen($domain)) { 76 + $errors[] = $this->newInvalidError( 77 + pht('Invoice email "%s" must be a valid email.', 78 + $xaction->getNewValue())); 79 + } 80 + 81 + $new_value = $xaction->getNewValue(); 82 + $new_length = strlen($new_value); 83 + if ($new_length > $max_length) { 84 + $errors[] = $this->newInvalidError( 85 + pht('The email can be no longer than %s characters.', 86 + new PhutilNumber($max_length))); 87 + } 88 + } 89 + } 90 + 91 + return $errors; 92 + } 93 + 94 + }
+56
src/applications/phortune/xaction/PhortuneMerchantInvoiceFooterTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneMerchantInvoiceFooterTransaction 4 + extends PhortuneMerchantTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'merchant:invoicefooter'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getInvoiceFooter(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setInvoiceFooter($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s updated the merchant invoice footer.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s updated the merchant invoice footer for %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + public function hasChangeDetailView() { 30 + return true; 31 + } 32 + 33 + public function getMailDiffSectionHeader() { 34 + return pht('CHANGES TO MERCHANT INVOICE FOOTER'); 35 + } 36 + 37 + public function newChangeDetailView() { 38 + $viewer = $this->getViewer(); 39 + 40 + return id(new PhabricatorApplicationTransactionTextDiffDetailView()) 41 + ->setViewer($viewer) 42 + ->setOldText($this->getOldValue()) 43 + ->setNewText($this->getNewValue()); 44 + } 45 + 46 + public function newRemarkupChanges() { 47 + $changes = array(); 48 + 49 + $changes[] = $this->newRemarkupChange() 50 + ->setOldValue($this->getOldValue()) 51 + ->setNewValue($this->getNewValue()); 52 + 53 + return $changes; 54 + } 55 + 56 + }
+55
src/applications/phortune/xaction/PhortuneMerchantNameTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneMerchantNameTransaction 4 + extends PhortuneMerchantTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'merchant: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 + return pht( 18 + '%s renamed this merchant from %s to %s.', 19 + $this->renderAuthor(), 20 + $this->renderOldValue(), 21 + $this->renderNewValue()); 22 + } 23 + 24 + public function getTitleForFeed() { 25 + return pht( 26 + '%s renamed %s merchant name from %s to %s.', 27 + $this->renderAuthor(), 28 + $this->renderObject(), 29 + $this->renderOldValue(), 30 + $this->renderNewValue()); 31 + } 32 + 33 + public function validateTransactions($object, array $xactions) { 34 + $errors = array(); 35 + 36 + if ($this->isEmptyTextTransaction($object->getName(), $xactions)) { 37 + $errors[] = $this->newRequiredError( 38 + pht('Merchants must have a name.')); 39 + } 40 + 41 + $max_length = $object->getColumnMaximumByteLength('name'); 42 + foreach ($xactions as $xaction) { 43 + $new_value = $xaction->getNewValue(); 44 + $new_length = strlen($new_value); 45 + if ($new_length > $max_length) { 46 + $errors[] = $this->newInvalidError( 47 + pht('The name can be no longer than %s characters.', 48 + new PhutilNumber($max_length))); 49 + } 50 + } 51 + 52 + return $errors; 53 + } 54 + 55 + }
+33
src/applications/phortune/xaction/PhortuneMerchantPictureTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneMerchantPictureTransaction 4 + extends PhortuneMerchantTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'merchant:picture'; 7 + 8 + public function generateOldValue($object) { 9 + return $object->getProfileImagePHID(); 10 + } 11 + 12 + public function applyInternalEffects($object, $value) { 13 + $object->setProfileImagePHID($value); 14 + } 15 + 16 + public function getTitle() { 17 + return pht( 18 + '%s updated the picture.', 19 + $this->renderAuthor()); 20 + } 21 + 22 + public function getTitleForFeed() { 23 + return pht( 24 + '%s updated the picture for merchant %s.', 25 + $this->renderAuthor(), 26 + $this->renderObject()); 27 + } 28 + 29 + public function getIcon() { 30 + return 'fa-camera-retro'; 31 + } 32 + 33 + }
+4
src/applications/phortune/xaction/PhortuneMerchantTransactionType.php
··· 1 + <?php 2 + 3 + abstract class PhortuneMerchantTransactionType 4 + extends PhabricatorModularTransactionType {}
+14
src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
··· 1610 1610 1611 1611 '%s accepted this revision as %s reviewer(s): %s.' => 1612 1612 '%s accepted this revision as: %3$s.', 1613 + 1614 + '%s added %s merchant manager(s): %s.' => array( 1615 + array( 1616 + '%s added a merchant manager: %3$s.', 1617 + '%s added merchant managers: %3$s.', 1618 + ), 1619 + ), 1620 + 1621 + '%s removed %s merchant manager(s): %s.' => array( 1622 + array( 1623 + '%s removed a merchant manager: %3$s.', 1624 + '%s removed merchant managers: %3$s.', 1625 + ), 1626 + ), 1613 1627 ); 1614 1628 } 1615 1629