You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/files_sharing/lib/Listener/RestrictInteractionListener.php
+34-30Lines changed: 34 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -45,43 +45,47 @@ public function __construct(
45
45
*/
46
46
#[\Override]
47
47
publicfunctionhandle(Event$event): void {
48
-
if ($event->resourceinstanceof NodeResource && $event->actioninstanceof ShareAction) {
49
-
if (!$event->resource->getNode()->isShareable()) {
50
-
thrownewInteractionRestrictedException('Node is not shareable.', $this->l10n->t('You are not allowed to share "%s".', [$event->resource->getNode()->getName()]));
51
-
}
48
+
foreach ($event->resourcesas$resource) {
49
+
if ($resourceinstanceof NodeResource && $event->actioninstanceof ShareAction) {
50
+
if (!$resource->getNode()->isShareable()) {
51
+
thrownewInteractionRestrictedException('Node is not shareable.', $this->l10n->t('You are not allowed to share "%s".', [$resource->getNode()->getName()]));
thrownewInteractionRestrictedException('Cannot share home folder node.', $this->l10n->t('You cannot share your home folder.'));
57
+
}
57
58
58
-
if ($event->action->filesSharingPermissions !== null) {
59
-
if ($event->resource->getNode() instanceof File) {
60
-
if (($event->action->filesSharingPermissions & Constants::PERMISSION_DELETE) === Constants::PERMISSION_DELETE) {
61
-
thrownewInteractionRestrictedException('Cannot share file node with delete permission.', $this->l10n->t('File cannot be shared with delete permission.'));
62
-
}
59
+
if ($event->action->filesSharingPermissions !== null) {
60
+
if ($resource->getNode() instanceof File) {
61
+
if (($event->action->filesSharingPermissions & Constants::PERMISSION_DELETE) === Constants::PERMISSION_DELETE) {
62
+
thrownewInteractionRestrictedException('Cannot share file node with delete permission.', $this->l10n->t('File cannot be shared with delete permission.'));
63
+
}
63
64
64
-
if (($event->action->filesSharingPermissions & Constants::PERMISSION_CREATE) === Constants::PERMISSION_CREATE) {
65
-
thrownewInteractionRestrictedException('Cannot share file node with create permission.', $this->l10n->t('File cannot be shared with create permission.'));
65
+
if (($event->action->filesSharingPermissions & Constants::PERMISSION_CREATE) === Constants::PERMISSION_CREATE) {
66
+
thrownewInteractionRestrictedException('Cannot share file node with create permission.', $this->l10n->t('File cannot be shared with create permission.'));
thrownewInteractionRestrictedException('Cannot share node with more permissions than the node already has.', $this->l10n->t('You cannot share "%s" with more permission than you have yourself.', [$path]));
85
+
if (($event->action->filesSharingPermissions & ~$resource->getNodePermissions()) !== 0) {
thrownewInteractionRestrictedException('Cannot share node with more permissions than the node already has.', $this->l10n->t('You cannot share "%s" with more permission than you have yourself.', [$path]));
thrownewInteractionRestrictedException('Sharing is only allowed with group members.', $this->l10n->t('Sharing is only allowed with group members.'));
69
+
}
70
+
}
65
71
66
-
if ($groups === []) {
67
-
thrownewInteractionRestrictedException('Sharing is only allowed with group members.', $this->l10n->t('Sharing is only allowed with group members.'));
72
+
if ($receiverinstanceof GroupReceiver && (!$receiver->getGroup()->inGroup($event->getUser()) || in_array($receiver->getGroup()->getGID(), $this->manager->shareWithGroupMembersOnlyExcludeGroupsList(), true))) {
73
+
thrownewInteractionRestrictedException('Sharing is only allowed to the groups the user is a member of.', $this->l10n->t('Sharing is only allowed within your own groups.'));
68
74
}
69
75
}
70
76
71
-
if ($event->receiverinstanceof GroupReceiver && (!$event->receiver->getGroup()->inGroup($event->getUser()) || in_array($event->receiver->getGroup()->getGID(), $this->manager->shareWithGroupMembersOnlyExcludeGroupsList(), true))) {
72
-
thrownewInteractionRestrictedException('Sharing is only allowed to the groups the user is a member of.', $this->l10n->t('Sharing is only allowed within your own groups.'));
77
+
if ($receiverinstanceof GroupReceiver && !$this->manager->allowGroupSharing()) {
78
+
thrownewInteractionRestrictedException('Group sharing is not allowed.', $this->l10n->t('Group sharing is not allowed.'));
73
79
}
74
-
}
75
-
76
-
if ($event->receiverinstanceof GroupReceiver && !$this->manager->allowGroupSharing()) {
77
-
thrownewInteractionRestrictedException('Group sharing is not allowed.', $this->l10n->t('Group sharing is not allowed.'));
78
-
}
79
80
80
-
if (($event->receiverinstanceof LinkReceiver || $event->receiverinstanceof EmailReceiver) && !$this->manager->shareApiAllowLinks($event->getUser())) {
81
-
thrownewInteractionRestrictedException('Public link sharing is not allowed.', $this->l10n->t('Public link sharing is not allowed.'));
82
-
}
81
+
if (($receiverinstanceof LinkReceiver || $receiverinstanceof EmailReceiver) && !$this->manager->shareApiAllowLinks($event->getUser())) {
82
+
thrownewInteractionRestrictedException('Public link sharing is not allowed.', $this->l10n->t('Public link sharing is not allowed.'));
83
+
}
83
84
84
-
if ($event->receiverinstanceof RemoteUserReceiver && !$this->manager->outgoingServer2ServerSharesAllowed()) {
85
-
thrownewInteractionRestrictedException('Sharing to remote users is not allowed.', $this->l10n->t('Sharing to remote users is not allowed.'));
86
-
}
85
+
if ($receiverinstanceof RemoteUserReceiver && !$this->manager->outgoingServer2ServerSharesAllowed()) {
86
+
thrownewInteractionRestrictedException('Sharing to remote users is not allowed.', $this->l10n->t('Sharing to remote users is not allowed.'));
87
+
}
87
88
88
-
if ($event->receiverinstanceof RemoteGroupReceiver && !$this->manager->outgoingServer2ServerGroupSharesAllowed()) {
89
-
thrownewInteractionRestrictedException('Sharing to remote groups is not allowed.', $this->l10n->t('Sharing to remote groups is not allowed.'));
89
+
if ($receiverinstanceof RemoteGroupReceiver && !$this->manager->outgoingServer2ServerGroupSharesAllowed()) {
90
+
thrownewInteractionRestrictedException('Sharing to remote groups is not allowed.', $this->l10n->t('Sharing to remote groups is not allowed.'));
0 commit comments