mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Replace db on import. Update user_migration export function.
This commit is contained in:
parent
6906988b4e
commit
188a304625
3 changed files with 33 additions and 25 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue