$query = 'SELECT id, contact_id FROM civicrm_address WHERE master_id = %1';
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($addressId, 'Integer')));
+ // Default to TRUE if not set to maintain api backward compatibility.
+ $createRelationship = isset($params['update_current_employer']) ? $params['update_current_employer'] : TRUE;
+
// unset contact id
$skipFields = array('is_primary', 'location_type_id', 'is_billing', 'contact_id');
if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) {
- // call the function to create a relationship for the new shared address
- self::processSharedAddressRelationship($params['master_id'], $params['contact_id']);
+ if ($createRelationship) {
+ // call the function to create a relationship for the new shared address
+ self::processSharedAddressRelationship($params['master_id'], $params['contact_id']);
+ }
}
else {
// else no new shares will be created, only update shared addresses
$addressDAO = new CRM_Core_DAO_Address();
while ($dao->fetch()) {
// call the function to update the relationship
- if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) {
+ if ($createRelationship && isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) {
self::processSharedAddressRelationship($params['master_id'], $dao->contact_id);
}
$addressDAO->copyValues($params);