aboutsummaryrefslogtreecommitdiffstats
path: root/include/import.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-06-22 09:58:55 +0200
committerMario Vavti <mario@mariovavti.com>2016-06-22 09:58:55 +0200
commit5536df51f58a65f5a42051b0466b1c13c9a9718a (patch)
treee2000aa48946689e1c9e2b9d7b172854d69e2cbd /include/import.php
parentecae0b3d97d759603bb2bf9bc51187a2842964c8 (diff)
parentf48b12ff52c4fda85c09c1cc476f7cf4c0cfb649 (diff)
downloadvolse-hubzilla-5536df51f58a65f5a42051b0466b1c13c9a9718a.tar.gz
volse-hubzilla-5536df51f58a65f5a42051b0466b1c13c9a9718a.tar.bz2
volse-hubzilla-5536df51f58a65f5a42051b0466b1c13c9a9718a.zip
erge branch 'dev' into sabre32
Diffstat (limited to 'include/import.php')
-rw-r--r--include/import.php59
1 files changed, 24 insertions, 35 deletions
diff --git a/include/import.php b/include/import.php
index 0f52f3ff8..982eeb138 100644
--- a/include/import.php
+++ b/include/import.php
@@ -553,7 +553,7 @@ function sync_chatrooms($channel,$chatrooms) {
-function import_items($channel,$items,$sync = false) {
+function import_items($channel,$items,$sync = false,$relocate = null) {
if($channel && $items) {
$allow_code = false;
@@ -584,13 +584,6 @@ function import_items($channel,$items,$sync = false) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store_update($item,$allow_code,$deliver);
- if($sync && $item['item_wall']) {
- // deliver singletons if we have any
- if($item_result && $item_result['success']) {
- Zotlabs\Daemon\Master::Summon(array('Notifier','single_activity',$item_result['item_id']));
- }
- }
- continue;
}
}
else {
@@ -598,19 +591,37 @@ function import_items($channel,$items,$sync = false) {
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item,$allow_code,$deliver);
}
+
if($sync && $item['item_wall']) {
// deliver singletons if we have any
if($item_result && $item_result['success']) {
Zotlabs\Daemon\Master::Summon(array('Notifier','single_activity',$item_result['item_id']));
}
}
+ if($relocate && $item_result['item_id']) {
+ $item = $item_result['item'];
+ if($item['mid'] === $item['parent_mid']) {
+ item_url_replace($channel,$item,$relocate['url'],z_root(),$relocate['channel_address']);
+ dbesc_array($item);
+ $item_id = $item_result['item_id'];
+ unset($item['id']);
+ $str = '';
+ foreach($item as $k => $v) {
+ if($str)
+ $str .= ",";
+ $str .= " `" . $k . "` = '" . $v . "' ";
+ }
+
+ $r = dbq("update `item` set " . $str . " where id = " . $item_id );
+ }
+ }
}
}
}
-function sync_items($channel,$items) {
- import_items($channel,$items,true);
+function sync_items($channel,$items,$relocate = null) {
+ import_items($channel,$items,true,$relocate);
}
@@ -1200,31 +1211,9 @@ function sync_files($channel,$files) {
}
}
if($f['item']) {
- sync_items($channel,$f['item']);
- foreach($f['item'] as $i) {
- if($i['message_id'] !== $i['message_parent'])
- continue;
- $r = q("select * from item where mid = '%s' and uid = %d limit 1",
- dbesc($i['message_id']),
- intval($channel['channel_id'])
- );
- if($r) {
- $item = $r[0];
- item_url_replace($channel,$item,$oldbase,z_root(),$original_channel);
-
- dbesc_array($item);
- $item_id = $item['id'];
- unset($item['id']);
- $str = '';
- foreach($item as $k => $v) {
- if($str)
- $str .= ",";
- $str .= " `" . $k . "` = '" . $v . "' ";
- }
-
- $r = dbq("update `item` set " . $str . " where id = " . $item_id );
- }
- }
+ sync_items($channel,$f['item'],
+ ['channel_address' => $original_channel,'url' => $oldbase]
+ );
}
}
}