Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
f82fb0e1
Commit
f82fb0e1
authored
May 7, 2013
by
Florin Peter
Browse files
Options
Downloads
Plain Diff
Merge branch 'files_encryption' of
https://github.com/owncloud/core
into files_encryption
parents
cdf4bec6
763c8f78
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/files_encryption/hooks/hooks.php
+171
-132
171 additions, 132 deletions
apps/files_encryption/hooks/hooks.php
with
171 additions
and
132 deletions
apps/files_encryption/hooks/hooks.php
+
171
−
132
View file @
f82fb0e1
...
@@ -202,6 +202,7 @@ class Hooks {
...
@@ -202,6 +202,7 @@ class Hooks {
// [id] => 10
// [id] => 10
// [token] =>
// [token] =>
// TODO: Should other kinds of item be encrypted too?
// TODO: Should other kinds of item be encrypted too?
if
(
$params
[
'itemType'
]
===
'file'
||
$params
[
'itemType'
]
===
'folder'
)
{
if
(
$params
[
'itemType'
]
===
'file'
||
$params
[
'itemType'
]
===
'folder'
)
{
$view
=
new
\OC_FilesystemView
(
'/'
);
$view
=
new
\OC_FilesystemView
(
'/'
);
...
@@ -223,13 +224,19 @@ class Hooks {
...
@@ -223,13 +224,19 @@ class Hooks {
$path
=
'/Shared'
.
$parent
[
'file_target'
];
$path
=
'/Shared'
.
$parent
[
'file_target'
];
}
else
{
}
else
{
// parent is folder but shared was a file!
// NOTE: parent is folder but shared was a file!
// we try to rebuild the missing path
// we try to rebuild the missing path
// some examples we face here
// some examples we face here
// user1 share folder1 with user2 folder1 has the following structure /folder1/subfolder1/subsubfolder1/somefile.txt
// user1 share folder1 with user2 folder1 has
// the following structure
// /folder1/subfolder1/subsubfolder1/somefile.txt
// user2 re-share subfolder2 with user3
// user2 re-share subfolder2 with user3
// user3 re-share somefile.txt user4
// user3 re-share somefile.txt user4
// so our path should be /Shared/subfolder1/subsubfolder1/somefile.txt while user3 is sharing
// so our path should be
// /Shared/subfolder1/subsubfolder1/somefile.txt
// while user3 is sharing
if
(
$params
[
'itemType'
]
===
'file'
)
{
if
(
$params
[
'itemType'
]
===
'file'
)
{
// get target path
// get target path
$targetPath
=
$util
->
fileIdToPath
(
$params
[
'fileSource'
]
);
$targetPath
=
$util
->
fileIdToPath
(
$params
[
'fileSource'
]
);
...
@@ -241,11 +248,17 @@ class Hooks {
...
@@ -241,11 +248,17 @@ class Hooks {
// rebuild path
// rebuild path
foreach
(
$targetPathSplit
as
$pathPart
)
{
foreach
(
$targetPathSplit
as
$pathPart
)
{
if
(
$pathPart
!==
$sharedPart
)
{
if
(
$pathPart
!==
$sharedPart
)
{
$path
=
'/'
.
$pathPart
.
$path
;
$path
=
'/'
.
$pathPart
.
$path
;
}
else
{
}
else
{
break
;
break
;
}
}
}
}
// prefix path with Shared
// prefix path with Shared
...
@@ -265,10 +278,13 @@ class Hooks {
...
@@ -265,10 +278,13 @@ class Hooks {
if
(
$params
[
'itemType'
]
===
'folder'
)
{
if
(
$params
[
'itemType'
]
===
'folder'
)
{
$allFiles
=
$util
->
getAllFiles
(
$path
);
$allFiles
=
$util
->
getAllFiles
(
$path
);
}
else
{
}
else
{
$allFiles
=
array
(
$path
);
$allFiles
=
array
(
$path
);
}
}
foreach
(
$allFiles
as
$path
)
{
foreach
(
$allFiles
as
$path
)
{
$usersSharing
=
$util
->
getSharingUsersArray
(
$sharingEnabled
,
$path
);
$usersSharing
=
$util
->
getSharingUsersArray
(
$sharingEnabled
,
$path
);
$failed
=
array
();
$failed
=
array
();
...
@@ -282,9 +298,13 @@ class Hooks {
...
@@ -282,9 +298,13 @@ class Hooks {
// If no attempts to set keyfiles failed
// If no attempts to set keyfiles failed
if
(
empty
(
$failed
)
)
{
if
(
empty
(
$failed
)
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
}
}
}
}
...
@@ -292,8 +312,7 @@ class Hooks {
...
@@ -292,8 +312,7 @@ class Hooks {
/**
/**
* @brief
* @brief
*/
*/
public
static
function
postUnshare
(
$params
)
public
static
function
postUnshare
(
$params
)
{
{
// NOTE: $params has keys:
// NOTE: $params has keys:
// [itemType] => file
// [itemType] => file
...
@@ -325,11 +344,17 @@ class Hooks {
...
@@ -325,11 +344,17 @@ class Hooks {
// rebuild path
// rebuild path
foreach
(
$targetPathSplit
as
$pathPart
)
{
foreach
(
$targetPathSplit
as
$pathPart
)
{
if
(
$pathPart
!==
$sharedPart
)
{
if
(
$pathPart
!==
$sharedPart
)
{
$path
=
'/'
.
$pathPart
.
$path
;
$path
=
'/'
.
$pathPart
.
$path
;
}
else
{
}
else
{
break
;
break
;
}
}
}
}
// prefix path with Shared
// prefix path with Shared
...
@@ -338,15 +363,22 @@ class Hooks {
...
@@ -338,15 +363,22 @@ class Hooks {
// for group shares get a list of the group members
// for group shares get a list of the group members
if
(
$params
[
'shareType'
]
==
\OCP\Share
::
SHARE_TYPE_GROUP
)
{
if
(
$params
[
'shareType'
]
==
\OCP\Share
::
SHARE_TYPE_GROUP
)
{
$userIds
=
\OC_Group
::
usersInGroup
(
$params
[
'shareWith'
]);
$userIds
=
\OC_Group
::
usersInGroup
(
$params
[
'shareWith'
]);
}
else
{
}
else
{
$userIds
=
array
(
$params
[
'shareWith'
]
);
$userIds
=
array
(
$params
[
'shareWith'
]
);
}
}
// if we unshare a folder we need a list of all (sub-)files
// if we unshare a folder we need a list of all (sub-)files
if
(
$params
[
'itemType'
]
===
'folder'
)
{
if
(
$params
[
'itemType'
]
===
'folder'
)
{
$allFiles
=
$util
->
getAllFiles
(
$path
);
$allFiles
=
$util
->
getAllFiles
(
$path
);
}
else
{
}
else
{
$allFiles
=
array
(
$path
);
$allFiles
=
array
(
$path
);
}
}
...
@@ -357,17 +389,24 @@ class Hooks {
...
@@ -357,17 +389,24 @@ class Hooks {
// Unshare every user who no longer has access to the file
// Unshare every user who no longer has access to the file
$delUsers
=
array_diff
(
$userIds
,
$sharingUsers
);
$delUsers
=
array_diff
(
$userIds
,
$sharingUsers
);
if
(
!
Keymanager
::
delShareKey
(
$view
,
$delUsers
,
$path
)
)
{
if
(
!
Keymanager
::
delShareKey
(
$view
,
$delUsers
,
$path
)
)
{
$failed
[]
=
$path
;
$failed
[]
=
$path
;
}
}
}
}
// If no attempts to set keyfiles failed
// If no attempts to set keyfiles failed
if
(
empty
(
$failed
)
)
{
if
(
empty
(
$failed
)
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
}
}
}
}
...
...
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