Show nice errors
This commit is contained in:
parent
eba6a65908
commit
2fe0716cb4
|
@ -36,12 +36,18 @@ if (isset($_POST['user_import'])) {
|
|||
$from = $_FILES['owncloud_import']['tmp_name'];
|
||||
$to = get_temp_dir().'/'.$importname.'.zip';
|
||||
if( !move_uploaded_file( $from, $to ) ){
|
||||
$errors[] = array('error'=>'Failed to move the uploaded file','hint'=>'Try checking the permissions of the '.get_temp_dir().' dir.');
|
||||
OC_Log::write( 'user_migrate', "Failed to copy the uploaded file", OC_Log::ERROR );
|
||||
exit();
|
||||
$t = new OC_Template( '', 'error', 'user' );
|
||||
$t->assign('errors',$errors);
|
||||
$t->fetchPage();
|
||||
}
|
||||
|
||||
if( !$appsstatus = OC_Migrate::import( $to, 'user' ) ){
|
||||
die( 'failed to to import' );
|
||||
$errors[] = array('error'=>'There was an error while importing the user!','hint'=>'Please check the logs for a more detailed explaination');
|
||||
$t = new OC_Template( '', 'error', 'user' );
|
||||
$t->assign('errors',$errors);
|
||||
$t->fetchPage();
|
||||
} else {
|
||||
// Check import status
|
||||
foreach( $appsstatus as $app => $status ){
|
||||
|
@ -57,10 +63,20 @@ if (isset($_POST['user_import'])) {
|
|||
// Any problems?
|
||||
if( isset( $notsupported ) || isset( $failed ) ){
|
||||
if( count( $failed ) > 0 ){
|
||||
die( 'Some apps failed to import. View the log please.' );
|
||||
$errors[] = array('error'=>'Some app data failed to import','hint'=>'App data for: '.implode(', ', $failed).' failed to import.');
|
||||
$t = new OC_Template( '', 'error', 'user' );
|
||||
$t->assign('errors',$errors);
|
||||
$t->fetchPage();
|
||||
} else if( count( $notsupported ) > 0 ){
|
||||
die( 'Some apps were not found in this owncloud instance and therefore could not be installed' );
|
||||
$errors[] = array('error'=>'Some app data could not be imported, as the apps are not installed on this instance','hint'=>'App data for: '.implode(', ', $notsupported).' failed to import as they were not found. Please install the apps and try again');
|
||||
$t = new OC_Template( '', 'error', 'user' );
|
||||
$t->assign('errors',$errors);
|
||||
$t->fetchPage();
|
||||
}
|
||||
} else {
|
||||
// Went swimmingly!
|
||||
$tmpl = new OC_Template('user_migrate', 'admin');
|
||||
return $tmpl->fetchPage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue