LegacyFilter.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace OC\Activity;
  22. use OCP\Activity\IFilter;
  23. use OCP\Activity\IManager;
  24. class LegacyFilter implements IFilter {
  25. /** @var IManager */
  26. protected $manager;
  27. /** @var string */
  28. protected $identifier;
  29. /** @var string */
  30. protected $name;
  31. /** @var bool */
  32. protected $isTopFilter;
  33. /**
  34. * LegacySetting constructor.
  35. *
  36. * @param IManager $manager
  37. * @param string $identifier
  38. * @param string $name
  39. * @param bool $isTopFilter
  40. */
  41. public function __construct(IManager $manager,
  42. $identifier,
  43. $name,
  44. $isTopFilter) {
  45. $this->manager = $manager;
  46. $this->identifier = $identifier;
  47. $this->name = $name;
  48. $this->isTopFilter = $isTopFilter;
  49. }
  50. /**
  51. * @return string Lowercase a-z and underscore only identifier
  52. * @since 11.0.0
  53. */
  54. public function getIdentifier() {
  55. return $this->identifier;
  56. }
  57. /**
  58. * @return string A translated string
  59. * @since 11.0.0
  60. */
  61. public function getName() {
  62. return $this->name;
  63. }
  64. /**
  65. * @return int whether the filter should be rather on the top or bottom of
  66. * the admin section. The filters are arranged in ascending order of the
  67. * priority values. It is required to return a value between 0 and 100.
  68. * @since 11.0.0
  69. */
  70. public function getPriority() {
  71. return $this->isTopFilter ? 40 : 50;
  72. }
  73. /**
  74. * @return string Full URL to an icon, empty string when none is given
  75. * @since 11.0.0
  76. */
  77. public function getIcon() {
  78. // Old API was CSS class, so we can not use this...
  79. return '';
  80. }
  81. /**
  82. * @param string[] $types
  83. * @return string[] An array of allowed apps from which activities should be displayed
  84. * @since 11.0.0
  85. */
  86. public function filterTypes(array $types) {
  87. return $this->manager->filterNotificationTypes($types, $this->getIdentifier());
  88. }
  89. /**
  90. * @return string[] An array of allowed apps from which activities should be displayed
  91. * @since 11.0.0
  92. */
  93. public function allowedApps() {
  94. return [];
  95. }
  96. }