From d2d0b3a5628d280604be45313772140f8efb41bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20Sch=C3=BCle?=
Date: Tue, 25 Jun 2024 12:27:31 +0200
Subject: [PATCH] tweak(Addressbook/Import/Egw14): add infologs as note
---
tine20/Addressbook/Setup/Import/Egw14.php | 8 +++++--
.../Tinebase/Setup/Import/Egw14/Abstract.php | 22 ++++++++++++++++---
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/tine20/Addressbook/Setup/Import/Egw14.php b/tine20/Addressbook/Setup/Import/Egw14.php
index 2d3f1b367d..8fa2439814 100644
--- a/tine20/Addressbook/Setup/Import/Egw14.php
+++ b/tine20/Addressbook/Setup/Import/Egw14.php
@@ -156,6 +156,8 @@ public function import()
$this->_log->notice(__METHOD__ . '::' . __LINE__
. " found {$estimate} total contacts for migration ({$numPages} pages)");
+ // $numPages = 1;
+
for (; $page <= $numPages; $page++) {
$this->_log->info(__METHOD__ . '::' . __LINE__ . " starting migration page {$page} of {$numPages}");
@@ -176,7 +178,7 @@ public function import()
*/
protected function _migrateEgwRecordPage($recordPage)
{
- foreach($recordPage as $egwContactData) {
+ foreach ($recordPage as $egwContactData) {
try {
$this->_importResult['totalcount']++;
$currentUser = Tinebase_Core::get(Tinebase_Core::USER);
@@ -231,9 +233,11 @@ protected function _migrateEgwRecordPage($recordPage)
$this->getPrivateContainer($this->mapAccountIdEgw2Tine($egwContactData['contact_owner']))->getId() :
$this->getPersonalContainer($this->mapAccountIdEgw2Tine($egwContactData['contact_owner']))->getId();
}
+
+ $contactData['note'] = $this->_getInfoLogData($egwContactData['contact_id'], 'addressbook');
// finally create the record
- $tineContact = new Addressbook_Model_Contact ($contactData);
+ $tineContact = new Addressbook_Model_Contact($contactData);
$this->saveTineRecord($tineContact);
} catch (Exception $e) {
diff --git a/tine20/Tinebase/Setup/Import/Egw14/Abstract.php b/tine20/Tinebase/Setup/Import/Egw14/Abstract.php
index 4660a84a81..07bf02b5b5 100644
--- a/tine20/Tinebase/Setup/Import/Egw14/Abstract.php
+++ b/tine20/Tinebase/Setup/Import/Egw14/Abstract.php
@@ -279,7 +279,6 @@ public function mapAccountIdEgw2Tine($_egwAccountId, $_throwException = TRUE)
}
}
-// echo "$_egwAccountId => {$this->_accountIdMapCache[$_egwAccountId]} \n";
return $this->_accountIdMapCache[$_egwAccountId];
}
@@ -479,8 +478,6 @@ public function getGrantsByOwner($_application, $_accountId)
$tineGrants->addRecord($tineGrant);
}
-// print_r($tineGrants->toArray());
-
// for group owners (e.g. group addressbooks) we need an container admin
if ($egwAccountId < 0) {
$adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
@@ -630,4 +627,23 @@ public function saveAlarms(Tinebase_Record_RecordSet $alarms, $recordId)
return $createdAlarms;
}
+
+ protected function _getInfoLogData(int $recordId, string $recordApp): string
+ {
+ $select = $this->_egwDb->select()
+ ->from(array('infolog' => 'egw_infolog'))
+ ->join('egw_links', 'infolog.info_id = egw_links.link_id1')
+ ->where($this->_egwDb->quoteInto($this->_egwDb->quoteIdentifier('egw_links.link_app2') . ' = ?', $recordApp))
+ ->where($this->_egwDb->quoteInto($this->_egwDb->quoteIdentifier('egw_links.link_app1') . ' = ?', 'infolog'))
+ ->where($this->_egwDb->quoteInto($this->_egwDb->quoteIdentifier('egw_links.link_id2') . ' = ?', $recordId));
+
+ $egwInfologs = $this->_egwDb->fetchAll($select, null, Zend_Db::FETCH_ASSOC);
+
+ $result = '';
+ foreach ($egwInfologs as $infolog) {
+ $result = '[' . $infolog['info_type'] . '] ' . $infolog['info_subject'] . ": \n" . $infolog['info_from']
+ ." \n" . $infolog['info_des'] . "\n\n";
+ }
+ return $result;
+ }
}