]> source.dussan.org Git - nextcloud-server.git/commitdiff
Show nice errors
authorTom Needham <needham.thomas@gmail.com>
Fri, 6 Apr 2012 20:52:41 +0000 (20:52 +0000)
committerTom Needham <needham.thomas@gmail.com>
Fri, 6 Apr 2012 20:52:41 +0000 (20:52 +0000)
apps/user_migrate/admin.php

index 61b83c2a1404c5c77cea0e3c54dbb75f0acb1dc6..280f7b719697e6495a69b2a43f43cea97d32c170 100644 (file)
@@ -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();      
                }
        }