summaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Activity
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/lib/Activity')
-rw-r--r--apps/files/lib/Activity/Filter/Favorites.php160
-rw-r--r--apps/files/lib/Activity/Filter/FileChanges.php95
-rw-r--r--apps/files/lib/Activity/Helper.php85
-rw-r--r--apps/files/lib/Activity/Provider.php276
-rw-r--r--apps/files/lib/Activity/Settings/FileChanged.php98
-rw-r--r--apps/files/lib/Activity/Settings/FileCreated.php98
-rw-r--r--apps/files/lib/Activity/Settings/FileDeleted.php98
-rw-r--r--apps/files/lib/Activity/Settings/FileFavorite.php98
-rw-r--r--apps/files/lib/Activity/Settings/FileRestored.php98
9 files changed, 1106 insertions, 0 deletions
diff --git a/apps/files/lib/Activity/Filter/Favorites.php b/apps/files/lib/Activity/Filter/Favorites.php
new file mode 100644
index 00000000000..2639ae847fc
--- /dev/null
+++ b/apps/files/lib/Activity/Filter/Favorites.php
@@ -0,0 +1,160 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\Filter;
+
+
+use OCA\Files\Activity\Helper;
+use OCP\Activity\IFilter;
+use OCP\Activity\IManager;
+use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IDBConnection;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+
+class Favorites implements IFilter {
+
+ /** @var IL10N */
+ protected $l;
+
+ /** @var IURLGenerator */
+ protected $url;
+
+ /** @var IManager */
+ protected $activityManager;
+
+ /** @var Helper */
+ protected $helper;
+
+ /** @var IDBConnection */
+ protected $db;
+
+ /**
+ * @param IL10N $l
+ * @param IURLGenerator $url
+ * @param IManager $activityManager
+ * @param Helper $helper
+ * @param IDBConnection $db
+ */
+ public function __construct(IL10N $l, IURLGenerator $url, IManager $activityManager, Helper $helper, IDBConnection $db) {
+ $this->l = $l;
+ $this->url = $url;
+ $this->activityManager = $activityManager;
+ $this->helper = $helper;
+ $this->db = $db;
+ }
+
+ /**
+ * @return string Lowercase a-z only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'files_favorites';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('Favorites');
+ }
+
+ /**
+ * @return int
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 10;
+ }
+
+ /**
+ * @return string Full URL to an icon, empty string when none is given
+ * @since 11.0.0
+ */
+ public function getIcon() {
+ return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg'));
+ }
+
+ /**
+ * @param string[] $types
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function filterTypes(array $types) {
+ return array_intersect([
+ 'file_created',
+ 'file_changed',
+ 'file_deleted',
+ 'file_restored',
+ ], $types);
+ }
+
+ /**
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function allowedApps() {
+ return ['files'];
+ }
+
+ /**
+ * @param IQueryBuilder $query
+ */
+ public function filterFavorites(IQueryBuilder $query) {
+ try {
+ $user = $this->activityManager->getCurrentUserId();
+ } catch (\UnexpectedValueException $e) {
+ return;
+ }
+
+ try {
+ $favorites = $this->helper->getFavoriteFilePaths($user);
+ } catch (\RuntimeException $e) {
+ return;
+ }
+
+ $limitations = [];
+ if (!empty($favorites['items'])) {
+ $limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY));
+ }
+ foreach ($favorites['folders'] as $favorite) {
+ $limitations[] = $query->expr()->like('file', $query->createNamedParameter(
+ $this->db->escapeLikeParameter($favorite . '/') . '%'
+ ));
+ }
+
+ if (empty($limitations)) {
+ return;
+ }
+
+ $function = $query->createFunction('
+ CASE
+ WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1
+ WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . '
+ AND (' . implode(' OR ', $limitations) . ')
+ THEN 1
+ END = 1'
+ );
+
+ $query->andWhere($function);
+ }
+}
diff --git a/apps/files/lib/Activity/Filter/FileChanges.php b/apps/files/lib/Activity/Filter/FileChanges.php
new file mode 100644
index 00000000000..dc7daf96bac
--- /dev/null
+++ b/apps/files/lib/Activity/Filter/FileChanges.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\Filter;
+
+
+use OCP\Activity\IFilter;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+
+class FileChanges implements IFilter {
+
+ /** @var IL10N */
+ protected $l;
+
+ /** @var IURLGenerator */
+ protected $url;
+
+ public function __construct(IL10N $l, IURLGenerator $url) {
+ $this->l = $l;
+ $this->url = $url;
+ }
+
+ /**
+ * @return string Lowercase a-z only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'files';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('File changes');
+ }
+
+ /**
+ * @return int
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 30;
+ }
+
+ /**
+ * @return string Full URL to an icon, empty string when none is given
+ * @since 11.0.0
+ */
+ public function getIcon() {
+ return $this->url->getAbsoluteURL($this->url->imagePath('core', 'places/files-dark.svg'));
+ }
+
+ /**
+ * @param string[] $types
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function filterTypes(array $types) {
+ return array_intersect([
+ 'file_created',
+ 'file_changed',
+ 'file_deleted',
+ 'file_restored',
+ ], $types);
+ }
+
+ /**
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function allowedApps() {
+ return ['files'];
+ }
+}
diff --git a/apps/files/lib/Activity/Helper.php b/apps/files/lib/Activity/Helper.php
new file mode 100644
index 00000000000..d03d6e8e974
--- /dev/null
+++ b/apps/files/lib/Activity/Helper.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files\Activity;
+
+use OCP\Files\Folder;
+use OCP\ITagManager;
+
+class Helper {
+ /** If a user has a lot of favorites the query might get too slow and long */
+ const FAVORITE_LIMIT = 50;
+
+ /** @var ITagManager */
+ protected $tagManager;
+
+ /**
+ * @param ITagManager $tagManager
+ */
+ public function __construct(ITagManager $tagManager) {
+ $this->tagManager = $tagManager;
+ }
+
+ /**
+ * Returns an array with the favorites
+ *
+ * @param string $user
+ * @return array
+ * @throws \RuntimeException when too many or no favorites where found
+ */
+ public function getFavoriteFilePaths($user) {
+ $tags = $this->tagManager->load('files', [], false, $user);
+ $favorites = $tags->getFavorites();
+
+ if (empty($favorites)) {
+ throw new \RuntimeException('No favorites', 1);
+ } else if (isset($favorites[self::FAVORITE_LIMIT])) {
+ throw new \RuntimeException('Too many favorites', 2);
+ }
+
+ // Can not DI because the user is not known on instantiation
+ $rootFolder = \OC::$server->getUserFolder($user);
+ $folders = $items = [];
+ foreach ($favorites as $favorite) {
+ $nodes = $rootFolder->getById($favorite);
+ if (!empty($nodes)) {
+ /** @var \OCP\Files\Node $node */
+ $node = array_shift($nodes);
+ $path = substr($node->getPath(), strlen($user . '/files/'));
+
+ $items[] = $path;
+ if ($node instanceof Folder) {
+ $folders[] = $path;
+ }
+ }
+ }
+
+ if (empty($items)) {
+ throw new \RuntimeException('No favorites', 1);
+ }
+
+ return [
+ 'items' => $items,
+ 'folders' => $folders,
+ ];
+ }
+}
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php
new file mode 100644
index 00000000000..e95522a7d08
--- /dev/null
+++ b/apps/files/lib/Activity/Provider.php
@@ -0,0 +1,276 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files\Activity;
+
+use OCP\Activity\IEvent;
+use OCP\Activity\IManager;
+use OCP\Activity\IProvider;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+
+class Provider implements IProvider {
+
+ /** @var IL10N */
+ protected $l;
+
+ /** @var IURLGenerator */
+ protected $url;
+
+ /** @var IManager */
+ protected $activityManager;
+
+ /**
+ * @param IL10N $l
+ * @param IURLGenerator $url
+ * @param IManager $activityManager
+ */
+ public function __construct(IL10N $l, IURLGenerator $url, IManager $activityManager) {
+ $this->l = $l;
+ $this->url = $url;
+ $this->activityManager = $activityManager;
+ }
+
+ /**
+ * @param IEvent $event
+ * @param IEvent|null $previousEvent
+ * @return IEvent
+ * @throws \InvalidArgumentException
+ * @since 11.0.0
+ */
+ public function parse(IEvent $event, IEvent $previousEvent = null) {
+ if ($event->getApp() !== 'files') {
+ throw new \InvalidArgumentException();
+ }
+
+ if ($previousEvent instanceof IEvent && $event->getSubject() !== $previousEvent->getSubject()) {
+ // Different subject means not the same string, so no grouping
+ $previousEvent = null;
+ }
+
+ if ($this->activityManager->isFormattingFilteredObject()) {
+ try {
+ return $this->parseShortVersion($event);
+ } catch (\InvalidArgumentException $e) {
+ // Ignore and simply use the long version...
+ }
+ }
+
+ return $this->parseLongVersion($event);
+ }
+
+ /**
+ * @param IEvent $event
+ * @return IEvent
+ * @throws \InvalidArgumentException
+ * @since 11.0.0
+ */
+ public function parseShortVersion(IEvent $event) {
+ $parsedParameters = $this->getParsedParameters($event->getSubject(), $event->getSubjectParameters());
+ $richParameters = $this->getRichParameters($event->getSubject(), $event->getSubjectParameters());
+
+ if ($event->getSubject() === 'created_by') {
+ $event->setParsedSubject($this->l->t('Created by %s', [$parsedParameters[1]]))
+ ->setRichSubject($this->l->t('Created by {user1}'), ['user1' => $richParameters['user1']])
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
+ } else if ($event->getSubject() === 'changed_by') {
+ $event->setParsedSubject($this->l->t('Changed by %2$s', [$parsedParameters[1]]))
+ ->setRichSubject($this->l->t('Changed by {user1}'), ['user1' => $richParameters['user1']])
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'deleted_by') {
+ $event->setParsedSubject($this->l->t('Deleted by %2$s', [$parsedParameters[1]]))
+ ->setRichSubject($this->l->t('Deleted by {user1}'), ['user1' => $richParameters['user1']])
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
+ } else if ($event->getSubject() === 'restored_by') {
+ $event->setParsedSubject($this->l->t('Restored by %2$s', [$parsedParameters[1]]))
+ ->setRichSubject($this->l->t('Restored by {user1}'), ['user1' => $richParameters['user1']]);
+ } else if ($event->getSubject() === 'renamed_by') {
+ $event->setParsedSubject($this->l->t('Renamed by %2$s', [$parsedParameters[1]]))
+ ->setRichSubject($this->l->t('Renamed by {user1}'), ['user1' => $richParameters['user1']])
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'moved_by') {
+ $event->setParsedSubject($this->l->t('Moved by %2$s', [$parsedParameters[1]]))
+ ->setRichSubject($this->l->t('Moved by {user1}'), ['user1' => $richParameters['user1']])
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else {
+ throw new \InvalidArgumentException();
+ }
+
+ return $event;
+ }
+
+ /**
+ * @param IEvent $event
+ * @return IEvent
+ * @throws \InvalidArgumentException
+ * @since 11.0.0
+ */
+ public function parseLongVersion(IEvent $event) {
+ $parsedParameters = $this->getParsedParameters($event->getSubject(), $event->getSubjectParameters());
+ $richParameters = $this->getRichParameters($event->getSubject(), $event->getSubjectParameters());
+
+ if ($event->getSubject() === 'created_self') {
+ $event->setParsedSubject($this->l->t('You created %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('You created {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
+ } else if ($event->getSubject() === 'created_by') {
+ $event->setParsedSubject($this->l->t('%2$s created %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('{user1} created {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
+ } else if ($event->getSubject() === 'created_public') {
+ $event->setParsedSubject($this->l->t('%1$s was created in a public folder', $parsedParameters))
+ ->setRichSubject($this->l->t('{file1} was created in a public folder'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
+ } else if ($event->getSubject() === 'changed_self') {
+ $event->setParsedSubject($this->l->t('You changed %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('You changed {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'changed_by') {
+ $event->setParsedSubject($this->l->t('%2$s changed %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('{user1} changed {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'deleted_self') {
+ $event->setParsedSubject($this->l->t('You deleted %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('You deleted {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
+ } else if ($event->getSubject() === 'deleted_by') {
+ $event->setParsedSubject($this->l->t('%2$s deleted %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('{user1} deleted {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
+ } else if ($event->getSubject() === 'restored_self') {
+ $event->setParsedSubject($this->l->t('You restored %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('You restored {file1}'), $richParameters);
+ } else if ($event->getSubject() === 'restored_by') {
+ $event->setParsedSubject($this->l->t('%2$s restored %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('{user1} restored {file1}'), $richParameters);
+ } else if ($event->getSubject() === 'renamed_self') {
+ $event->setParsedSubject($this->l->t('You renamed %2$s to %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('You renamed {file2} to {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'renamed_by') {
+ $event->setParsedSubject($this->l->t('%2$s renamed %3$s to %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('{user1} renamed {file2} to {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'moved_self') {
+ $event->setParsedSubject($this->l->t('You moved %2$s to %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('You moved {file2} to {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else if ($event->getSubject() === 'moved_by') {
+ $event->setParsedSubject($this->l->t('%2$s moved %3$s to %1$s', $parsedParameters))
+ ->setRichSubject($this->l->t('{user1} moved {file2} to {file1}'), $richParameters)
+ ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
+ } else {
+ throw new \InvalidArgumentException();
+ }
+
+ return $event;
+ }
+
+ protected function getParsedParameters($subject, array $parameters) {
+ switch ($subject) {
+ case 'created_self':
+ case 'created_public':
+ case 'changed_self':
+ case 'deleted_self':
+ case 'restored_self':
+ return [
+ array_shift($parameters[0]),
+ ];
+ case 'created_by':
+ case 'changed_by':
+ case 'deleted_by':
+ case 'restored_by':
+ return [
+ array_shift($parameters[0]),
+ $parameters[1],
+ ];
+ case 'renamed_self':
+ case 'moved_self':
+ return [
+ array_shift($parameters[0]),
+ array_shift($parameters[1]),
+ ];
+ case 'renamed_by':
+ case 'moved_by':
+ return [
+ array_shift($parameters[0]),
+ $parameters[1],
+ array_shift($parameters[2]),
+ ];
+ }
+ return [];
+ }
+
+ protected function getRichParameters($subject, array $parameters) {
+ switch ($subject) {
+ case 'created_self':
+ case 'created_public':
+ case 'changed_self':
+ case 'deleted_self':
+ case 'restored_self':
+ return [
+ 'file1' => $this->getRichFileParameter($parameters[0]),
+ ];
+ case 'created_by':
+ case 'changed_by':
+ case 'deleted_by':
+ case 'restored_by':
+ return [
+ 'file1' => $this->getRichFileParameter($parameters[0]),
+ 'user1' => $this->getRichUserParameter($parameters[1]),
+ ];
+ case 'renamed_self':
+ case 'moved_self':
+ return [
+ 'file1' => $this->getRichFileParameter($parameters[0]),
+ 'file2' => $this->getRichFileParameter($parameters[1]),
+ ];
+ case 'renamed_by':
+ case 'moved_by':
+ return [
+ 'file1' => $this->getRichFileParameter($parameters[0]),
+ 'user1' => $this->getRichUserParameter($parameters[1]),
+ 'file2' => $this->getRichFileParameter($parameters[2]),
+ ];
+ }
+ return [];
+ }
+
+ protected function getRichFileParameter($parameter) {
+ $path = reset($parameter);
+ $id = key($parameter);
+ return [
+ 'type' => 'file',
+ 'id' => $id,
+ 'name' => basename($path),
+ 'path' => $path,
+ ];
+ }
+
+ protected function getRichUserParameter($parameter) {
+ return [
+ 'type' => 'user',
+ 'id' => $parameter,
+ 'name' => $parameter,// FIXME Use display name
+ ];
+ }
+}
diff --git a/apps/files/lib/Activity/Settings/FileChanged.php b/apps/files/lib/Activity/Settings/FileChanged.php
new file mode 100644
index 00000000000..1c20fb6f01a
--- /dev/null
+++ b/apps/files/lib/Activity/Settings/FileChanged.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\ISetting;
+use OCP\IL10N;
+
+class FileChanged implements ISetting {
+
+ /** @var IL10N */
+ protected $l;
+
+ /**
+ * @param IL10N $l
+ */
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'file_changed';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('A file or folder has been <strong>changed</strong> or <strong>renamed</strong>');
+ }
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 1;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function canChangeStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 11.0.0
+ */
+ public function canChangeMail() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledMail() {
+ return false;
+ }
+}
+
diff --git a/apps/files/lib/Activity/Settings/FileCreated.php b/apps/files/lib/Activity/Settings/FileCreated.php
new file mode 100644
index 00000000000..dfde00ae7ec
--- /dev/null
+++ b/apps/files/lib/Activity/Settings/FileCreated.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\ISetting;
+use OCP\IL10N;
+
+class FileCreated implements ISetting {
+
+ /** @var IL10N */
+ protected $l;
+
+ /**
+ * @param IL10N $l
+ */
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'file_created';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('A new file or folder has been <strong>created</strong>');
+ }
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 0;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function canChangeStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 11.0.0
+ */
+ public function canChangeMail() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledMail() {
+ return false;
+ }
+}
+
diff --git a/apps/files/lib/Activity/Settings/FileDeleted.php b/apps/files/lib/Activity/Settings/FileDeleted.php
new file mode 100644
index 00000000000..c4948ded2fa
--- /dev/null
+++ b/apps/files/lib/Activity/Settings/FileDeleted.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\ISetting;
+use OCP\IL10N;
+
+class FileDeleted implements ISetting {
+
+ /** @var IL10N */
+ protected $l;
+
+ /**
+ * @param IL10N $l
+ */
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'file_deleted';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('A new file or folder has been <strong>deleted</strong>');
+ }
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 3;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function canChangeStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 11.0.0
+ */
+ public function canChangeMail() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledMail() {
+ return false;
+ }
+}
+
diff --git a/apps/files/lib/Activity/Settings/FileFavorite.php b/apps/files/lib/Activity/Settings/FileFavorite.php
new file mode 100644
index 00000000000..b2f20688df9
--- /dev/null
+++ b/apps/files/lib/Activity/Settings/FileFavorite.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\ISetting;
+use OCP\IL10N;
+
+class FileFavorite implements ISetting {
+
+ /** @var IL10N */
+ protected $l;
+
+ /**
+ * @param IL10N $l
+ */
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'file_favorite';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>');
+ }
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 2;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function canChangeStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledStream() {
+ return false;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 11.0.0
+ */
+ public function canChangeMail() {
+ return false;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledMail() {
+ return false;
+ }
+}
+
diff --git a/apps/files/lib/Activity/Settings/FileRestored.php b/apps/files/lib/Activity/Settings/FileRestored.php
new file mode 100644
index 00000000000..cedfef441ed
--- /dev/null
+++ b/apps/files/lib/Activity/Settings/FileRestored.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
+ *
+ * @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\ISetting;
+use OCP\IL10N;
+
+class FileRestored implements ISetting {
+
+ /** @var IL10N */
+ protected $l;
+
+ /**
+ * @param IL10N $l
+ */
+ public function __construct(IL10N $l) {
+ $this->l = $l;
+ }
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'file_restored';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l->t('A new file or folder has been <strong>restored</strong>');
+ }
+
+ /**
+ * @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.
+ * @since 11.0.0
+ */
+ public function getPriority() {
+ return 4;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function canChangeStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledStream() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the mail
+ * @since 11.0.0
+ */
+ public function canChangeMail() {
+ return true;
+ }
+
+ /**
+ * @return bool True when the option can be changed for the stream
+ * @since 11.0.0
+ */
+ public function isDefaultEnabledMail() {
+ return false;
+ }
+}
+