Permalink
Browse files

Notifications: send alerts to a larger scope: repository "*" and/or f…

…ull groupPath. Handle that in messageExchanger and in notification DB persistence.

Use this new system to send an alert when sharing a file or folder with a user.
  • Loading branch information...
1 parent ae5d6e2 commit 339f543cfb6d3cfca1c4d85dd494b809cfb0d951 @cdujeu cdujeu committed Sep 30, 2016
Showing with 949 additions and 823 deletions.
  1. +6 −3 core/src/plugins/core.notifications/IFeedStore.php
  2. +60 −2 core/src/plugins/core.notifications/NotificationCenter.php
  3. +1 −0 core/src/plugins/core.notifications/manifest.xml
  4. +46 −44 core/src/plugins/core.notifications/templates/block/ca.php
  5. +46 −44 core/src/plugins/core.notifications/templates/block/de.php
  6. +2 −0 core/src/plugins/core.notifications/templates/block/en.php
  7. +46 −44 core/src/plugins/core.notifications/templates/block/es.php
  8. +46 −44 core/src/plugins/core.notifications/templates/block/fr.php
  9. +3 −1 core/src/plugins/core.notifications/templates/block/pt.php
  10. +46 −44 core/src/plugins/core.notifications/templates/block/ru.php
  11. +38 −36 core/src/plugins/core.notifications/templates/group/ca.php
  12. +38 −36 core/src/plugins/core.notifications/templates/group/de.php
  13. +2 −0 core/src/plugins/core.notifications/templates/group/en.php
  14. +38 −36 core/src/plugins/core.notifications/templates/group/es.php
  15. +38 −36 core/src/plugins/core.notifications/templates/group/fr.php
  16. +38 −36 core/src/plugins/core.notifications/templates/group/pt.php
  17. +38 −36 core/src/plugins/core.notifications/templates/group/ru.php
  18. +46 −44 core/src/plugins/core.notifications/templates/long/ca.php
  19. +45 −43 core/src/plugins/core.notifications/templates/long/de.php
  20. +2 −0 core/src/plugins/core.notifications/templates/long/en.php
  21. +46 −44 core/src/plugins/core.notifications/templates/long/es.php
  22. +45 −43 core/src/plugins/core.notifications/templates/long/fr.php
  23. +3 −1 core/src/plugins/core.notifications/templates/long/pt.php
  24. +45 −43 core/src/plugins/core.notifications/templates/long/ru.php
  25. +21 −19 core/src/plugins/core.notifications/templates/short/ca.php
  26. +21 −19 core/src/plugins/core.notifications/templates/short/de.php
  27. +2 −1 core/src/plugins/core.notifications/templates/short/en.php
  28. +21 −19 core/src/plugins/core.notifications/templates/short/es.php
  29. +38 −36 core/src/plugins/core.notifications/templates/short/fr.php
  30. +38 −36 core/src/plugins/core.notifications/templates/short/pt.php
  31. +21 −19 core/src/plugins/core.notifications/templates/short/ru.php
  32. +23 −14 core/src/plugins/feed.sql/SqlFeedStore.php
