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

at recaptime-dev/main 93 lines 2.5 kB view raw
1<?php 2 3final 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 '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-university'; 90 } 91 92 93}