[Pkg-owncloud-commits] [owncloud] 35/134: we need the file_source to delete a share successfully
David Prévot
taffit at moszumanska.debian.org
Fri Apr 18 21:43:58 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 0f40acb9a8a26d0d13a9c2c7100655648147f2bb
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Mon Mar 10 11:16:09 2014 +0100
we need the file_source to delete a share successfully
---
apps/files_sharing/lib/api.php | 13 ++++++-------
apps/files_sharing/tests/api.php | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 7a3e25e..370640b 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -68,7 +68,7 @@ class Api {
public static function getShare($params) {
$s = self::getShareFromId($params['id']);
- $params['itemSource'] = $s['item_source'];
+ $params['itemSource'] = $s['file_source'];
$params['itemType'] = $s['item_type'];
$params['specificShare'] = true;
@@ -281,9 +281,8 @@ class Api {
public static function updateShare($params) {
$share = self::getShareFromId($params['id']);
- $itemSource = isset($share['item_source']) ? $share['item_source'] : null;
- if($itemSource === null) {
+ if(!isset($share['file_source'])) {
return new \OC_OCS_Result(null, 404, "wrong share Id, share doesn't exist.");
}
@@ -431,10 +430,10 @@ class Api {
public static function deleteShare($params) {
$share = self::getShareFromId($params['id']);
- $itemSource = isset($share['item_source']) ? $share['item_source'] : null;
+ $fileSource = isset($share['file_source']) ? $share['file_source'] : null;
$itemType = isset($share['item_type']) ? $share['item_type'] : null;;
- if($itemSource === null) {
+ if($fileSource === null) {
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
}
@@ -448,7 +447,7 @@ class Api {
try {
$return = \OCP\Share::unshare(
$itemType,
- $itemSource,
+ $fileSource,
$shareType,
$shareWith);
} catch (\Exception $e) {
@@ -504,7 +503,7 @@ class Api {
* @return array with: item_source, share_type, share_with, item_type, permissions
*/
private static function getShareFromId($shareID) {
- $sql = 'SELECT `item_source`, `share_type`, `share_with`, `item_type`, `permissions` FROM `*PREFIX*share` WHERE `id` = ?';
+ $sql = 'SELECT `file_source`, `item_source`, `share_type`, `share_with`, `item_type`, `permissions` FROM `*PREFIX*share` WHERE `id` = ?';
$args = array($shareID);
$query = \OCP\DB::prepare($sql);
$result = $query->execute($args);
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php
index 0d3d9b9..073e2dd 100644
--- a/apps/files_sharing/tests/api.php
+++ b/apps/files_sharing/tests/api.php
@@ -559,4 +559,38 @@ class Test_Files_Sharing_Api extends Test_Files_Sharing_Base {
$this->assertTrue(empty($itemsAfterDelete));
}
+
+ /**
+ * @brief test unshare of a reshared file
+ */
+ function testDeleteReshare() {
+
+ // user 1 shares a folder with user2
+ \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
+
+ $fileInfo1 = $this->view->getFileInfo($this->folder);
+ $fileInfo2 = $this->view->getFileInfo($this->folder.'/'.$this->filename);
+
+ $result1 = \OCP\Share::shareItem('folder', $fileInfo1['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
+
+ $this->assertTrue($result1);
+
+ // user2 shares a file from the folder as link
+ \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+
+ $result2 = \OCP\Share::shareItem('file', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_LINK, null, 1);
+
+ $this->assertTrue(is_string($result2));
+
+ // test if we can unshare the link again
+ $items = \OCP\Share::getItemShared('file', null);
+ $this->assertEquals(1, count($items));
+
+ $item = reset($items);
+ $result3 = Share\Api::deleteShare(array('id' => $item['id']));
+
+ $this->assertTrue($result3->succeeded());
+
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list