diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php
index a33c872ccf..cafd35570c 100644
--- a/apps/admin_export/settings.php
+++ b/apps/admin_export/settings.php
@@ -5,6 +5,8 @@
*
* @author Thomas Schmidt
* @copyright 2011 Thomas Schmidt tom@opensuse.org
+ * @author Tom Needham
+ * @copyright 2012 Tom Needham tom@owncloud.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
@@ -22,13 +24,15 @@
*/
OC_Util::checkAdminUser();
OC_Util::checkAppEnabled('admin_export');
+
+
if (isset($_POST['admin_export'])) {
$root = OC::$SERVERROOT . "/";
$zip = new ZipArchive();
$filename = get_temp_dir() . "/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");
+ exit("Cannot open <$filename>\n");
}
if (isset($_POST['owncloud_system'])) {
@@ -49,6 +53,7 @@ if (isset($_POST['admin_export'])) {
}
if (isset($_POST['user_files'])) {
+ // needs to handle data outside of the default data dir.
// adding user files
$zip->addFile($root . '/data/.htaccess', basename($root) . "/data/.htaccess");
$zip->addFile($root . '/data/index.html', basename($root) . "/data/index.html");
diff --git a/apps/bookmarks/lib/migrate.php b/apps/bookmarks/lib/migrate.php
new file mode 100644
index 0000000000..2e6581cd9f
--- /dev/null
+++ b/apps/bookmarks/lib/migrate.php
@@ -0,0 +1,18 @@
+appid = 'bookmarks';
+ // Create the xml for the user supplied
+ function export($uid){
+ $xml = '';
+ $query = OC_DB::prepare("SELECT * FROM *PREFIX*bookmarks WHERE *PREFIX*bookmakrs.user_id = ?");
+ $bookmarks = $query->execute($uid);
+ OC_Log::write('user_migrate',print_r($bookmarks));
+ foreach($bookmarks as $bookmark){
+ $xml .= '';
+ $xml .='DATA WILL BE HERE';
+ $xml .= '';
+ }
+ return $xml;
+ }
+}
diff --git a/apps/user_migrate/appinfo/app.php b/apps/user_migrate/appinfo/app.php
new file mode 100644
index 0000000000..4a795a5474
--- /dev/null
+++ b/apps/user_migrate/appinfo/app.php
@@ -0,0 +1,26 @@
+.
+*
+*/
+
+OC_APP::registerPersonal('user_migrate','settings');
+
+?>
\ No newline at end of file
diff --git a/apps/user_migrate/appinfo/info.xml b/apps/user_migrate/appinfo/info.xml
new file mode 100644
index 0000000000..6abcb4af92
--- /dev/null
+++ b/apps/user_migrate/appinfo/info.xml
@@ -0,0 +1,11 @@
+
+
+ user_migrate
+ User Account Migration
+ Migrate your user accounts
+ 0.1
+ AGPL
+ Tom Needham
+ 2
+
+
diff --git a/apps/user_migrate/settings.php b/apps/user_migrate/settings.php
new file mode 100644
index 0000000000..fbf190e37d
--- /dev/null
+++ b/apps/user_migrate/settings.php
@@ -0,0 +1,95 @@
+.
+ *
+ */
+OC_Util::checkAppEnabled('user_migrate');
+
+
+if (isset($_POST['user_migrate'])) {
+ // Looks like they want to migrate
+ $errors = array();
+ $root = OC::$SERVERROOT . "/";
+ $user = OC_User::getUser();
+ $zip = new ZipArchive();
+ $tempdir = get_temp_dir();
+ $filename = $tempdir . "/" . $user . "_export_" . date("y-m-d_H-i-s") . ".zip";
+ OC_Log::write('user_migrate',"Creating user export file at: " . $filename,OC_Log::INFO);
+ if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
+ exit("Cannot open <$filename>\n");
+ }
+
+ // Does the user want to include their files?
+ if (isset($_POST['user_files'])) {
+ // needs to handle data outside of the default data dir.
+ // adding user files
+ OC_Log::write('user_migrate',"Adding owncloud user files of $user to export",OC_Log::INFO);
+ zipAddDir($root . "data/" . $user, $zip, true, "files/");
+ }
+
+ // Does the user want their app data?
+ if (isset($_POST['user_appdata'])) {
+ // adding owncloud system files
+ OC_Log::write('user_migrate',"Adding app data to user export",OC_Log::INFO);
+ // Call to OC_Migrate for the xml file.
+ $appdatafile = $tempdir . "/appdata.xml";
+ $fh = fopen($appdatafile, 'w');
+ $appdata = OC_Migrate::export(OC_User::getUser());
+ fwrite($fh, $appdata);
+ $zip->addFile($appdatafile, "appdata.xml");
+ fclose($fh);
+ }
+
+ $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);
+} else {
+// fill template
+ $tmpl = new OC_Template('user_migrate', 'settings');
+ return $tmpl->fetchPage();
+}
+
+function zipAddDir($dir, $zip, $recursive=true, $internalDir='') {
+ $dirname = basename($dir);
+ $zip->addEmptyDir($internalDir . $dirname);
+ $internalDir.=$dirname.='/';
+
+ if ($dirhandle = opendir($dir)) {
+ while (false !== ( $file = readdir($dirhandle))) {
+
+ if (( $file != '.' ) && ( $file != '..' )) {
+
+ if (is_dir($dir . '/' . $file) && $recursive) {
+ zipAddDir($dir . '/' . $file, $zip, $recursive, $internalDir);
+ } elseif (is_file($dir . '/' . $file)) {
+ $zip->addFile($dir . '/' . $file, $internalDir . $file);
+ }
+ }
+ }
+ closedir($dirhandle);
+ } else {
+ OC_Log::write('admin_export',"Was not able to open directory: " . $dir,OC_Log::ERROR);
+ }
+}
diff --git a/apps/user_migrate/templates/settings.php b/apps/user_migrate/templates/settings.php
new file mode 100644
index 0000000000..ece8f70e06
--- /dev/null
+++ b/apps/user_migrate/templates/settings.php
@@ -0,0 +1,12 @@
+
diff --git a/lib/migrate.php b/lib/migrate.php
new file mode 100644
index 0000000000..8f13d07f46
--- /dev/null
+++ b/lib/migrate.php
@@ -0,0 +1,66 @@
+.
+ *
+ */
+
+
+/**
+ * provides an interface to all search providers
+ */
+class OC_Migrate{
+ static public $providers=array();
+
+ /**
+ * register a new migration provider
+ * @param OC_Migrate_Provider $provider
+ */
+ public static function registerProvider($provider){
+ self::$providers[]=$provider;
+ }
+
+ /**
+ * export app data for a user
+ * @param string userid
+ * @return string xml of app data
+ */
+ public static function export($uid){
+ $xml = '';
+ foreach(self::$providers as $provider){
+ $xml .= '';
+ $xml .= self::appInfoXML($provider->$appid);
+ $xml .= $provider->export($uid));
+ $xml .= '';
+ }
+ return $xml;
+ }
+
+ /**
+ * generates the app info xml
+ * @param string appid
+ * @return string xml app info
+ */
+ public static function appInfoXML($appid){
+ $info = OC_App::getAppInfo($appid);
+ $xml = '';
+ $zml .= 'INFO HERE';
+ $xml .= '';
+ return $xml;
+ }
+}
diff --git a/lib/migrate/provider.php b/lib/migrate/provider.php
new file mode 100644
index 0000000000..920fde7db3
--- /dev/null
+++ b/lib/migrate/provider.php
@@ -0,0 +1,23 @@
+