aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Activity/ActivitySettingsAdapter.php59
-rw-r--r--lib/private/Activity/Event.php11
-rw-r--r--lib/private/Activity/Manager.php11
-rw-r--r--lib/private/AppFramework/App.php14
4 files changed, 92 insertions, 3 deletions
diff --git a/lib/private/Activity/ActivitySettingsAdapter.php b/lib/private/Activity/ActivitySettingsAdapter.php
new file mode 100644
index 00000000000..c49231bee2c
--- /dev/null
+++ b/lib/private/Activity/ActivitySettingsAdapter.php
@@ -0,0 +1,59 @@
+<?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 OC\Activity;
+
+use OCP\Activity\ActivitySettings;
+use OCP\Activity\ISetting;
+
+/**
+ * Adapt the old interface based settings into the new abstract
+ * class based one
+ */
+class ActivitySettingsAdapter extends ActivitySettings {
+ private $oldSettings;
+
+ public function __construct(ISetting $oldSettings) {
+ $this->oldSettings = $oldSettings;
+ }
+
+ public function getIdentifier() {
+ return $this->oldSettings->getIdentifier();
+ }
+
+ public function getName() {
+ return $this->oldSettings->getName();
+ }
+
+ public function getPriority() {
+ return $this->oldSettings->getPriority();
+ }
+
+ public function canChangeMail() {
+ return $this->oldSettings->canChangeMail();
+ }
+
+ public function isDefaultEnabledMail() {
+ return $this->oldSettings->isDefaultEnabledMail();
+ }
+}
diff --git a/lib/private/Activity/Event.php b/lib/private/Activity/Event.php
index 4958cdfd46e..5f82b37c91a 100644
--- a/lib/private/Activity/Event.php
+++ b/lib/private/Activity/Event.php
@@ -74,6 +74,8 @@ class Event implements IEvent {
protected $link = '';
/** @var string */
protected $icon = '';
+ /** @var bool */
+ protected $generateNotification = true;
/** @var IEvent|null */
protected $child;
@@ -532,4 +534,13 @@ class Event implements IEvent {
*/
;
}
+
+ public function setGenerateNotification(bool $generate): IEvent {
+ $this->generateNotification = $generate;
+ return $this;
+ }
+
+ public function getGenerateNotification(): bool {
+ return $this->generateNotification;
+ }
}
diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php
index ffe6c335b27..cbe2d8c3eee 100644
--- a/lib/private/Activity/Manager.php
+++ b/lib/private/Activity/Manager.php
@@ -28,6 +28,7 @@
namespace OC\Activity;
+use OCP\Activity\ActivitySettings;
use OCP\Activity\IConsumer;
use OCP\Activity\IEvent;
use OCP\Activity\IFilter;
@@ -262,7 +263,7 @@ class Manager implements IManager {
}
/**
- * @return ISetting[]
+ * @return ActivitySettings[]
* @throws \InvalidArgumentException
*/
public function getSettings(): array {
@@ -271,6 +272,10 @@ class Manager implements IManager {
$setting = \OC::$server->query($class);
if (!$setting instanceof ISetting) {
+ if (!$setting instanceof ActivitySettings) {
+ $setting = new ActivitySettingsAdapter($setting);
+ }
+ } else {
throw new \InvalidArgumentException('Invalid activity filter registered');
}
@@ -283,11 +288,11 @@ class Manager implements IManager {
/**
* @param string $id
- * @return ISetting
+ * @return ActivitySettings
* @throws \InvalidArgumentException when the setting was not found
* @since 11.0.0
*/
- public function getSettingById(string $id): ISetting {
+ public function getSettingById(string $id): ActivitySettings {
$settings = $this->getSettings();
if (isset($settings[$id])) {
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php
index ea97ea4096d..75876055d80 100644
--- a/lib/private/AppFramework/App.php
+++ b/lib/private/AppFramework/App.php
@@ -87,6 +87,20 @@ class App {
return $topNamespace . self::$nameSpaceCache[$appId];
}
+ public static function getAppIdForClass(string $className, string $topNamespace='OCA\\'): ?string {
+ if (strpos($className, $topNamespace) !== 0) {
+ return null;
+ }
+
+ foreach (self::$nameSpaceCache as $appId => $namespace) {
+ if (strpos($className, $topNamespace . $namespace . '\\') === 0) {
+ return $appId;
+ }
+ }
+
+ return null;
+ }
+
/**
* Shortcut for calling a controller method and printing the result