diff options
author | Tom Needham <needham.thomas@gmail.com> | 2012-03-16 00:52:43 +0400 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2012-03-16 00:52:43 +0400 |
commit | 50233d075c47c86a5a26d4f946f8aa09f703cb15 (patch) | |
tree | e562c0e6ee1457aa3ea72a0564e401ee924094ba /apps/admin_export | |
parent | c9be325af2707b256f83cafbda3f7e3713f97876 (diff) |
Improve admin_export ui and move system export cde to OC_Migrate
Diffstat (limited to 'apps/admin_export')
-rw-r--r-- | apps/admin_export/settings.php | 78 | ||||
-rw-r--r-- | apps/admin_export/templates/settings.php | 11 |
2 files changed, 21 insertions, 68 deletions
diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php index 73a4209d3f8..9db1d75db96 100644 --- a/apps/admin_export/settings.php +++ b/apps/admin_export/settings.php @@ -28,70 +28,22 @@ OC_Util::checkAppEnabled('admin_export'); define('DS', '/'); - +// Export? if (isset($_POST['admin_export'])) { - $root = OC::$SERVERROOT . "/"; - $datadir = OC_Config::getValue( 'datadirectory' ); - $zip = new ZipArchive(); - $tempdir = get_temp_dir(); - $filename = $tempdir . "/owncloud_export_" . date("y-m-d_H-i-s") . ".zip"; - OC_Log::write('admin_export',"Creating export file at: " . $filename,OC_Log::INFO); - if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { - exit("Cannot open <$filename>\n"); - } - - if (isset($_POST['owncloud_system'])) { - // adding owncloud system files - OC_Log::write('admin_export',"Adding owncloud system files to export",OC_Log::INFO); - zipAddDir($root, $zip, false); - foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dirname) { - zipAddDir($root . $dirname, $zip, true, "/"); - } - } - - if (isset($_POST['owncloud_config'])) { - // adding owncloud config - // todo: add database export - $dbfile = $tempdir . "/dbexport.xml"; - OC_DB::getDbStructure( $dbfile, 'MDB2_SCHEMA_DUMP_ALL'); - - // Now add in *dbname* and *dbtableprefix* - $dbexport = file_get_contents( $dbfile ); - - $dbnamestring = "<database>\n\n <name>" . OC_Config::getValue( "dbname", "owncloud" ); - $dbtableprefixstring = "<table>\n\n <name>" . OC_Config::getValue( "dbtableprefix", "_oc" ); - - $dbexport = str_replace( $dbnamestring, "<database>\n\n <name>*dbname*", $dbexport ); - $dbexport = str_replace( $dbtableprefixstring, "<table>\n\n <name>*dbprefix*", $dbexport ); - - // Write the new db export file - file_put_contents( $dbfile, $dbexport ); - - $zip->addFile($dbfile, "dbexport.xml"); - - OC_Log::write('admin_export',"Adding owncloud config to export",OC_Log::INFO); - zipAddDir($root . "config/", $zip, true, "/"); - } - - if (isset($_POST['user_files'])) { - // needs to handle data outside of the default data dir. - // adding user files - $zip->addFile($root . '/data/.htaccess', "data/.htaccess"); - $zip->addFile($root . '/data/index.html', "data/index.html"); - foreach (OC_User::getUsers() as $i) { - OC_Log::write('admin_export',"Adding owncloud user files of $i to export",OC_Log::INFO); - zipAddDir($datadir . '/' . $i, $zip, true, "/data/"); - } - } - - $zip->close(); - header("Content-Type: application/zip"); - header("Content-Disposition: attachment; filename=" . basename($filename)); - header("Content-Length: " . filesize($filename)); - @ob_end_clean(); - readfile($filename); - unlink($filename); - unlink($dbfile); + // Create the export zip + if( !$path = OC_Migrate::createSysExportFile( $_POST['export_type'] ) ){ + // Error + die('error'); + } else { + // Download it + header("Content-Type: application/zip"); + header("Content-Disposition: attachment; filename=" . basename($path)); + header("Content-Length: " . filesize($path)); + @ob_end_clean(); + readfile($path); + OC_Migrate::cleanUp( $path ); + } +// Import? } else if( isset($_POST['admin_import']) ){ $root = OC::$SERVERROOT . "/"; diff --git a/apps/admin_export/templates/settings.php b/apps/admin_export/templates/settings.php index 9f0845bf55f..15a19b7c633 100644 --- a/apps/admin_export/templates/settings.php +++ b/apps/admin_export/templates/settings.php @@ -2,12 +2,13 @@ <fieldset class="personalblock"> <legend><strong><?php echo $l->t('Export this ownCloud instance');?></strong></legend> <p><?php echo $l->t('This will create a compressed file that contains the data of this owncloud instance. - Please choose which components should be included:');?> - </p> - <p><input type="checkbox" id="user_files" name="user_files" value="true"><label for="user_files"><?php echo $l->t('User files');?></label><br/> - <input type="checkbox" id="owncloud_system" name="owncloud_system" value="true"><label for="owncloud_system"><?php echo $l->t('ownCloud system files');?></label><br/> - <input type="checkbox" id="owncloud_config" name="owncloud_config" value="true"><label for="owncloud_config"><?php echo $l->t('ownCloud configuration');?></label> + Please choose the export type:');?> </p> + <h3>What would you like to export?</h3> + <p> + <input type="radio" name="export_type" value="instance" /> ownCloud instance ( suitable for import )<br /> + <input type="radio" name="export_type" value="system" /> ownCloud system files<br /> + <input type="radio" name="export_type" value="userfiles" /> Just user files <input type="submit" name="admin_export" value="<?php echo $l->t('Export'); ?>" /> </fieldset> </form> |