Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
960d89ae
Unverified
Commit
960d89ae
authored
5 years ago
by
Roeland Jago Douma
Browse files
Options
Downloads
Patches
Plain Diff
Listen to the right even for auto share accept
Signed-off-by:
Roeland Jago Douma
<
roeland@famdouma.nl
>
parent
3d03d820
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
+30
-9
30 additions, 9 deletions
...iles_sharing/lib/Listener/UserShareAcceptanceListener.php
with
30 additions
and
9 deletions
apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
+
30
−
9
View file @
960d89ae
...
...
@@ -29,8 +29,10 @@ namespace OCA\Files_Sharing\Listener;
use
OCP\EventDispatcher\Event
;
use
OCP\EventDispatcher\IEventListener
;
use
OCP\IConfig
;
use
OCP\Share\Events\SharedEvent
;
use
OCP\IGroupManager
;
use
OCP\Share\Events\ShareCreatedEvent
;
use
OCP\Share\IManager
;
use
OCP\Share\IShare
;
class
UserShareAcceptanceListener
implements
IEventListener
{
...
...
@@ -38,23 +40,42 @@ class UserShareAcceptanceListener implements IEventListener {
private
$config
;
/** @var IManager */
private
$shareManager
;
/** @var
string
*/
private
$
userId
;
/** @var
IGroupManager
*/
private
$
groupManager
;
public
function
__construct
(
IConfig
$config
,
IManager
$shareManager
,
string
$userId
)
{
public
function
__construct
(
IConfig
$config
,
IManager
$shareManager
,
IGroupManager
$groupManager
)
{
$this
->
config
=
$config
;
$this
->
shareManager
=
$shareManager
;
$this
->
userId
=
$userId
;
$this
->
groupManager
=
$groupManager
;
}
public
function
handle
(
Event
$event
):
void
{
if
(
!
(
$event
instanceof
SharedEvent
))
{
if
(
!
(
$event
instanceof
Share
Create
dEvent
))
{
return
;
}
if
(
$this
->
config
->
getUserValue
(
$this
->
userId
,
'files_sharing'
,
'default_accept'
,
'no'
)
===
'yes'
)
{
$share
=
$event
->
getShare
();
$this
->
shareManager
->
acceptShare
(
$share
,
$this
->
userId
);
$share
=
$event
->
getShare
();
if
(
$share
->
getShareType
()
===
IShare
::
TYPE_USER
)
{
$this
->
handleAutoAccept
(
$share
,
$share
->
getSharedWith
());
}
else
if
(
$share
->
getShareType
()
===
IShare
::
TYPE_GROUP
)
{
$group
=
$this
->
groupManager
->
get
(
$share
->
getSharedWith
());
if
(
$group
===
null
)
{
return
;
}
$users
=
$group
->
getUsers
();
foreach
(
$users
as
$user
)
{
$this
->
handleAutoAccept
(
$share
,
$user
->
getUID
());
}
}
}
private
function
handleAutoAccept
(
IShare
$share
,
string
$userId
)
{
if
(
$this
->
config
->
getUserValue
(
$userId
,
'files_sharing'
,
'default_accept'
,
'no'
)
===
'yes'
)
{
$this
->
shareManager
->
acceptShare
(
$share
,
$userId
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment