From dc961e38edd78aa367362c4f05986a2f9351397b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 19 Aug 2022 10:27:47 +1200 Subject: [PATCH] Enotice fix on payment processor browse --- CRM/Admin/Page/PaymentProcessor.php | 52 ++++++++----------- templates/CRM/Admin/Page/PaymentProcessor.tpl | 2 +- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/CRM/Admin/Page/PaymentProcessor.php b/CRM/Admin/Page/PaymentProcessor.php index 1fb115f8e8..c0758c5337 100644 --- a/CRM/Admin/Page/PaymentProcessor.php +++ b/CRM/Admin/Page/PaymentProcessor.php @@ -15,6 +15,8 @@ * @copyright CiviCRM LLC https://civicrm.org/licensing */ +use Civi\Api4\PaymentProcessor; + /** * Page for displaying list of payment processors. */ @@ -105,53 +107,43 @@ class CRM_Admin_Page_PaymentProcessor extends CRM_Core_Page_Basic { * Browse all payment processors. * * @param null $action + * + * @throws \API_Exception */ - public function browse($action = NULL) { - // get all custom groups sorted by weight - $paymentProcessor = []; - $dao = new CRM_Financial_DAO_PaymentProcessor(); - $dao->is_test = 0; - $dao->domain_id = CRM_Core_Config::domainID(); - $dao->orderBy('name'); - $dao->find(); - - while ($dao->fetch()) { - $paymentProcessor[$dao->id] = []; - CRM_Core_DAO::storeValues($dao, $paymentProcessor[$dao->id]); - $paymentProcessor[$dao->id]['payment_processor_type'] = CRM_Core_PseudoConstant::getLabel( - 'CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', $dao->payment_processor_type_id - ); + public function browse($action = NULL): void { + $paymentProcessors = PaymentProcessor::get(FALSE) + ->addWhere('is_test', '=', 0) + ->addWhere('domain_id', '=', CRM_Core_Config::domainID()) + ->setSelect(['id', 'name', 'description', 'title', 'is_active', 'is_default', 'payment_processor_type_id:label']) + ->addOrderBy('name')->execute()->indexBy('id'); + + foreach ($paymentProcessors as $paymentProcessorID => $paymentProcessor) { + // Annoyingly Smarty can't handle the colon syntax (or a .) + $paymentProcessors[$paymentProcessorID]['payment_processor_type'] = $paymentProcessor['payment_processor_type_id:label']; // form all action links $action = array_sum(array_keys($this->links())); + $action -= $paymentProcessor['is_active'] ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; - // update enable/disable links. - if ($dao->is_active) { - $action -= CRM_Core_Action::ENABLE; - } - else { - $action -= CRM_Core_Action::DISABLE; - } - - $paymentProcessor[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id), + $paymentProcessors[$paymentProcessorID]['action'] = CRM_Core_Action::formLink($this->links(), $action, + ['id' => $paymentProcessorID], ts('more'), FALSE, 'paymentProcessor.manage.action', 'PaymentProcessor', - $dao->id + $paymentProcessorID ); - $paymentProcessor[$dao->id]['financialAccount'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($dao->id, NULL, 'civicrm_payment_processor', 'financial_account_id.name'); + $paymentProcessors[$paymentProcessorID]['financialAccount'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($paymentProcessorID, NULL, 'civicrm_payment_processor', 'financial_account_id.name'); try { - $paymentProcessor[$dao->id]['test_id'] = CRM_Financial_BAO_PaymentProcessor::getTestProcessorId($dao->id); + $paymentProcessors[$paymentProcessorID]['test_id'] = CRM_Financial_BAO_PaymentProcessor::getTestProcessorId($paymentProcessorID); } catch (CiviCRM_API3_Exception $e) { - CRM_Core_Session::setStatus(ts('No test processor entry exists for %1. Not having a test entry for each processor could cause problems', [$dao->name])); + CRM_Core_Session::setStatus(ts('No test processor entry exists for %1. Not having a test entry for each processor could cause problems', [$paymentProcessor['name']])); } } - $this->assign('rows', $paymentProcessor); + $this->assign('rows', $paymentProcessors); } /** diff --git a/templates/CRM/Admin/Page/PaymentProcessor.tpl b/templates/CRM/Admin/Page/PaymentProcessor.tpl index 92dffc63a2..94e84730f1 100644 --- a/templates/CRM/Admin/Page/PaymentProcessor.tpl +++ b/templates/CRM/Admin/Page/PaymentProcessor.tpl @@ -34,7 +34,7 @@ {foreach from=$rows item=row} - + {$row.id} {$row.test_id} {$row.name} -- 2.25.1