aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-08-11 11:24:23 +0200
committerGitHub <noreply@github.com>2020-08-11 11:24:23 +0200
commit8fc877ff7dbe7e51a6da93f076f27216b57bc8cb (patch)
treed34dc9fea0323ea810d4c76a07eff87c9e5a8038 /lib
parent5d3ecfdffdf97e7b7e67263dd582618c3e24e874 (diff)
parent227e362842a2340591608d6cb209e46a817f3403 (diff)
downloadnextcloud-server-8fc877ff7dbe7e51a6da93f076f27216b57bc8cb.tar.gz
nextcloud-server-8fc877ff7dbe7e51a6da93f076f27216b57bc8cb.zip
Merge pull request #22117 from nextcloud/activity-settings-grouping
allow grouping of activity settings
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Activity/ActivitySettingsAdapter.php13
-rw-r--r--lib/private/Activity/Manager.php17
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/public/Activity/ActivitySettings.php12
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 8d771bec3a1..04ef2c6f502 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -695,11 +695,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.