CRM-20988, list only permissioned batches
authorPradeep Nayak <pradpnayak@gmail.com>
Mon, 31 Jul 2017 06:51:02 +0000 (12:21 +0530)
committerPradeep Nayak <pradpnayak@gmail.com>
Mon, 31 Jul 2017 06:51:02 +0000 (12:21 +0530)
----------------------------------------
* CRM-20988: Don't display option of Export, Delete etc to users who lack that permission
  https://issues.civicrm.org/jira/browse/CRM-20988

CRM/Batch/BAO/Batch.php

index 19b02e58ae82e42e66d8ea756330a0117af78b01..7a4db7ce052958daa4e74e743a35550c80623696 100644 (file)
@@ -391,6 +391,15 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
       "created_id.sort_name",
       "created_id",
     );
+    if (!CRM_Core_Permission::check("view all manual batches")) {
+      if (CRM_Core_Permission::check("view own manual batches")) {
+        $loggedInContactId = CRM_Core_Session::singleton()->get('userID');
+        $params['created_id'] = $loggedInContactId;
+      }
+      else {
+        $params['created_id'] = 0;
+      }
+    }
     foreach ($return as $field) {
       if (!isset($params[$field])) {
         continue;