Fix some more contact bugs:

- Contact would only actually change every second time you changed it
- Contact would sometimes stay even after being removed
This commit is contained in:
nathangray 2016-12-21 10:02:26 -07:00
parent c2e12a6583
commit 43b07dfb04
2 changed files with 53 additions and 45 deletions

View File

@ -953,11 +953,13 @@ class infolog_bo
$values['link_to']['to_id'] = $info_id; $values['link_to']['to_id'] = $info_id;
} }
$this->write_check_links($to_write); $this->write_check_links($to_write);
if(!$values['info_link_id'] && $to_write['info_link_id']) if(!$values['info_link_id'] || $values['info_link_id'] != $to_write['info_link_id'])
{ {
// Just got a link ID, need to save it // Just got a link ID, need to save it
$this->so->write($to_write); $this->so->write($to_write);
$values['info_link_id'] = $to_write['info_link_id']; $values['info_link_id'] = $to_write['info_link_id'];
$values['info_contact'] = $to_write['info_contact'];
$this->link_id2from($values);
} }
if (($info_from_set = ($values['info_link_id'] && isset($values['info_from']) && empty($values['info_from'])))) if (($info_from_set = ($values['info_link_id'] && isset($values['info_from']) && empty($values['info_from']))))
@ -1040,8 +1042,6 @@ class infolog_bo
* @param Array $values * @param Array $values
*/ */
protected function write_check_links(&$values) protected function write_check_links(&$values)
{
if ($values['info_contact'])
{ {
$old_link_id = (int)$values['info_link_id']; $old_link_id = (int)$values['info_link_id'];
if(is_array($values['info_contact'])) if(is_array($values['info_contact']))
@ -1091,7 +1091,6 @@ class infolog_bo
$values['old_pm_id'] = $values['pm_id'] = $id; $values['old_pm_id'] = $values['pm_id'] = $id;
} }
} }
}
/** /**
* Query the number of children / subs for one or more info_id's * Query the number of children / subs for one or more info_id's

View File

@ -1741,6 +1741,14 @@ class infolog_ui
{ {
$content['info_link_id'] = 0; // as field has to be int $content['info_link_id'] = 0; // as field has to be int
} }
if (is_array($content['info_contact']) && $content['info_contact']['id'])
{
$content['info_contact'] = $content['info_contact']['app'] . ':' . $content['info_contact']['id'];
}
else
{
$content['info_contact'] = false;
}
$active_tab = $content['tabs']; $active_tab = $content['tabs'];
if (!($info_id = $this->bo->write($content, true, true, true, $content['no_notifications']))) if (!($info_id = $this->bo->write($content, true, true, true, $content['no_notifications'])))
{ {
@ -1785,6 +1793,7 @@ class infolog_ui
} }
$content['old_pm_id'] = $content['pm_id']; $content['old_pm_id'] = $content['pm_id'];
} }
$content['link_to']['to_app'] = 'infolog';
$content['link_to']['to_id'] = $info_id; $content['link_to']['to_id'] = $info_id;
if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary if ($info_link_id && strpos($info_link_id,':') !== false) // updating info_link_id if necessary