aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-05-01 20:29:07 -0700
committerzotlabs <mike@macgirvin.com>2018-05-01 20:29:07 -0700
commit7a55ead97db94284146612364b8ce1c59de8771f (patch)
treeae2226660ee56eafdc8d2d0a95884ed89b2dbb19
parentcd200ee7064159e4bc253fefe04ddf6ba25d4dde (diff)
downloadvolse-hubzilla-7a55ead97db94284146612364b8ce1c59de8771f.tar.gz
volse-hubzilla-7a55ead97db94284146612364b8ce1c59de8771f.tar.bz2
volse-hubzilla-7a55ead97db94284146612364b8ce1c59de8771f.zip
new feature (post 3.4): allow a different username to be used when importing.
-rw-r--r--Zotlabs/Module/Import.php18
-rw-r--r--include/import.php7
-rwxr-xr-xview/tpl/channel_import.tpl1
3 files changed, 24 insertions, 2 deletions
diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php
index c36e4723a..d031bf16b 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -6,6 +6,7 @@ require_once('include/zot.php');
require_once('include/channel.php');
require_once('include/import.php');
require_once('include/perm_upgrade.php');
+require_once('library/urlify/URLify.php');
/**
@@ -38,6 +39,7 @@ class Import extends \Zotlabs\Web\Controller {
$filename = basename($_FILES['filename']['name']);
$filesize = intval($_FILES['filename']['size']);
$filetype = $_FILES['filename']['type'];
+ $newname = trim(strtolower($_REQUEST['newname']));
// import channel from file
if($src) {
@@ -146,7 +148,20 @@ class Import extends \Zotlabs\Web\Controller {
}
}
- $channel = import_channel($data['channel'], $account_id, $seize);
+ if($newname) {
+ $x = false;
+
+ if(get_config('system','unicode_usernames')) {
+ $x = punify(mb_strtolower($newname));
+ }
+
+ if((! $x) || strlen($x) > 64) {
+ $x = strtolower(\URLify::transliterate($newname));
+ }
+ $newname = $x;
+ }
+
+ $channel = import_channel($data['channel'], $account_id, $seize, $newname);
}
else {
$moving = false;
@@ -542,6 +557,7 @@ class Import extends \Zotlabs\Web\Controller {
'$make_primary' => [ 'make_primary', t('Make this hub my primary location'), false, '', [ t('No'), t('Yes') ] ],
'$moving' => [ 'moving', t('Move this channel (disable all previous locations)'), false, '', [ t('No'), t('Yes') ] ],
+ '$newname' => [ 'newname', t('Use this channel nickname instead of the one provided'), '', t('Leave blank to keep your existing channel nickname. You will be randomly assigned a similar nickname if either name is already allocated on this site.')],
'$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'),
diff --git a/include/import.php b/include/import.php
index 0d3fb8c32..ae6a0ab6a 100644
--- a/include/import.php
+++ b/include/import.php
@@ -14,7 +14,7 @@ require_once('include/perm_upgrade.php');
* @param int $seize
* @return boolean|array
*/
-function import_channel($channel, $account_id, $seize) {
+function import_channel($channel, $account_id, $seize, $newname = '') {
if(! array_key_exists('channel_system',$channel)) {
$channel['channel_system'] = (($channel['channel_pageflags'] & 0x1000) ? 1 : 0);
@@ -30,6 +30,11 @@ function import_channel($channel, $account_id, $seize) {
$channel['channel_hash'] = make_xchan_hash($channel['channel_guid'],$channel['channel_guid_sig']);
+ if($newname) {
+ $channel['channel_address'] = $newname;
+ }
+
+
// Check for duplicate channels
$r = q("select * from channel where (channel_guid = '%s' or channel_hash = '%s' or channel_address = '%s' ) limit 1",
diff --git a/view/tpl/channel_import.tpl b/view/tpl/channel_import.tpl
index d702a2437..c7cbb1742 100755
--- a/view/tpl/channel_import.tpl
+++ b/view/tpl/channel_import.tpl
@@ -24,6 +24,7 @@
{{include file="field_checkbox.tpl" field=$make_primary}}
{{include file="field_checkbox.tpl" field=$moving}}
+ {{include file="field_input.tpl" field=$newname}}
<div id="import-common-desc" class="section-content-info-wrapper">{{$pleasewait}}</div>