// to get billing address if present
$billingAddress = array();
foreach ($addressDetails as $address) {
- if ((isset($address['is_billing']) && $address['is_billing'] == 1) && (isset($address['is_primary']) && $address['is_primary'] == 1) && $address['contact_id'] == $contribution->contact_id) {
+ if (($address['is_billing'] == 1) && ($address['is_primary'] == 1) && ($address['contact_id'] == $contribution->contact_id)) {
$billingAddress[$address['contact_id']] = $address;
break;
}
- elseif (($address['is_billing'] == 0 && $address['is_primary'] == 1) || (isset($address['is_billing']) && $address['is_billing'] == 1) && $address['contact_id'] == $contribution->contact_id) {
+ elseif (($address['is_billing'] == 0 && $address['is_primary'] == 1) || ($address['is_billing'] == 1) && ($address['contact_id'] == $contribution->contact_id)) {
$billingAddress[$address['contact_id']] = $address;
}
}
$addresses[$count] = $values;
- //unset is_primary after first block. Due to some bug in earlier version
- //there might be more than one primary blocks, hence unset is_primary other than first
+ //There should never be more than one primary blocks, hence set is_primary = 0 other than first
+ // Calling functions expect the key is_primary to be set, so do not unset it here!
if ($count > 1) {
- unset($addresses[$count]['is_primary']);
+ $addresses[$count]['is_primary'] = 0;
}
$count++;
$contributionID = CRM_Member_BAO_Membership::getMembershipContributionId($this->_id);
// check delete permission for contribution
if ($this->_id && $contributionID && !CRM_Core_Permission::checkActionPermission('CiviContribute', $this->_action)) {
- CRM_Core_Error::statusBounce(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
+ CRM_Core_Error::fatal(ts("This Membership is linked to a contribution. You must have 'delete in CiviContribute' permission in order to delete this record."));
}
}