diff options
-rw-r--r-- | apps/admin_export/settings.php | 3 | ||||
-rw-r--r-- | apps/user_migrate/settings.php | 21 | ||||
-rw-r--r-- | lib/migrate.php | 34 |
3 files changed, 33 insertions, 25 deletions
diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php index 5ba6f716a2b..5584181fbb9 100644 --- a/apps/admin_export/settings.php +++ b/apps/admin_export/settings.php @@ -59,11 +59,9 @@ if (isset($_POST['admin_export'])) { $dbnamestring = "<database>\n\n <name>" . OC_Config::getValue( "dbname", "owncloud" ); $dbtableprefixstring = "<table>\n\n <name>" . OC_Config::getValue( "dbtableprefix", "_oc" ); - $createstring = "<database>\n\n <name>*dbname*</name>\n <create>true</create>"; $dbexport = str_replace( $dbnamestring, "<database>\n\n <name>*dbname*", $dbexport ); $dbexport = str_replace( $dbtableprefixstring, "<table>\n\n <name>*dbprefix*", $dbexport ); - $dbexport = str_replace( $createstring, "<database>\n\n <name>*dbname*</name>\n <create>false</create>", $dbexport ); // Write the new db export file file_put_contents( $dbfile, $dbexport ); @@ -134,7 +132,6 @@ if (isset($_POST['admin_export'])) { exit(); } - // TODO: Import db OC_DB::replaceDB( get_temp_dir() . '/' . $importname . '/dbexport.xml' ); } else { // fill template diff --git a/apps/user_migrate/settings.php b/apps/user_migrate/settings.php index 7e3510d97ef..7c00dace3c2 100644 --- a/apps/user_migrate/settings.php +++ b/apps/user_migrate/settings.php @@ -49,23 +49,22 @@ if (isset($_POST['user_migrate'])) { // adding owncloud system files OC_Log::write('user_migrate',"Adding app data to user export file",OC_Log::INFO); // Call to OC_Migrate for the xml file. - //$appdatafile = $tempdir . "/appdata.xml"; - //$fh = fopen($appdatafile, 'w'); + $appdatafile = $tempdir . "/appdata.xml"; + $appdata = OC_Migrate::export(OC_User::getUser()); - //fwrite($fh, $appdata); - //$zip->addFile($appdatafile, "appdata.xml"); - //fclose($fh); + file_put_contents($appdatafile, $appdata); + $zip->addFile($appdatafile, "appdata.xml"); + } $zip->close(); - //header("Content-Type: application/zip"); - //header("Content-Disposition: attachment; filename=" . basename($filename)); - //header("Content-Length: " . filesize($filename)); - //@ob_end_clean(); - echo htmlspecialchars($appdata); - //readfile($filename); + header("Content-Type: application/zip"); + header("Content-Disposition: attachment; filename=" . basename($filename)); + header("Content-Length: " . filesize($filename)); + readfile($filename); unlink($filename); + } else { // fill template $tmpl = new OC_Template('user_migrate', 'settings'); diff --git a/lib/migrate.php b/lib/migrate.php index a1b4c5019bc..c5def5b5830 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -41,16 +41,26 @@ class OC_Migrate{ * @return string xml of app data */ public static function export($uid){ + + $doc = new DOMDocument(); + $doc->formatOutput = true; + OC_Log::write('user_migrate','App data export started for user: '.$uid,OC_Log::INFO); - $xml = ''; + foreach(self::$providers as $provider){ + OC_Log::write('user_migrate','Getting app data for app:'.$provider->appid,OC_Log::INFO); - $xml .= '<app>'; - $xml .= self::appInfoXML($provider->appid); - $xml .= $provider->export($uid); - $xml .= '</app>'; + $app = $doc->createElement('app'); + $doc->appendChild($app); + // Append app info + $app = $doc->appendChild( self::appInfoXML( $provider->appid ) ); + + // Add the app data + $app->appendChild($provider->export($uid)); + } - return $xml; + + return $doc->saveXML(); } /** @@ -59,10 +69,12 @@ class OC_Migrate{ * @return string xml app info */ public static function appInfoXML($appid){ - $info = OC_App::getAppInfo($appid); - $xml = '<appinfo>'; - $xml .= 'INFO HERE'; - $xml .= '</appinfo>'; - return $xml; + $doc = new DOMDocument(); + $appinfo = $doc->createElement('appinfo'); + $appinfo = $doc->appendChild($appinfo); + $data = $doc->createTextNode($appid); + $appinfo->appendChild($data); + + return $appinfo; } } |