CRM-12675: removed hard-coded references
authoryashodha <yashodha.chaku@webaccessglobal.com>
Mon, 15 Jun 2015 14:42:37 +0000 (20:12 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Mon, 15 Jun 2015 14:42:37 +0000 (20:12 +0530)
----------------------------------------
* CRM-12675: Contribution activities shown to users without permission
  https://issues.civicrm.org/jira/browse/CRM-12675

CRM/Activity/Form/Task.php
CRM/Activity/Selector/Search.php
CRM/Report/Form/Activity.php

index 13819f62124b5e04e1dbcebb4ad07d737c0c5439..1ccc41e36bedc78c39532d1eb9f47dd4edd5d370 100644 (file)
@@ -116,8 +116,11 @@ class CRM_Activity_Form_Task extends CRM_Core_Form {
 
       // CRM-12675
       $activityClause = NULL;
+
       if (! CRM_Core_Permission::check('access CiviContribute')) {
-        $activityClause = ' (activity_type.component_id IS NULL OR activity_type.component_id <> 2) ';
+        $components = CRM_Core_Component::getNames();
+        $contribute = CRM_Utils_Array::key('CiviContribute', $components);
+        $activityClause = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$contribute}) ";
       }
 
       $result = $query->searchQuery(0, 0, NULL, FALSE, FALSE, FALSE, FALSE, FALSE, $activityClause);
index 34318a2068f33d927935c23e8bf28434ef61928b..cb8a342963f782ea7f8c464ed2b4c1df6474a03d 100644 (file)
@@ -175,7 +175,9 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
 
     // CRM-12675
     if (! CRM_Core_Permission::check('access CiviContribute')) {
-      $componentRestriction = ' (activity_type.component_id IS NULL OR activity_type.component_id <> 2) ';
+      $components = CRM_Core_Component::getNames();
+      $contribute = CRM_Utils_Array::key('CiviContribute', $components);
+      $componentRestriction = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$contribute}) ";
       if (empty($this->_activityClause)) {
         $this->_activityClause = $componentRestriction;
       }
index 49f33103b859c298b00e6c5ceda8b53f18d20af2..832b492482f09d7a0f4c690174ed11c6cad6c43b 100644 (file)
@@ -599,7 +599,9 @@ class CRM_Report_Form_Activity extends CRM_Report_Form {
 
     // CRM-12675
     if (! CRM_Core_Permission::check('access CiviContribute')) {
-      $clauses[] = " ({$this->_aliases['civicrm_option_value']}.component_id IS NULL OR {$this->_aliases['civicrm_option_value']}.component_id <> 2) ";
+      $components = CRM_Core_Component::getNames();
+      $contribute = CRM_Utils_Array::key('CiviContribute', $components);
+      $clauses[] = " ({$this->_aliases['civicrm_option_value']}.component_id IS NULL OR {$this->_aliases['civicrm_option_value']}.component_id <> {$contribute}) ";
     }
 
     if (empty($clauses)) {