From d5c9aa02e8b007067463957b412f9544736e8f3d Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 1 Sep 2017 13:34:26 +1200 Subject: [PATCH] CRM-20237 keep some of original name in name field --- CRM/Price/BAO/PriceSet.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 27fdb9014e..7d92106f67 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -1240,24 +1240,25 @@ WHERE id = %1"; */ public static function copy($id) { $maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set"); - $oldTitle = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $id, 'title', 'id'); - $newTitle = preg_replace('/\[Copy id \d+\]$/', "", $oldTitle); + $priceSet = civicrm_api3('PriceSet', 'getsingle', array('id' => $id)); + + $newTitle = preg_replace('/\[Copy id \d+\]$/', "", $priceSet['title']); $title = ts('[Copy id %1]', array(1 => $maxId + 1)); $fieldsFix = array( 'replace' => array( 'title' => trim($newTitle) . ' ' . $title, - 'name' => 'Price_Set__id_' . ($maxId + 1) . '_', + 'name' => substr($priceSet['name'], 0, 20) . 'price_set_' . ($maxId + 1), ), ); - $copy = &CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSet', + $copy = CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSet', array('id' => $id), NULL, $fieldsFix ); //copying all the blocks pertaining to the price set - $copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceField', + $copyPriceField = CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceField', array('price_set_id' => $id), array('price_set_id' => $copy->id) ); -- 2.25.1