aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-02-19 19:08:04 -0800
committerfriendica <info@friendica.com>2013-02-19 19:08:04 -0800
commitef360f0a5ce9b422642a395d1cbd62dac8dda973 (patch)
tree23557d394f5e3ad953ae982a1cda260d22184c3f
parent24eac8c65614a71ac1ec0ffec8bcf877c1fa0355 (diff)
downloadvolse-hubzilla-ef360f0a5ce9b422642a395d1cbd62dac8dda973.tar.gz
volse-hubzilla-ef360f0a5ce9b422642a395d1cbd62dac8dda973.tar.bz2
volse-hubzilla-ef360f0a5ce9b422642a395d1cbd62dac8dda973.zip
dang - this is almost testable. Still have to figure out the best way to deal with the profile photo. Otherwise if you're really brave you could give it a go and see what happens. The worst that could happen is that it destroys the universe. Not a big deal. More likely you could end up with a bunch of imported things that have to be cleaned up. Less likely but entirely possible is that nothing useful will happen at all and it'll white screen.
-rw-r--r--include/identity.php9
-rw-r--r--mod/import.php79
-rw-r--r--mod/new_channel.php2
-rw-r--r--view/css/mod_import.css37
-rw-r--r--view/php/mod_import.php2
-rw-r--r--view/tpl/new_channel.tpl4
-rw-r--r--view/tpl/smarty3/new_channel.tpl4
7 files changed, 110 insertions, 27 deletions
diff --git a/include/identity.php b/include/identity.php
index 9f8bc0ab0..62092443e 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -275,6 +275,15 @@ function identity_basic_export($channel_id) {
$ret['hubloc'] = $r;
}
+ $r = q("select type, data from photo where scale = 4 and profile = 1 and uid = %d limit 1",
+ intval($channel_id)
+ );
+
+ if($r) {
+ $ret['photo'] = array('type' => $r[0]['type'], 'data' => base64url_encode($r[0]['data']));
+ }
+
+
return $ret;
}
diff --git a/mod/import.php b/mod/import.php
index e9885cc7a..5c778e2b2 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -69,16 +69,17 @@ function import_post(&$a) {
$channel = $data['channel'];
- $r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s') limit 1",
+ $r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s' or channel_address = '%s' ) limit 1",
dbesc($channel['channel_guid']),
- dbesc($channel['channel_hash'])
+ dbesc($channel['channel_hash']),
+ dbesc($channel['channel_address'])
);
// We should probably also verify the hash
if($r) {
logger('mod_import: duplicate channel. ', print_r($channel,true));
- notice( t('Duplicate channel unique ID. Import failed.') . EOL);
+ notice( t('Cannot create a duplicate channel identifier on this system. Import failed.') . EOL);
return;
}
@@ -112,6 +113,11 @@ function import_post(&$a) {
// reset
$channel = $r[0];
+
+// FIXME - import the default profile photo (it has now been exported as a base64 blob)
+
+
+
$profiles = $data['profile'];
if($profiles) {
foreach($profiles as $profile) {
@@ -134,6 +140,7 @@ function import_post(&$a) {
}
}
+
$hublocs = $data['hubloc'];
if($hublocs) {
foreach($hublocs as $hubloc) {
@@ -157,11 +164,36 @@ function import_post(&$a) {
}
- // create new hubloc for the new channel at this site
- // and reset the original hubloc if it is being seized but wasn't created just now
}
}
+ // create new hubloc for the new channel at this site
+
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags,
+ hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey )
+ values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s' )",
+ dbesc($channel['channel_guid']),
+ dbesc($channel['channel_guid_sig']),
+ dbesc($channel['channel_hash']),
+ dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
+ intval(($seize) ? HUBLOC_FLAGS_PRIMARY : 0),
+ dbesc(z_root()),
+ dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))),
+ dbesc(get_app()->get_hostname()),
+ dbesc(z_root() . '/post'),
+ dbesc(get_config('system','pubkey'))
+ );
+
+ // reset the original primary hubloc if it is being seized
+
+ if($seize)
+ $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where (hubloc_flags & %d) and hubloc_hash = '%s' and hubloc_url != '%s' ",
+ intval(HUBLOC_FLAGS_PRIMARY),
+ intval(HUBLOC_FLAGS_PRIMARY),
+ dbesc($channel['channel_hash']),
+ dbesc(z_root())
+ );
+
// import xchans and contact photos
@@ -197,6 +229,8 @@ function import_post(&$a) {
}
}
+// FIXME - ensure we have an xchan if somebody is trying to pull a fast one
+
// import contacts
$abooks = $data['abook'];
@@ -213,37 +247,38 @@ function import_post(&$a) {
}
}
+// FIXME - ensure we have a self entry if somebody is trying to pull a fast one
if($seize) {
// notify old server that it is no longer primary.
}
-
// send out refresh requests
+ notice( t('Import completed.') . EOL);
+
}
function import_content(&$a) {
-/*
- * Pass in a channel name and desired channel_address
- * Check this for validity and duplication
- * The page template should have a place to change it and check again
- */
-
-
-$o .= <<< EOT
-<form action="import" method="post" >
-Old Address <input type="text" name="old_address" /><br />
-Login <input type="text" name="email" /><br />
-Password <input type="password" name="password" /><br />
-<input type="submit" name="submit" value="submit" />
-</form>
+ $o = replace_macros(get_markup_template('channel_import.tpl'),array(
+ '$title' => t('Import Channel'),
+ '$desc' => t('Use this form to import an existing channel from a different server/hub. You may retrieve the channel identity from the old server/hub via the network or provide an export file. Only identity and connections/relationships will be imported. Importation of content is not yet available.'),
+ '$label_filename' => t('File to Upload'),
+ '$choice' => t('Or provide the old server/hub details'),
+ '$label_old_address' => t('Your old identity address (xyz@example.com)'),
+ '$label_old_email' => t('Your old login email address'),
+ '$label_old_pass' => t('Your old login password'),
+ '$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'),
+ '$label_import_primary' => t('Make this hub my primary location'),
+ '$email' => '',
+ '$pass' => '',
+ '$submit' => t('Submit')
+ ));
-EOT;
+ return $o;
-return $o;
} \ No newline at end of file
diff --git a/mod/new_channel.php b/mod/new_channel.php
index 8d0776ff0..eafef2c08 100644
--- a/mod/new_channel.php
+++ b/mod/new_channel.php
@@ -111,7 +111,7 @@ function new_channel_content(&$a) {
'$help_name' => t('Examples: "Bob Jameson", "Lisa and her Horses", "Soccer", "Aviation Group" '),
'$label_nick' => t('Choose a short nickname'),
'$nick_desc' => t('Your nickname will be used to create an easily remembered channel address (like an email address) which you can share with others.'),
- '$label_import' => t('Check this box to import an existing channel file from another location'),
+ '$label_import' => t('Or <a href="import">import an existing channel</a> from another location'),
'$name' => $name,
'$nickname' => $nickname,
'$submit' => t('Create')
diff --git a/view/css/mod_import.css b/view/css/mod_import.css
new file mode 100644
index 000000000..8b988b324
--- /dev/null
+++ b/view/css/mod_import.css
@@ -0,0 +1,37 @@
+h2 {
+ margin-left: 15%;
+ margin-top: 8%;
+}
+
+#import-channel-form {
+ font-size: 1.4em;
+ margin-left: 15%;
+ margin-top: 5%;
+ width: 50%;
+}
+
+
+
+#import-channel-form .descriptive-paragraph {
+ color: #888;
+ margin-left: 20px;
+ margin-bottom: 25px;
+}
+
+.import-label {
+ float: left;
+ width: 275px;
+}
+
+.import-input {
+ float: left;
+ width: 275px;
+ padding: 5px;
+}
+
+
+.import-field-end {
+ clear: both;
+ margin-bottom: 20px;
+}
+
diff --git a/view/php/mod_import.php b/view/php/mod_import.php
new file mode 100644
index 000000000..1ca2866bc
--- /dev/null
+++ b/view/php/mod_import.php
@@ -0,0 +1,2 @@
+<?php
+$a->page['template'] = 'full';
diff --git a/view/tpl/new_channel.tpl b/view/tpl/new_channel.tpl
index f83bc3a11..0ea764621 100644
--- a/view/tpl/new_channel.tpl
+++ b/view/tpl/new_channel.tpl
@@ -19,8 +19,8 @@
<div id="newchannel-nick-desc" class="descriptive-paragraph">$nick_desc</div>
- <input type="checkbox" name="import" id="newchannel-import" value="1" />
- <label for="newchannel-import" id="label-newchannel-import">$label_import</label>
+ <div id="newchannel-import-link" class="descriptive-paragraph" >$label_import</div>
+
<div id="newchannel-import-end" class="newchannel-field-end"></div>
<input type="submit" name="submit" id="newchannel-submit-button" value="$submit" />
diff --git a/view/tpl/smarty3/new_channel.tpl b/view/tpl/smarty3/new_channel.tpl
index c76eaf04e..a7aa44991 100644
--- a/view/tpl/smarty3/new_channel.tpl
+++ b/view/tpl/smarty3/new_channel.tpl
@@ -24,8 +24,8 @@
<div id="newchannel-nick-desc" class="descriptive-paragraph">{{$nick_desc}}</div>
- <input type="checkbox" name="import" id="newchannel-import" value="1" />
- <label for="newchannel-import" id="label-newchannel-import">{{$label_import}}</label>
+ <div id="newchannel-import-link" class="descriptive-paragraph" >{{$label_import}}</div>
+
<div id="newchannel-import-end" class="newchannel-field-end"></div>
<input type="submit" name="submit" id="newchannel-submit-button" value="{{$submit}}" />