Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 339f543

Browse files
committed
Notifications: send alerts to a larger scope: repository "*" and/or full 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.
1 parent ae5d6e2 commit 339f543

File tree

32 files changed

+949
-823
lines changed

32 files changed

+949
-823
lines changed

core/src/plugins/core.notifications/IFeedStore.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
namespace Pydio\Notification\Core;
2222

2323
use Pydio\Core\Model\ContextInterface;
24+
use Pydio\Core\Model\UserInterface;
2425

2526
defined('AJXP_EXEC') or die('Access not allowed');
2627

@@ -69,17 +70,19 @@ public function deleteFeed($types='event', $userId = null, $repositoryId = null,
6970
/**
7071
* @abstract
7172
* @param Notification $notif
73+
* @param bool $repoScopeAll
74+
* @param bool|string $groupScope
7275
* @return mixed
7376
*/
74-
public function persistAlert(Notification $notif);
77+
public function persistAlert(Notification $notif, $repoScopeAll = false, $groupScope = false);
7578

7679
/**
7780
* @abstract
78-
* @param $userId
81+
* @param UserInterface $userObject
7982
* @param null $repositoryIdFilter
8083
* @return Notification[]
8184
*/
82-
public function loadAlerts($userId, $repositoryIdFilter = null);
85+
public function loadAlerts($userObject, $repositoryIdFilter = null);
8386

8487

8588
/**

core/src/plugins/core.notifications/NotificationCenter.php

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
use Pydio\Access\Core\Model\AJXP_Node;
2626
use Pydio\Core\Exception\PydioException;
2727
use Pydio\Core\Model\ContextInterface;
28+
use Pydio\Core\Model\RepositoryInterface;
29+
use Pydio\Core\Model\UserInterface;
2830
use Pydio\Core\PluginFramework\PluginsService;
2931
use Pydio\Core\Services\ConfService;
3032
use Pydio\Core\Controller\Controller;
@@ -397,7 +399,7 @@ public function loadUserAlerts(\Psr\Http\Message\ServerRequestInterface $request
397399
if ($repositoryFilter == null) {
398400
$repositoryFilter = $ctx->getRepositoryId();
399401
}
400-
$res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
402+
$res = $this->eventStore->loadAlerts($u, $repositoryFilter);
401403
if(!count($res)) return;
402404

403405
// Recompute children notifs
@@ -436,7 +438,7 @@ public function loadUserAlerts(\Psr\Http\Message\ServerRequestInterface $request
436438
$path = $node->getPath();
437439
$nodeRepo = $node->getRepository();
438440

439-
if($nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter){
441+
if($notification->getAction() !== "share" && $nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter){
440442
$newCtx = $node->getContext();
441443
$currentRoot = $nodeRepo->getContextOption($newCtx, "PATH");
442444
$contentFilter = $nodeRepo->getContentFilter();
@@ -575,6 +577,62 @@ public function generateNotificationFromChangeHook(AJXP_Node $oldNode = null, AJ
575577
return $notif;
576578
}
577579

580+
/**
581+
* @param ContextInterface $context
582+
* @param UserInterface|string $userOrRole
583+
* @param RepositoryInterface $sharedRepository
584+
* @param AJXP_Node $originalNode
585+
*/
586+
public function shareAssignRight($context, $userOrRole, $sharedRepository, $originalNode){
587+
588+
$notification = new Notification();
589+
$notification->setAction("share");
590+
$notification->setAuthor($context->getUser()->getId());
591+
592+
if($userOrRole instanceof UserInterface && !$userOrRole->isHidden()){
593+
594+
$targetIdentifier = $userOrRole->getId();
595+
$notification->setTarget($targetIdentifier);
596+
if($originalNode->isLeaf()){
597+
$node = new AJXP_Node("pydio://".$targetIdentifier."@inbox/".$originalNode->getLabel());
598+
$node->setLeaf(true);
599+
}else{
600+
$node = new AJXP_Node("pydio://".$targetIdentifier."@".$sharedRepository->getId()."/");
601+
$node->setLeaf(false);
602+
}
603+
$notification->setNode($node);
604+
$this->eventStore->persistAlert($notification, true);
605+
Controller::applyHook("msg.instant",array(
606+
$context->withRepositoryId(null),
607+
"<reload_user_feed/>",
608+
$targetIdentifier
609+
));
610+
611+
}else if(is_string($userOrRole) && strpos($userOrRole, "AJXP_GRP_/") === 0){
612+
613+
$groupPath = substr($userOrRole, strlen("AJXP_GRP_"));
614+
$notification->setTarget("*");
615+
if($originalNode->isLeaf()){
616+
$node = new AJXP_Node("pydio://*@inbox/".$originalNode->getLabel());
617+
$node->setLeaf(true);
618+
}else{
619+
$node = new AJXP_Node("pydio://*@".$sharedRepository->getId()."/");
620+
$node->setLeaf(false);
621+
}
622+
$notification->setNode($node);
623+
$this->eventStore->persistAlert($notification, true, $groupPath);
624+
Controller::applyHook("msg.instant",array(
625+
$context->withRepositoryId(null),
626+
"<reload_user_feed/>",
627+
null,
628+
$groupPath
629+
));
630+
631+
632+
}
633+
634+
}
635+
578636

579637
/**
580638
* @param Notification $notif

core/src/plugins/core.notifications/manifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<serverCallback methodName="persistChangeHookToFeed" hookName="node.change" defer="true"/>
129129
<serverCallback methodName="persistNotificationToAlerts" hookName="msg.notification"/>
130130
<serverCallback methodName="loadRepositoryInfo" hookName="repository.load_info"/>
131+
<serverCallback methodName="shareAssignRight" hookName="node.share.assign_right"/>
131132
</hooks>
132133
<client_configs>
133134
<component_config className="InfoPanel">
Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
11
<?php
2-
/*
3-
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
4-
* This file is part of Pydio.
5-
*
6-
* Pydio is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU Affero General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* Pydio is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU Affero General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU Affero General Public License
17-
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18-
*
19-
* The latest code can be found at <https://pydio.com>.
20-
*/
2+
/*
3+
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
4+
* This file is part of Pydio.
5+
*
6+
* Pydio is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Pydio is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* The latest code can be found at <https://pydio.com>.
20+
*/
2121
// catalan translation: Salva Gómez <salva.gomez at gmail.com>, 2016
2222
$mess=array(
23-
"user_link" => "per",
24-
"file.add" => "creat",
25-
"file.delete" => "eliminat",
26-
"file.change" => "modificat",
27-
"file.rename" => "renombrat a AJXP_NODE_LABEL",
28-
"file.view" => "consultat",
29-
"file.copy" => "copiat a AJXP_PARENT_PATH",
30-
"file.copy_to" => "copiat a AJXP_TARGET_FOLDER",
31-
"file.copy_from" => "copiat des de AJXP_SOURCE_FOLDER",
32-
"file.move" => "mogut a AJXP_PARENT_PATH",
33-
"file.move_to" => "mogut a AJXP_TARGET_FOLDER",
34-
"file.move_from" => "mogut des de AJXP_SOURCE_FOLDER",
35-
"folder.add" => "creada",
36-
"folder.delete" => "eliminada",
37-
"folder.rename" => "renombrada a AJXP_NODE_LABEL",
38-
"folder.change" => "contingut modificat modificado",
39-
"folder.view" => "oberta",
40-
"folder.copy" => "copiada des de AJXP_SOURCE_FOLDER",
41-
"folder.copy_to" => "copiada a AJXP_TARGET_FOLDER",
42-
"folder.copy_from" => "copiada des de AJXP_SOURCE_FOLDER",
43-
"folder.move" => "moguda des de AJXP_SOURCE_FOLDER",
44-
"folder.move_to" => "moguda a AJXP_TARGET_FOLDER",
45-
"folder.move_from" => "moguda des de AJXP_SOURCE_FOLDER",
46-
"ajxp_link" => "Faci click aquí per anar directament a <a href='AJXP_LINK'>AJXP_NODE_LABEL</a>",
47-
);
23+
"user_link" => "per",
24+
"file.add" => "creat",
25+
"file.delete" => "eliminat",
26+
"file.change" => "modificat",
27+
"file.rename" => "renombrat a AJXP_NODE_LABEL",
28+
"file.view" => "consultat",
29+
"file.copy" => "copiat a AJXP_PARENT_PATH",
30+
"file.copy_to" => "copiat a AJXP_TARGET_FOLDER",
31+
"file.copy_from" => "copiat des de AJXP_SOURCE_FOLDER",
32+
"file.move" => "mogut a AJXP_PARENT_PATH",
33+
"file.move_to" => "mogut a AJXP_TARGET_FOLDER",
34+
"file.move_from" => "mogut des de AJXP_SOURCE_FOLDER",
35+
"folder.add" => "creada",
36+
"folder.delete" => "eliminada",
37+
"folder.rename" => "renombrada a AJXP_NODE_LABEL",
38+
"folder.change" => "contingut modificat modificado",
39+
"folder.view" => "oberta",
40+
"folder.copy" => "copiada des de AJXP_SOURCE_FOLDER",
41+
"folder.copy_to" => "copiada a AJXP_TARGET_FOLDER",
42+
"folder.copy_from" => "copiada des de AJXP_SOURCE_FOLDER",
43+
"folder.move" => "moguda des de AJXP_SOURCE_FOLDER",
44+
"folder.move_to" => "moguda a AJXP_TARGET_FOLDER",
45+
"folder.move_from" => "moguda des de AJXP_SOURCE_FOLDER",
46+
"ajxp_link" => "Faci click aquí per anar directament a <a href='AJXP_LINK'>AJXP_NODE_LABEL</a>",
47+
"file.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
48+
"folder.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
49+
);
Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
<?php
2-
/*
3-
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
4-
* This file is part of Pydio.
5-
*
6-
* Pydio is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU Affero General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* Pydio is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU Affero General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU Affero General Public License
17-
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18-
*
19-
* The latest code can be found at <https://pydio.com>.
20-
*/
2+
/*
3+
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
4+
* This file is part of Pydio.
5+
*
6+
* Pydio is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Pydio is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* The latest code can be found at <https://pydio.com>.
20+
*/
2121
$mess=array(
22-
"user_link" => "von",
23-
"file.add" => "erstellt",
24-
"file.delete" => "gelöscht",
25-
"file.change" => "bearbeitet",
26-
"file.rename" => "zu AJXP_NODE_LABEL umbenannt",
27-
"file.view" => "consulted",
28-
"file.copy" => "nach AJXP_PARENT_PATH kopiert",
29-
"file.copy_to" => "in AJXP_TARGET_FOLDER kopiert ",
30-
"file.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
31-
"file.move" => "nach AJXP_PARENT_PATH verschoben",
32-
"file.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
33-
"file.move_from" => "aus AJXP_SOURCE_FOLDER verschoben",
34-
"folder.add" => "erstellt",
35-
"folder.delete" => "gelöscht",
36-
"folder.rename" => "zu AJXP_NODE_LABEL umbenannt",
37-
"folder.change" => "Inhalt modifiziert",
38-
"folder.view" => "geöffnet",
39-
"folder.copy" => "von AJXP_SOURCE_FOLDER kopiert",
40-
"folder.copy_to" => "nach AJXP_TARGET_FOLDER kopiert",
41-
"folder.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
42-
"folder.move" => "von AJXP_SOURCE_FOLDER verschoben",
43-
"folder.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
44-
"folder.move_from" => "von AJXP_SOURCE_FOLDER verschoben",
45-
"ajxp_link" => "Hier klicken um direkt zu <a href='AJXP_LINK'>AJXP_NODE_LABEL</a> gehen",
46-
);
22+
"user_link" => "von",
23+
"file.add" => "erstellt",
24+
"file.delete" => "gelöscht",
25+
"file.change" => "bearbeitet",
26+
"file.rename" => "zu AJXP_NODE_LABEL umbenannt",
27+
"file.view" => "consulted",
28+
"file.copy" => "nach AJXP_PARENT_PATH kopiert",
29+
"file.copy_to" => "in AJXP_TARGET_FOLDER kopiert ",
30+
"file.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
31+
"file.move" => "nach AJXP_PARENT_PATH verschoben",
32+
"file.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
33+
"file.move_from" => "aus AJXP_SOURCE_FOLDER verschoben",
34+
"folder.add" => "erstellt",
35+
"folder.delete" => "gelöscht",
36+
"folder.rename" => "zu AJXP_NODE_LABEL umbenannt",
37+
"folder.change" => "Inhalt modifiziert",
38+
"folder.view" => "geöffnet",
39+
"folder.copy" => "von AJXP_SOURCE_FOLDER kopiert",
40+
"folder.copy_to" => "nach AJXP_TARGET_FOLDER kopiert",
41+
"folder.copy_from" => "von AJXP_SOURCE_FOLDER kopiert",
42+
"folder.move" => "von AJXP_SOURCE_FOLDER verschoben",
43+
"folder.move_to" => "nach AJXP_TARGET_FOLDER verschoben",
44+
"folder.move_from" => "von AJXP_SOURCE_FOLDER verschoben",
45+
"ajxp_link" => "Hier klicken um direkt zu <a href='AJXP_LINK'>AJXP_NODE_LABEL</a> gehen",
46+
"file.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
47+
"folder.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
48+
);

core/src/plugins/core.notifications/templates/block/en.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
"folder.move" => "moved from AJXP_SOURCE_FOLDER",
4444
"folder.move_to" => "moved to AJXP_TARGET_FOLDER",
4545
"folder.move_from" => "moved from AJXP_SOURCE_FOLDER",
46+
"file.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
47+
"folder.share" => "User AJXP_USER shared AJXP_NODE_LABEL with you",
4648
"ajxp_link" => "Click here to get go directly to <a href='AJXP_LINK'>AJXP_NODE_LABEL</a>",
4749
);

0 commit comments

Comments
 (0)