From: jitendrapurohit Date: Fri, 4 Sep 2015 07:14:06 +0000 (+0530) Subject: include changes for website block -- CRM-16877 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=139a60f319534bf29cf146dcd1b892345375c056;p=civicrm-core.git include changes for website block -- CRM-16877 --- diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index c3658b59c9..a972eb461e 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -365,6 +365,9 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact { foreach ($blocks as $name => $value) { $contact->$name = $value; } + if (!empty($params['updateBlankLocInfo'])) { + $skipDelete = TRUE; + } //add website CRM_Core_BAO_Website::create($params['website'], $contact->id, $skipDelete); diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index b0d5294eaa..5374d0ee44 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -988,7 +988,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $parseStatusMsg = self::parseAddressStatusMsg($parseResult); } - $blocks = array('address', 'email', 'phone', 'im', 'openid'); + $blocks = array('email', 'phone', 'im', 'openid', 'address', 'website'); foreach ($blocks as $block) { if (!empty($this->_preEditValues[$block]) && is_array($this->_preEditValues[$block])) { foreach ($this->_preEditValues[$block] as $count => $value) { diff --git a/CRM/Contact/Form/Inline/Website.php b/CRM/Contact/Form/Inline/Website.php index 2265e20cbf..042bb74495 100644 --- a/CRM/Contact/Form/Inline/Website.php +++ b/CRM/Contact/Form/Inline/Website.php @@ -122,6 +122,11 @@ class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline { public function postProcess() { $params = $this->exportValues(); + foreach ($this->_websites as $count => $value) { + if (!empty($value['id']) && isset($params['website'][$count])) { + $params['website'][$count]['id'] = $value['id']; + } + } // Process / save websites CRM_Core_BAO_Website::create($params['website'], $this->_contactId, TRUE); diff --git a/CRM/Core/BAO/Website.php b/CRM/Core/BAO/Website.php index 0ea8c53012..df47e975cc 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -77,35 +77,20 @@ class CRM_Core_BAO_Website extends CRM_Core_DAO_Website { $ids = self::allWebsites($contactID); foreach ($params as $key => $values) { - $websiteId = CRM_Utils_Array::value('id', $values); - if ($websiteId) { - if (array_key_exists($websiteId, $ids)) { - unset($ids[$websiteId]); - } - else { - unset($values['id']); - } - } - - if (empty($values['id']) && - is_array($ids) && !empty($ids) - ) { + if (empty($values['id']) && is_array($ids) && !empty($ids)) { foreach ($ids as $id => $value) { - if (($value['website_type_id'] == $values['website_type_id']) && !empty($values['url'])) { + if (($value['website_type_id'] == $values['website_type_id'])) { $values['id'] = $id; - unset($ids[$id]); - break; } } } - $values['contact_id'] = $contactID; if (!empty($values['url'])) { + $values['contact_id'] = $contactID; self::add($values); } - } - - if ($skipDelete && !empty($ids)) { - self::del(array_keys($ids)); + elseif ($skipDelete && !empty($values['id'])) { + self::del(array($values['id'])); + } } }