You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @author Björn Schießle <bjoern@schiessle.org>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Thomas Müller <thomas.mueller@tmit.eu>
  6. *
  7. * @copyright Copyright (c) 2016, ownCloud, Inc.
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. use OCA\DAV\AppInfo\Application;
  24. use Symfony\Component\EventDispatcher\GenericEvent;
  25. $app = new Application();
  26. $app->registerHooks();
  27. \OC::$server->registerService('CardDAVSyncService', function() use ($app) {
  28. return $app->getSyncService();
  29. });
  30. $eventDispatcher = \OC::$server->getEventDispatcher();
  31. $eventDispatcher->addListener('OCP\Federation\TrustedServerEvent::remove',
  32. function(GenericEvent $event) use ($app) {
  33. /** @var \OCA\DAV\CardDAV\CardDavBackend $cardDavBackend */
  34. $cardDavBackend = $app->getContainer()->query('CardDavBackend');
  35. $addressBookUri = $event->getSubject();
  36. $addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri);
  37. if (!is_null($addressBook)) {
  38. $cardDavBackend->deleteAddressBook($addressBook['id']);
  39. }
  40. }
  41. );
  42. $cm = \OC::$server->getContactsManager();
  43. $cm->register(function() use ($cm, $app) {
  44. $user = \OC::$server->getUserSession()->getUser();
  45. if (!is_null($user)) {
  46. $app->setupContactsProvider($cm, $user->getUID());
  47. }
  48. });