app.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Vincent Petry <pvince81@owncloud.com>
  7. *
  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. $eventDispatcher = \OC::$server->getEventDispatcher();
  24. $eventDispatcher->addListener(
  25. 'OCA\Files::loadAdditionalScripts',
  26. function() {
  27. \OCP\Util::addScript('oc-backbone-webdav');
  28. \OCP\Util::addScript('comments', 'app');
  29. \OCP\Util::addScript('comments', 'commentmodel');
  30. \OCP\Util::addScript('comments', 'commentcollection');
  31. \OCP\Util::addScript('comments', 'commentsummarymodel');
  32. \OCP\Util::addScript('comments', 'commentstabview');
  33. \OCP\Util::addScript('comments', 'filesplugin');
  34. \OCP\Util::addScript('comments', 'activitytabviewplugin');
  35. \OCP\Util::addStyle('comments', 'comments');
  36. }
  37. );
  38. $activityManager = \OC::$server->getActivityManager();
  39. $activityManager->registerExtension(function() {
  40. $application = new \OCP\AppFramework\App('comments');
  41. /** @var \OCA\Comments\Activity\Extension $extension */
  42. $extension = $application->getContainer()->query(\OCA\Comments\Activity\Extension::class);
  43. return $extension;
  44. });
  45. $eventDispatcher->addListener(\OCP\Comments\CommentsEntityEvent::EVENT_ENTITY, function(\OCP\Comments\CommentsEntityEvent $event) {
  46. $event->addEntityCollection('files', function($name) {
  47. $nodes = \OC::$server->getUserFolder()->getById(intval($name));
  48. return !empty($nodes);
  49. });
  50. });
  51. $notificationManager = \OC::$server->getNotificationManager();
  52. $notificationManager->registerNotifier(
  53. function() {
  54. $application = new \OCP\AppFramework\App('comments');
  55. return $application->getContainer()->query(\OCA\Comments\Notification\Notifier::class);
  56. },
  57. function () {
  58. $l = \OC::$server->getL10N('comments');
  59. return ['id' => 'comments', 'name' => $l->t('Comments')];
  60. }
  61. );
  62. $commentsManager = \OC::$server->getCommentsManager();
  63. $commentsManager->registerEventHandler(function () {
  64. $application = new \OCP\AppFramework\App('comments');
  65. /** @var \OCA\Comments\Activity\Extension $extension */
  66. $handler = $application->getContainer()->query(\OCA\Comments\EventHandler::class);
  67. return $handler;
  68. });