X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FWebsite.php;h=af12e416a6b156b1727b1dbeec466f01cbe6622e;hb=beccc0d657ee873b40b54af732aed9f5a368a36f;hp=e20e43de390de7a82025fccfbffaa107cd3a4f02;hpb=ef7bc49671ef1b69503899f9090cb4cbe4d523b2;p=civicrm-core.git diff --git a/CRM/Core/BAO/Website.php b/CRM/Core/BAO/Website.php index e20e43de39..af12e416a6 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -1,7 +1,7 @@ $submittedValue) { - - // Check for matching IDs on submitted / existing data - $websiteId = CRM_Utils_Array::value('id', $submittedValue); - if ($websiteId) { - if (array_key_exists($websiteId, $existingWebsites)) { - unset($existingWebsites[$websiteId]); - } - else { - unset($submittedValue['id']); - } - } - - // Match up submitted values to existing ones, based on type - if (empty($submittedValue['id']) && !empty($existingWebsites)) { - foreach ($existingWebsites as $id => $existingValue) { - if ($existingValue['website_type_id'] == $submittedValue['website_type_id']) { - $submittedValue['id'] = $id; - unset($existingWebsites[$id]); - break; + $ids = self::allWebsites($contactID); + foreach ($params as $key => $values) { + if (empty($values['id']) && is_array($ids) && !empty($ids)) { + foreach ($ids as $id => $value) { + if (($value['website_type_id'] == $values['website_type_id'])) { + $values['id'] = $id; } } } - - $submittedValue['contact_id'] = $contactID; - - // CRM-10551 - // If there is a matching ID, the URL is empty and we are deleting blanked values - // Then remove it from the contact - if (!empty($submittedValue['id']) && empty($submittedValue['url']) && $updateBlankLocInfo) { - self::del(array($submittedValue['id'])); + if (!empty($values['url'])) { + $values['contact_id'] = $contactID; + self::add($values); } - - // Otherwise, add the website if the URL isn't empty - elseif (!empty($submittedValue['url'])) { - self::add($submittedValue); + elseif ($skipDelete && !empty($values['id'])) { + self::del(array($values['id'])); } } } @@ -129,7 +98,7 @@ class CRM_Core_BAO_Website extends CRM_Core_DAO_Website { * @param array $ids * Website ids. * - * @return void + * @return bool */ public static function del($ids) { $query = 'DELETE FROM civicrm_website WHERE id IN ( ' . implode(',', $ids) . ')';