'OCA\\Files\\Activity\\Helper' => $baseDir . '/../lib/Activity/Helper.php',
'OCA\\Files\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
'OCA\\Files\\Activity\\Settings\\FavoriteAction' => $baseDir . '/../lib/Activity/Settings/FavoriteAction.php',
+ 'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => $baseDir . '/../lib/Activity/Settings/FileActivitySettings.php',
'OCA\\Files\\Activity\\Settings\\FileChanged' => $baseDir . '/../lib/Activity/Settings/FileChanged.php',
'OCA\\Files\\Activity\\Settings\\FileCreated' => $baseDir . '/../lib/Activity/Settings/FileCreated.php',
'OCA\\Files\\Activity\\Settings\\FileDeleted' => $baseDir . '/../lib/Activity/Settings/FileDeleted.php',
'OCA\\Files\\Activity\\Helper' => __DIR__ . '/..' . '/../lib/Activity/Helper.php',
'OCA\\Files\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
'OCA\\Files\\Activity\\Settings\\FavoriteAction' => __DIR__ . '/..' . '/../lib/Activity/Settings/FavoriteAction.php',
+ 'OCA\\Files\\Activity\\Settings\\FileActivitySettings' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileActivitySettings.php',
'OCA\\Files\\Activity\\Settings\\FileChanged' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileChanged.php',
'OCA\\Files\\Activity\\Settings\\FileCreated' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileCreated.php',
'OCA\\Files\\Activity\\Settings\\FileDeleted' => __DIR__ . '/..' . '/../lib/Activity/Settings/FileDeleted.php',
namespace OCA\Files\Activity\Settings;
-use OCP\Activity\ISetting;
-use OCP\IL10N;
-
-class FavoriteAction implements ISetting {
-
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
- public function __construct(IL10N $l) {
- $this->l = $l;
- }
-
+class FavoriteAction extends FileActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
--- /dev/null
+<?php
+
+declare(strict_types=1);
+
+/**
+ * @copyright Copyright (c) 2020 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files\Activity\Settings;
+
+use OCP\Activity\ActivitySettings;
+use OCP\IL10N;
+
+abstract class FileActivitySettings extends ActivitySettings {
+ /** @var IL10N */
+ protected $l;
+
+ /**
+ * @param IL10N $l
+ */
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ public function getGroupIdentifier() {
+ return 'files';
+ }
+
+ public function getGroupName() {
+ return $this->l->t('Files');
+ }
+}
namespace OCA\Files\Activity\Settings;
-use OCP\Activity\ISetting;
-use OCP\IL10N;
-
-class FileChanged implements ISetting {
-
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
- public function __construct(IL10N $l) {
- $this->l = $l;
- }
-
+class FileChanged extends FileActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
namespace OCA\Files\Activity\Settings;
-use OCP\Activity\ISetting;
-use OCP\IL10N;
-
-class FileCreated implements ISetting {
-
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
- public function __construct(IL10N $l) {
- $this->l = $l;
- }
-
+class FileCreated extends FileActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
namespace OCA\Files\Activity\Settings;
-use OCP\Activity\ISetting;
-use OCP\IL10N;
-
-class FileDeleted implements ISetting {
-
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
- public function __construct(IL10N $l) {
- $this->l = $l;
- }
-
+class FileDeleted extends FileActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
namespace OCA\Files\Activity\Settings;
-use OCP\Activity\ISetting;
-use OCP\IL10N;
-
-class FileFavorite implements ISetting {
-
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
- public function __construct(IL10N $l) {
- $this->l = $l;
- }
-
+class FileFavorite extends FileActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
namespace OCA\Files\Activity\Settings;
-use OCP\Activity\ISetting;
-use OCP\IL10N;
-
-class FileRestored implements ISetting {
-
- /** @var IL10N */
- protected $l;
-
- /**
- * @param IL10N $l
- */
- public function __construct(IL10N $l) {
- $this->l = $l;
- }
-
+class FileRestored extends FileActivitySettings {
/**
* @return string Lowercase a-z and underscore only identifier
* @since 11.0.0
use OCP\Activity\ActivitySettings;
use OCP\Activity\ISetting;
+use OCP\IL10N;
/**
* Adapt the old interface based settings into the new abstract
*/
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() {
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();
}
use OCP\Activity\IProvider;
use OCP\Activity\ISetting;
use OCP\IConfig;
+use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
/** @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[] */
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');
});
$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);
*/
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
$this->request,
$this->session,
$this->config,
- $this->validator
+ $this->validator,
+ $this->createMock(IL10N::class)
);
$this->assertSame([], self::invokePrivate($this->activityManager, 'getConsumers'));