CRM-12675 - Hide Contribution activities from users without Access CiviContribute...
[civicrm-core.git] / CRM / Activity / Selector / Search.php
index 2609ea2b58a7d2616b60addc3d87e6173325fcd8..34318a2068f33d927935c23e8bf28434ef61928b 100644 (file)
@@ -173,6 +173,17 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
 
     $this->_activityClause = $activityClause;
 
+    // CRM-12675
+    if (! CRM_Core_Permission::check('access CiviContribute')) {
+      $componentRestriction = ' (activity_type.component_id IS NULL OR activity_type.component_id <> 2) ';
+      if (empty($this->_activityClause)) {
+        $this->_activityClause = $componentRestriction;
+      }
+      else {
+        $this->_activityClause .= ' AND ' . $componentRestriction;
+      }
+    }
+
     // type of selector
     $this->_action = $action;
     $this->_query = new CRM_Contact_BAO_Query($this->_queryParams,