diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-06-19 16:39:03 -0700 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-06-19 16:39:03 -0700 |
commit | 6bd90816dd76d5fbd2374f72ac302537bc1ef047 (patch) | |
tree | 559f45b371f14a48ab589e9b0a07d24235f2393c /include | |
parent | 25e134dd9cb4768291517678286a197d5a4e79a6 (diff) | |
download | volse-hubzilla-6bd90816dd76d5fbd2374f72ac302537bc1ef047.tar.gz volse-hubzilla-6bd90816dd76d5fbd2374f72ac302537bc1ef047.tar.bz2 volse-hubzilla-6bd90816dd76d5fbd2374f72ac302537bc1ef047.zip |
very early attempt diaspora import from diaspora export file. Currently the json export has to be gunzipped prior to uploading and we're net yet adding connections (which should come soon) and we can't import items until they add guids to the export file - so consider it a work in progress. This first attempt should create a channel and get your profile details setup providing there isn't a nickname conflict on the server. That will also be handled later.
Diffstat (limited to 'include')
-rw-r--r-- | include/Import/import_diaspora.php | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/include/Import/import_diaspora.php b/include/Import/import_diaspora.php new file mode 100644 index 000000000..c9c785385 --- /dev/null +++ b/include/Import/import_diaspora.php @@ -0,0 +1,100 @@ +<?php + +require_once('include/bb2diaspora.php'); +require_once('include/group.php'); + +function import_diaspora($data) { + $a = get_app(); + + $account = $a->get_account(); + if(! $account) + return false; + + + $c = create_identity(array( + 'name' => $data['user']['name'], + 'nickname' => $data['user']['username'], + 'account_id' => $account['account_id'], + 'permissions_role' => 'social' + )); + + + if(! $c['success']) + return; + + $channel_id = $c['channel']['channel_id']; + + // todo - add nsfw, auto follow, (and strip exif in hubzilla) + + $location = escape_tags($data['user']['profile']['location']); + if(! $location) + $location = ''; + + q("update channel set channel_location = '%s' where channel_id = %d", + dbesc($location) + ); + + + $photos = import_profile_photo($data['user']['profile']['image_url'],$c['channel']['channel_hash']); + if($photos[4]) + $photodate = NULL_DATE; + else + $photodate = $xchan['xchan_photo_date']; + + $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' + where xchan_hash = '%s'", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($photodate), + dbesc($c['channel']['channel_hash']) + ); + + + $gender = escape_tags($data['user']['profile']['gender']); + $about = diaspora2bb($data['user']['profile']['bio']); + if($data['user']['profile']['birthday']) + $dob = datetime_convert('UTC','UTC',$data['user']['profile']['birthday'],'Y-m-d'); + else + $dob = '0000-00-00'; + + $r = q("update profile set gender = '%s', about = '%s', dob = '%s' where uid = %d", + dbesc($gender), + dbesc($about), + dbesc($dob), + intval($channel_id) + ); + + if($data['aspects']) { + foreach($data['aspects'] as $aspect) { + group_add($channel_id,escape_tags($aspect['name']),intval($aspect['contacts_visible'])); + } + } + + // now add connections and send friend requests + + + + + + + // Then add items - note this can't be done until Diaspora adds guids to exported + // items and comments + + + + + proc_run('php','include/notifier.php','location',$channel_id); + + // This will indirectly perform a refresh_all *and* update the directory + + proc_run('php', 'include/directory.php', $channel_id); + + notice( t('Import completed.') . EOL); + + change_channel($channel_id); + + goaway(z_root() . '/network' ); + +}
\ No newline at end of file |