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);
$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) {
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);
$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']));
+ }
}
}