diff options
author | Mario Vavti <mario@mariovavti.com> | 2015-10-15 09:36:51 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2015-10-15 09:36:51 +0200 |
commit | 2848f5dab4e0f904280e77d6403ab69926cabe1d (patch) | |
tree | bcb2f2a70660d7abe319b126035d2e0b2ddd2c41 /include/import.php | |
parent | 3c7d2d4cea80fae5113de8c78ed522ce8b32c16d (diff) | |
parent | f0f5a8f2b510b92aa1fde2cbaf118a784c154432 (diff) | |
download | volse-hubzilla-2848f5dab4e0f904280e77d6403ab69926cabe1d.tar.gz volse-hubzilla-2848f5dab4e0f904280e77d6403ab69926cabe1d.tar.bz2 volse-hubzilla-2848f5dab4e0f904280e77d6403ab69926cabe1d.zip |
Merge branch 'master' of https://github.com/redmatrix/hubzilla
Diffstat (limited to 'include/import.php')
-rw-r--r-- | include/import.php | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/include/import.php b/include/import.php index ad8bcd84e..1734bd263 100644 --- a/include/import.php +++ b/include/import.php @@ -790,7 +790,7 @@ function import_likes($channel,$likes) { if($r) continue; - dbesc_array($config); + dbesc_array($like); $r = dbq("INSERT INTO likes (`" . implode("`, `", array_keys($like)) . "`) VALUES ('" @@ -800,6 +800,72 @@ function import_likes($channel,$likes) { } } +function import_conv($channel,$convs) { + if($channel && $convs) { + foreach($convs as $conv) { + if($conv['deleted']) { + q("delete from conv where guid = '%s' and uid = %d limit 1", + dbesc($conv['guid']), + intval($channel['channel_id']) + ); + continue; + } + + unset($conv['id']); + + $conv['uid'] = $channel['channel_id']; + $conv['subject'] = str_rot47(base64url_encode($conv['subject'])); + + $r = q("select id from conv where guid = '%s' and uid = %d limit 1", + dbesc($conv['guid']), + intval($channel['channel_id']) + ); + if($r) + continue; + + dbesc_array($conv); + $r = dbq("INSERT INTO conv (`" + . implode("`, `", array_keys($conv)) + . "`) VALUES ('" + . implode("', '", array_values($conv)) + . "')" ); + } + } +} + + + +function import_mail($channel,$mails) { + if($channel && $mails) { + foreach($mails as $mail) { + if(array_key_exists('flags',$mail) && in_array('deleted',$mail['flags'])) { + q("delete from mail where mid = '%s' and uid = %d limit 1", + dbesc($mail['message_id']), + intval($channel['channel_id']) + ); + continue; + } + $m = get_mail_elements($mail); + if(! $m) + continue; + + if($mail['conv_guid']) { + $x = q("select id from conv where guid = '%s' and uid = %d limit 1", + dbesc($mail['conv_guid']), + intval($channel['channel_id']) + ); + if($x) { + $m['convid'] = $x[0]['id']; + } + } + $m['aid'] = $channel['channel_account_id']; + $m['uid'] = $channel['channel_id']; + mail_store($m); + } + } +} + + |