From f07fc4c94265d68c1f5dd11f1b1186df5ea41fc7 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Thu, 3 Aug 2017 22:49:40 +0530 Subject: [PATCH] CRM-21189, updated code to respect new permission on batches ---------------------------------------- * CRM-21189: Add permission for Close and reopen Batch https://issues.civicrm.org/jira/browse/CRM-21189 --- CRM/Batch/BAO/Batch.php | 11 +++++++---- CRM/Financial/Form/BatchTransaction.php | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 163a32abdf..378d13f3c5 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -302,7 +302,13 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { CRM_Utils_Array::remove($newLinks, 'close', 'edit', 'reopen', 'export'); } if (!CRM_Batch_BAO_Batch::checkBatchPermission('edit', $values['created_id'])) { - CRM_Utils_Array::remove($newLinks, 'close', 'edit', 'export'); + CRM_Utils_Array::remove($newLinks, 'edit'); + } + if (!CRM_Batch_BAO_Batch::checkBatchPermission('close', $values['created_id'])) { + CRM_Utils_Array::remove($newLinks, 'close', 'export'); + } + if (!CRM_Batch_BAO_Batch::checkBatchPermission('reopen', $values['created_id'])) { + CRM_Utils_Array::remove($newLinks, 'reopen'); } if (!CRM_Batch_BAO_Batch::checkBatchPermission('export', $values['created_id'])) { CRM_Utils_Array::remove($newLinks, 'export', 'download'); @@ -815,9 +821,6 @@ WHERE {$where} * @return bool */ public static function checkBatchPermission($action, $batchCreatedId = NULL) { - if (in_array($action, array('reopen', 'close'))) { - $action = 'edit'; - } if (CRM_Core_Permission::check("{$action} all manual batches")) { return TRUE; } diff --git a/CRM/Financial/Form/BatchTransaction.php b/CRM/Financial/Form/BatchTransaction.php index f5ee8bbe73..e43e557335 100644 --- a/CRM/Financial/Form/BatchTransaction.php +++ b/CRM/Financial/Form/BatchTransaction.php @@ -100,7 +100,7 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { } parent::buildQuickForm(); - if (CRM_Batch_BAO_Batch::checkBatchPermission('edit', $this->_values['created_id'])) { + if (CRM_Batch_BAO_Batch::checkBatchPermission('close', $this->_values['created_id'])) { $this->add('submit', 'close_batch', ts('Close Batch')); if (CRM_Batch_BAO_Batch::checkBatchPermission('export', $this->_values['created_id'])) { $this->add('submit', 'export_batch', ts('Close & Export Batch')); -- 2.25.1