From 92e088c99ce2835e9603ca6ffd3982b7e94f91f4 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 17 May 2017 03:55:14 +0530 Subject: [PATCH] CRM-20588, code cleanup ---------------------------------------- * CRM-20588: Pre and Post hook for Batch https://issues.civicrm.org/jira/browse/CRM-20588 --- CRM/Batch/BAO/Batch.php | 10 +--------- CRM/Financial/Form/Export.php | 5 ++--- CRM/Financial/Form/FinancialBatch.php | 4 +--- CRM/Financial/Page/AJAX.php | 11 +---------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 541669a584..ad4e487d2a 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -51,24 +51,16 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { * Create a new batch. * * @param array $params - * @param array $ids - * Associated array of ids. - * @param string $context - * String. * * @return object * $batch batch object */ - public static function create(&$params, $ids = NULL, $context = NULL) { + public static function create(&$params) { if (empty($params['id'])) { $params['name'] = CRM_Utils_String::titleToVar($params['title']); } - $batch = new CRM_Batch_DAO_Batch(); $batch->copyValues($params); - if ($context == 'financialBatch' && !empty($ids['batchID'])) { - $batch->id = $ids['batchID']; - } $batch->save(); return $batch; diff --git a/CRM/Financial/Form/Export.php b/CRM/Financial/Form/Export.php index 7267d0469c..31e3b3b1e4 100644 --- a/CRM/Financial/Form/Export.php +++ b/CRM/Financial/Form/Export.php @@ -167,12 +167,11 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { $batchParams['modified_id'] = $session->get('userID'); $batchParams['status_id'] = $this->_exportStatusId; - $ids = array(); foreach ($batchIds as $batchId) { - $batchParams['id'] = $ids['batchID'] = $batchId; + $batchParams['id'] = $batchId; // Update totals $batchParams = array_merge($batchParams, $totals[$batchId]); - CRM_Batch_BAO_Batch::create($batchParams, $ids, 'financialBatch'); + CRM_Batch_BAO_Batch::create($batchParams); } CRM_Batch_BAO_Batch::exportFinancialBatch($batchIds, $this->_exportFormat); diff --git a/CRM/Financial/Form/FinancialBatch.php b/CRM/Financial/Form/FinancialBatch.php index c64287de4d..d1755ba36a 100644 --- a/CRM/Financial/Form/FinancialBatch.php +++ b/CRM/Financial/Form/FinancialBatch.php @@ -196,11 +196,9 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { */ public function postProcess() { $session = CRM_Core_Session::singleton(); - $ids = array(); $params = $this->exportValues(); $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); if ($this->_id) { - $ids['batchID'] = $this->_id; $params['id'] = $this->_id; } @@ -228,7 +226,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { $activityTypeName = 'Edit Batch'; } - $batch = CRM_Batch_BAO_Batch::create($params, $ids, 'financialBatch'); + $batch = CRM_Batch_BAO_Batch::create($params); $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name'); diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 2715e99b9e..d20b4d4dee 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -183,7 +183,6 @@ class CRM_Financial_Page_AJAX { if ($recordClass[0] == 'CRM' && count($recordClass) >= 3) { foreach ($records as $recordID) { $params = array(); - $ids = NULL; switch ($op) { case 'assign': case 'remove': @@ -207,14 +206,12 @@ class CRM_Financial_Page_AJAX { $params = $totals[$recordID]; case 'reopen': $status = $op == 'close' ? 'Closed' : 'Reopened'; - $ids['batchID'] = $recordID; $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name')); $params['status_id'] = CRM_Utils_Array::key($status, $batchStatus); $session = CRM_Core_Session::singleton(); $params['modified_date'] = date('YmdHis'); $params['modified_id'] = $session->get('userID'); $params['id'] = $recordID; - $context = "financialBatch"; break; case 'export': @@ -223,17 +220,11 @@ class CRM_Financial_Page_AJAX { case 'delete': $params = $recordID; - $context = "financialBatch"; break; } if (method_exists($recordBAO, $methods[$op]) & !empty($params)) { - if (isset($context)) { - $updated = call_user_func_array(array($recordBAO, $methods[$op]), array(&$params, $ids, $context)); - } - else { - $updated = call_user_func_array(array($recordBAO, $methods[$op]), array(&$params, $ids)); - } + $updated = call_user_func_array(array($recordBAO, $methods[$op]), array(&$params)); if ($updated) { $redirectStatus = $updated->status_id; if ($batchStatus[$updated->status_id] == "Reopened") { -- 2.25.1