[Pkg-owncloud-commits] [owncloud] 24/129: When sharing with the owner show the path
David Prévot
taffit at moszumanska.debian.org
Thu Nov 5 01:04:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit 206eb293319316df9e44da1f2dc52475e5da3bcc
Author: Roeland Jago Douma <rullzer at owncloud.com>
Date: Fri Oct 16 09:27:02 2015 +0200
When sharing with the owner show the path
The error message should contain the path that is being shared not the
numeric id.
---
lib/private/share/share.php | 5 ++++-
tests/lib/share/share.php | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index c64bb31..15a5cb8 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -619,10 +619,13 @@ class Share extends Constants {
if (is_null($itemSourceName)) {
$itemSourceName = $itemSource;
}
+ $itemName = $itemSourceName;
// check if file can be shared
if ($itemType === 'file' or $itemType === 'folder') {
$path = \OC\Files\Filesystem::getPath($itemSource);
+ $itemName = $path;
+
// verify that the file exists before we try to share it
if (!$path) {
$message = 'Sharing %s failed, because the file does not exist';
@@ -678,7 +681,7 @@ class Share extends Constants {
if ($shareType === self::SHARE_TYPE_USER) {
if ($shareWith == $uidOwner) {
$message = 'Sharing %s failed, because the user %s is the item owner';
- $message_t = $l->t('Sharing %s failed, because the user %s is the item owner', array($itemSourceName, $shareWith));
+ $message_t = $l->t('Sharing %s failed, because the user %s is the item owner', array($itemName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
throw new \Exception($message_t);
}
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index 4cb0577..e6f4809 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -1679,6 +1679,30 @@ class Test_Share extends \Test\TestCase {
$config->deleteAppValue('core', 'shareapi_default_expire_date');
$config->deleteAppValue('core', 'shareapi_expire_after_n_days');
}
+
+ public function testShareWithOwnerError() {
+ OC_User::setUserId($this->user1);
+ $view = new \OC\Files\View('/' . $this->user1 . '/');
+ $view->mkdir('files/folder1');
+
+ $fileInfo = $view->getFileInfo('files/folder1');
+ $this->assertInstanceOf('\OC\Files\FileInfo', $fileInfo);
+ $fileId = $fileInfo->getId();
+
+ $this->assertTrue(
+ OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL),
+ 'Failed asserting that user 1 successfully shared "test" with user 2.'
+ );
+
+ OC_User::setUserId($this->user1);
+
+ try {
+ OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
+ $this->fail();
+ } catch (\Exception $e) {
+ $this->assertEquals('Sharing /folder1 failed, because the user ' . $this->user1 . ' is the item owner', $e->getMessage());
+ }
+ }
}
class DummyShareClass extends \OC\Share\Share {
--
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