[Pkg-owncloud-commits] [owncloud] 11/55: we need the file_source to delete a share successfully
David Prévot
taffit at moszumanska.debian.org
Wed Apr 23 19:51:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v5.0.16RC1
in repository owncloud.
commit 53d36e6c43e2c256321aba15248c689aa7956331
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
Conflicts:
apps/files_sharing/tests/api.php
---
apps/files_sharing/lib/api.php | 13 ++++++-------
apps/files_sharing/tests/api.php | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 64ae6bd..1f74ccc 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;
@@ -283,9 +283,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.");
}
@@ -437,10 +436,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.");
}
@@ -454,7 +453,7 @@ class Api {
try {
$return = \OCP\Share::unshare(
$itemType,
- $itemSource,
+ $fileSource,
$shareType,
$shareWith);
} catch (\Exception $e) {
@@ -510,7 +509,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 44fc4d8..d4a5113 100644
--- a/apps/files_sharing/tests/api.php
+++ b/apps/files_sharing/tests/api.php
@@ -550,6 +550,7 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
}
/**
+<<<<<<< HEAD
* @param $user
* @param bool $create
* @param bool $password
@@ -594,4 +595,39 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase {
}
+
+ /**
+ * @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