*/
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)
);