diff options
author | Robin Appelman <robin@icewind.nl> | 2020-08-05 15:57:51 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-08-05 16:13:03 +0200 |
commit | 227e362842a2340591608d6cb209e46a817f3403 (patch) | |
tree | d9a3a22b6f5298b1e433b7f79f603daff7ab5aa2 /lib | |
parent | a4d511d82767f54af086b366a6c08bc927cb870c (diff) | |
download | nextcloud-server-227e362842a2340591608d6cb209e46a817f3403.tar.gz nextcloud-server-227e362842a2340591608d6cb209e46a817f3403.zip |
allow grouping of activity settings
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Activity/ActivitySettingsAdapter.php | 13 | ||||
-rw-r--r-- | lib/private/Activity/Manager.php | 17 | ||||
-rw-r--r-- | lib/private/Server.php | 4 | ||||
-rw-r--r-- | lib/public/Activity/ActivitySettings.php | 12 |
4 files changed, 39 insertions, 7 deletions
diff --git a/lib/private/Activity/ActivitySettingsAdapter.php b/lib/private/Activity/ActivitySettingsAdapter.php index c49231bee2c..ef629be72f7 100644 --- a/lib/private/Activity/ActivitySettingsAdapter.php +++ b/lib/private/Activity/ActivitySettingsAdapter.php @@ -25,6 +25,7 @@ namespace OC\Activity; use OCP\Activity\ActivitySettings; use OCP\Activity\ISetting; +use OCP\IL10N; /** * Adapt the old interface based settings into the new abstract @@ -32,9 +33,11 @@ use OCP\Activity\ISetting; */ class ActivitySettingsAdapter extends ActivitySettings { private $oldSettings; + private $l10n; - public function __construct(ISetting $oldSettings) { + public function __construct(ISetting $oldSettings, IL10N $l10n) { $this->oldSettings = $oldSettings; + $this->l10n = $l10n; } public function getIdentifier() { @@ -45,6 +48,14 @@ class ActivitySettingsAdapter extends ActivitySettings { return $this->oldSettings->getName(); } + public function getGroupIdentifier() { + return 'other'; + } + + public function getGroupName() { + return $this->l10n->t('Other activities'); + } + public function getPriority() { return $this->oldSettings->getPriority(); } diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 81fd91c778a..f5ea59491e5 100644 --- a/lib/private/Activity/Manager.php +++ b/lib/private/Activity/Manager.php @@ -36,6 +36,7 @@ use OCP\Activity\IManager; use OCP\Activity\IProvider; use OCP\Activity\ISetting; use OCP\IConfig; +use OCP\IL10N; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; @@ -66,14 +67,20 @@ class Manager implements IManager { /** @var string */ protected $currentUserId; - public function __construct(IRequest $request, - IUserSession $session, - IConfig $config, - IValidator $validator) { + protected $l10n; + + public function __construct( + IRequest $request, + IUserSession $session, + IConfig $config, + IValidator $validator, + IL10N $l10n + ) { $this->request = $request; $this->session = $session; $this->config = $config; $this->validator = $validator; + $this->l10n = $l10n; } /** @var \Closure[] */ @@ -273,7 +280,7 @@ class Manager implements IManager { if ($setting instanceof ISetting) { if (!$setting instanceof ActivitySettings) { - $setting = new ActivitySettingsAdapter($setting); + $setting = new ActivitySettingsAdapter($setting, $this->l10n); } } else { throw new \InvalidArgumentException('Invalid activity filter registered'); diff --git a/lib/private/Server.php b/lib/private/Server.php index 09bb7336785..e59befda727 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -694,11 +694,13 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { + $l10n = $this->get(IFactory::class)->get('activity'); return new \OC\Activity\Manager( $c->getRequest(), $c->getUserSession(), $c->getConfig(), - $c->query(IValidator::class) + $c->query(IValidator::class), + $l10n ); }); $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class); diff --git a/lib/public/Activity/ActivitySettings.php b/lib/public/Activity/ActivitySettings.php index 98b95061cd7..c7d1ca81fef 100644 --- a/lib/public/Activity/ActivitySettings.php +++ b/lib/public/Activity/ActivitySettings.php @@ -40,6 +40,18 @@ abstract class ActivitySettings implements ISetting { abstract public function getName(); /** + * @return string Lowercase a-z and underscore only group identifier + * @since 20.0.0 + */ + abstract public function getGroupIdentifier(); + + /** + * @return string A translated string for the settings group + * @since 20.0.0 + */ + abstract public function getGroupName(); + + /** * @return int whether the filter should be rather on the top or bottom of * the admin section. The filters are arranged in ascending order of the * priority values. It is required to return a value between 0 and 100. |