diff options
author | Tom Needham <needham.thomas@gmail.com> | 2012-04-07 21:55:16 +0000 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2012-04-07 21:55:16 +0000 |
commit | c0869887cf91bf17421a9163069584d29ec5ed49 (patch) | |
tree | 920725089a1216a093b7c2892bbd6323777a1dc9 /apps | |
parent | 9edf45a324c2f1d4532d02e5c8fa37ebfa0c9dab (diff) | |
download | nextcloud-server-c0869887cf91bf17421a9163069584d29ec5ed49.tar.gz nextcloud-server-c0869887cf91bf17421a9163069584d29ec5ed49.zip |
Return JSON for import and export methods of OC_Migrate
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmarks/appinfo/migrate.php | 1 | ||||
-rw-r--r-- | apps/user_migrate/admin.php | 6 | ||||
-rw-r--r-- | apps/user_migrate/ajax/export.php | 35 |
3 files changed, 21 insertions, 21 deletions
diff --git a/apps/bookmarks/appinfo/migrate.php b/apps/bookmarks/appinfo/migrate.php index 603a8b72d3c..c1251e816ec 100644 --- a/apps/bookmarks/appinfo/migrate.php +++ b/apps/bookmarks/appinfo/migrate.php @@ -3,7 +3,6 @@ class OC_Migration_Provider_Bookmarks extends OC_Migration_Provider{ // Create the xml for the user supplied function export( ){ - OC_Log::write('migration','starting export for bookmarks',OC_Log::INFO); $options = array( 'table'=>'bookmarks', 'matchcol'=>'user_id', diff --git a/apps/user_migrate/admin.php b/apps/user_migrate/admin.php index 510c54abe3d..0160753af22 100644 --- a/apps/user_migrate/admin.php +++ b/apps/user_migrate/admin.php @@ -42,15 +42,15 @@ if (isset($_POST['user_import'])) { $tmpl->assign('error',$error); return $tmpl->fetchPage(); } - - if( !$appsstatus = OC_Migrate::import( $to, 'user' ) ){ + $response = json_decode( OC_Migrate::import( $to, 'user' ) ); + if( !$response->success ){ $error = array('error'=>'There was an error while importing the user!','hint'=>'Please check the logs for a more detailed explaination'); $tmpl = new OC_Template('user_migrate', 'admin'); $tmpl->assign('error',$error); return $tmpl->fetchPage(); } else { // Check import status - foreach( $appsstatus as $app => $status ){ + foreach( $response->data as $app => $status ){ if( $status != 'true' ){ // It failed for some reason if( $status == 'notsupported' ){ diff --git a/apps/user_migrate/ajax/export.php b/apps/user_migrate/ajax/export.php index fac96577fa2..86745d6b162 100644 --- a/apps/user_migrate/ajax/export.php +++ b/apps/user_migrate/ajax/export.php @@ -28,28 +28,29 @@ OC_JSON::checkLoggedIn(); OC_Util::checkAppEnabled('user_migrate'); // Which operation if( $_GET['operation']=='create' ){ -$uid = !empty( $_POST['uid'] ) ? $_POST['uid'] : OC_User::getUser(); -if( $uid != OC_User::getUser() ){ - // Needs to be admin to export someone elses account - OC_JSON::error(); - die(); -} -// Create the export zip -if( !$path = OC_Migrate::export( $uid ) ){ - // Error - OC_JSON::error(); + $uid = !empty( $_POST['uid'] ) ? $_POST['uid'] : OC_User::getUser(); + if( $uid != OC_User::getUser() ){ + // Needs to be admin to export someone elses account + OC_JSON::error(); + die(); + } + // Create the export zip + $response = json_decode( OC_Migrate::export( $uid ) ); + if( !$response->success ){ + // Error + OC_JSON::error(); + die(); + } else { + // Save path in session + $_SESSION['ocuserexportpath'] = $response->data; + } + OC_JSON::success(); die(); -} else { - // Save path in session - $_SESSION['ocuserexportpath'] = $path; -} -OC_JSON::success(); -die(); } else if( $_GET['operation']=='download' ){ // Download the export $path = isset( $_SESSION['ocuserexportpath'] ) ? $_SESSION['ocuserexportpath'] : false; if( !$path ){ - die(); + OC_JSON::error(); } header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=" . basename($path)); |