provide resumable imports if things go wrong
This commit is contained in:
parent
10406c6d15
commit
caaf7192ff
@ -35,7 +35,8 @@ function import_post(&$a) {
|
||||
$filename = basename($_FILES['filename']['name']);
|
||||
$filesize = intval($_FILES['filename']['size']);
|
||||
$filetype = $_FILES['filename']['type'];
|
||||
$resume = ((array_key_exists('resume',$_REQUEST)) ? intval($_REQUEST['resume']) : 0);
|
||||
|
||||
$completed = ((array_key_exists('import_step',$_SESSION)) ? intval($_SESSION['import_step']) : 0);
|
||||
|
||||
|
||||
if($src) {
|
||||
@ -115,8 +116,11 @@ function import_post(&$a) {
|
||||
|
||||
// import channel
|
||||
|
||||
if(array_key_exists('channel',$data)) {
|
||||
$channel = $data['channel'];
|
||||
|
||||
if($completed < 1) {
|
||||
|
||||
if(! array_key_exists('channel_system',$channel)) {
|
||||
$channel['channel_system'] = (($channel['channel_pageflags'] & 0x1000) ? 1 : 0);
|
||||
$channel['channel_removed'] = (($channel['channel_pageflags'] & 0x8000) ? 1 : 0);
|
||||
@ -192,6 +196,14 @@ function import_post(&$a) {
|
||||
|
||||
set_default_login_identity(get_account_id(),$channel['channel_id'],false);
|
||||
|
||||
$_SESSION['import_step'] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
$channel = $a->get_channel();
|
||||
|
||||
|
||||
if($completed < 2) {
|
||||
|
||||
$configs = $data['config'];
|
||||
if($configs) {
|
||||
@ -207,6 +219,12 @@ function import_post(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION['import_step'] = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($completed < 3) {
|
||||
|
||||
if($data['photo']) {
|
||||
require_once('include/photo/photo_driver.php');
|
||||
@ -235,8 +253,11 @@ function import_post(&$a) {
|
||||
. "')" );
|
||||
}
|
||||
}
|
||||
$_SESSION['import_step'] = 3;
|
||||
}
|
||||
|
||||
|
||||
if($completed < 4) {
|
||||
$hublocs = $data['hubloc'];
|
||||
if($hublocs) {
|
||||
foreach($hublocs as $hubloc) {
|
||||
@ -266,12 +287,13 @@ function import_post(&$a) {
|
||||
. "`) VALUES ('"
|
||||
. implode("', '", array_values($hubloc))
|
||||
. "')" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$_SESSION['import_step'] = 4;
|
||||
}
|
||||
|
||||
if($completed < 5) {
|
||||
// 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_network, hubloc_primary,
|
||||
@ -292,11 +314,18 @@ function import_post(&$a) {
|
||||
|
||||
// reset the original primary hubloc if it is being seized
|
||||
|
||||
if($seize)
|
||||
if($seize) {
|
||||
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
|
||||
dbesc($channel['channel_hash']),
|
||||
dbesc(z_root())
|
||||
);
|
||||
}
|
||||
|
||||
$_SESSION['import_step'] = 5;
|
||||
}
|
||||
|
||||
|
||||
if($completed < 6) {
|
||||
|
||||
// import xchans and contact photos
|
||||
|
||||
@ -327,6 +356,10 @@ function import_post(&$a) {
|
||||
0,0,0,0,0,0,0
|
||||
);
|
||||
}
|
||||
$_SESSION['import_step'] = 6;
|
||||
}
|
||||
|
||||
if($completed < 7) {
|
||||
|
||||
$xchans = $data['xchan'];
|
||||
if($xchans) {
|
||||
@ -375,10 +408,15 @@ function import_post(&$a) {
|
||||
|
||||
}
|
||||
}
|
||||
$_SESSION['import_step'] = 7;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FIXME - ensure we have an xchan if somebody is trying to pull a fast one
|
||||
|
||||
|
||||
if($completed < 8) {
|
||||
$friends = 0;
|
||||
$feeds = 0;
|
||||
|
||||
@ -426,9 +464,12 @@ function import_post(&$a) {
|
||||
$feeds ++;
|
||||
}
|
||||
}
|
||||
$_SESSION['import_step'] = 8;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($completed < 9) {
|
||||
$groups = $data['group'];
|
||||
if($groups) {
|
||||
$saved = array();
|
||||
@ -470,6 +511,8 @@ function import_post(&$a) {
|
||||
. "')" );
|
||||
}
|
||||
}
|
||||
$_SESSION['import_step'] = 9;
|
||||
}
|
||||
|
||||
$saved_notification_flags = notifications_off($channel['channel_id']);
|
||||
|
||||
@ -545,6 +588,7 @@ function import_post(&$a) {
|
||||
|
||||
change_channel($channel['channel_id']);
|
||||
|
||||
unset($_SESSION['import_step']);
|
||||
goaway(z_root() . '/network' );
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user