From 81421f8195bc8ea56564431db205d1636d1d81f8 Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 9 Dec 2016 12:02:02 -0700 Subject: [PATCH] Fix contact not saved properly for new entries --- infolog/inc/class.infolog_bo.inc.php | 4 +++- infolog/inc/class.infolog_tracking.inc.php | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/infolog/inc/class.infolog_bo.inc.php b/infolog/inc/class.infolog_bo.inc.php index 02b5426d64..cc525410e1 100644 --- a/infolog/inc/class.infolog_bo.inc.php +++ b/infolog/inc/class.infolog_bo.inc.php @@ -423,7 +423,7 @@ class infolog_bo */ function link_id2from(&$info,$not_app='',$not_id='') { - //echo "

boinfolog::link_id2from(subject='$info[info_subject]', link_id='$info[info_link_id]', from='$info[info_from]', not_app='$not_app', not_id='$not_id')"; + //error_log(__METHOD__ . "(subject='{$info['info_subject']}', link_id='{$info['info_link_id']}', from='{$info['info_from']}', not_app='$not_app', not_id='$not_id')"); if ($info['info_link_id'] > 0 && (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info @@ -955,6 +955,8 @@ class infolog_bo $this->write_check_links($to_write); if(!$values['info_link_id'] && $to_write['info_link_id']) { + // Just got a link ID, need to save it + $this->so->write($to_write); $values['info_link_id'] = $to_write['info_link_id']; } diff --git a/infolog/inc/class.infolog_tracking.inc.php b/infolog/inc/class.infolog_tracking.inc.php index 8f2e4a6b82..9706688a7e 100644 --- a/infolog/inc/class.infolog_tracking.inc.php +++ b/infolog/inc/class.infolog_tracking.inc.php @@ -233,15 +233,22 @@ class infolog_tracking extends Api\Storage\Tracking ) as $name => $value) { //error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value)); - if ($name=='info_from' && empty($value) && !empty($data['info_contact']) && is_array($data['link_to']['to_id'])) - { - $lkeys = array_keys($data['link_to']['to_id']); - if (in_array($data['info_contact'],$lkeys)) + if ($name=='info_from' && empty($value)) + if(!empty($data['info_contact']) && is_array($data['link_to']['to_id'])) { + $lkeys = array_keys($data['link_to']['to_id']); + if (in_array($data['info_contact'],$lkeys)) + { + list($app,$id) = explode(':',$data['info_contact']); + if (!empty($app)&&!empty($id)) $value = Link::title($app,$id); + } + } + else if ($data['info_link_id']) + { + $this->infolog->link_id2from($data); list($app,$id) = explode(':',$data['info_contact']); if (!empty($app)&&!empty($id)) $value = Link::title($app,$id); } - } $details[$name] = array( 'label' => lang($this->field2label[$name]), 'value' => $value,