Skip to content

Commit

Permalink
tweak(Addressbook/Import/Egw14): add infologs as note
Browse files Browse the repository at this point in the history
  • Loading branch information
pschuele committed Jun 25, 2024
1 parent 815c7ff commit d2d0b3a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
8 changes: 6 additions & 2 deletions tine20/Addressbook/Setup/Import/Egw14.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");

Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 19 additions & 3 deletions tine20/Tinebase/Setup/Import/Egw14/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ public function mapAccountIdEgw2Tine($_egwAccountId, $_throwException = TRUE)
}
}

// echo "$_egwAccountId => {$this->_accountIdMapCache[$_egwAccountId]} \n";
return $this->_accountIdMapCache[$_egwAccountId];
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}

0 comments on commit d2d0b3a

Please sign in to comment.