@@ -21,6 +21,7 @@
namespace Pydio\Notification\Core;
use Pydio\Core\Model\ContextInterface;
+use Pydio\Core\Model\UserInterface;
defined('AJXP_EXEC') or die('Access not allowed');
@@ -69,17 +70,19 @@ public function deleteFeed($types='event', $userId = null, $repositoryId = null,
/**
* @abstract
* @param Notification $notif
+ * @param bool $repoScopeAll
+ * @param bool|string $groupScope
* @return mixed
*/
- public function persistAlert(Notification $notif);
+ public function persistAlert(Notification $notif, $repoScopeAll = false, $groupScope = false);
/**
* @abstract
- * @param $userId
+ * @param UserInterface $userObject
* @param null $repositoryIdFilter
* @return Notification[]
*/
- public function loadAlerts($userId, $repositoryIdFilter = null);
+ public function loadAlerts($userObject, $repositoryIdFilter = null);
/**
@@ -25,6 +25,8 @@
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Core\Exception\PydioException;
use Pydio\Core\Model\ContextInterface;
+use Pydio\Core\Model\RepositoryInterface;
+use Pydio\Core\Model\UserInterface;
use Pydio\Core\PluginFramework\PluginsService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Controller\Controller;
@@ -397,7 +399,7 @@ public function loadUserAlerts(\Psr\Http\Message\ServerRequestInterface $request
if ($repositoryFilter == null) {
$repositoryFilter = $ctx->getRepositoryId();
}
- $res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
+ $res = $this->eventStore->loadAlerts($u, $repositoryFilter);
if(!count($res)) return;
// Recompute children notifs
@@ -436,7 +438,7 @@ public function loadUserAlerts(\Psr\Http\Message\ServerRequestInterface $request
$path = $node->getPath();
$nodeRepo = $node->getRepository();
- if($nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter){
+ if($notification->getAction() !== "share" && $nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter){
$newCtx = $node->getContext();
$currentRoot = $nodeRepo->getContextOption($newCtx, "PATH");
$contentFilter = $nodeRepo->getContentFilter();
@@ -575,6 +577,62 @@ public function generateNotificationFromChangeHook(AJXP_Node $oldNode = null, AJ
return $notif;
}
+ /**
+ * @param ContextInterface $context
+ * @param UserInterface|string $userOrRole
+ * @param RepositoryInterface $sharedRepository
+ * @param AJXP_Node $originalNode
+ */
+ public function shareAssignRight($context, $userOrRole, $sharedRepository, $originalNode){
+
+ $notification = new Notification();
+ $notification->setAction("share");
+ $notification->setAuthor($context->getUser()->getId());
+
+ if($userOrRole instanceof UserInterface && !$userOrRole->isHidden()){
+
+ $targetIdentifier = $userOrRole->getId();
+ $notification->setTarget($targetIdentifier);
+ if($originalNode->isLeaf()){
+ $node = new AJXP_Node("pydio://".$targetIdentifier."@inbox/".$originalNode->getLabel());
+ $node->setLeaf(true);
+ }else{
+ $node = new AJXP_Node("pydio://".$targetIdentifier."@".$sharedRepository->getId()."/");
+ $node->setLeaf(false);
+ }
+ $notification->setNode($node);
+ $this->eventStore->persistAlert($notification, true);
+ Controller::applyHook("msg.instant",array(
+ $context->withRepositoryId(null),
+ "<reload_user_feed/>",
+ $targetIdentifier
+ ));
+
+ }else if(is_string($userOrRole) && strpos($userOrRole, "AJXP_GRP_/") === 0){
+
+ $groupPath = substr($userOrRole, strlen("AJXP_GRP_"));
+ $notification->setTarget("*");
+ if($originalNode->isLeaf()){
+ $node = new AJXP_Node("pydio://*@inbox/".$originalNode->getLabel());
+ $node->setLeaf(true);
+ }else{
+ $node = new AJXP_Node("pydio://*@".$sharedRepository->getId()."/");
+ $node->setLeaf(false);
+ }
+ $notification->setNode($node);
+ $this->eventStore->persistAlert($notification, true, $groupPath);
+ Controller::applyHook("msg.instant",array(
+ $context->withRepositoryId(null),
+ "<reload_user_feed/>",
+ null,
+ $groupPath
+ ));
+
+
+ }
+
+ }
+
/**
* @param Notification $notif
@@ -128,6 +128,7 @@
<serverCallback methodName="persistChangeHookToFeed" hookName="node.change" defer="true"/>
<serverCallback methodName="persistNotificationToAlerts" hookName="msg.notification"/>
<serverCallback methodName="loadRepositoryInfo" hookName="repository.load_info"/>
+ <serverCallback methodName="shareAssignRight" hookName="node.share.assign_right"/>
</hooks>
<client_configs>
<component_config className="InfoPanel">
@@ -1,47 +1,49 @@
<?php
- /*
- * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
- * This file is part of Pydio.
- *
- * Pydio 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.
- *
- * Pydio 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 Pydio. If not, see <http://www.gnu.org/licenses/>.
- *
- * The latest code can be found at <https://pydio.com>.
- */
+/*
+* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
+* This file is part of Pydio.
+*
+* Pydio 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.
+*
+* Pydio 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 Pydio. If not, see <http://www.gnu.org/licenses/>.
+*
+* The latest code can be found at <https://pydio.com>.
+*/
// catalan translation: Salva Gómez <salva.gomez at gmail.com>, 2016
$mess=array(
- "user_link" => "per",
- "file.add" => "creat",
- "file.delete" => "eliminat",
- "file.change" => "modificat",
- "file.rename" => "renombrat a AJXP_NODE_LABEL",
- "file.view" => "consultat",
- "file.copy" => "copiat a AJXP_PARENT_PATH",
- "file.copy_to" => "copiat a AJXP_TARGET_FOLDER",
- "file.copy_from" => "copiat des de AJXP_SOURCE_FOLDER",
- "file.move" => "mogut a AJXP_PARENT_PATH",
- "file.move_to" => "mogut a AJXP_TARGET_FOLDER",
- "file.move_from" => "mogut des de AJXP_SOURCE_FOLDER",
- "folder.add" => "creada",
- "folder.delete" => "eliminada",
- "folder.rename" => "renombrada a AJXP_NODE_LABEL",
- "folder.change" => "contingut modificat modificado",
- "folder.view" => "oberta",
- "folder.copy" => "copiada des de AJXP_SOURCE_FOLDER",
- "folder.copy_to" => "copiada a AJXP_TARGET_FOLDER",
- "folder.copy_from" => "copiada des de AJXP_SOURCE_FOLDER",
- "folder.move" => "moguda des de AJXP_SOURCE_FOLDER",
- "folder.move_to" => "moguda a AJXP_TARGET_FOLDER",
- "folder.move_from" => "moguda des de AJXP_SOURCE_FOLDER",
- "ajxp_link" => "Faci click aquí per anar directament a <a href='AJXP_LINK'>AJXP_NODE_LABEL</a>",
-);
+"user_link" => "per",
+"file.add" => "creat",
+"file.delete" => "eliminat",
+"file.change" => "modificat",
+"file.rename" => "renombrat a AJXP_NODE_LABEL",
+"file.view" => "consultat",
+"file.copy" => "copiat a AJXP_PARENT_PATH",
+"file.copy_to" => "copiat a AJXP_TARGET_FOLDER",
+"file.copy_from" => "copiat des de AJXP_SOURCE_FOLDER",
+"file.move" => "mogut a AJXP_PARENT_PATH",
+"file.move_to" => "mogut a AJXP_TARGET_FOLDER",
+"file.move_from" => "mogut des de AJXP_SOURCE_FOLDER",
+"folder.add" => "creada",
+"folder.delete" => "eliminada",
+"folder.rename" => "renombrada a AJXP_NODE_LABEL",
+"folder.change" => "contingut modificat modificado",
+"folder.view" => "oberta",
+"folder.copy" => "copiada des de AJXP_SOURCE_FOLDER",
+"folder.copy_to" => "copiada a AJXP_TARGET_FOLDER",
+"folder.copy_from" => "copiada des de AJXP_SOURCE_FOLDER",
+"folder.move" => "moguda des de AJXP_SOURCE_FOLDER",
+"folder.move_to" => "moguda a AJXP_TARGET_FOLDER",
+"folder.move_from" => "moguda des de AJXP_SOURCE_FOLDER",
+"ajxp_link" => "Faci click aquí per anar directament a <a href='AJXP_LINK'>AJXP_NODE_LABEL</a>",
+"file.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
+"folder.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
+);
@@ -1,46 +1,48 @@
<?php
- /*
- * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
- * This file is part of Pydio.
- *
- * Pydio 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.
- *
- * Pydio 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 Pydio. If not, see <http://www.gnu.org/licenses/>.
- *
- * The latest code can be found at <https://pydio.com>.
- */
+/*
+* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
+* This file is part of Pydio.
+*
+* Pydio 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.
+*
+* Pydio 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 Pydio. If not, see <http://www.gnu.org/licenses/>.
+*
+* The latest code can be found at <https://pydio.com>.
+*/
$mess=array(
- "user_link" => "von",
- "file.add" => "erstellt",
- "file.delete" => "gelöscht",
- "file.change" => "bearbeitet",
- "file.rename" => "zu AJXP_NODE_LABEL umbenannt",
- "file.view" => "consulted",
- "file.copy" => "nach AJXP_PARENT_PATH kopiert",
- "file.copy_to" => "in AJXP_TARGET_FOLDER kopiert ",
- "file.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
- "file.move" => "nach AJXP_PARENT_PATH verschoben",
- "file.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
- "file.move_from" => "aus AJXP_SOURCE_FOLDER verschoben",
- "folder.add" => "erstellt",
- "folder.delete" => "gelöscht",
- "folder.rename" => "zu AJXP_NODE_LABEL umbenannt",
- "folder.change" => "Inhalt modifiziert",
- "folder.view" => "geöffnet",
- "folder.copy" => "von AJXP_SOURCE_FOLDER kopiert",
- "folder.copy_to" => "nach AJXP_TARGET_FOLDER kopiert",
- "folder.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
- "folder.move" => "von AJXP_SOURCE_FOLDER verschoben",
- "folder.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
- "folder.move_from" => "von AJXP_SOURCE_FOLDER verschoben",
- "ajxp_link" => "Hier klicken um direkt zu <a href='AJXP_LINK'>AJXP_NODE_LABEL</a> gehen",
-);
+"user_link" => "von",
+"file.add" => "erstellt",
+"file.delete" => "gelöscht",
+"file.change" => "bearbeitet",
+"file.rename" => "zu AJXP_NODE_LABEL umbenannt",
+"file.view" => "consulted",
+"file.copy" => "nach AJXP_PARENT_PATH kopiert",
+"file.copy_to" => "in AJXP_TARGET_FOLDER kopiert ",
+"file.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
+"file.move" => "nach AJXP_PARENT_PATH verschoben",
+"file.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
+"file.move_from" => "aus AJXP_SOURCE_FOLDER verschoben",
+"folder.add" => "erstellt",
+"folder.delete" => "gelöscht",
+"folder.rename" => "zu AJXP_NODE_LABEL umbenannt",
+"folder.change" => "Inhalt modifiziert",
+"folder.view" => "geöffnet",
+"folder.copy" => "von AJXP_SOURCE_FOLDER kopiert",
+"folder.copy_to" => "nach AJXP_TARGET_FOLDER kopiert",
+"folder.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
+"folder.move" => "von AJXP_SOURCE_FOLDER verschoben",
+"folder.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
+"folder.move_from" => "von AJXP_SOURCE_FOLDER verschoben",
+"ajxp_link" => "Hier klicken um direkt zu <a href='AJXP_LINK'>AJXP_NODE_LABEL</a> gehen",
+"file.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
+"folder.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
+);
@@ -43,5 +43,7 @@
"folder.move" => "moved from AJXP_SOURCE_FOLDER",
"folder.move_to" => "moved to AJXP_TARGET_FOLDER",
"folder.move_from" => "moved from AJXP_SOURCE_FOLDER",
+ "file.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
+ "folder.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
"ajxp_link" => "Click here to get go directly to <a href='AJXP_LINK'>AJXP_NODE_LABEL</a>",
);
Oops, something went wrong.

0 comments on commit 339f543

Please sign in to comment.