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
582b679c
Unverified
Commit
582b679c
authored
5 years ago
by
Morris Jobke
Browse files
Options
Downloads
Patches
Plain Diff
Deprecate legacy share code and cleanup some unused methods
Signed-off-by:
Morris Jobke
<
hey@morrisjobke.de
>
parent
9f9b89fc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/private/Share/Share.php
+0
-74
0 additions, 74 deletions
lib/private/Share/Share.php
lib/public/Share.php
+11
-4
11 additions, 4 deletions
lib/public/Share.php
tests/lib/Share/ShareTest.php
+0
-14
0 additions, 14 deletions
tests/lib/Share/ShareTest.php
with
11 additions
and
92 deletions
lib/private/Share/Share.php
+
0
−
74
View file @
582b679c
...
@@ -256,49 +256,6 @@ class Share extends Constants {
...
@@ -256,49 +256,6 @@ class Share extends Constants {
$parameters
,
1
,
$includeCollections
,
true
);
$parameters
,
1
,
$includeCollections
,
true
);
}
}
/**
* Based on the given token the share information will be returned - password protected shares will be verified
* @param string $token
* @param bool $checkPasswordProtection
* @return array|boolean false will be returned in case the token is unknown or unauthorized
*/
public
static
function
getShareByToken
(
$token
,
$checkPasswordProtection
=
true
)
{
$query
=
\OC_DB
::
prepare
(
'SELECT * FROM `*PREFIX*share` WHERE `token` = ?'
,
1
);
$result
=
$query
->
execute
(
array
(
$token
));
if
(
$result
===
false
)
{
\OCP\Util
::
writeLog
(
'OCP\Share'
,
\OC_DB
::
getErrorMessage
()
.
', token='
.
$token
,
ILogger
::
ERROR
);
}
$row
=
$result
->
fetchRow
();
if
(
$row
===
false
)
{
return
false
;
}
if
(
is_array
(
$row
)
and
self
::
expireItem
(
$row
))
{
return
false
;
}
// password protected shares need to be authenticated
if
(
$checkPasswordProtection
&&
!
\OC\Share\Share
::
checkPasswordProtectedShare
(
$row
))
{
return
false
;
}
return
$row
;
}
/**
* Get the shared items of item type owned by the current user
* @param string $itemType
* @param int $format (optional) Format type must be defined by the backend
* @param mixed $parameters
* @param int $limit Number of items to return (optional) Returns all by default
* @param boolean $includeCollections
* @return mixed Return depends on format
*/
public
static
function
getItemsShared
(
$itemType
,
$format
=
self
::
FORMAT_NONE
,
$parameters
=
null
,
$limit
=
-
1
,
$includeCollections
=
false
)
{
return
self
::
getItems
(
$itemType
,
null
,
null
,
null
,
\OC_User
::
getUser
(),
$format
,
$parameters
,
$limit
,
$includeCollections
);
}
/**
/**
* Get the shared item of item type owned by the current user
* Get the shared item of item type owned by the current user
* @param string $itemType
* @param string $itemType
...
@@ -420,29 +377,6 @@ class Share extends Constants {
...
@@ -420,29 +377,6 @@ class Share extends Constants {
return
false
;
return
false
;
}
}
/**
* sent status if users got informed by mail about share
* @param string $itemType
* @param string $itemSource
* @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
* @param string $recipient with whom was the file shared
* @param boolean $status
*/
public
static
function
setSendMailStatus
(
$itemType
,
$itemSource
,
$shareType
,
$recipient
,
$status
)
{
$status
=
$status
?
1
:
0
;
$query
=
\OC_DB
::
prepare
(
'UPDATE `*PREFIX*share`
SET `mail_send` = ?
WHERE `item_type` = ? AND `item_source` = ? AND `share_type` = ? AND `share_with` = ?'
);
$result
=
$query
->
execute
(
array
(
$status
,
$itemType
,
$itemSource
,
$shareType
,
$recipient
));
if
(
$result
===
false
)
{
\OCP\Util
::
writeLog
(
'OCP\Share'
,
'Couldn\'t set send mail status'
,
ILogger
::
ERROR
);
}
}
/**
/**
* Checks whether a share has expired, calls unshareItem() if yes.
* Checks whether a share has expired, calls unshareItem() if yes.
* @param array $item Share data (usually database row)
* @param array $item Share data (usually database row)
...
@@ -1616,14 +1550,6 @@ class Share extends Constants {
...
@@ -1616,14 +1550,6 @@ class Share extends Constants {
return
(
$result
[
'success'
]
&&
(
$status
[
'ocs'
][
'meta'
][
'statuscode'
]
===
100
||
$status
[
'ocs'
][
'meta'
][
'statuscode'
]
===
200
));
return
(
$result
[
'success'
]
&&
(
$status
[
'ocs'
][
'meta'
][
'statuscode'
]
===
100
||
$status
[
'ocs'
][
'meta'
][
'statuscode'
]
===
200
));
}
}
/**
* @return bool
*/
public
static
function
isDefaultExpireDateEnabled
()
{
$defaultExpireDateEnabled
=
\OC
::
$server
->
getConfig
()
->
getAppValue
(
'core'
,
'shareapi_default_expire_date'
,
'no'
);
return
$defaultExpireDateEnabled
===
'yes'
;
}
/**
/**
* @return int
* @return int
*/
*/
...
...
This diff is collapsed.
Click to expand it.
lib/public/Share.php
+
11
−
4
View file @
582b679c
...
@@ -43,6 +43,7 @@ namespace OCP;
...
@@ -43,6 +43,7 @@ namespace OCP;
* It provides the following hooks:
* It provides the following hooks:
* - post_shared
* - post_shared
* @since 5.0.0
* @since 5.0.0
* @deprecated 17.0.0
*/
*/
class
Share
extends
\OC\Share\Constants
{
class
Share
extends
\OC\Share\Constants
{
...
@@ -54,6 +55,7 @@ class Share extends \OC\Share\Constants {
...
@@ -54,6 +55,7 @@ class Share extends \OC\Share\Constants {
* @param string $owner Owner of the share
* @param string $owner Owner of the share
* @return array Return list of items with file_target, permissions and expiration
* @return array Return list of items with file_target, permissions and expiration
* @since 6.0.0 - parameter $owner was added in 8.0.0
* @since 6.0.0 - parameter $owner was added in 8.0.0
* @deprecated 17.0.0
*/
*/
public
static
function
getItemSharedWithUser
(
$itemType
,
$itemSource
,
$user
,
$owner
=
null
)
{
public
static
function
getItemSharedWithUser
(
$itemType
,
$itemSource
,
$user
,
$owner
=
null
)
{
return
\OC\Share\Share
::
getItemSharedWithUser
(
$itemType
,
$itemSource
,
$user
,
$owner
);
return
\OC\Share\Share
::
getItemSharedWithUser
(
$itemType
,
$itemSource
,
$user
,
$owner
);
...
@@ -68,10 +70,11 @@ class Share extends \OC\Share\Constants {
...
@@ -68,10 +70,11 @@ class Share extends \OC\Share\Constants {
* @param bool $includeCollections
* @param bool $includeCollections
* @return array
* @return array
* @since 5.0.0
* @since 5.0.0
* @deprecated 17.0.0
*/
*/
public
static
function
getItemSharedWithBySource
(
$itemType
,
$itemSource
,
$format
=
self
::
FORMAT_NONE
,
public
static
function
getItemSharedWithBySource
(
$itemType
,
$itemSource
,
$format
=
self
::
FORMAT_NONE
,
$parameters
=
null
,
$includeCollections
=
false
)
{
$parameters
=
null
,
$includeCollections
=
false
)
{
return
\OC\Share\Share
::
getItemSharedWithBySource
(
$itemType
,
$itemSource
,
$format
,
$parameters
,
$includeCollections
);
// not used by any app - only here to not break apps syntax
}
}
/**
/**
...
@@ -80,9 +83,10 @@ class Share extends \OC\Share\Constants {
...
@@ -80,9 +83,10 @@ class Share extends \OC\Share\Constants {
* @param bool $checkPasswordProtection
* @param bool $checkPasswordProtection
* @return array|bool false will be returned in case the token is unknown or unauthorized
* @return array|bool false will be returned in case the token is unknown or unauthorized
* @since 5.0.0 - parameter $checkPasswordProtection was added in 7.0.0
* @since 5.0.0 - parameter $checkPasswordProtection was added in 7.0.0
* @deprecated 17.0.0
*/
*/
public
static
function
getShareByToken
(
$token
,
$checkPasswordProtection
=
true
)
{
public
static
function
getShareByToken
(
$token
,
$checkPasswordProtection
=
true
)
{
return
\OC\Share\Share
::
getShareByToken
(
$token
,
$checkPasswordProtection
);
// not used by any app - only here to not break apps syntax
}
}
...
@@ -95,11 +99,12 @@ class Share extends \OC\Share\Constants {
...
@@ -95,11 +99,12 @@ class Share extends \OC\Share\Constants {
* @param bool $includeCollections
* @param bool $includeCollections
* @return mixed Return depends on format
* @return mixed Return depends on format
* @since 5.0.0
* @since 5.0.0
* @deprecated 17.0.0
*/
*/
public
static
function
getItemsShared
(
$itemType
,
$format
=
self
::
FORMAT_NONE
,
$parameters
=
null
,
public
static
function
getItemsShared
(
$itemType
,
$format
=
self
::
FORMAT_NONE
,
$parameters
=
null
,
$limit
=
-
1
,
$includeCollections
=
false
)
{
$limit
=
-
1
,
$includeCollections
=
false
)
{
return
\OC\Share\Share
::
getItemsShared
(
$itemType
,
$format
,
$parameters
,
$limit
,
$includeCollections
);
// only used by AppVNCSafe app (https://github.com/vnc-biz/nextcloud-appvncsafe/issues/2) - only here to not break apps syntax
}
}
/**
/**
...
@@ -111,6 +116,7 @@ class Share extends \OC\Share\Constants {
...
@@ -111,6 +116,7 @@ class Share extends \OC\Share\Constants {
* @param bool $includeCollections
* @param bool $includeCollections
* @return mixed Return depends on format
* @return mixed Return depends on format
* @since 5.0.0
* @since 5.0.0
* @deprecated 17.0.0
*/
*/
public
static
function
getItemShared
(
$itemType
,
$itemSource
,
$format
=
self
::
FORMAT_NONE
,
public
static
function
getItemShared
(
$itemType
,
$itemSource
,
$format
=
self
::
FORMAT_NONE
,
$parameters
=
null
,
$includeCollections
=
false
)
{
$parameters
=
null
,
$includeCollections
=
false
)
{
...
@@ -126,8 +132,9 @@ class Share extends \OC\Share\Constants {
...
@@ -126,8 +132,9 @@ class Share extends \OC\Share\Constants {
* @param string $recipient with whom was the item shared
* @param string $recipient with whom was the item shared
* @param bool $status
* @param bool $status
* @since 6.0.0 - parameter $originIsSource was added in 8.0.0
* @since 6.0.0 - parameter $originIsSource was added in 8.0.0
* @deprecated 17.0.0
*/
*/
public
static
function
setSendMailStatus
(
$itemType
,
$itemSource
,
$shareType
,
$recipient
,
$status
)
{
public
static
function
setSendMailStatus
(
$itemType
,
$itemSource
,
$shareType
,
$recipient
,
$status
)
{
return
\OC\Share\Share
::
setSendMailStatus
(
$itemType
,
$itemSource
,
$shareType
,
$recipient
,
$status
);
// not used by any app - only here to not break apps syntax
}
}
}
}
This diff is collapsed.
Click to expand it.
tests/lib/Share/ShareTest.php
+
0
−
14
View file @
582b679c
...
@@ -134,20 +134,6 @@ class ShareTest extends \Test\TestCase {
...
@@ -134,20 +134,6 @@ class ShareTest extends \Test\TestCase {
parent
::
tearDown
();
parent
::
tearDown
();
}
}
/**
* @param boolean|string $token
* @return array
*/
protected
function
getShareByValidToken
(
$token
)
{
$row
=
\OCP\Share
::
getShareByToken
(
$token
);
$this
->
assertInternalType
(
'array'
,
$row
,
"Failed asserting that a share for token
$token
exists."
);
return
$row
;
}
public
function
testGetItemSharedWithUser
()
{
public
function
testGetItemSharedWithUser
()
{
\OC_User
::
setUserId
(
$this
->
user1
->
getUID
());
\OC_User
::
setUserId
(
$this
->
user1
->
getUID
());
...
...
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