From 11411abef516a94a4208ecad5c4550b48ce9bb92 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Wed, 11 May 2011 15:09:16 +0000 Subject: [PATCH] fix for 'cf_link_fields do not create link on inital save' in calendar: reason no id passed when called tracking for new events --- calendar/inc/class.calendar_boupdate.inc.php | 1 + etemplate/inc/class.bo_tracking.inc.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index a86a36d45c..a25e553c11 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1005,6 +1005,7 @@ class calendar_boupdate extends calendar_bo $tracking = new calendar_tracking($this); $event['category'] = implode(',', $this->get_categories($event['category'])); $old_event['category'] = implode(',', $this->get_categories($old_event['category'])); + if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; $tracking->track($event, $old_event); return $cal_id; diff --git a/etemplate/inc/class.bo_tracking.inc.php b/etemplate/inc/class.bo_tracking.inc.php index b0fa479ed4..f3be5c75ee 100644 --- a/etemplate/inc/class.bo_tracking.inc.php +++ b/etemplate/inc/class.bo_tracking.inc.php @@ -266,9 +266,12 @@ abstract class bo_tracking */ protected function update_links(array $data, array $old) { + //error_log(__METHOD__.__LINE__.array2string($data).function_backtrace()); + //error_log(__METHOD__.__LINE__.array2string($this->cf_link_fields)); $current_ids = array_unique(array_diff(array_intersect_key($data,$this->cf_link_fields),array('',0,NULL))); $old_ids = $old ? array_unique(array_diff(array_intersect_key($old,$this->cf_link_fields),array('',0,NULL))) : array(); - + //error_log(__METHOD__.__LINE__.array2string($current_ids)); + //error_log(__METHOD__.__LINE__.array2string($old_ids)); // create links for added application entry foreach(array_diff($current_ids,$old_ids) as $name => $id) { @@ -277,7 +280,10 @@ abstract class bo_tracking list($app,$id) = explode(':',$id); if (!$id) continue; // can be eg. 'addressbook:', if no contact selected } - egw_link::link($this->app,$data[$this->id_field],$app,$id); + $source_id = $data[$this->id_field]; + //error_log(__METHOD__.__LINE__.array2string($source_id)); + if ($source_id) egw_link::link($this->app,$source_id,$app,$id); + //error_log(__METHOD__.__LINE__."egw_link::link('$this->app',".array2string($source_id).",'$app',$id);"); //echo "

egw_link::link('$this->app',{$data[$this->id_field]},'$app',$id);

\n"; } @@ -289,7 +295,8 @@ abstract class bo_tracking list($app,$id) = explode(':',$id); if (!$id) continue; } - egw_link::unlink(null,$this->app,$data[$this->id_field],0,$app,$id); + $source_id = $data[$this->id_field]; + if ($source_id) egw_link::unlink(null,$this->app,$source_id,0,$app,$id); //echo "

egw_link::unlink(NULL,'$this->app',{$data[$this->id_field]},0,'$app',$id);

\n"; } }