From fa202dd4173410890dfdd35e37ab68ee1b4500b1 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 3 Jun 2014 23:58:01 +1200 Subject: [PATCH] CRM-14778 store names as lower Conflicts: CRM/Price/BAO/PriceField.php CRM/Price/BAO/PriceFieldValue.php --- CRM/Price/BAO/PriceField.php | 3 +++ CRM/Price/BAO/PriceFieldValue.php | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 93d2872b9a..bb0f1cf668 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -80,6 +80,9 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { * @static */ static function create(&$params) { + if(empty($params['id']) && empty($params['name'])) { + $params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242)); + } $transaction = new CRM_Core_Transaction(); $priceField = self::add($params); diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index fee5a90bb1..1199fae363 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -80,6 +80,9 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { if (!is_array($params) || empty($params)) { return; } + if(empty($params['id']) && empty($params['name'])) { + $params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242)); + } if ($id = CRM_Utils_Array::value('id', $ids)) { if (isset($params['name']))unset($params['name']); @@ -218,9 +221,9 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { $fieldValueDAO->id = $id; return $fieldValueDAO->delete(); } - + /** - * Update civicrm_price_field_value.financial_type_id + * Update civicrm_price_field_value.financial_type_id * when financial_type_id of contribution_page or event is changed * * @param int $entityId Id @@ -245,8 +248,8 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { $join = " LEFT JOIN civicrm_discount cd ON cd.price_set_id = cps.id AND cd.entity_id = %1 AND cd.entity_table = %2 "; $where = ' OR cd.id IS NOT NULL '; } - $sql = "UPDATE civicrm_price_set cps -LEFT JOIN civicrm_price_set_entity cpse ON cpse.price_set_id = cps.id AND cpse.entity_id = %1 AND cpse.entity_table = %2 + $sql = "UPDATE civicrm_price_set cps +LEFT JOIN civicrm_price_set_entity cpse ON cpse.price_set_id = cps.id AND cpse.entity_id = %1 AND cpse.entity_table = %2 LEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cps.id LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id {$join} @@ -257,7 +260,7 @@ SET cpfv.financial_type_id = CASE END, cps.financial_type_id = %3 WHERE cpse.id IS NOT NULL {$where}"; - + CRM_Core_DAO::executeQuery($sql, $params); } } -- 2.25.1