+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\Deck\Activity;
+
+
+use OCP\Activity\IEvent;
+use OCP\Activity\IProvider;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+
+class DeckProvider implements IProvider {
+
+ /** @var string */
+ private $userId;
+ /** @var IURLGenerator */
+ private $urlGenerator;
+ /** @var ActivityManager */
+ private $activityManager;
+
+ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, $userId) {
+ $this->userId = $userId;
+ $this->urlGenerator = $urlGenerator;
+ $this->activityManager = $activityManager;
+ }
+
+
+ /**
+ * @param string $language The language which should be used for translating, e.g. "en"
+ * @param IEvent $event The current event which should be parsed
+ * @param IEvent|null $previousEvent A potential previous event which you can combine with the current one.
+ * To do so, simply use setChildEvent($previousEvent) after setting the
+ * combined subject on the current event.
+ * @return IEvent
+ * @throws \InvalidArgumentException Should be thrown if your provider does not know this event
+ * @since 11.0.0
+ */
+ public function parse($language, IEvent $event, IEvent $previousEvent = null) {
+ if ($event->getApp() !== 'deck') {
+ throw new \InvalidArgumentException();
+ }
+
+ $event->setIcon(\OC::$server->getURLGenerator()->imagePath('deck', 'deck-dark.svg'));
+
+ $subjectIdentifier = $event->getSubject();
+ $subjectParams = $event->getSubjectParameters();
+
+ $ownActivity = ($event->getAuthor() === $this->userId);
+
+ if ($event->getObjectType() === ActivityManager::DECK_OBJECT_BOARD) {
+ $board = [
+ 'type' => 'highlight',
+ 'id' => $event->getObjectId(),
+ 'name' => $event->getObjectName(),
+ 'link' => $this->deckUrl('/board/' . $event->getObjectId()),
+ ];
+ }
+
+ if ($event->getObjectType() === ActivityManager::DECK_OBJECT_CARD) {
+ $card = [
+ 'type' => 'highlight',
+ 'id' => $event->getObjectId(),
+ 'name' => $event->getObjectName(),
+ ];
+
+ if ($subjectParams['board']) {
+ // TODO: check if archvied?
+ $card['link'] = $this->deckUrl('/board/' . $subjectParams['board']['id'] . '//card/' . $event->getObjectId());
+ }
+ }
+
+ $userManager = \OC::$server->getUserManager();
+ $author = $event->getAuthor();
+ $user = $userManager->get($author);
+ $params = [
+ 'board' => $board,
+ 'card' => $card,
+ 'user' => [
+ 'type' => 'user',
+ 'id' => $author,
+ 'name' => $user !== null ? $user->getDisplayName() : $author
+ ]
+ ];
+
+ if (array_key_exists('stack', $subjectParams)) {
+ $params['stack'] = [
+ 'type' => 'highlight',
+ 'id' => $subjectParams['stack']['id'],
+ 'name' => $subjectParams['stack']['title'],
+ 'link' => $this->deckUrl('/board/' . $subjectParams['stack']['boardId'] . '/'),
+ ];
+ }
+
+ if (array_key_exists('board', $subjectParams)) {
+ $params['board'] = [
+ 'type' => 'highlight',
+ 'id' => $subjectParams['board']['id'],
+ 'name' => $subjectParams['board']['title'],
+ 'link' => $this->deckUrl('/board/' . $subjectParams['board']['id'] . '/'),
+ ];
+ }
+
+ if (array_key_exists('before', $subjectParams)) {
+ $params['before'] = [
+ 'type' => 'highlight',
+ 'id' => $subjectParams['before'],
+ 'name' => $subjectParams['before']
+ ];
+ }
+
+ $subject = $this->activityManager->getActivityFormat($subjectIdentifier, $ownActivity);
+ $event->setParsedSubject($subject);
+ $event->setRichSubject(
+ $subject,
+ $params
+ );
+ if ($event->getMessage() !== '') {
+ $event->setParsedMessage('' . $event->getMessage() . '
');
+ }
+
+ return $event;
+ }
+
+ public function deckUrl($endpoint) {
+ return $this->urlGenerator->linkToRoute('deck.page.index') . '#!' . $endpoint;
+ }
+}
diff --git a/lib/Activity/Filter.php b/lib/Activity/Filter.php
new file mode 100644
index 000000000..4dcbd5260
--- /dev/null
+++ b/lib/Activity/Filter.php
@@ -0,0 +1,89 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\Deck\Activity;
+
+use OCP\IL10N;
+
+class Filter implements \OCP\Activity\IFilter {
+
+ private $l10n;
+
+ public function __construct(
+ IL10N $l10n
+ ) {
+ $this->l10n = $l10n;
+ }
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'deck';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return $this->l10n->t('Deck');
+ }
+
+ /**
+ * @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 90;
+ }
+
+ /**
+ * @return string Full URL to an icon, empty string when none is given
+ * @since 11.0.0
+ */
+ public function getIcon() {
+ //TODO: inject
+ return \OC::$server->getURLGenerator()->imagePath('deck', 'deck-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 $types;
+ }
+
+ /**
+ * @return string[] An array of allowed apps from which activities should be displayed
+ * @since 11.0.0
+ */
+ public function allowedApps() {
+ return ['deck'];
+ }
+}
\ No newline at end of file
diff --git a/lib/Activity/Setting.php b/lib/Activity/Setting.php
new file mode 100644
index 000000000..12080f263
--- /dev/null
+++ b/lib/Activity/Setting.php
@@ -0,0 +1,86 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @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 .
+ *
+ */
+
+namespace OCA\Deck\Activity;
+
+
+class Setting implements \OCP\Activity\ISetting {
+
+ /**
+ * @return string Lowercase a-z and underscore only identifier
+ * @since 11.0.0
+ */
+ public function getIdentifier() {
+ return 'deck';
+ }
+
+ /**
+ * @return string A translated string
+ * @since 11.0.0
+ */
+ public function getName() {
+ return 'Deck';
+ }
+
+ /**
+ * @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 90;
+ }
+
+ /**
+ * @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/lib/Service/StackService.php b/lib/Service/StackService.php
index f2bdbaff8..4f8e4be24 100644
--- a/lib/Service/StackService.php
+++ b/lib/Service/StackService.php
@@ -32,6 +32,7 @@ use OCA\Deck\Db\Stack;
use OCA\Deck\Db\StackMapper;
use OCA\Deck\StatusException;
use OCA\Deck\BadRequestException;
+use OCP\Activity\IManager;
class StackService {
@@ -45,6 +46,7 @@ class StackService {
private $cardService;
private $assignedUsersMapper;
private $attachmentService;
+ private $activityManager;
public function __construct(
StackMapper $stackMapper,
@@ -55,7 +57,8 @@ class StackService {
BoardService $boardService,
CardService $cardService,
AssignedUsersMapper $assignedUsersMapper,
- AttachmentService $attachmentService
+ AttachmentService $attachmentService,
+ IManager $activityManager
) {
$this->stackMapper = $stackMapper;
$this->boardMapper = $boardMapper;
@@ -66,6 +69,7 @@ class StackService {
$this->cardService = $cardService;
$this->assignedUsersMapper = $assignedUsersMapper;
$this->attachmentService = $attachmentService;
+ $this->activityManager = $activityManager;
}
private function enrichStackWithCards($stack) {
@@ -195,8 +199,33 @@ class StackService {
$stack->setTitle($title);
$stack->setBoardId($boardId);
$stack->setOrder($order);
- return $this->stackMapper->insert($stack);
+ $result = $this->stackMapper->insert($stack);
+ $board = $this->boardMapper->find($boardId);
+ $event = $this->activityManager->generateEvent();
+ $event->setApp('deck')
+ ->setType('deck_own_boards')
+ ->setAffectedUser($board->getOwner())
+ ->setAuthor($board->getOwner())
+ ->setObject('stack', $result->getId())
+ ->setSubject('foo')
+ ->setTimestamp(time());
+ /*->setSubject('{actor} created a new stack {stack} on {board}',
+ [
+ 'actor' => $event->getAuthor(),
+ 'stack' => [
+ 'id' => (int) $result->getId(),
+ //'uri' => $calendarData['uri'],
+ 'name' => $stack->getTitle(),
+ ],
+ 'board' => [
+ 'id' => (int) $boardId,
+ 'name' => $board->getTitle(),
+ ],
+ ]);*/
+
+ $this->activityManager->publish($event);
+ return $result;
}
/**