diff options
Diffstat (limited to 'apps/dav/appinfo/application.php')
-rw-r--r-- | apps/dav/appinfo/application.php | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/apps/dav/appinfo/application.php b/apps/dav/appinfo/application.php index 07905db7368..11ab384d75d 100644 --- a/apps/dav/appinfo/application.php +++ b/apps/dav/appinfo/application.php @@ -20,12 +20,16 @@ */ namespace OCA\Dav\AppInfo; +use OCA\DAV\CalDAV\CalDavBackend; +use OCA\DAV\CardDAV\CardDavBackend; use OCA\DAV\CardDAV\ContactsManager; use OCA\DAV\CardDAV\SyncJob; use OCA\DAV\CardDAV\SyncService; use OCA\DAV\HookManager; use OCA\Dav\Migration\AddressBookAdapter; +use OCA\Dav\Migration\CalendarAdapter; use OCA\Dav\Migration\MigrateAddressbooks; +use OCA\Dav\Migration\MigrateCalendars; use \OCP\AppFramework\App; use OCP\AppFramework\IAppContainer; use OCP\Contacts\IManager; @@ -73,7 +77,17 @@ class Application extends App { $c->getServer()->getUserManager(), $c->getServer()->getGroupManager() ); - return new \OCA\DAV\CardDAV\CardDavBackend($db, $principal, $logger); + return new CardDavBackend($db, $principal, $logger); + }); + + $container->registerService('CalDavBackend', function($c) { + /** @var IAppContainer $c */ + $db = $c->getServer()->getDatabaseConnection(); + $principal = new \OCA\DAV\Connector\Sabre\Principal( + $c->getServer()->getUserManager(), + $c->getServer()->getGroupManager() + ); + return new CalDavBackend($db, $principal); }); $container->registerService('MigrateAddressbooks', function($c) { @@ -84,6 +98,15 @@ class Application extends App { $c->query('CardDavBackend') ); }); + + $container->registerService('MigrateCalendars', function($c) { + /** @var IAppContainer $c */ + $db = $c->getServer()->getDatabaseConnection(); + return new MigrateCalendars( + new CalendarAdapter($db), + $c->query('CalDavBackend') + ); + }); } /** @@ -112,8 +135,8 @@ class Application extends App { } public function migrateAddressbooks() { - try { + /** @var MigrateAddressbooks $migration */ $migration = $this->getContainer()->query('MigrateAddressbooks'); $migration->setup(); $userManager = $this->getContainer()->getServer()->getUserManager(); @@ -127,4 +150,19 @@ class Application extends App { } } + public function migrateCalendars() { + try { + /** @var MigrateCalendars $migration */ + $migration = $this->getContainer()->query('MigrateCalendars'); + $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); + } + } } |