From 6091117ffac5adaa66abd0f93ef4750f33989a1a Mon Sep 17 00:00:00 2001 From: monishdeb Date: Thu, 7 Nov 2013 18:56:42 +0530 Subject: [PATCH] CRM-10225 fix - New Price Set Error http://issues.civicrm.org/jira/browse/CRM-10225 --- CRM/Price/Form/Set.php | 75 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 32a2910126..30d1fea663 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -134,46 +134,47 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $config = CRM_Core_Config::singleton(); $showContribution = FALSE; - $components = array('CiviEvent' => array('title' => ts('Event'), - 'extend' => CRM_Core_Component::getComponentID('CiviEvent'), - 'tables' => array( - 'civicrm_event', - 'civicrm_participant', - ), - ), - 'CiviContribute' => array('title' => ts('Contribution'), - 'extend' => CRM_Core_Component::getComponentID('CiviContribute'), - 'tables' => array( - 'civicrm_contribution', - 'civicrm_contribution_page', - ), - ), - 'CiviMember' => array('title' => ts('Membership'), - 'extend' => CRM_Core_Component::getComponentID('CiviMember'), - 'tables' => array( - 'civicrm_membership', - 'civicrm_contribution_page', - ), - ), - ); - foreach ($components as $compName => $compValues) { - // take only enabled components. - if (!in_array($compName, $config->enableComponents)) { - continue; - } - $option = $this->createElement('checkbox', $compValues['extend'], NULL, $compValues['title']); - - //if price set is used than freeze it. - if (!empty($priceSetUsedTables)) { - foreach ($compValues['tables'] as $table) { + $enabledComponents = CRM_Core_Component::getEnabledComponents(); - if (in_array($table, $priceSetUsedTables)) { - $option->freeze(); - break; + foreach ($enabledComponents as $name => $compObj) { + switch ($name) { + case 'CiviEvent': + $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Event')); + if (!empty($priceSetUsedTables)) { + foreach (array('civicrm_event', 'civicrm_participant') as $table) { + if (in_array($table, $priceSetUsedTables)) { + $option->freeze(); + break; + } + } + } + $extends[] = $option; + break; + case 'CiviContribute': + $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Contribution')); + if (!empty($priceSetUsedTables)) { + foreach (array('civicrm_contribution', 'civicrm_contribution_page') as $table) { + if (in_array($table, $priceSetUsedTables)) { + $option->freeze(); + break; + } + } + } + $extends[] = $option; + break; + case 'CiviMember': + $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Membership')); + if (!empty($priceSetUsedTables)) { + foreach (array('civicrm_membership', 'civicrm_contribution_page') as $table) { + if (in_array($table, $priceSetUsedTables)) { + $option->freeze(); + break; + } + } } - } + $extends[] = $option; + break; } - $extends[] = $option; } if (CRM_Utils_System::isNull($extends)) { -- 2.25.1