Skip to content

Commit

Permalink
tweak(Addressbook/Import/Egw14): add infolog tags to contact
Browse files Browse the repository at this point in the history
  • Loading branch information
pschuele committed Jul 1, 2024
1 parent 410fd1d commit d63c1a5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 3 additions & 1 deletion tine20/Addressbook/Setup/Import/Egw14.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function import()
. " found {$estimate} total contacts for migration ({$numPages} pages)");

// for testing
// $page = $numPages = 3;
// $page = $numPages = 4;

for (; $page <= $numPages; $page++) {
$this->_log->info(__METHOD__ . '::' . __LINE__ . " starting migration page {$page} of {$numPages}");
Expand Down Expand Up @@ -238,6 +238,8 @@ protected function _migrateEgwRecordPage($recordPage)
}

$contactData['note'] = $this->_getInfoLogData($egwContactData['contact_id'], 'addressbook');
$contactData['tags'] = array_merge($contactData['tags'],
$this->_getInfoLogTags($egwContactData['contact_id'], 'addressbook'));
$contactData['customfields'] = $this->_getCustomFields($egwContactData['contact_id']);

// finally create the record
Expand Down
23 changes: 19 additions & 4 deletions tine20/Tinebase/Setup/Import/Egw14/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,17 @@ public function saveAlarms(Tinebase_Record_RecordSet $alarms, $recordId)
}

protected function _getInfoLogData(int $recordId, string $recordApp): string
{
$egwInfologs = $this->_fetchInfoLogs($recordId, $recordApp);
$result = '';
foreach ($egwInfologs as $infolog) {
$result = '[' . $infolog['info_type'] . '] ' . $infolog['info_subject'] . ": \n" . $infolog['info_from']
." \n" . $infolog['info_des'] . "\n\n";
}
return $result;
}

protected function _fetchInfoLogs(int $recordId, string $recordApp): array
{
$select = $this->_egwDb->select()
->from(array('infolog' => 'egw_infolog'))
Expand All @@ -637,12 +648,16 @@ protected function _getInfoLogData(int $recordId, string $recordApp): string
->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);
return $this->_egwDb->fetchAll($select, null, Zend_Db::FETCH_ASSOC);
}

$result = '';
protected function _getInfoLogTags(int $recordId, string $recordApp): array
{
$egwInfologs = $this->_fetchInfoLogs($recordId, $recordApp);

$result = [];
foreach ($egwInfologs as $infolog) {
$result = '[' . $infolog['info_type'] . '] ' . $infolog['info_subject'] . ": \n" . $infolog['info_from']
." \n" . $infolog['info_des'] . "\n\n";
$result = $this->convertCategories($infolog['info_cat']);
}
return $result;
}
Expand Down

0 comments on commit d63c1a5

Please sign in to comment.