Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev
This commit is contained in:
commit
e9a27393b8
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zotlabs\Module;
|
namespace Zotlabs\Module;
|
||||||
|
|
||||||
// Import a channel, either by direct file upload or via
|
// Import a channel, either by direct file upload or via
|
||||||
@ -21,32 +22,17 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$max_identities = account_service_class_fetch($account_id,'total_identities');
|
|
||||||
$max_friends = account_service_class_fetch($account_id,'total_channels');
|
$max_friends = account_service_class_fetch($account_id,'total_channels');
|
||||||
$max_feeds = account_service_class_fetch($account_id,'total_feeds');
|
$max_feeds = account_service_class_fetch($account_id,'total_feeds');
|
||||||
|
|
||||||
if($max_identities !== false) {
|
|
||||||
$r = q("select channel_id from channel where channel_account_id = %d",
|
|
||||||
intval($account_id)
|
|
||||||
);
|
|
||||||
if($r && count($r) > $max_identities) {
|
|
||||||
notice( sprintf( t('Your service plan only allows %d channels.'), $max_identities) . EOL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$data = null;
|
$data = null;
|
||||||
$seize = ((x($_REQUEST,'make_primary')) ? intval($_REQUEST['make_primary']) : 0);
|
$seize = ((x($_REQUEST,'make_primary')) ? intval($_REQUEST['make_primary']) : 0);
|
||||||
$import_posts = ((x($_REQUEST,'import_posts')) ? intval($_REQUEST['import_posts']) : 0);
|
$import_posts = ((x($_REQUEST,'import_posts')) ? intval($_REQUEST['import_posts']) : 0);
|
||||||
|
$moving = intval($_REQUEST['moving']);
|
||||||
$src = $_FILES['filename']['tmp_name'];
|
$src = $_FILES['filename']['tmp_name'];
|
||||||
$filename = basename($_FILES['filename']['name']);
|
$filename = basename($_FILES['filename']['name']);
|
||||||
$filesize = intval($_FILES['filename']['size']);
|
$filesize = intval($_FILES['filename']['size']);
|
||||||
$filetype = $_FILES['filename']['type'];
|
$filetype = $_FILES['filename']['type'];
|
||||||
|
|
||||||
$completed = ((array_key_exists('import_step',$_SESSION)) ? intval($_SESSION['import_step']) : 0);
|
|
||||||
if($completed)
|
|
||||||
logger('saved import step: ' . $_SESSION['import_step']);
|
|
||||||
|
|
||||||
if($src) {
|
if($src) {
|
||||||
|
|
||||||
@ -118,8 +104,6 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$moving = intval($_REQUEST['moving']);
|
|
||||||
|
|
||||||
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
|
if(array_key_exists('compatibility',$data) && array_key_exists('database',$data['compatibility'])) {
|
||||||
$v1 = substr($data['compatibility']['database'],-4);
|
$v1 = substr($data['compatibility']['database'],-4);
|
||||||
$v2 = substr(DB_UPDATE_VERSION,-4);
|
$v2 = substr(DB_UPDATE_VERSION,-4);
|
||||||
@ -140,27 +124,25 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
if(array_key_exists('channel',$data)) {
|
if(array_key_exists('channel',$data)) {
|
||||||
|
|
||||||
if($completed < 1) {
|
$max_identities = account_service_class_fetch($account_id,'total_identities');
|
||||||
$channel = import_channel($data['channel'], $account_id, $seize);
|
|
||||||
|
|
||||||
}
|
if($max_identities !== false) {
|
||||||
else {
|
$r = q("select channel_id from channel where channel_account_id = %d",
|
||||||
$r = q("select * from channel where channel_account_id = %d and channel_guid = '%s' limit 1",
|
intval($account_id)
|
||||||
intval($account_id),
|
|
||||||
dbesc($channel['channel_guid'])
|
|
||||||
);
|
);
|
||||||
if($r)
|
if($r && count($r) > $max_identities) {
|
||||||
$channel = $r[0];
|
notice( sprintf( t('Your service plan only allows %d channels.'), $max_identities) . EOL);
|
||||||
}
|
|
||||||
if(! $channel) {
|
|
||||||
logger('mod_import: channel not found. ', print_r($channel,true));
|
|
||||||
notice( t('Cloned channel not found. Import failed.') . EOL);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $channel)
|
$channel = import_channel($data['channel'], $account_id, $seize);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$moving = false;
|
||||||
$channel = \App::get_channel();
|
$channel = \App::get_channel();
|
||||||
|
}
|
||||||
|
|
||||||
if(! $channel) {
|
if(! $channel) {
|
||||||
logger('mod_import: channel not found. ', print_r($channel,true));
|
logger('mod_import: channel not found. ', print_r($channel,true));
|
||||||
@ -169,17 +151,15 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($completed < 2) {
|
|
||||||
if(is_array($data['config'])) {
|
if(is_array($data['config'])) {
|
||||||
import_config($channel,$data['config']);
|
import_config($channel,$data['config']);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('import step 2');
|
logger('import step 2');
|
||||||
$_SESSION['import_step'] = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($completed < 3) {
|
|
||||||
|
|
||||||
if(array_key_exists('channel',$data)) {
|
if(array_key_exists('channel',$data)) {
|
||||||
if($data['photo']) {
|
if($data['photo']) {
|
||||||
@ -190,22 +170,15 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
if(is_array($data['profile']))
|
if(is_array($data['profile']))
|
||||||
import_profiles($channel,$data['profile']);
|
import_profiles($channel,$data['profile']);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('import step 3');
|
logger('import step 3');
|
||||||
$_SESSION['import_step'] = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($completed < 4) {
|
|
||||||
|
|
||||||
if(is_array($data['hubloc'])) {
|
if(is_array($data['hubloc'])) {
|
||||||
import_hublocs($channel,$data['hubloc'],$seize,$moving);
|
import_hublocs($channel,$data['hubloc'],$seize,$moving);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('import step 4');
|
logger('import step 4');
|
||||||
$_SESSION['import_step'] = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($completed < 5) {
|
|
||||||
// create new hubloc for the new channel at this site
|
// create new hubloc for the new channel at this site
|
||||||
|
|
||||||
if(array_key_exists('channel',$data)) {
|
if(array_key_exists('channel',$data)) {
|
||||||
@ -237,11 +210,8 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger('import step 5');
|
logger('import step 5');
|
||||||
$_SESSION['import_step'] = 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($completed < 6) {
|
|
||||||
|
|
||||||
// import xchans and contact photos
|
// import xchans and contact photos
|
||||||
|
|
||||||
@ -274,11 +244,10 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
logger('import step 6');
|
|
||||||
$_SESSION['import_step'] = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($completed < 7) {
|
logger('import step 6');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$xchans = $data['xchan'];
|
$xchans = $data['xchan'];
|
||||||
if($xchans) {
|
if($xchans) {
|
||||||
@ -315,8 +284,7 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
else
|
else
|
||||||
$photodate = $xchan['xchan_photo_date'];
|
$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'
|
$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'",
|
||||||
where xchan_hash = '%s'",
|
|
||||||
dbesc($photos[0]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[1]),
|
dbesc($photos[1]),
|
||||||
dbesc($photos[2]),
|
dbesc($photos[2]),
|
||||||
@ -326,15 +294,11 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
logger('import step 7');
|
logger('import step 7');
|
||||||
$_SESSION['import_step'] = 7;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - ensure we have an xchan if somebody is trying to pull a fast one
|
|
||||||
|
|
||||||
if($completed < 8) {
|
|
||||||
$friends = 0;
|
$friends = 0;
|
||||||
$feeds = 0;
|
$feeds = 0;
|
||||||
|
|
||||||
@ -398,18 +362,11 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
|
set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('import step 8');
|
logger('import step 8');
|
||||||
$_SESSION['import_step'] = 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($completed < 9) {
|
|
||||||
$groups = $data['group'];
|
$groups = $data['group'];
|
||||||
if($groups) {
|
if($groups) {
|
||||||
$saved = array();
|
$saved = array();
|
||||||
@ -447,9 +404,8 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
create_table_from_array('group_member',$group_member);
|
create_table_from_array('group_member',$group_member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('import step 9');
|
logger('import step 9');
|
||||||
$_SESSION['import_step'] = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_array($data['obj']))
|
if(is_array($data['obj']))
|
||||||
import_objs($channel,$data['obj']);
|
import_objs($channel,$data['obj']);
|
||||||
@ -498,9 +454,6 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
if(array_key_exists('item_id',$data) && $data['item_id'])
|
if(array_key_exists('item_id',$data) && $data['item_id'])
|
||||||
import_item_ids($channel,$data['item_id']);
|
import_item_ids($channel,$data['item_id']);
|
||||||
|
|
||||||
|
|
||||||
// FIXME - ensure we have a self entry if somebody is trying to pull a fast one
|
|
||||||
|
|
||||||
// send out refresh requests
|
// send out refresh requests
|
||||||
// notify old server that it may no longer be primary.
|
// notify old server that it may no longer be primary.
|
||||||
|
|
||||||
@ -515,7 +468,6 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
change_channel($channel['channel_id']);
|
change_channel($channel['channel_id']);
|
||||||
|
|
||||||
unset($_SESSION['import_step']);
|
|
||||||
goaway(z_root() . '/network' );
|
goaway(z_root() . '/network' );
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -547,10 +499,8 @@ class Import extends \Zotlabs\Web\Controller {
|
|||||||
'$label_old_pass' => t('Your old login password'),
|
'$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.'),
|
'$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'),
|
'$label_import_primary' => t('Make this hub my primary location'),
|
||||||
'$allow_move' => 0,
|
|
||||||
'$label_import_moving' => t('Move this channel (disable all previous locations)'),
|
'$label_import_moving' => t('Move this channel (disable all previous locations)'),
|
||||||
|
'$label_import_posts' => t('Import a few months of posts if possible (limited by available memory'),
|
||||||
'$label_import_posts' => t('Import existing posts if possible (experimental - limited by available memory'),
|
|
||||||
'$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'),
|
'$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'),
|
||||||
'$email' => '',
|
'$email' => '',
|
||||||
'$pass' => '',
|
'$pass' => '',
|
||||||
|
@ -26,18 +26,15 @@
|
|||||||
<label for="import-posts" id="label-import-posts">{{$label_import_posts}}</label>
|
<label for="import-posts" id="label-import-posts">{{$label_import_posts}}</label>
|
||||||
<div id="import-posts-end" class="import-field-end"></div>
|
<div id="import-posts-end" class="import-field-end"></div>
|
||||||
|
|
||||||
|
|
||||||
<div id="import-common-desc" class="descriptive-paragraph">{{$common}}</div>
|
<div id="import-common-desc" class="descriptive-paragraph">{{$common}}</div>
|
||||||
|
|
||||||
<input type="checkbox" name="make_primary" id="import-make-primary" value="1" />
|
<input type="checkbox" name="make_primary" id="import-make-primary" value="1" />
|
||||||
<label for="import-make-primary" id="label-import-make-primary">{{$label_import_primary}}</label>
|
<label for="import-make-primary" id="label-import-make-primary">{{$label_import_primary}}</label>
|
||||||
<div id="import-make-primary-end" class="import-field-end"></div>
|
<div id="import-make-primary-end" class="import-field-end"></div>
|
||||||
|
|
||||||
{{if $allow_move}}
|
|
||||||
<input type="checkbox" name="moving" id="import-moving" value="1" />
|
<input type="checkbox" name="moving" id="import-moving" value="1" />
|
||||||
<label for="import-moving" id="label-import-moving">{{$label_import_moving}}</label>
|
<label for="import-moving" id="label-import-moving">{{$label_import_moving}}</label>
|
||||||
<div id="import-moving-end" class="import-field-end"></div>
|
<div id="import-moving-end" class="import-field-end"></div>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
<input type="submit" name="submit" id="import-submit-button" value="{{$submit}}" />
|
<input type="submit" name="submit" id="import-submit-button" value="{{$submit}}" />
|
||||||
<div id="import-submit-end" class="import-field-end"></div>
|
<div id="import-submit-end" class="import-field-end"></div>
|
||||||
|
Reference in New Issue
Block a user