diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-06-11 15:34:43 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2016-06-11 15:34:43 +0200 |
commit | 42c66efea5ef512d3a3442112f820168e6499265 (patch) | |
tree | 97ef44632d653656608e71e096fd537bbd609936 /apps/files_sharing | |
parent | 75f37f550bb7895757325d3f9a3215bcc4471065 (diff) | |
parent | 52a0c939ab8674857bbfe9a9fb0ee7308eee960e (diff) | |
download | nextcloud-server-42c66efea5ef512d3a3442112f820168e6499265.tar.gz nextcloud-server-42c66efea5ef512d3a3442112f820168e6499265.zip |
Merge branch 'master' of https://github.com/owncloud/core into downstream-160611
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/l10n/pl.js | 3 | ||||
-rw-r--r-- | apps/files_sharing/l10n/pl.json | 3 | ||||
-rw-r--r-- | apps/files_sharing/l10n/ro.js | 22 | ||||
-rw-r--r-- | apps/files_sharing/l10n/ro.json | 22 | ||||
-rw-r--r-- | apps/files_sharing/lib/API/Share20OCS.php | 24 | ||||
-rw-r--r-- | apps/files_sharing/tests/API/Share20OCSTest.php | 21 | ||||
-rw-r--r-- | apps/files_sharing/tests/ApiTest.php | 41 |
7 files changed, 113 insertions, 23 deletions
diff --git a/apps/files_sharing/l10n/pl.js b/apps/files_sharing/l10n/pl.js index ebdfe2aa738..e1bec669533 100644 --- a/apps/files_sharing/l10n/pl.js +++ b/apps/files_sharing/l10n/pl.js @@ -25,6 +25,9 @@ OC.L10N.register( "Invalid ownCloud url" : "Błędny adres URL", "Shared by" : "Udostępniane przez", "Sharing" : "Udostępnianie", + "Public link sharing is disabled by the administrator" : "Udostępnianie linków publicznych zostało zablokowane przez twojego administratora", + "Public upload disabled by the administrator" : "Publiczne wczytywanie zostało zablokowane przez twojego administratora", + "Public upload is only possible for publicly shared folders" : "Publiczne wczytywanie jest możliwe wyłącznie do katalogów publicznych", "A file or folder has been <strong>shared</strong>" : "Plik lub folder stał się <strong>współdzielony</strong>", "You shared %1$s with %2$s" : "Współdzielisz %1$s z %2$s", "You shared %1$s with group %2$s" : "Współdzielisz %1$s z grupą %2$s", diff --git a/apps/files_sharing/l10n/pl.json b/apps/files_sharing/l10n/pl.json index f5de5dd368c..6190871b16f 100644 --- a/apps/files_sharing/l10n/pl.json +++ b/apps/files_sharing/l10n/pl.json @@ -23,6 +23,9 @@ "Invalid ownCloud url" : "Błędny adres URL", "Shared by" : "Udostępniane przez", "Sharing" : "Udostępnianie", + "Public link sharing is disabled by the administrator" : "Udostępnianie linków publicznych zostało zablokowane przez twojego administratora", + "Public upload disabled by the administrator" : "Publiczne wczytywanie zostało zablokowane przez twojego administratora", + "Public upload is only possible for publicly shared folders" : "Publiczne wczytywanie jest możliwe wyłącznie do katalogów publicznych", "A file or folder has been <strong>shared</strong>" : "Plik lub folder stał się <strong>współdzielony</strong>", "You shared %1$s with %2$s" : "Współdzielisz %1$s z %2$s", "You shared %1$s with group %2$s" : "Współdzielisz %1$s z grupą %2$s", diff --git a/apps/files_sharing/l10n/ro.js b/apps/files_sharing/l10n/ro.js index 2481f77bcc6..5cddb6e8cdf 100644 --- a/apps/files_sharing/l10n/ro.js +++ b/apps/files_sharing/l10n/ro.js @@ -12,12 +12,28 @@ OC.L10N.register( "Shared with others" : "Partajat cu alții", "Shared by link" : "Partajat prin link", "Nothing shared with you yet" : "Nimic nu e partajat cu tine încă", + "Files and folders others share with you will show up here" : "Fișierele și directoarele partajate cu tine vor apărea aici", "Nothing shared yet" : "Nimic partajat încă", + "Files and folders you share will show up here" : "Fișierele și directoarele pe care le partajezi vor apărea aici", + "No shared links" : "Nicio legătură partajată", + "Files and folders you share by link will show up here" : "Fișierele și directoarele pe care le partajezi prin legături vor apărea aici", + "Remote share" : "Element partajat la distanță", + "Remote share password" : "Parolă element partajat la distanță", "Cancel" : "Anulare", + "Add remote share" : "Adaugă element partajat la distanță", + "You can upload into this folder" : "Poți încărca în acest director", "No ownCloud installation (7 or higher) found at {remote}" : "Nu s-a găsit nicio instanță ownCloud (versiunea 7 sau mai mare) la {remote}", "Invalid ownCloud url" : "URL ownCloud invalid", "Shared by" : "impartite in ", "Sharing" : "Partajare", + "Share API is disabled" : "API-ul de partajare este dezactivat", + "Wrong share ID, share doesn't exist" : "ID greșit al elementului partajat, acesta nu există", + "Could not delete share" : "Nu s-a putut șterge elementul partajat", + "Please specify a file or folder path" : "Specifică un fișier sau o cale către un director", + "Wrong path, file/folder doesn't exist" : "Cale greșită, fișierul/directorul nu există", + "Please specify a valid user" : "Specifică un utilizator valid", + "Please specify a valid group" : "Specifică un grup valid", + "Invalid date, date format must be YYYY-MM-DD" : "Dată invalidă, formatul trebuie să fie AAAA-LL-ZZ", "Not a directory" : "Nu este un director", "Could not lock path" : "Calea nu a putut fi blocată", "Cannot increase permissions" : "Nu se pot extinde permisiunile", @@ -26,6 +42,9 @@ OC.L10N.register( "You shared %1$s with group %2$s" : "Ai partajat %1$s cu grupul %2$s", "You shared %1$s via link" : "Ai partajat %1$s prin legătură", "%2$s shared %1$s with you" : "%2$s a partajat %1$s cu tine", + "Shared with %2$s" : "Partajat cu %2$s", + "Shared with %3$s by %2$s" : "Partajat de %2$s cu %3$s", + "Shared with group %2$s" : "Partajat cu grupul %2$s", "Shares" : "Partajări", "This share is password-protected" : "Această partajare este protejată cu parolă", "The password is wrong. Try again." : "Parola este incorectă. Încercaţi din nou.", @@ -38,6 +57,7 @@ OC.L10N.register( "sharing is disabled" : "Partajare este oprită", "Add to your ownCloud" : "Adaugă propriul tău ownCloud", "Download" : "Descarcă", - "Download %s" : "Descarcă %s" + "Download %s" : "Descarcă %s", + "Direct link" : "Legătură directă" }, "nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));"); diff --git a/apps/files_sharing/l10n/ro.json b/apps/files_sharing/l10n/ro.json index e3f9450bcb5..6d0d87037db 100644 --- a/apps/files_sharing/l10n/ro.json +++ b/apps/files_sharing/l10n/ro.json @@ -10,12 +10,28 @@ "Shared with others" : "Partajat cu alții", "Shared by link" : "Partajat prin link", "Nothing shared with you yet" : "Nimic nu e partajat cu tine încă", + "Files and folders others share with you will show up here" : "Fișierele și directoarele partajate cu tine vor apărea aici", "Nothing shared yet" : "Nimic partajat încă", + "Files and folders you share will show up here" : "Fișierele și directoarele pe care le partajezi vor apărea aici", + "No shared links" : "Nicio legătură partajată", + "Files and folders you share by link will show up here" : "Fișierele și directoarele pe care le partajezi prin legături vor apărea aici", + "Remote share" : "Element partajat la distanță", + "Remote share password" : "Parolă element partajat la distanță", "Cancel" : "Anulare", + "Add remote share" : "Adaugă element partajat la distanță", + "You can upload into this folder" : "Poți încărca în acest director", "No ownCloud installation (7 or higher) found at {remote}" : "Nu s-a găsit nicio instanță ownCloud (versiunea 7 sau mai mare) la {remote}", "Invalid ownCloud url" : "URL ownCloud invalid", "Shared by" : "impartite in ", "Sharing" : "Partajare", + "Share API is disabled" : "API-ul de partajare este dezactivat", + "Wrong share ID, share doesn't exist" : "ID greșit al elementului partajat, acesta nu există", + "Could not delete share" : "Nu s-a putut șterge elementul partajat", + "Please specify a file or folder path" : "Specifică un fișier sau o cale către un director", + "Wrong path, file/folder doesn't exist" : "Cale greșită, fișierul/directorul nu există", + "Please specify a valid user" : "Specifică un utilizator valid", + "Please specify a valid group" : "Specifică un grup valid", + "Invalid date, date format must be YYYY-MM-DD" : "Dată invalidă, formatul trebuie să fie AAAA-LL-ZZ", "Not a directory" : "Nu este un director", "Could not lock path" : "Calea nu a putut fi blocată", "Cannot increase permissions" : "Nu se pot extinde permisiunile", @@ -24,6 +40,9 @@ "You shared %1$s with group %2$s" : "Ai partajat %1$s cu grupul %2$s", "You shared %1$s via link" : "Ai partajat %1$s prin legătură", "%2$s shared %1$s with you" : "%2$s a partajat %1$s cu tine", + "Shared with %2$s" : "Partajat cu %2$s", + "Shared with %3$s by %2$s" : "Partajat de %2$s cu %3$s", + "Shared with group %2$s" : "Partajat cu grupul %2$s", "Shares" : "Partajări", "This share is password-protected" : "Această partajare este protejată cu parolă", "The password is wrong. Try again." : "Parola este incorectă. Încercaţi din nou.", @@ -36,6 +55,7 @@ "sharing is disabled" : "Partajare este oprită", "Add to your ownCloud" : "Adaugă propriul tău ownCloud", "Download" : "Descarcă", - "Download %s" : "Descarcă %s" + "Download %s" : "Descarcă %s", + "Direct link" : "Legătură directă" },"pluralForm" :"nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));" }
\ No newline at end of file diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index b10c51ce2c9..3d6a715be99 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -100,15 +100,8 @@ class Share20OCS { */ protected function formatShare(\OCP\Share\IShare $share) { $sharedBy = $this->userManager->get($share->getSharedBy()); - // for federated shares the owner can be a remote user, in this - // case we use the initiator - if ($this->userManager->userExists($share->getShareOwner())) { - $shareOwner = $this->userManager->get($share->getShareOwner()); - $localUser = $share->getShareOwner(); - } else { - $shareOwner = $this->userManager->get($share->getSharedBy()); - $localUser = $share->getSharedBy(); - } + $shareOwner = $this->userManager->get($share->getShareOwner()); + $result = [ 'id' => $share->getId(), 'share_type' => $share->getShareType(), @@ -123,8 +116,16 @@ class Share20OCS { 'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(), ]; - $node = $share->getNode(); - $result['path'] = $this->rootFolder->getUserFolder($localUser)->getRelativePath($node->getPath()); + $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); + $nodes = $userFolder->getById($share->getNodeId()); + + if (empty($nodes)) { + throw new NotFoundException(); + } + + $node = $nodes[0]; + + $result['path'] = $userFolder->getRelativePath($node->getPath()); if ($node instanceOf \OCP\Files\Folder) { $result['item_type'] = 'folder'; } else { @@ -536,7 +537,6 @@ class Share20OCS { $shares = array_merge($shares, $federatedShares); } - $formatted = []; foreach ($shares as $share) { try { diff --git a/apps/files_sharing/tests/API/Share20OCSTest.php b/apps/files_sharing/tests/API/Share20OCSTest.php index 02b16d7bf88..b760a0f47a0 100644 --- a/apps/files_sharing/tests/API/Share20OCSTest.php +++ b/apps/files_sharing/tests/API/Share20OCSTest.php @@ -433,8 +433,12 @@ class Share20OCSTest extends \Test\TestCase { ->method('getRelativePath') ->will($this->returnArgument(0)); + $userFolder->method('getById') + ->with($share->getNodeId()) + ->willReturn([$share->getNode()]); + $this->rootFolder->method('getUserFolder') - ->with($share->getShareOwner()) + ->with($this->currentUser->getUID()) ->willReturn($userFolder); $this->urlGenerator @@ -2006,8 +2010,19 @@ class Share20OCSTest extends \Test\TestCase { ->willReturn('myLink'); - $this->rootFolder->method('getUserFolder')->with($share->getShareOwner())->will($this->returnSelf()); - $this->rootFolder->method('getRelativePath')->will($this->returnArgument(0)); + $this->rootFolder->method('getUserFolder') + ->with($this->currentUser->getUID()) + ->will($this->returnSelf()); + + if (!$exception) { + $this->rootFolder->method('getById') + ->with($share->getNodeId()) + ->willReturn([$share->getNode()]); + + $this->rootFolder->method('getRelativePath') + ->with($share->getNode()->getPath()) + ->will($this->returnArgument(0)); + } try { $result = $this->invokePrivate($this->ocs, 'formatShare', [$share]); diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index f44c346236e..058b0c4758c 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -764,8 +764,7 @@ class ApiTest extends TestCase { // we should get exactly one result $this->assertCount(1, $data); - $expectedPath = $this->folder . $this->subfolder; - $this->assertEquals($expectedPath, $data[0]['path']); + $this->assertEquals($this->subfolder, $data[0]['path']); $this->shareManager->deleteShare($share2); $this->shareManager->deleteShare($share1); @@ -801,6 +800,9 @@ class ApiTest extends TestCase { ->setPermissions(1); $share3 = $this->shareManager->createShare($share3); + /* + * Test as recipient + */ $request = $this->createRequest(['path' => '/', 'subfiles' => 'true']); $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER3); $result = $ocs->getShares(); @@ -811,9 +813,37 @@ class ApiTest extends TestCase { // we should get exactly one result $this->assertCount(1, $data); + $this->assertEquals($this->subsubfolder, $data[0]['path']); - $expectedPath = $this->folder . $this->subfolder . $this->subsubfolder; - $this->assertEquals($expectedPath, $data[0]['path']); + /* + * Test for first owner/initiator + */ + $request = $this->createRequest([]); + $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1); + $result = $ocs->getShares(); + $this->assertTrue($result->succeeded()); + + // test should return one share within $this->folder + $data = $result->getData(); + + // we should get exactly one result + $this->assertCount(1, $data); + $this->assertEquals($this->folder . $this->subfolder, $data[0]['path']); + + /* + * Test for second initiator + */ + $request = $this->createRequest([]); + $ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2); + $result = $ocs->getShares(); + $this->assertTrue($result->succeeded()); + + // test should return one share within $this->folder + $data = $result->getData(); + + // we should get exactly one result + $this->assertCount(1, $data); + $this->assertEquals($this->subfolder . $this->subsubfolder, $data[0]['path']); $this->shareManager->deleteShare($share1); $this->shareManager->deleteShare($share2); @@ -922,8 +952,7 @@ class ApiTest extends TestCase { // we should get exactly one result $this->assertCount(1, $data); - $expectedPath = $this->folder.$this->subfolder.$this->filename; - $this->assertEquals($expectedPath, $data[0]['path']); + $this->assertEquals($this->filename, $data[0]['path']); $this->shareManager->deleteShare($share1); $this->shareManager->deleteShare($share2); |