From 291ebece65e24a05f8b4ef0efffe84bed76b50cb Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 3 Jun 2014 23:49:58 +1200 Subject: [PATCH] CRM-14778 set name by default on price_field & price_field_value --- CRM/Price/BAO/PriceField.php | 3 +++ CRM/Price/BAO/PriceFieldValue.php | 13 +++++++------ api/v3/PriceField.php | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 89598bf8c6..a1c27d965d 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -81,6 +81,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'] = 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 2183747326..0690f8358a 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -50,7 +50,7 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * @access public * @static */ - static function &add(&$params, $ids) { + static function add(&$params, $ids = array()) { $fieldValueBAO = new CRM_Price_BAO_PriceFieldValue(); $fieldValueBAO->copyValues($params); @@ -79,11 +79,14 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * @access public * @static */ - static function create(&$params, $ids) { + static function create(&$params, $ids = array()) { if (!is_array($params) || empty($params)) { return; } + if(empty($params['id']) && empty($params['name'])) { + $params['name'] = CRM_Utils_String::munge($params['label'], '_', 242); + } if ($id = CRM_Utils_Array::value('id', $ids)) { if (isset($params['name']))unset($params['name']); @@ -188,14 +191,13 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * * @param int $fieldId Price field id * - * @return boolean * * @access public * @static */ static function deleteValues($fieldId) { if (!$fieldId) { - return FALSE; + return; } $fieldValueDAO = new CRM_Price_DAO_PriceFieldValue(); @@ -231,13 +233,12 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * @param String $entityTable entity table * @param String $financialTypeID financial type id * - * @return bool * @access public * @static */ static function updateFinancialType($entityId, $entityTable, $financialTypeID) { if (!$entityId || !$entityTable || !$financialTypeID) { - return FALSE; + return; } $params = array( 1 => array($entityId, 'Integer'), diff --git a/api/v3/PriceField.php b/api/v3/PriceField.php index 7901b7dd5e..1fdbe9800d 100644 --- a/api/v3/PriceField.php +++ b/api/v3/PriceField.php @@ -57,6 +57,7 @@ function civicrm_api3_price_field_create($params) { * @param array $params array or parameters determined by getfields */ function _civicrm_api3_price_field_create_spec(&$params) { + $params['label']['api.required'] = TRUE; } /** -- 2.25.1