CRM-17645 - Prevent adding case acl clause inappropriately
authorColeman Watts <coleman@civicrm.org>
Thu, 21 Jan 2016 02:50:34 +0000 (21:50 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 21 Jan 2016 02:50:34 +0000 (21:50 -0500)
CRM/Case/BAO/Query.php

index 19867be3c0e570246711d9b2cc6715a056f5de5c..503d6f01215bcfe22d3e4842724825b6fa47a37f 100644 (file)
@@ -233,9 +233,13 @@ class CRM_Case_BAO_Query {
       }
     }
     // Add acl clause
-    $aclClauses = array_filter(CRM_Case_BAO_Case::getSelectWhereClause());
-    foreach ($aclClauses as $clause) {
-      $query->_where[0][] = $clause;
+    // This is new and so far only for cases - it would be good to find a more abstract
+    // way to auto-apply this for all search components rather than copy-pasting this code to others
+    if (isset($query->_tables['civicrm_case'])) {
+      $aclClauses = array_filter(CRM_Case_BAO_Case::getSelectWhereClause());
+      foreach ($aclClauses as $clause) {
+        $query->_where[0][] = $clause;
+      }
     }
   }