From ac9ccca6e5aa7eb4b4354f9a8fbaeed7fc050e43 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 7 Sep 2010 15:45:47 +0000 Subject: [PATCH] * infologs with parents in projectmanager templates, got now the new parent not the original one from the template (egw.stylite.de #8164) --- infolog/inc/class.infolog_datasource.inc.php | 28 +++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/infolog/inc/class.infolog_datasource.inc.php b/infolog/inc/class.infolog_datasource.inc.php index 3101233680..b9d66cf258 100644 --- a/infolog/inc/class.infolog_datasource.inc.php +++ b/infolog/inc/class.infolog_datasource.inc.php @@ -136,7 +136,33 @@ class infolog_datasource extends datasource } egw_link::link('infolog',$info['info_id'],$link['app'],$link['id'],$link['remark']); } - return array($info['info_id'],$info['info_link_id']); + $ret = array($info['info_id'],$info['info_link_id']); + + // if we have a parent set, return our callback to modify the parent id, after all entries are copied + if ($info['info_id_parent']) + { + $ret[] = array($this,'copy_callback'); // callback + $ret[] = array($info['info_id'],$info['info_id_parent']); // $param + } + return $ret; + } + + /** + * Callback called after copying of all datasource, used to: + * - fix parent id's + * + * @param array $param array($info_id,$info_id_parent) + * @param array $apps_copied array('infolog' => array($old_info_id => $new_info_id)) + */ + public function copy_callback(array $param, array $apps_copied) + { + //error_log(__METHOD__."(".array2string($param).', '.array2string($apps_copied).')'); + list($info_id,$parent_id) = $param; + if (isset($apps_copied['infolog'][$parent_id]) && ($info = $this->infolog_bo->read($info_id))) + { + $info['info_id_parent'] = $apps_copied['infolog'][$parent_id]; + $this->infolog_bo->write($info,false,true,true,true); // no default and no notification + } } /**