diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-12-22 16:12:44 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-27 12:10:06 +0100 |
commit | 07a5c2658373f310c707a184e40201685cb04622 (patch) | |
tree | f25b23f495abf127319fd99213cc317a1e32f9ee /apps/dav/appinfo | |
parent | ea9331062353c45498c6b455690bb143c776830e (diff) | |
download | nextcloud-server-07a5c2658373f310c707a184e40201685cb04622.tar.gz nextcloud-server-07a5c2658373f310c707a184e40201685cb04622.zip |
Add app to migrate contacts and calendars
Add group sharing migration
Migrate all users
Diffstat (limited to 'apps/dav/appinfo')
-rw-r--r-- | apps/dav/appinfo/application.php | 26 | ||||
-rw-r--r-- | apps/dav/appinfo/install.php | 1 | ||||
-rw-r--r-- | apps/dav/appinfo/register_command.php | 8 |
3 files changed, 35 insertions, 0 deletions
diff --git a/apps/dav/appinfo/application.php b/apps/dav/appinfo/application.php index d8cf2a34115..b771bf2b3a2 100644 --- a/apps/dav/appinfo/application.php +++ b/apps/dav/appinfo/application.php @@ -24,9 +24,11 @@ use OCA\DAV\CardDAV\ContactsManager; use OCA\DAV\CardDAV\SyncJob; use OCA\DAV\CardDAV\SyncService; use OCA\DAV\HookManager; +use OCA\Dav\Migration\MigrateAddressbooks; use \OCP\AppFramework\App; use OCP\AppFramework\IAppContainer; use OCP\Contacts\IManager; +use OCP\IUser; class Application extends App { @@ -73,6 +75,14 @@ class Application extends App { return new \OCA\DAV\CardDAV\CardDavBackend($db, $principal, $logger); }); + $container->registerService('MigrateAddressbooks', function($c) { + /** @var IAppContainer $c */ + $db = $c->getServer()->getDatabaseConnection(); + return new MigrateAddressbooks( + $db, + $c->query('CardDavBackend') + ); + }); } /** @@ -100,4 +110,20 @@ class Application extends App { $jl->add(new SyncJob()); } + public function migrateAddressbooks() { + + try { + $migration = $this->getContainer()->query('MigrateAddressbooks'); + $migration->setup(); + $userManager = $this->getContainer()->getServer()->getUserManager(); + + $userManager->callForAllUsers(function($user) use($migration) { + /** @var IUser $user */ + $migration->migrateForUser($user->getUID()); + }); + } catch (\Exception $ex) { + $this->getContainer()->getServer()->getLogger()->logException($ex); + } + } + } diff --git a/apps/dav/appinfo/install.php b/apps/dav/appinfo/install.php index aaa36052cd2..f6ef533958e 100644 --- a/apps/dav/appinfo/install.php +++ b/apps/dav/appinfo/install.php @@ -23,3 +23,4 @@ use OCA\Dav\AppInfo\Application; $app = new Application(); $app->setupCron(); +$app->migrateAddressbooks(); diff --git a/apps/dav/appinfo/register_command.php b/apps/dav/appinfo/register_command.php index 8ef1979aa08..e8fea5daf23 100644 --- a/apps/dav/appinfo/register_command.php +++ b/apps/dav/appinfo/register_command.php @@ -22,6 +22,7 @@ use OCA\Dav\AppInfo\Application; use OCA\DAV\Command\CreateAddressBook; use OCA\DAV\Command\CreateCalendar; +use OCA\Dav\Command\MigrateAddressbooks; use OCA\DAV\Command\SyncSystemAddressBook; $config = \OC::$server->getConfig(); @@ -37,3 +38,10 @@ $app = new Application(); $application->add(new CreateAddressBook($userManager, $groupManager, $dbConnection, $logger)); $application->add(new CreateCalendar($userManager, $dbConnection)); $application->add(new SyncSystemAddressBook($app->getSyncService())); + +// the occ tool is *for now* only available in debug mode for developers to test +if ($config->getSystemValue('debug', false)){ + $app = new \OCA\Dav\AppInfo\Application(); + $migration = $app->getContainer()->query('MigrateAddressbooks'); + $application->add(new MigrateAddressbooks($userManager, $migration)); +} |