Path: blob/master/src/applications/fund/xaction/FundInitiativeMerchantTransaction.php
12256 views
<?php12final class FundInitiativeMerchantTransaction3extends FundInitiativeTransactionType {45const TRANSACTIONTYPE = 'fund:merchant';67public function generateOldValue($object) {8return $object->getMerchantPHID();9}1011public function applyInternalEffects($object, $value) {12$object->setMerchantPHID($value);13}1415public function getTitle() {16$new = $this->getNewValue();17$new_merchant = $this->renderHandleList(array($new));1819$old = $this->getOldValue();20$old_merchant = $this->renderHandleList(array($old));2122if ($old) {23return pht(24'%s changed the merchant receiving funds from this '.25'initiative from %s to %s.',26$this->renderAuthor(),27$old_merchant,28$new_merchant);29} else {30return pht(31'%s set the merchant receiving funds from this '.32'initiative to %s.',33$this->renderAuthor(),34$new_merchant);35}36}3738public function getTitleForFeed() {39$new = $this->getNewValue();40$new_merchant = $this->renderHandleList(array($new));4142$old = $this->getOldValue();43$old_merchant = $this->renderHandleList(array($old));4445return pht(46'%s changed the merchant receiving funds from %s '.47'from %s to %s.',48$this->renderAuthor(),49$this->renderObject(),50$old_merchant,51$new_merchant);52}5354public function validateTransactions($object, array $xactions) {55$errors = array();5657if ($this->isEmptyTextTransaction($object->getMerchantPHID(), $xactions)) {58$errors[] = $this->newRequiredError(59pht('Initiatives must have a payable merchant.'));60}6162foreach ($xactions as $xaction) {63$merchant_phid = $xaction->getNewValue();6465// Make sure the actor has permission to edit the merchant they're66// selecting. You aren't allowed to send payments to an account you67// do not control.68$merchants = id(new PhortuneMerchantQuery())69->setViewer($this->getActor())70->withPHIDs(array($merchant_phid))71->requireCapabilities(72array(73PhabricatorPolicyCapability::CAN_VIEW,74PhabricatorPolicyCapability::CAN_EDIT,75))76->execute();77if (!$merchants) {78$errors[] = $this->newInvalidError(79pht('You must specify a merchant account you control as the '.80'recipient of funds from this initiative.'));81}82}8384return $errors;85}8687public function getIcon() {88return 'fa-bank';89}909192}939495