aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Import/import_diaspora.php146
-rw-r--r--include/RedDAV/RedBrowser.php7
-rwxr-xr-xinclude/items.php14
3 files changed, 156 insertions, 11 deletions
diff --git a/include/Import/import_diaspora.php b/include/Import/import_diaspora.php
new file mode 100644
index 000000000..fca9fa4f2
--- /dev/null
+++ b/include/Import/import_diaspora.php
@@ -0,0 +1,146 @@
+<?php
+
+require_once('include/bb2diaspora.php');
+require_once('include/group.php');
+require_once('include/follow.php');
+require_once('include/photo/photo_driver.php');
+
+function import_diaspora($data) {
+ $a = get_app();
+
+ $account = $a->get_account();
+ if(! $account)
+ return false;
+
+ $address = escape_tags($data['user']['username']);
+ if(! $address) {
+ notice( t('No username found in import file.') . EOL);
+ return false;
+ }
+
+ $r = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($address)
+ );
+ if($r) {
+ // try at most ten times to generate a unique address.
+ $x = 0;
+ $found_unique = false;
+ do {
+ $tmp = $address . mt_rand(1000,9999);
+ $r = q("select * from channel where channel_address = '%s' limit 1",
+ dbesc($tmp)
+ );
+ if(! $r) {
+ $address = $tmp;
+ $found_unique = true;
+ break;
+ }
+ $x ++;
+ } while ($x < 10);
+ if(! $found_unique) {
+ logger('import_diaspora: duplicate channel address. randomisation failed.');
+ notice( t('Unable to create a unique channel address. Import failed.') . EOL);
+ return;
+ }
+ }
+
+
+ $c = create_identity(array(
+ 'name' => escape_tags($data['user']['name']),
+ 'nickname' => $address,
+ 'account_id' => $account['account_id'],
+ 'permissions_role' => 'social'
+ ));
+
+ if(! $c['success'])
+ return;
+
+ $channel_id = $c['channel']['channel_id'];
+
+ // todo - add auto follow settings, (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),
+ intval($channel_id)
+ );
+
+ if($data['user']['profile']['nsfw']) {
+ // fixme for hubzilla which doesn't use pageflags any more
+ q("update channel set channel_pageflags = (channel_pageflags | %d) where channel_id = %d",
+ intval(PAGE_ADULT),
+ intval($channel_id)
+ );
+ }
+
+ if($data['user']['profile']['image_url']) {
+ $p = z_fetch_url($data['user']['profile']['image_url'],true);
+ if($p['success']) {
+ $rawbytes = $p['body'];
+ $type = guess_image_type('dummyfile',$p['header']);
+ import_channel_photo($rawbytes,$type,$c['channel']['channel_account_id'],$channel_id);
+ }
+ }
+
+ $gender = escape_tags($data['user']['profile']['gender']);
+ $about = diaspora2bb($data['user']['profile']['bio']);
+ $publish = intval($data['user']['profile']['searchable']);
+ if($data['user']['profile']['birthday'])
+ $dob = datetime_convert('UTC','UTC',$data['user']['profile']['birthday'],'Y-m-d');
+ else
+ $dob = '0000-00-00';
+
+ // we're relying on the fact that this channel was just created and will only
+ // have the default profile currently
+
+ $r = q("update profile set gender = '%s', about = '%s', dob = '%s', publish = %d where uid = %d",
+ dbesc($gender),
+ dbesc($about),
+ dbesc($dob),
+ dbesc($publish),
+ intval($channel_id)
+ );
+
+ if($data['user']['aspects']) {
+ foreach($data['user']['aspects'] as $aspect) {
+ group_add($channel_id,escape_tags($aspect['name']),intval($aspect['contacts_visible']));
+ }
+ }
+
+ // now add connections and send friend requests
+
+
+ if($data['user']['contacts']) {
+ foreach($data['user']['contacts'] as $contact) {
+ $result = new_contact($channel_id, $contact['person_diaspora_handle'], $c['channel']);
+ if($result['success']) {
+ if($contact['aspects']) {
+ foreach($contact['aspects'] as $aspect) {
+ group_add_member($channel_id,$aspect['name'],$result['abook']['xchan_hash']);
+ }
+ }
+ }
+ }
+ }
+
+
+ // Then add items - note this can't be done until Diaspora adds guids to exported
+ // items and comments
+
+
+
+ // 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
diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php
index a0330d7cc..d74bba220 100644
--- a/include/RedDAV/RedBrowser.php
+++ b/include/RedDAV/RedBrowser.php
@@ -247,7 +247,7 @@ class RedBrowser extends DAV\Browser\Plugin {
$this->server->broadcastEvent('onHTMLActionsPanel', array($parent, &$output));
}
- $html .= replace_macros(get_markup_template('cloud_header.tpl'), array(
+ $html .= replace_macros(get_markup_template('cloud.tpl'), array(
'$header' => t('Files') . ": " . $this->escapeHTML($path) . "/",
'$quota' => $quota,
'$total' => t('Total'),
@@ -255,10 +255,7 @@ class RedBrowser extends DAV\Browser\Plugin {
'$shared' => t('Shared'),
'$create' => t('Create'),
'$upload' => t('Upload'),
- '$is_owner' => $is_owner
- ));
-
- $html .= replace_macros(get_markup_template('cloud_directory.tpl'), array(
+ '$is_owner' => $is_owner,
'$parentpath' => $parentpath,
'$entries' => $f,
'$name' => t('Name'),
diff --git a/include/items.php b/include/items.php
index ca7ceae42..73cb69342 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2592,6 +2592,7 @@ function item_store_update($arr,$allow_exec = false) {
$arr['item_blocked'] = ((array_key_exists('item_blocked',$arr)) ? intval($arr['item_blocked']) : $orig[0]['item_blocked'] );
+
$arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
$arr['layout_mid'] = ((array_key_exists('layout_mid',$arr)) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] );
@@ -2635,12 +2636,11 @@ function item_store_update($arr,$allow_exec = false) {
return $ret;
}
- $r = q("delete from term where oid = %d and otype = %d",
- intval($orig_post_id),
- intval(TERM_OBJ_POST)
- );
-
- if(($terms) && (is_array($terms))) {
+ if(is_array($terms)) {
+ $r = q("delete from term where oid = %d and otype = %d",
+ intval($orig_post_id),
+ intval(TERM_OBJ_POST)
+ );
foreach($terms as $t) {
q("insert into term (uid,oid,otype,type,term,url)
values(%d,%d,%d,%d,'%s','%s') ",
@@ -2667,6 +2667,8 @@ function item_store_update($arr,$allow_exec = false) {
return $ret;
}
+
+
function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id, $walltowall = false) {
// We won't be able to sign Diaspora comments for authenticated visitors