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.

54 lines
1.8 KiB

10 years ago
  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 \OC::$server->query(\OCA\UpdateNotification\Notification\Notifier::class);
  44. }, function() {
  45. $l = \OC::$server->getL10N('updatenotification');
  46. return [
  47. 'id' => 'updatenotification',
  48. 'name' => $l->t('Update notifications'),
  49. ];
  50. });
  51. }