Revert "CRM-21575 - Websites of same type are over-written"
authorAndrew Hunt <andrew@aghstrategies.com>
Tue, 6 Feb 2018 02:00:08 +0000 (21:00 -0500)
committerAndrew Hunt <andrew@aghstrategies.com>
Tue, 6 Feb 2018 02:00:08 +0000 (21:00 -0500)
This reverts commit dddcec4545602395fc865273175eb7227947cf74.

CRM/Core/BAO/Website.php

index 3094bf73cc4bdff612fbd45c57e61c50dc0f6528..96f91873d97885216ae764c8ea25b0cd7d79b502 100644 (file)
@@ -73,7 +73,15 @@ class CRM_Core_BAO_Website extends CRM_Core_DAO_Website {
       return FALSE;
     }
 
+    $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;
+          }
+        }
+      }
       if (!empty($values['url'])) {
         $values['contact_id'] = $contactID;
         self::add($values);