aboutsummaryrefslogtreecommitdiffstats
path: root/include/import.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-06-27 04:00:10 -0700
committerredmatrix <git@macgirvin.com>2016-06-27 04:00:10 -0700
commit85d2ad4aea106417dc3d8ce2429d13dd858c5201 (patch)
tree72e03b3fe379829a4e2f9c521366fb14e1eaa970 /include/import.php
parentd5d5d78e3aded9a3238ccb7e93b4c6fd4b873331 (diff)
parent8d298d5a068845856c9827c0d2ea3f02f1399d72 (diff)
downloadvolse-hubzilla-85d2ad4aea106417dc3d8ce2429d13dd858c5201.tar.gz
volse-hubzilla-85d2ad4aea106417dc3d8ce2429d13dd858c5201.tar.bz2
volse-hubzilla-85d2ad4aea106417dc3d8ce2429d13dd858c5201.zip
Merge branch 'dev' into perms
Diffstat (limited to 'include/import.php')
-rw-r--r--include/import.php110
1 files changed, 54 insertions, 56 deletions
diff --git a/include/import.php b/include/import.php
index 6fcb08416..982eeb138 100644
--- a/include/import.php
+++ b/include/import.php
@@ -122,6 +122,11 @@ function import_profiles($channel,$profiles) {
$profile['aid'] = get_account_id();
$profile['uid'] = $channel['channel_id'];
+ convert_oldfields($profile,'name','fullname');
+ convert_oldfields($profile,'with','partner');
+ convert_oldfields($profile,'work','employment');
+
+
// we are going to reset all profile photos to the original
// somebody will have to fix this later and put all the applicable photos into the export
@@ -548,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;
@@ -579,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 {
@@ -593,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);
}
@@ -619,19 +635,14 @@ function import_item_ids($channel,$itemids) {
);
if(! $r)
continue;
- $z = q("select * from item_id where service = '%s' and sid = '%s' and iid = %d and uid = %d limit 1",
+ $z = q("select * from iconfig where iconfig.cat = 'system' and iconfig.k = '%s'
+ and iconfig.v = '%s' and iid = %d limit 1",
dbesc($i['service']),
dbesc($i['sid']),
- intval($r[0]['id']),
- intval($channel['channel_id'])
+ intval($r[0]['id'])
);
if(! $z) {
- q("insert into item_id (iid,uid,sid,service) values(%d,%d,'%s','%s')",
- intval($r[0]['id']),
- intval($channel['channel_id']),
- dbesc($i['sid']),
- dbesc($i['service'])
- );
+ \Zotlabs\Lib\IConfig::Set($r[0]['id'],'system',$i['service'],$i['sid'],true);
}
}
}
@@ -644,6 +655,10 @@ function import_events($channel,$events) {
unset($event['id']);
$event['aid'] = $channel['channel_account_id'];
$event['uid'] = $channel['channel_id'];
+ convert_oldfields($event,'start','dtstart');
+ convert_oldfields($event,'finish','dtend');
+ convert_oldfields($event,'type','etype');
+ convert_oldfields($event,'ignore','dismissed');
dbesc_array($event);
$r = dbq("INSERT INTO event (`"
@@ -677,6 +692,12 @@ function sync_events($channel,$events) {
$event['aid'] = $channel['channel_account_id'];
$event['uid'] = $channel['channel_id'];
+ convert_oldfields($event,'start','dtstart');
+ convert_oldfields($event,'finish','dtend');
+ convert_oldfields($event,'type','etype');
+ convert_oldfields($event,'ignore','dismissed');
+
+
$exists = false;
$x = q("select * from event where event_hash = '%s' and uid = %d limit 1",
@@ -974,10 +995,7 @@ function sync_files($channel,$files) {
$attachment_stored = false;
foreach($f['attach'] as $att) {
- if(array_key_exists('data',$att)) {
- $att['content'] = $att['data'];
- unset($att['data']);
- }
+ convert_oldfields($att,'data','content');
if($att['deleted']) {
attach_delete($channel,$att['hash']);
@@ -1130,14 +1148,10 @@ function sync_files($channel,$files) {
$p['aid'] = $channel['channel_account_id'];
$p['uid'] = $channel['channel_id'];
- if(array_key_exists('data',$p)) {
- $p['content'] = $p['data'];
- unset($p['data']);
- }
- if(array_key_exists('scale',$p)) {
- $p['imgscale'] = $p['scale'];
- unset($p['scale']);
- }
+ convert_oldfields($p,'data','content');
+ convert_oldfields($p,'scale','imgscale');
+ convert_oldfields($p,'size','filesize');
+ convert_oldfields($p,'type','mimetype');
// if this is a profile photo, undo the profile photo bit
// for any other photo which previously held it.
@@ -1197,34 +1211,18 @@ 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]
+ );
}
}
}
}
+function convert_oldfields(&$arr,$old,$new) {
+ if(array_key_exists($old,$arr)) {
+ $arr[$new] = $arr[$old];
+ unset($arr[$old]);
+ }
+}