From 9d6dcd435557c9663a91a2201f81174f63656d2a Mon Sep 17 00:00:00 2001 From: yashodha Date: Mon, 15 Jun 2015 20:12:37 +0530 Subject: [PATCH] CRM-12675: removed hard-coded references ---------------------------------------- * CRM-12675: Contribution activities shown to users without permission https://issues.civicrm.org/jira/browse/CRM-12675 --- CRM/Activity/Form/Task.php | 5 ++++- CRM/Activity/Selector/Search.php | 4 +++- CRM/Report/Form/Activity.php | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CRM/Activity/Form/Task.php b/CRM/Activity/Form/Task.php index 13819f6212..1ccc41e36b 100644 --- a/CRM/Activity/Form/Task.php +++ b/CRM/Activity/Form/Task.php @@ -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); diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index 34318a2068..cb8a342963 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -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; } diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index 49f33103b8..832b492482 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -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)) { -- 2.25.1