@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.

Modernize PhortuneAccount with EditEngine/Modular Transactions

Summary: This updates the backend of PhortuneAccount to use EditEngine and Modular Transactions and updates language to "account manager" for clarity of role.

Test Plan:
- Wiped `phortune_account` table
- Visit Phortune, see new account automatically created.
- Edit name and managers
- Try to set no name or remove myself as a manager, get error messages
- Visit `/phortune/` and create another new account

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+255 -247
+7 -1
src/__phutil_library_map__.php
··· 4322 4322 'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php', 4323 4323 'PhortuneAccountChargeListController' => 'applications/phortune/controller/account/PhortuneAccountChargeListController.php', 4324 4324 'PhortuneAccountEditController' => 'applications/phortune/controller/account/PhortuneAccountEditController.php', 4325 + 'PhortuneAccountEditEngine' => 'applications/phortune/editor/PhortuneAccountEditEngine.php', 4325 4326 'PhortuneAccountEditor' => 'applications/phortune/editor/PhortuneAccountEditor.php', 4326 4327 'PhortuneAccountHasMemberEdgeType' => 'applications/phortune/edge/PhortuneAccountHasMemberEdgeType.php', 4327 4328 'PhortuneAccountListController' => 'applications/phortune/controller/account/PhortuneAccountListController.php', 4329 + 'PhortuneAccountNameTransaction' => 'applications/phortune/xaction/PhortuneAccountNameTransaction.php', 4328 4330 'PhortuneAccountPHIDType' => 'applications/phortune/phid/PhortuneAccountPHIDType.php', 4329 4331 'PhortuneAccountQuery' => 'applications/phortune/query/PhortuneAccountQuery.php', 4330 4332 'PhortuneAccountTransaction' => 'applications/phortune/storage/PhortuneAccountTransaction.php', 4331 4333 'PhortuneAccountTransactionQuery' => 'applications/phortune/query/PhortuneAccountTransactionQuery.php', 4334 + 'PhortuneAccountTransactionType' => 'applications/phortune/xaction/PhortuneAccountTransactionType.php', 4332 4335 'PhortuneAccountViewController' => 'applications/phortune/controller/account/PhortuneAccountViewController.php', 4333 4336 'PhortuneAdHocCart' => 'applications/phortune/cart/PhortuneAdHocCart.php', 4334 4337 'PhortuneAdHocProduct' => 'applications/phortune/product/PhortuneAdHocProduct.php', ··· 9771 9774 ), 9772 9775 'PhortuneAccountChargeListController' => 'PhortuneController', 9773 9776 'PhortuneAccountEditController' => 'PhortuneController', 9777 + 'PhortuneAccountEditEngine' => 'PhabricatorEditEngine', 9774 9778 'PhortuneAccountEditor' => 'PhabricatorApplicationTransactionEditor', 9775 9779 'PhortuneAccountHasMemberEdgeType' => 'PhabricatorEdgeType', 9776 9780 'PhortuneAccountListController' => 'PhortuneController', 9781 + 'PhortuneAccountNameTransaction' => 'PhortuneAccountTransactionType', 9777 9782 'PhortuneAccountPHIDType' => 'PhabricatorPHIDType', 9778 9783 'PhortuneAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 9779 - 'PhortuneAccountTransaction' => 'PhabricatorApplicationTransaction', 9784 + 'PhortuneAccountTransaction' => 'PhabricatorModularTransaction', 9780 9785 'PhortuneAccountTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 9786 + 'PhortuneAccountTransactionType' => 'PhabricatorModularTransactionType', 9781 9787 'PhortuneAccountViewController' => 'PhortuneController', 9782 9788 'PhortuneAdHocCart' => 'PhortuneCartImplementation', 9783 9789 'PhortuneAdHocProduct' => 'PhortuneProductImplementation',
+2 -1
src/applications/phortune/application/PhabricatorPhortuneApplication.php
··· 67 67 ), 68 68 'account/' => array( 69 69 '' => 'PhortuneAccountListController', 70 - 'edit/(?:(?P<id>\d+)/)?' => 'PhortuneAccountEditController', 70 + $this->getEditRoutePattern('edit/') 71 + => 'PhortuneAccountEditController', 71 72 ), 72 73 'product/' => array( 73 74 '' => 'PhortuneProductListController',
+5 -131
src/applications/phortune/controller/account/PhortuneAccountEditController.php
··· 1 1 <?php 2 2 3 - final class PhortuneAccountEditController extends PhortuneController { 3 + final class PhortuneAccountEditController extends 4 + PhortuneController { 4 5 5 6 public function handleRequest(AphrontRequest $request) { 6 - $viewer = $request->getViewer(); 7 - $id = $request->getURIData('id'); 8 - 9 - if ($id) { 10 - $account = id(new PhortuneAccountQuery()) 11 - ->setViewer($viewer) 12 - ->withIDs(array($id)) 13 - ->requireCapabilities( 14 - array( 15 - PhabricatorPolicyCapability::CAN_VIEW, 16 - PhabricatorPolicyCapability::CAN_EDIT, 17 - )) 18 - ->executeOne(); 19 - if (!$account) { 20 - return new Aphront404Response(); 21 - } 22 - $is_new = false; 23 - } else { 24 - $account = PhortuneAccount::initializeNewAccount($viewer); 25 - $account->attachMemberPHIDs(array($viewer->getPHID())); 26 - $is_new = true; 27 - } 28 - 29 - $v_name = $account->getName(); 30 - $e_name = true; 31 - 32 - $v_members = $account->getMemberPHIDs(); 33 - $e_members = null; 34 - 35 - $validation_exception = null; 36 - 37 - if ($request->isFormPost()) { 38 - $v_name = $request->getStr('name'); 39 - $v_members = $request->getArr('memberPHIDs'); 40 - 41 - $type_name = PhortuneAccountTransaction::TYPE_NAME; 42 - $type_edge = PhabricatorTransactions::TYPE_EDGE; 43 - 44 - $xactions = array(); 45 - $xactions[] = id(new PhortuneAccountTransaction()) 46 - ->setTransactionType($type_name) 47 - ->setNewValue($v_name); 48 - 49 - $xactions[] = id(new PhortuneAccountTransaction()) 50 - ->setTransactionType($type_edge) 51 - ->setMetadataValue( 52 - 'edge:type', 53 - PhortuneAccountHasMemberEdgeType::EDGECONST) 54 - ->setNewValue( 55 - array( 56 - '=' => array_fuse($v_members), 57 - )); 58 - 59 - $editor = id(new PhortuneAccountEditor()) 60 - ->setActor($viewer) 61 - ->setContentSourceFromRequest($request) 62 - ->setContinueOnNoEffect(true); 63 - 64 - try { 65 - $editor->applyTransactions($account, $xactions); 66 - 67 - $account_uri = $this->getApplicationURI($account->getID().'/'); 68 - return id(new AphrontRedirectResponse())->setURI($account_uri); 69 - } catch (PhabricatorApplicationTransactionValidationException $ex) { 70 - $validation_exception = $ex; 71 - $e_name = $ex->getShortMessage($type_name); 72 - $e_members = $ex->getShortMessage($type_edge); 73 - } 74 - } 75 - 76 - $crumbs = $this->buildApplicationCrumbs(); 77 - $crumbs->setBorder(true); 78 - 79 - if ($is_new) { 80 - $cancel_uri = $this->getApplicationURI('account/'); 81 - $crumbs->addTextCrumb(pht('Accounts'), $cancel_uri); 82 - $crumbs->addTextCrumb(pht('Create Account')); 83 - 84 - $title = pht('Create Payment Account'); 85 - $submit_button = pht('Create Account'); 86 - } else { 87 - $cancel_uri = $this->getApplicationURI($account->getID().'/'); 88 - $crumbs->addTextCrumb($account->getName(), $cancel_uri); 89 - $crumbs->addTextCrumb(pht('Edit')); 90 - 91 - $title = pht('Edit %s', $account->getName()); 92 - $submit_button = pht('Save Changes'); 93 - } 94 - 95 - $form = id(new AphrontFormView()) 96 - ->setUser($viewer) 97 - ->appendChild( 98 - id(new AphrontFormTextControl()) 99 - ->setName('name') 100 - ->setLabel(pht('Name')) 101 - ->setValue($v_name) 102 - ->setError($e_name)) 103 - ->appendControl( 104 - id(new AphrontFormTokenizerControl()) 105 - ->setDatasource(new PhabricatorPeopleDatasource()) 106 - ->setLabel(pht('Members')) 107 - ->setName('memberPHIDs') 108 - ->setValue($v_members) 109 - ->setError($e_members)) 110 - ->appendChild( 111 - id(new AphrontFormSubmitControl()) 112 - ->setValue($submit_button) 113 - ->addCancelButton($cancel_uri)); 114 - 115 - $box = id(new PHUIObjectBoxView()) 116 - ->setHeaderText(pht('Account')) 117 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 118 - ->setValidationException($validation_exception) 119 - ->setForm($form); 120 - 121 - $header = id(new PHUIHeaderView()) 122 - ->setHeader($title) 123 - ->setHeaderIcon('fa-pencil'); 124 - 125 - $view = id(new PHUITwoColumnView()) 126 - ->setHeader($header) 127 - ->setFooter(array( 128 - $box, 129 - )); 130 - 131 - return $this->newPage() 132 - ->setTitle($title) 133 - ->setCrumbs($crumbs) 134 - ->appendChild($view); 7 + return id(new PhortuneAccountEditEngine()) 8 + ->setController($this) 9 + ->buildResponse(); 135 10 } 136 - 137 11 }
+1 -1
src/applications/phortune/controller/account/PhortuneAccountViewController.php
··· 129 129 ->appendChild($status_view); 130 130 131 131 $curtain->newPanel() 132 - ->setHeaderText(pht('Members')) 132 + ->setHeaderText(pht('Managers')) 133 133 ->appendChild($member_list); 134 134 135 135 return $curtain;
+1 -1
src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
··· 21 21 return new Aphront404Response(); 22 22 } 23 23 24 - $uri = $merchant->getViewURI(); 24 + $uri = $merchant->getURI(); 25 25 26 26 $supported_formats = PhabricatorFile::getTransformableImageFormats(); 27 27 $e_file = true;
+6 -6
src/applications/phortune/edge/PhortuneAccountHasMemberEdgeType.php
··· 14 14 $add_edges) { 15 15 16 16 return pht( 17 - '%s added %s account member(s): %s.', 17 + '%s added %s account 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 account member(s): %s.', 29 + '%s removed %s account 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 account member(s), added %s: %s; removed %s: %s.', 44 + '%s edited %s account 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 account member(s) to %s: %s.', 60 + '%s added %s account 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 account member(s) from %s: %s.', 74 + '%s removed %s account 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 account member(s) for %s, added %s: %s; removed %s: %s.', 91 + '%s edited %s account manager(s) for %s, added %s: %s; removed %s: %s.', 92 92 $actor, 93 93 $total_count, 94 94 $object,
+108
src/applications/phortune/editor/PhortuneAccountEditEngine.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountEditEngine 4 + extends PhabricatorEditEngine { 5 + 6 + const ENGINECONST = 'phortune.account'; 7 + 8 + public function getEngineName() { 9 + return pht('Phortune Accounts'); 10 + } 11 + 12 + public function getEngineApplicationClass() { 13 + return 'PhabricatorPhortuneApplication'; 14 + } 15 + 16 + public function getSummaryHeader() { 17 + return pht('Configure Phortune Account Forms'); 18 + } 19 + 20 + public function getSummaryText() { 21 + return pht('Configure creation and editing forms in Phortune Accounts.'); 22 + } 23 + 24 + public function isEngineConfigurable() { 25 + return false; 26 + } 27 + 28 + protected function newEditableObject() { 29 + return PhortuneAccount::initializeNewAccount($this->getViewer()); 30 + } 31 + 32 + protected function newObjectQuery() { 33 + return new PhortuneAccountQuery(); 34 + } 35 + 36 + protected function getObjectCreateTitleText($object) { 37 + return pht('Create Payment Account'); 38 + } 39 + 40 + protected function getObjectEditTitleText($object) { 41 + return pht('Edit Account: %s', $object->getName()); 42 + } 43 + 44 + protected function getObjectEditShortText($object) { 45 + return $object->getName(); 46 + } 47 + 48 + protected function getObjectCreateShortText() { 49 + return pht('Create Account'); 50 + } 51 + 52 + protected function getObjectName() { 53 + return pht('Account'); 54 + } 55 + 56 + protected function getObjectCreateCancelURI($object) { 57 + return $this->getApplication()->getApplicationURI('/'); 58 + } 59 + 60 + protected function getEditorURI() { 61 + return $this->getApplication()->getApplicationURI('edit/'); 62 + } 63 + 64 + protected function getObjectViewURI($object) { 65 + return $object->getURI(); 66 + } 67 + 68 + protected function buildCustomEditFields($object) { 69 + $viewer = $this->getViewer(); 70 + 71 + if ($this->getIsCreate()) { 72 + $member_phids = array($viewer->getPHID()); 73 + } else { 74 + $member_phids = $object->getMemberPHIDs(); 75 + } 76 + 77 + $fields = array( 78 + id(new PhabricatorTextEditField()) 79 + ->setKey('name') 80 + ->setLabel(pht('Name')) 81 + ->setDescription(pht('Account name.')) 82 + ->setConduitTypeDescription(pht('New account name.')) 83 + ->setTransactionType( 84 + PhortuneAccountNameTransaction::TRANSACTIONTYPE) 85 + ->setValue($object->getName()) 86 + ->setIsRequired(true), 87 + 88 + id(new PhabricatorUsersEditField()) 89 + ->setKey('managers') 90 + ->setAliases(array('memberPHIDs', 'managerPHIDs')) 91 + ->setLabel(pht('Managers')) 92 + ->setUseEdgeTransactions(true) 93 + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 94 + ->setMetadataValue( 95 + 'edge:type', 96 + PhortuneAccountHasMemberEdgeType::EDGECONST) 97 + ->setDescription(pht('Initial account managers.')) 98 + ->setConduitDescription(pht('Set account managers.')) 99 + ->setConduitTypeDescription(pht('New list of managers.')) 100 + ->setInitialValue($object->getMemberPHIDs()) 101 + ->setValue($member_phids), 102 + ); 103 + 104 + return $fields; 105 + 106 + } 107 + 108 + }
+40 -76
src/applications/phortune/editor/PhortuneAccountEditor.php
··· 1 1 <?php 2 2 3 - 4 3 final class PhortuneAccountEditor 5 4 extends PhabricatorApplicationTransactionEditor { 6 5 ··· 12 11 return pht('Phortune Accounts'); 13 12 } 14 13 14 + public function getCreateObjectTitle($author, $object) { 15 + return pht('%s created this payment account.', $author); 16 + } 17 + 15 18 public function getTransactionTypes() { 16 19 $types = parent::getTransactionTypes(); 17 - 18 20 $types[] = PhabricatorTransactions::TYPE_EDGE; 19 - $types[] = PhortuneAccountTransaction::TYPE_NAME; 20 - 21 21 return $types; 22 22 } 23 23 24 - 25 - protected function getCustomTransactionOldValue( 26 - PhabricatorLiskDAO $object, 27 - PhabricatorApplicationTransaction $xaction) { 28 - switch ($xaction->getTransactionType()) { 29 - case PhortuneAccountTransaction::TYPE_NAME: 30 - return $object->getName(); 31 - } 32 - return parent::getCustomTransactionOldValue($object, $xaction); 33 - } 34 - 35 - protected function getCustomTransactionNewValue( 36 - PhabricatorLiskDAO $object, 37 - PhabricatorApplicationTransaction $xaction) { 38 - switch ($xaction->getTransactionType()) { 39 - case PhortuneAccountTransaction::TYPE_NAME: 40 - return $xaction->getNewValue(); 41 - } 42 - return parent::getCustomTransactionNewValue($object, $xaction); 43 - } 44 - 45 - protected function applyCustomInternalTransaction( 46 - PhabricatorLiskDAO $object, 47 - PhabricatorApplicationTransaction $xaction) { 48 - switch ($xaction->getTransactionType()) { 49 - case PhortuneAccountTransaction::TYPE_NAME: 50 - $object->setName($xaction->getNewValue()); 51 - return; 52 - } 53 - return parent::applyCustomInternalTransaction($object, $xaction); 54 - } 55 - 56 - protected function applyCustomExternalTransaction( 57 - PhabricatorLiskDAO $object, 58 - PhabricatorApplicationTransaction $xaction) { 59 - switch ($xaction->getTransactionType()) { 60 - case PhortuneAccountTransaction::TYPE_NAME: 61 - return; 62 - } 63 - return parent::applyCustomExternalTransaction($object, $xaction); 64 - } 65 - 66 24 protected function validateTransaction( 67 25 PhabricatorLiskDAO $object, 68 26 $type, ··· 71 29 $errors = parent::validateTransaction($object, $type, $xactions); 72 30 73 31 switch ($type) { 74 - case PhortuneAccountTransaction::TYPE_NAME: 75 - $missing = $this->validateIsEmptyTextField( 76 - $object->getName(), 77 - $xactions); 78 - 79 - if ($missing) { 80 - $error = new PhabricatorApplicationTransactionValidationError( 81 - $type, 82 - pht('Required'), 83 - pht('Account name is required.'), 84 - nonempty(last($xactions), null)); 85 - 86 - $error->setIsMissingFieldError(true); 87 - $errors[] = $error; 88 - } 89 - break; 90 32 case PhabricatorTransactions::TYPE_EDGE: 91 33 foreach ($xactions as $xaction) { 92 34 switch ($xaction->getMetadataValue('edge:type')) { 93 35 case PhortuneAccountHasMemberEdgeType::EDGECONST: 94 - // TODO: This is a bit cumbersome, but validation happens before 95 - // transaction normalization. Maybe provide a cleaner attack on 96 - // this eventually? There's no way to generate "+" or "-" 97 - // transactions right now. 36 + $actor_phid = $this->requireActor()->getPHID(); 98 37 $new = $xaction->getNewValue(); 99 - $set = idx($new, '=', array()); 38 + $old = $object->getMemberPHIDs(); 100 39 101 - if (empty($set[$this->requireActor()->getPHID()])) { 102 - $error = new PhabricatorApplicationTransactionValidationError( 103 - $type, 104 - pht('Invalid'), 105 - pht('You can not remove yourself as an account member.'), 106 - $xaction); 107 - $errors[] = $error; 40 + // Check if user is trying to not set themselves on creation 41 + if (!$old) { 42 + $set = idx($new, '+', array()); 43 + $actor_set = false; 44 + foreach ($set as $phid) { 45 + if ($actor_phid == $phid) { 46 + $actor_set = true; 47 + } 48 + } 49 + if (!$actor_set) { 50 + $error = new PhabricatorApplicationTransactionValidationError( 51 + $type, 52 + pht('Invalid'), 53 + pht('You can not remove yourself as an account manager.'), 54 + $xaction); 55 + $errors[] = $error; 56 + 57 + } 108 58 } 109 - break; 59 + 60 + // Check if user is trying to remove themselves on edit 61 + $set = idx($new, '-', array()); 62 + foreach ($set as $phid) { 63 + if ($actor_phid == $phid) { 64 + $error = new PhabricatorApplicationTransactionValidationError( 65 + $type, 66 + pht('Invalid'), 67 + pht('You can not remove yourself as an account manager.'), 68 + $xaction); 69 + $errors[] = $error; 70 + 71 + } 72 + } 73 + break; 110 74 } 111 75 } 112 76 break; 113 77 } 114 - 115 78 return $errors; 116 79 } 80 + 117 81 }
+1 -1
src/applications/phortune/editor/PhortuneMerchantEditEngine.php
··· 58 58 } 59 59 60 60 protected function getObjectViewURI($object) { 61 - return $object->getViewURI(); 61 + return $object->getURI(); 62 62 } 63 63 64 64 public function isEngineConfigurable() {
+5 -2
src/applications/phortune/storage/PhortuneAccount.php
··· 17 17 18 18 public static function initializeNewAccount(PhabricatorUser $actor) { 19 19 $account = id(new PhortuneAccount()); 20 - 21 20 $account->memberPHIDs = array(); 22 21 23 22 return $account; ··· 31 30 32 31 $xactions = array(); 33 32 $xactions[] = id(new PhortuneAccountTransaction()) 34 - ->setTransactionType(PhortuneAccountTransaction::TYPE_NAME) 33 + ->setTransactionType(PhortuneAccountNameTransaction::TRANSACTIONTYPE) 35 34 ->setNewValue(pht('Default Account')); 36 35 37 36 $xactions[] = id(new PhortuneAccountTransaction()) ··· 94 93 public function attachMemberPHIDs(array $phids) { 95 94 $this->memberPHIDs = $phids; 96 95 return $this; 96 + } 97 + 98 + public function getURI() { 99 + return '/phortune/'.$this->getID().'/'; 97 100 } 98 101 99 102
+3 -26
src/applications/phortune/storage/PhortuneAccountTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhortuneAccountTransaction 4 - extends PhabricatorApplicationTransaction { 5 - 6 - const TYPE_NAME = 'phortune:name'; 4 + extends PhabricatorModularTransaction { 7 5 8 6 public function getApplicationName() { 9 7 return 'phortune'; ··· 17 15 return null; 18 16 } 19 17 20 - public function getTitle() { 21 - $author_phid = $this->getAuthorPHID(); 22 - 23 - $old = $this->getOldValue(); 24 - $new = $this->getNewValue(); 25 - 26 - switch ($this->getTransactionType()) { 27 - case self::TYPE_NAME: 28 - if ($old === null) { 29 - return pht( 30 - '%s created this account.', 31 - $this->renderHandleLink($author_phid)); 32 - } else { 33 - return pht( 34 - '%s renamed this account from "%s" to "%s".', 35 - $this->renderHandleLink($author_phid), 36 - $old, 37 - $new); 38 - } 39 - break; 40 - } 41 - 42 - return parent::getTitle(); 18 + public function getBaseTransactionClass() { 19 + return 'PhortuneAccountTransactionType'; 43 20 } 44 21 45 22 }
+2 -1
src/applications/phortune/storage/PhortuneMerchant.php
··· 53 53 return $this; 54 54 } 55 55 56 - public function getViewURI() { 56 + public function getURI() { 57 57 return '/phortune/merchant/'.$this->getID().'/'; 58 58 } 59 59 ··· 69 69 public function getProfileImageFile() { 70 70 return $this->assertAttached($this->profileImageFile); 71 71 } 72 + 72 73 73 74 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 74 75
+55
src/applications/phortune/xaction/PhortuneAccountNameTransaction.php
··· 1 + <?php 2 + 3 + final class PhortuneAccountNameTransaction 4 + extends PhortuneAccountTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'phortune: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 + $new = $this->getNewValue(); 19 + 20 + if (strlen($old) && strlen($new)) { 21 + return pht( 22 + '%s renamed this account from %s to %s.', 23 + $this->renderAuthor(), 24 + $this->renderOldValue(), 25 + $this->renderNewValue()); 26 + } else { 27 + return pht( 28 + '%s created this account.', 29 + $this->renderAuthor()); 30 + } 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('Accounts 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->newRequiredError( 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 + }
+4
src/applications/phortune/xaction/PhortuneAccountTransactionType.php
··· 1 + <?php 2 + 3 + abstract class PhortuneAccountTransactionType 4 + extends PhabricatorModularTransactionType {}
+15
src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
··· 1624 1624 '%s removed merchant managers: %3$s.', 1625 1625 ), 1626 1626 ), 1627 + 1628 + '%s added %s account manager(s): %s.' => array( 1629 + array( 1630 + '%s added an account manager: %3$s.', 1631 + '%s added account managers: %3$s.', 1632 + ), 1633 + ), 1634 + 1635 + '%s removed %s account manager(s): %s.' => array( 1636 + array( 1637 + '%s removed an account manager: %3$s.', 1638 + '%s removed account managers: %3$s.', 1639 + ), 1640 + ), 1641 + 1627 1642 ); 1628 1643 } 1629 1644