app.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. if(\OC::$server->getConfig()->getSystemValue('updatechecker', true) === true) {
  25. $updater = new \OC\Updater\VersionCheck(
  26. \OC::$server->getHTTPClientService(),
  27. \OC::$server->getConfig()
  28. );
  29. $updateChecker = new \OCA\UpdateNotification\UpdateChecker(
  30. $updater
  31. );
  32. $userObject = \OC::$server->getUserSession()->getUser();
  33. if($userObject !== null) {
  34. if(\OC::$server->getGroupManager()->isAdmin($userObject->getUID())) {
  35. if($updateChecker->getUpdateState() !== []) {
  36. \OCP\Util::addScript('updatenotification', 'notification');
  37. OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'getJavaScript');
  38. }
  39. }
  40. }
  41. $manager = \OC::$server->getNotificationManager();
  42. $manager->registerNotifier(function() use ($manager) {
  43. return new \OCA\UpdateNotification\Notification\Notifier(
  44. $manager,
  45. \OC::$server->getL10NFactory()
  46. );
  47. }, function() {
  48. $l = \OC::$server->getL10N('updatenotification');
  49. return [
  50. 'id' => 'updatenotification',
  51. 'name' => $l->t('Update notifications'),
  52. ];
  53. });
  54. }