'CRM_Core_DAO_StateProvince',
'CRM_Core_DAO_Country',
'CRM_Core_DAO_Domain',
+ 'CRM_Financial_DAO_FinancialType'//because valid ones exist & we use pick them due to pseudoconstant can't reliably create & delete these
);
for ($i = 0; $i < $numObjects; ++$i) {
if ($FKClassName != NULL
&& $object->$dbName
&& !in_array($FKClassName, CRM_Core_DAO::$_testEntitiesToSkip)
- && ($required || $dbName == 'contact_id')) {
+ && ($required || $dbName == 'contact_id')
+ //I'm a bit stuck on this one - we might need to change the singleValueAlter so that the entities don't share a contact
+ // to make this test process pass - line below makes pass for now
+ && $dbName != 'member_of_contact_id') {
$deletions[] = array($FKClassName, array('id' => $object->$dbName)); // x
}
}
// $previousID is the old organization id for membership type i.e 'member_of_contact_id'. This is used when an organization is changed.
$previousID = NULL;
- if ($membershipType->id) {
- $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $membershipType->id, 'member_of_contact_id');
+ if ($id) {
+ $previousID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $id, 'member_of_contact_id');
}
$membershipType->save();
-
+ if ($id) {
+ // on update we may need to retrieve some details for the price field function - otherwise we get e-notices on attempts to retrieve
+ // name etc - the presence of previous id tells us this is an update
+ $params = array_merge(civicrm_api3('membership_type', 'getsingle', array('id' => $membershipType->id)), $params);
+ }
self::createMembershipPriceField($params, $previousID, $membershipType->id);
// update all price field value for quick config when membership type is set CRM-11718
if ($id) {
CRM_Member_Form_MembershipType::checkPreviousPriceField($previousID, $priceSetId, $membershipTypeId, $optionsIds);
$fieldParams['option_id'] = CRM_Utils_Array::value('option_id', $optionsIds);
}
- $priceField = CRM_Price_BAO_PriceField::create($fieldParams);
+ CRM_Price_BAO_PriceField::create($fieldParams);
}
else {
$fieldID = $results['id'];
'Note',
'OptionGroup',
'Membership',
- 'MembershipType',
'MembershipStatus',
'Group',
'GroupOrganization',
'id' => $entity['id'],
$field => isset($entity[$field]) ? $entity[$field] : NULL,
);
- if(isset($updateParams['financial_type_id']) && $entityName != 'Product') {
+ if(isset($updateParams['financial_type_id']) && !in_array($entityName, array('Product', 'MembershipType'))) {
//api has special handling on these 2 fields for backward compatibility reasons
$entity['contribution_type_id'] = $updateParams['financial_type_id'];
}