summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/comments/activity/extension.php11
-rw-r--r--apps/comments/l10n/cs_CZ.js1
-rw-r--r--apps/comments/l10n/cs_CZ.json1
-rw-r--r--apps/comments/l10n/da.js1
-rw-r--r--apps/comments/l10n/da.json1
-rw-r--r--apps/comments/l10n/de.js1
-rw-r--r--apps/comments/l10n/de.json1
-rw-r--r--apps/comments/l10n/de_DE.js1
-rw-r--r--apps/comments/l10n/de_DE.json1
-rw-r--r--apps/comments/l10n/el.js1
-rw-r--r--apps/comments/l10n/el.json1
-rw-r--r--apps/comments/l10n/en_GB.js3
-rw-r--r--apps/comments/l10n/en_GB.json3
-rw-r--r--apps/comments/l10n/eo.js1
-rw-r--r--apps/comments/l10n/eo.json1
-rw-r--r--apps/comments/l10n/es.js1
-rw-r--r--apps/comments/l10n/es.json1
-rw-r--r--apps/comments/l10n/et_EE.js1
-rw-r--r--apps/comments/l10n/et_EE.json1
-rw-r--r--apps/comments/l10n/fi_FI.js1
-rw-r--r--apps/comments/l10n/fi_FI.json1
-rw-r--r--apps/comments/l10n/fr.js1
-rw-r--r--apps/comments/l10n/fr.json1
-rw-r--r--apps/comments/l10n/he.js1
-rw-r--r--apps/comments/l10n/he.json1
-rw-r--r--apps/comments/l10n/hu_HU.js1
-rw-r--r--apps/comments/l10n/hu_HU.json1
-rw-r--r--apps/comments/l10n/id.js1
-rw-r--r--apps/comments/l10n/id.json1
-rw-r--r--apps/comments/l10n/is.js1
-rw-r--r--apps/comments/l10n/is.json1
-rw-r--r--apps/comments/l10n/it.js1
-rw-r--r--apps/comments/l10n/it.json1
-rw-r--r--apps/comments/l10n/ja.js1
-rw-r--r--apps/comments/l10n/ja.json1
-rw-r--r--apps/comments/l10n/ko.js1
-rw-r--r--apps/comments/l10n/ko.json1
-rw-r--r--apps/comments/l10n/nb_NO.js1
-rw-r--r--apps/comments/l10n/nb_NO.json1
-rw-r--r--apps/comments/l10n/nl.js1
-rw-r--r--apps/comments/l10n/nl.json1
-rw-r--r--apps/comments/l10n/pl.js1
-rw-r--r--apps/comments/l10n/pl.json1
-rw-r--r--apps/comments/l10n/pt_BR.js1
-rw-r--r--apps/comments/l10n/pt_BR.json1
-rw-r--r--apps/comments/l10n/pt_PT.js1
-rw-r--r--apps/comments/l10n/pt_PT.json1
-rw-r--r--apps/comments/l10n/ru.js1
-rw-r--r--apps/comments/l10n/ru.json1
-rw-r--r--apps/comments/l10n/sl.js1
-rw-r--r--apps/comments/l10n/sl.json1
-rw-r--r--apps/comments/l10n/sq.js1
-rw-r--r--apps/comments/l10n/sq.json1
-rw-r--r--apps/comments/l10n/sr.js1
-rw-r--r--apps/comments/l10n/sr.json1
-rw-r--r--apps/comments/l10n/sv.js1
-rw-r--r--apps/comments/l10n/sv.json1
-rw-r--r--apps/comments/l10n/th_TH.js1
-rw-r--r--apps/comments/l10n/th_TH.json1
-rw-r--r--apps/comments/l10n/tr.js1
-rw-r--r--apps/comments/l10n/tr.json1
-rw-r--r--apps/comments/l10n/uk.js1
-rw-r--r--apps/comments/l10n/uk.json1
-rw-r--r--apps/comments/l10n/zh_CN.js1
-rw-r--r--apps/comments/l10n/zh_CN.json1
-rw-r--r--apps/comments/l10n/zh_TW.js1
-rw-r--r--apps/comments/l10n/zh_TW.json1
-rw-r--r--apps/dav/lib/connector/sabre/node.php2
-rw-r--r--apps/encryption/appinfo/application.php5
-rw-r--r--apps/encryption/hooks/userhooks.php71
-rw-r--r--apps/encryption/lib/keymanager.php12
-rw-r--r--apps/encryption/lib/users/setup.php22
-rw-r--r--apps/encryption/tests/hooks/UserHooksTest.php80
-rw-r--r--apps/encryption/tests/lib/users/SetupTest.php59
-rw-r--r--apps/files/appinfo/routes.php5
-rw-r--r--apps/files/controller/apicontroller.php12
-rw-r--r--apps/files/controller/viewcontroller.php4
-rw-r--r--apps/files/css/files.css5
-rw-r--r--apps/files/js/app.js51
-rw-r--r--apps/files/js/file-upload.js2
-rw-r--r--apps/files/js/filelist.js50
-rw-r--r--apps/files/js/jquery.iframe-transport.js205
-rw-r--r--apps/files/l10n/en_GB.js1
-rw-r--r--apps/files/l10n/en_GB.json1
-rw-r--r--apps/files/templates/appnavigation.php10
-rw-r--r--apps/files/templates/index.php1
-rw-r--r--apps/files/tests/controller/ViewControllerTest.php6
-rw-r--r--apps/files/tests/controller/apicontrollertest.php14
-rw-r--r--apps/files_sharing/appinfo/application.php3
-rw-r--r--apps/files_sharing/js/app.js9
-rw-r--r--apps/files_sharing/lib/mountprovider.php25
-rw-r--r--apps/files_sharing/lib/scanner.php6
-rw-r--r--apps/files_sharing/lib/sharedmount.php97
-rw-r--r--apps/files_sharing/lib/sharedpropagator.php3
-rw-r--r--apps/files_sharing/lib/sharedstorage.php452
-rw-r--r--apps/files_sharing/lib/updater.php17
-rw-r--r--apps/files_sharing/templates/public.php1
-rw-r--r--apps/files_sharing/tests/api.php46
-rw-r--r--apps/files_sharing/tests/cache.php101
-rw-r--r--apps/files_sharing/tests/etagpropagation.php148
-rw-r--r--apps/files_sharing/tests/groupetagpropagation.php30
-rw-r--r--apps/files_sharing/tests/locking.php8
-rw-r--r--apps/files_sharing/tests/permissions.php63
-rw-r--r--apps/files_sharing/tests/share.php383
-rw-r--r--apps/files_sharing/tests/sharedmount.php194
-rw-r--r--apps/files_sharing/tests/sharedstorage.php226
-rw-r--r--apps/files_sharing/tests/sizepropagation.php20
-rw-r--r--apps/files_sharing/tests/testcase.php33
-rw-r--r--apps/files_sharing/tests/unsharechildren.php17
-rw-r--r--apps/files_sharing/tests/updater.php36
-rw-r--r--apps/files_sharing/tests/watcher.php34
-rw-r--r--apps/files_trashbin/js/app.js3
-rw-r--r--apps/files_trashbin/tests/storage.php22
-rw-r--r--apps/files_trashbin/tests/trashbin.php11
-rw-r--r--apps/files_versions/tests/versions.php81
-rw-r--r--apps/systemtags/js/app.js3
-rw-r--r--apps/user_ldap/js/wizard/wizardTabGeneric.js2
117 files changed, 1205 insertions, 1568 deletions
diff --git a/apps/comments/activity/extension.php b/apps/comments/activity/extension.php
index 6bf7cae5882..ef800e88abc 100644
--- a/apps/comments/activity/extension.php
+++ b/apps/comments/activity/extension.php
@@ -80,7 +80,10 @@ class Extension implements IExtension {
$l = $this->getL10N($languageCode);
return array(
- self::APP_NAME => (string) $l->t('<strong>Comments</strong> for files'),
+ self::APP_NAME => [
+ 'desc' => (string) $l->t('<strong>Comments</strong> for files <em>(always listed in stream)</em>'),
+ 'methods' => [self::METHOD_MAIL], // self::METHOD_STREAM is forced true by the default value
+ ],
);
}
@@ -274,7 +277,11 @@ class Extension implements IExtension {
*/
public function filterNotificationTypes($types, $filter) {
if ($filter === self::APP_NAME) {
- return array_intersect($types, [self::APP_NAME]);
+ return [self::APP_NAME];
+ }
+ if (in_array($filter, ['all', 'by', 'self', 'filter'])) {
+ $types[] = self::APP_NAME;
+ return $types;
}
return false;
}
diff --git a/apps/comments/l10n/cs_CZ.js b/apps/comments/l10n/cs_CZ.js
index 73190bcb567..872020eee66 100644
--- a/apps/comments/l10n/cs_CZ.js
+++ b/apps/comments/l10n/cs_CZ.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Komentáře</strong> souborů",
"You commented" : "Okomentoval(a) jsi",
"%1$s commented" : "%1$s okomentován",
"You commented on %2$s" : "Okomentoval(a) jsi %2$s",
diff --git a/apps/comments/l10n/cs_CZ.json b/apps/comments/l10n/cs_CZ.json
index ca6f727bb0f..ab470d98989 100644
--- a/apps/comments/l10n/cs_CZ.json
+++ b/apps/comments/l10n/cs_CZ.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Komentáře</strong> souborů",
"You commented" : "Okomentoval(a) jsi",
"%1$s commented" : "%1$s okomentován",
"You commented on %2$s" : "Okomentoval(a) jsi %2$s",
diff --git a/apps/comments/l10n/da.js b/apps/comments/l10n/da.js
index 5725a7b57c6..196a298a61a 100644
--- a/apps/comments/l10n/da.js
+++ b/apps/comments/l10n/da.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentarer</strong> til filer",
"You commented" : "Du kommenterede",
"%1$s commented" : "%1$s kommenterede",
"You commented on %2$s" : "Du kommenterede %2$s",
diff --git a/apps/comments/l10n/da.json b/apps/comments/l10n/da.json
index a7b12851157..f9ce94f7d70 100644
--- a/apps/comments/l10n/da.json
+++ b/apps/comments/l10n/da.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentarer</strong> til filer",
"You commented" : "Du kommenterede",
"%1$s commented" : "%1$s kommenterede",
"You commented on %2$s" : "Du kommenterede %2$s",
diff --git a/apps/comments/l10n/de.js b/apps/comments/l10n/de.js
index 0e51b02662a..afb262cbc82 100644
--- a/apps/comments/l10n/de.js
+++ b/apps/comments/l10n/de.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentare</strong> für Dateien",
"You commented" : "Du hast kommentiert",
"%1$s commented" : "%1$s kommentierte",
"You commented on %2$s" : "Du hast %2$s kommentiert",
diff --git a/apps/comments/l10n/de.json b/apps/comments/l10n/de.json
index 8dc0bdb0427..2dbcd94f1c7 100644
--- a/apps/comments/l10n/de.json
+++ b/apps/comments/l10n/de.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentare</strong> für Dateien",
"You commented" : "Du hast kommentiert",
"%1$s commented" : "%1$s kommentierte",
"You commented on %2$s" : "Du hast %2$s kommentiert",
diff --git a/apps/comments/l10n/de_DE.js b/apps/comments/l10n/de_DE.js
index 424ae79e10e..ecb40a76771 100644
--- a/apps/comments/l10n/de_DE.js
+++ b/apps/comments/l10n/de_DE.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentare</strong> für Dateien",
"You commented" : "Durch dich kommentiert",
"%1$s commented" : "%1$s kommentiert",
"You commented on %2$s" : "Sie haben %2$s kommentiert",
diff --git a/apps/comments/l10n/de_DE.json b/apps/comments/l10n/de_DE.json
index 4fd810c7006..167a480824a 100644
--- a/apps/comments/l10n/de_DE.json
+++ b/apps/comments/l10n/de_DE.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentare</strong> für Dateien",
"You commented" : "Durch dich kommentiert",
"%1$s commented" : "%1$s kommentiert",
"You commented on %2$s" : "Sie haben %2$s kommentiert",
diff --git a/apps/comments/l10n/el.js b/apps/comments/l10n/el.js
index 1ca7886fdc5..c88bf2c2ecc 100644
--- a/apps/comments/l10n/el.js
+++ b/apps/comments/l10n/el.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Σχόλια</strong> για αρχεία",
"You commented" : "Σχολιάσατε",
"%1$s commented" : "%1$s σχολίασε",
"You commented on %2$s" : "Σχολιάσατε στο %2$s",
diff --git a/apps/comments/l10n/el.json b/apps/comments/l10n/el.json
index 234f6b79045..30c1fb9de34 100644
--- a/apps/comments/l10n/el.json
+++ b/apps/comments/l10n/el.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Σχόλια</strong> για αρχεία",
"You commented" : "Σχολιάσατε",
"%1$s commented" : "%1$s σχολίασε",
"You commented on %2$s" : "Σχολιάσατε στο %2$s",
diff --git a/apps/comments/l10n/en_GB.js b/apps/comments/l10n/en_GB.js
index 04a366a4f6d..cabce50d16d 100644
--- a/apps/comments/l10n/en_GB.js
+++ b/apps/comments/l10n/en_GB.js
@@ -1,8 +1,9 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Comments</strong> for files",
+ "You commented" : "You commented",
"%1$s commented" : "%1$s commented",
+ "You commented on %2$s" : "You commented on %2$s",
"%1$s commented on %2$s" : "%1$s commented on %2$s",
"Comments" : "Comments",
"Type in a new comment..." : "Type in a new comment...",
diff --git a/apps/comments/l10n/en_GB.json b/apps/comments/l10n/en_GB.json
index c43c1f4a629..2b4e51ccd80 100644
--- a/apps/comments/l10n/en_GB.json
+++ b/apps/comments/l10n/en_GB.json
@@ -1,6 +1,7 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Comments</strong> for files",
+ "You commented" : "You commented",
"%1$s commented" : "%1$s commented",
+ "You commented on %2$s" : "You commented on %2$s",
"%1$s commented on %2$s" : "%1$s commented on %2$s",
"Comments" : "Comments",
"Type in a new comment..." : "Type in a new comment...",
diff --git a/apps/comments/l10n/eo.js b/apps/comments/l10n/eo.js
index 515156d663b..2843625bc5b 100644
--- a/apps/comments/l10n/eo.js
+++ b/apps/comments/l10n/eo.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Komentoj</strong> por dosieroj",
"%1$s commented" : "%1$s komentis",
"%1$s commented on %2$s" : "%1$s komentis %2$s",
"Comments" : "Komentoj",
diff --git a/apps/comments/l10n/eo.json b/apps/comments/l10n/eo.json
index 33b8109abb9..3fcecdd4e34 100644
--- a/apps/comments/l10n/eo.json
+++ b/apps/comments/l10n/eo.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Komentoj</strong> por dosieroj",
"%1$s commented" : "%1$s komentis",
"%1$s commented on %2$s" : "%1$s komentis %2$s",
"Comments" : "Komentoj",
diff --git a/apps/comments/l10n/es.js b/apps/comments/l10n/es.js
index 02e45762e09..906b5643f04 100644
--- a/apps/comments/l10n/es.js
+++ b/apps/comments/l10n/es.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Comentarios</strong> en archivos",
"You commented" : "Has comentado",
"%1$s commented" : "%1$s comentados",
"You commented on %2$s" : "Has comentado en %2$s",
diff --git a/apps/comments/l10n/es.json b/apps/comments/l10n/es.json
index 232fea3a18b..7eeade965d2 100644
--- a/apps/comments/l10n/es.json
+++ b/apps/comments/l10n/es.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Comentarios</strong> en archivos",
"You commented" : "Has comentado",
"%1$s commented" : "%1$s comentados",
"You commented on %2$s" : "Has comentado en %2$s",
diff --git a/apps/comments/l10n/et_EE.js b/apps/comments/l10n/et_EE.js
index e950b52a14e..cba33642bfa 100644
--- a/apps/comments/l10n/et_EE.js
+++ b/apps/comments/l10n/et_EE.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentaarid</strong> failidele",
"You commented" : "Sa kommenteerisid",
"%1$s commented" : "%1$s kommenteeris",
"You commented on %2$s" : "Sa kommenteerisid %2$s",
diff --git a/apps/comments/l10n/et_EE.json b/apps/comments/l10n/et_EE.json
index 6a983fd5191..be23a869c28 100644
--- a/apps/comments/l10n/et_EE.json
+++ b/apps/comments/l10n/et_EE.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentaarid</strong> failidele",
"You commented" : "Sa kommenteerisid",
"%1$s commented" : "%1$s kommenteeris",
"You commented on %2$s" : "Sa kommenteerisid %2$s",
diff --git a/apps/comments/l10n/fi_FI.js b/apps/comments/l10n/fi_FI.js
index 741dea8252b..5a7f03ca229 100644
--- a/apps/comments/l10n/fi_FI.js
+++ b/apps/comments/l10n/fi_FI.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentit</strong> tiedostoille",
"You commented" : "Kommentoit",
"%1$s commented" : "%1$s kommentoi",
"You commented on %2$s" : "Kommentoit %2$s",
diff --git a/apps/comments/l10n/fi_FI.json b/apps/comments/l10n/fi_FI.json
index 52a9f1955ef..71f7a2314f7 100644
--- a/apps/comments/l10n/fi_FI.json
+++ b/apps/comments/l10n/fi_FI.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentit</strong> tiedostoille",
"You commented" : "Kommentoit",
"%1$s commented" : "%1$s kommentoi",
"You commented on %2$s" : "Kommentoit %2$s",
diff --git a/apps/comments/l10n/fr.js b/apps/comments/l10n/fr.js
index fc065bd0db0..64f95662029 100644
--- a/apps/comments/l10n/fr.js
+++ b/apps/comments/l10n/fr.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Commentaires</strong> pour les fichiers",
"You commented" : "Vous avez commenté",
"%1$s commented" : "%1$s a commenté",
"You commented on %2$s" : "Vous avez commenté %2$s",
diff --git a/apps/comments/l10n/fr.json b/apps/comments/l10n/fr.json
index d69887540f9..5d1c1895447 100644
--- a/apps/comments/l10n/fr.json
+++ b/apps/comments/l10n/fr.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Commentaires</strong> pour les fichiers",
"You commented" : "Vous avez commenté",
"%1$s commented" : "%1$s a commenté",
"You commented on %2$s" : "Vous avez commenté %2$s",
diff --git a/apps/comments/l10n/he.js b/apps/comments/l10n/he.js
index 640ec297dd3..e8b5e22222f 100644
--- a/apps/comments/l10n/he.js
+++ b/apps/comments/l10n/he.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>תגובות</strong> לקבצים",
"You commented" : "הערות שלך",
"%1$s commented" : "התקבלו תגובות %1$s",
"You commented on %2$s" : "הערות שלך ב- %2$s",
diff --git a/apps/comments/l10n/he.json b/apps/comments/l10n/he.json
index 0f79918c472..8e38f34839e 100644
--- a/apps/comments/l10n/he.json
+++ b/apps/comments/l10n/he.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>תגובות</strong> לקבצים",
"You commented" : "הערות שלך",
"%1$s commented" : "התקבלו תגובות %1$s",
"You commented on %2$s" : "הערות שלך ב- %2$s",
diff --git a/apps/comments/l10n/hu_HU.js b/apps/comments/l10n/hu_HU.js
index cae1ae5e46f..37f36e8bd7d 100644
--- a/apps/comments/l10n/hu_HU.js
+++ b/apps/comments/l10n/hu_HU.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Hozzászólások</strong> a fájlokhoz",
"You commented" : "Hozzászólt",
"%1$s commented" : "%1$s hozzászólt",
"You commented on %2$s" : "Hozzászólt ehhez: %2$s",
diff --git a/apps/comments/l10n/hu_HU.json b/apps/comments/l10n/hu_HU.json
index 268bb7dd3d8..720fe62d447 100644
--- a/apps/comments/l10n/hu_HU.json
+++ b/apps/comments/l10n/hu_HU.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Hozzászólások</strong> a fájlokhoz",
"You commented" : "Hozzászólt",
"%1$s commented" : "%1$s hozzászólt",
"You commented on %2$s" : "Hozzászólt ehhez: %2$s",
diff --git a/apps/comments/l10n/id.js b/apps/comments/l10n/id.js
index 28965c9e91e..87a17367b11 100644
--- a/apps/comments/l10n/id.js
+++ b/apps/comments/l10n/id.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Komentar</strong> untuk berkas",
"%1$s commented" : "%1$s dikomentari",
"%1$s commented on %2$s" : "%1$s dikomentari pada %2$s",
"Comments" : "Komentar",
diff --git a/apps/comments/l10n/id.json b/apps/comments/l10n/id.json
index f66594eca16..601e88987a8 100644
--- a/apps/comments/l10n/id.json
+++ b/apps/comments/l10n/id.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Komentar</strong> untuk berkas",
"%1$s commented" : "%1$s dikomentari",
"%1$s commented on %2$s" : "%1$s dikomentari pada %2$s",
"Comments" : "Komentar",
diff --git a/apps/comments/l10n/is.js b/apps/comments/l10n/is.js
index c55ebf7ef85..2330e6fe10b 100644
--- a/apps/comments/l10n/is.js
+++ b/apps/comments/l10n/is.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Athugasemdir</strong> við skrár",
"You commented" : "Þú settir inn athugasemd",
"%1$s commented" : "%1$s setti inn athugasemd",
"You commented on %2$s" : "Þú settir inn athugasemd við %2$s",
diff --git a/apps/comments/l10n/is.json b/apps/comments/l10n/is.json
index 1a73471addf..1fbd21f55dd 100644
--- a/apps/comments/l10n/is.json
+++ b/apps/comments/l10n/is.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Athugasemdir</strong> við skrár",
"You commented" : "Þú settir inn athugasemd",
"%1$s commented" : "%1$s setti inn athugasemd",
"You commented on %2$s" : "Þú settir inn athugasemd við %2$s",
diff --git a/apps/comments/l10n/it.js b/apps/comments/l10n/it.js
index 56660b5a779..304262bfbcf 100644
--- a/apps/comments/l10n/it.js
+++ b/apps/comments/l10n/it.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Commenti</strong> sui file",
"You commented" : "Hai commentato",
"%1$s commented" : "%1$s ha commentato",
"You commented on %2$s" : "Hai commentato su %2$s",
diff --git a/apps/comments/l10n/it.json b/apps/comments/l10n/it.json
index 8d113baa6e4..6bd508c0b11 100644
--- a/apps/comments/l10n/it.json
+++ b/apps/comments/l10n/it.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Commenti</strong> sui file",
"You commented" : "Hai commentato",
"%1$s commented" : "%1$s ha commentato",
"You commented on %2$s" : "Hai commentato su %2$s",
diff --git a/apps/comments/l10n/ja.js b/apps/comments/l10n/ja.js
index ff20dcedbc6..2a8cc5fb352 100644
--- a/apps/comments/l10n/ja.js
+++ b/apps/comments/l10n/ja.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "ファイルについての<strong>コメント</strong>",
"%1$s commented" : "%1$s がコメントを追加",
"%1$s commented on %2$s" : "%2$s について、%1$s がコメントしました",
"Comments" : "コメント",
diff --git a/apps/comments/l10n/ja.json b/apps/comments/l10n/ja.json
index 603d2e3d49b..d27a4b66160 100644
--- a/apps/comments/l10n/ja.json
+++ b/apps/comments/l10n/ja.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "ファイルについての<strong>コメント</strong>",
"%1$s commented" : "%1$s がコメントを追加",
"%1$s commented on %2$s" : "%2$s について、%1$s がコメントしました",
"Comments" : "コメント",
diff --git a/apps/comments/l10n/ko.js b/apps/comments/l10n/ko.js
index c1aafb01d9c..ac1ed9310cb 100644
--- a/apps/comments/l10n/ko.js
+++ b/apps/comments/l10n/ko.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "파일에 <strong>댓글</strong> 남기기",
"%1$s commented" : "%1$s 님의 댓글",
"%1$s commented on %2$s" : "%2$s에 %1$s 님이 댓글 남김",
"Comments" : "댓글",
diff --git a/apps/comments/l10n/ko.json b/apps/comments/l10n/ko.json
index 5ccd0dc52eb..08356aaf9fa 100644
--- a/apps/comments/l10n/ko.json
+++ b/apps/comments/l10n/ko.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "파일에 <strong>댓글</strong> 남기기",
"%1$s commented" : "%1$s 님의 댓글",
"%1$s commented on %2$s" : "%2$s에 %1$s 님이 댓글 남김",
"Comments" : "댓글",
diff --git a/apps/comments/l10n/nb_NO.js b/apps/comments/l10n/nb_NO.js
index 5d3732da827..fd1dc3c6508 100644
--- a/apps/comments/l10n/nb_NO.js
+++ b/apps/comments/l10n/nb_NO.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentarer</strong> for filer",
"%1$s commented" : "%1$s kommentert",
"%1$s commented on %2$s" : "%1$s kommenterte %2$s",
"Comments" : "Kommentarer",
diff --git a/apps/comments/l10n/nb_NO.json b/apps/comments/l10n/nb_NO.json
index 80724fff6de..151bac73e15 100644
--- a/apps/comments/l10n/nb_NO.json
+++ b/apps/comments/l10n/nb_NO.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentarer</strong> for filer",
"%1$s commented" : "%1$s kommentert",
"%1$s commented on %2$s" : "%1$s kommenterte %2$s",
"Comments" : "Kommentarer",
diff --git a/apps/comments/l10n/nl.js b/apps/comments/l10n/nl.js
index eb9faf55e1a..8c0d8960ddc 100644
--- a/apps/comments/l10n/nl.js
+++ b/apps/comments/l10n/nl.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Reacties</strong> voor bestanden",
"You commented" : "U heeft gereageerd",
"%1$s commented" : "%1$s heeft gereageerd",
"You commented on %2$s" : "U heeft gereageerd op %2$s",
diff --git a/apps/comments/l10n/nl.json b/apps/comments/l10n/nl.json
index d2a811207f6..e5b9e8e88ba 100644
--- a/apps/comments/l10n/nl.json
+++ b/apps/comments/l10n/nl.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Reacties</strong> voor bestanden",
"You commented" : "U heeft gereageerd",
"%1$s commented" : "%1$s heeft gereageerd",
"You commented on %2$s" : "U heeft gereageerd op %2$s",
diff --git a/apps/comments/l10n/pl.js b/apps/comments/l10n/pl.js
index 09142286773..c0183e817d5 100644
--- a/apps/comments/l10n/pl.js
+++ b/apps/comments/l10n/pl.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Komentarze</strong> dla plików",
"%1$s commented" : "%1$s skomentował",
"%1$s commented on %2$s" : "%1$s skomentował %2$s",
"Comments" : "Komentarze",
diff --git a/apps/comments/l10n/pl.json b/apps/comments/l10n/pl.json
index 92b9f66bf1c..e2f70b11d90 100644
--- a/apps/comments/l10n/pl.json
+++ b/apps/comments/l10n/pl.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Komentarze</strong> dla plików",
"%1$s commented" : "%1$s skomentował",
"%1$s commented on %2$s" : "%1$s skomentował %2$s",
"Comments" : "Komentarze",
diff --git a/apps/comments/l10n/pt_BR.js b/apps/comments/l10n/pt_BR.js
index 9d143822a99..84c774a2a8c 100644
--- a/apps/comments/l10n/pt_BR.js
+++ b/apps/comments/l10n/pt_BR.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Comentários</strong> por arquivos",
"You commented" : "Você comentou",
"%1$s commented" : "%1$s comentado",
"You commented on %2$s" : "Você comentou em %2$s",
diff --git a/apps/comments/l10n/pt_BR.json b/apps/comments/l10n/pt_BR.json
index 10b32799a54..ce68be38af9 100644
--- a/apps/comments/l10n/pt_BR.json
+++ b/apps/comments/l10n/pt_BR.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Comentários</strong> por arquivos",
"You commented" : "Você comentou",
"%1$s commented" : "%1$s comentado",
"You commented on %2$s" : "Você comentou em %2$s",
diff --git a/apps/comments/l10n/pt_PT.js b/apps/comments/l10n/pt_PT.js
index 5c874329fcd..b661ac7b73e 100644
--- a/apps/comments/l10n/pt_PT.js
+++ b/apps/comments/l10n/pt_PT.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Comentários</strong> para ficheiros",
"You commented" : "Comentou",
"%1$s commented" : "%1$s comentou",
"You commented on %2$s" : "Comentou %2$s",
diff --git a/apps/comments/l10n/pt_PT.json b/apps/comments/l10n/pt_PT.json
index f5fc1d7070b..fe4198cae45 100644
--- a/apps/comments/l10n/pt_PT.json
+++ b/apps/comments/l10n/pt_PT.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Comentários</strong> para ficheiros",
"You commented" : "Comentou",
"%1$s commented" : "%1$s comentou",
"You commented on %2$s" : "Comentou %2$s",
diff --git a/apps/comments/l10n/ru.js b/apps/comments/l10n/ru.js
index 755ca9e5d58..a7c2fbc1411 100644
--- a/apps/comments/l10n/ru.js
+++ b/apps/comments/l10n/ru.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Комментарии</strong> к файлам",
"You commented" : "Вы откомментировали",
"%1$s commented" : "%1$s откомментировано",
"You commented on %2$s" : "Вы откомментировали в %2$s",
diff --git a/apps/comments/l10n/ru.json b/apps/comments/l10n/ru.json
index 7c5d8aa10cc..eea01451765 100644
--- a/apps/comments/l10n/ru.json
+++ b/apps/comments/l10n/ru.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Комментарии</strong> к файлам",
"You commented" : "Вы откомментировали",
"%1$s commented" : "%1$s откомментировано",
"You commented on %2$s" : "Вы откомментировали в %2$s",
diff --git a/apps/comments/l10n/sl.js b/apps/comments/l10n/sl.js
index 79d8fc8e977..95d3b4ab591 100644
--- a/apps/comments/l10n/sl.js
+++ b/apps/comments/l10n/sl.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Opombe</strong> datotek",
"You commented" : "Vaša opomba",
"%1$s commented" : "%1$s opomb",
"You commented on %2$s" : "Napisali ste opombo na %2$s",
diff --git a/apps/comments/l10n/sl.json b/apps/comments/l10n/sl.json
index 1e71acbec39..770da087867 100644
--- a/apps/comments/l10n/sl.json
+++ b/apps/comments/l10n/sl.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Opombe</strong> datotek",
"You commented" : "Vaša opomba",
"%1$s commented" : "%1$s opomb",
"You commented on %2$s" : "Napisali ste opombo na %2$s",
diff --git a/apps/comments/l10n/sq.js b/apps/comments/l10n/sq.js
index fdb47e2425a..60fda55c550 100644
--- a/apps/comments/l10n/sq.js
+++ b/apps/comments/l10n/sq.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Komente</strong> për kartela",
"You commented" : "Komentuat",
"%1$s commented" : "%1$s komentoi",
"You commented on %2$s" : "Komentuat te %2$s",
diff --git a/apps/comments/l10n/sq.json b/apps/comments/l10n/sq.json
index deaeceac8ce..78c9f392c9f 100644
--- a/apps/comments/l10n/sq.json
+++ b/apps/comments/l10n/sq.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Komente</strong> për kartela",
"You commented" : "Komentuat",
"%1$s commented" : "%1$s komentoi",
"You commented on %2$s" : "Komentuat te %2$s",
diff --git a/apps/comments/l10n/sr.js b/apps/comments/l10n/sr.js
index aae126ef40f..230f79c9214 100644
--- a/apps/comments/l10n/sr.js
+++ b/apps/comments/l10n/sr.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Коментари</strong> фајлова",
"%1$s commented" : "%1$s коментариса",
"%1$s commented on %2$s" : "%1$s коментариса на %2$s",
"Comments" : "Коментари",
diff --git a/apps/comments/l10n/sr.json b/apps/comments/l10n/sr.json
index 12cdb29deb5..a9940b644e1 100644
--- a/apps/comments/l10n/sr.json
+++ b/apps/comments/l10n/sr.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Коментари</strong> фајлова",
"%1$s commented" : "%1$s коментариса",
"%1$s commented on %2$s" : "%1$s коментариса на %2$s",
"Comments" : "Коментари",
diff --git a/apps/comments/l10n/sv.js b/apps/comments/l10n/sv.js
index 6c3b17555bc..b64ad9e8173 100644
--- a/apps/comments/l10n/sv.js
+++ b/apps/comments/l10n/sv.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Kommentarer</strong> till filer",
"You commented" : "Du kommenterade",
"%1$s commented" : "%1$s har kommenterat",
"You commented on %2$s" : "Du kommenterade %2$s",
diff --git a/apps/comments/l10n/sv.json b/apps/comments/l10n/sv.json
index 6b2e9b7b71d..f7c9db11cf6 100644
--- a/apps/comments/l10n/sv.json
+++ b/apps/comments/l10n/sv.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Kommentarer</strong> till filer",
"You commented" : "Du kommenterade",
"%1$s commented" : "%1$s har kommenterat",
"You commented on %2$s" : "Du kommenterade %2$s",
diff --git a/apps/comments/l10n/th_TH.js b/apps/comments/l10n/th_TH.js
index ba0e9aa812c..3f5b61c805d 100644
--- a/apps/comments/l10n/th_TH.js
+++ b/apps/comments/l10n/th_TH.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>แสดงความคิดเห็น</strong> สำหรับไฟล์",
"%1$s commented" : "%1$s ได้ถูกแสดงความคิดเห็น",
"%1$s commented on %2$s" : "%1$s ได้ถูกแสดงความคิดเห็นบน %2$s",
"Comments" : "ความคิดเห็น",
diff --git a/apps/comments/l10n/th_TH.json b/apps/comments/l10n/th_TH.json
index 02ce39195c7..dfcfee58d69 100644
--- a/apps/comments/l10n/th_TH.json
+++ b/apps/comments/l10n/th_TH.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>แสดงความคิดเห็น</strong> สำหรับไฟล์",
"%1$s commented" : "%1$s ได้ถูกแสดงความคิดเห็น",
"%1$s commented on %2$s" : "%1$s ได้ถูกแสดงความคิดเห็นบน %2$s",
"Comments" : "ความคิดเห็น",
diff --git a/apps/comments/l10n/tr.js b/apps/comments/l10n/tr.js
index ff5bbca4081..558684161cf 100644
--- a/apps/comments/l10n/tr.js
+++ b/apps/comments/l10n/tr.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "Dosyalar için <strong>yorumlar</strong>",
"You commented" : "Yorum yaptınız",
"%1$s commented" : "%1$s yorumlanmış",
"You commented on %2$s" : "%2$s için yorum yaptınız",
diff --git a/apps/comments/l10n/tr.json b/apps/comments/l10n/tr.json
index 724670c53ae..25d539e57e3 100644
--- a/apps/comments/l10n/tr.json
+++ b/apps/comments/l10n/tr.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "Dosyalar için <strong>yorumlar</strong>",
"You commented" : "Yorum yaptınız",
"%1$s commented" : "%1$s yorumlanmış",
"You commented on %2$s" : "%2$s için yorum yaptınız",
diff --git a/apps/comments/l10n/uk.js b/apps/comments/l10n/uk.js
index a7e1cbad958..e958597b40e 100644
--- a/apps/comments/l10n/uk.js
+++ b/apps/comments/l10n/uk.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>Коментарі</strong> до файлів",
"%1$s commented" : "%1$s прокоментовано",
"%1$s commented on %2$s" : "%1$s прокоментовано у %2$s",
"Comments" : "Коментарі",
diff --git a/apps/comments/l10n/uk.json b/apps/comments/l10n/uk.json
index ff3f3b7dc64..59fb9f7eb76 100644
--- a/apps/comments/l10n/uk.json
+++ b/apps/comments/l10n/uk.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>Коментарі</strong> до файлів",
"%1$s commented" : "%1$s прокоментовано",
"%1$s commented on %2$s" : "%1$s прокоментовано у %2$s",
"Comments" : "Коментарі",
diff --git a/apps/comments/l10n/zh_CN.js b/apps/comments/l10n/zh_CN.js
index edfd32a9926..79d12423208 100644
--- a/apps/comments/l10n/zh_CN.js
+++ b/apps/comments/l10n/zh_CN.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "<strong>评论文件</strong>",
"%1$s commented" : "%1$s 已评论",
"%1$s commented on %2$s" : "%1$s 评论了 %2$s",
"Comments" : "评论",
diff --git a/apps/comments/l10n/zh_CN.json b/apps/comments/l10n/zh_CN.json
index 0eaefb409b1..b27364e4638 100644
--- a/apps/comments/l10n/zh_CN.json
+++ b/apps/comments/l10n/zh_CN.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "<strong>评论文件</strong>",
"%1$s commented" : "%1$s 已评论",
"%1$s commented on %2$s" : "%1$s 评论了 %2$s",
"Comments" : "评论",
diff --git a/apps/comments/l10n/zh_TW.js b/apps/comments/l10n/zh_TW.js
index 41c0dd4b0f2..251752fedb8 100644
--- a/apps/comments/l10n/zh_TW.js
+++ b/apps/comments/l10n/zh_TW.js
@@ -1,7 +1,6 @@
OC.L10N.register(
"comments",
{
- "<strong>Comments</strong> for files" : "檔案的<strong>留言</strong>",
"You commented" : "您留言",
"%1$s commented" : "%1$s 留言",
"You commented on %2$s" : "您對 %2$s 留言",
diff --git a/apps/comments/l10n/zh_TW.json b/apps/comments/l10n/zh_TW.json
index 7fe1b0fb1fa..d75f11523b9 100644
--- a/apps/comments/l10n/zh_TW.json
+++ b/apps/comments/l10n/zh_TW.json
@@ -1,5 +1,4 @@
{ "translations": {
- "<strong>Comments</strong> for files" : "檔案的<strong>留言</strong>",
"You commented" : "您留言",
"%1$s commented" : "%1$s 留言",
"You commented on %2$s" : "您對 %2$s 留言",
diff --git a/apps/dav/lib/connector/sabre/node.php b/apps/dav/lib/connector/sabre/node.php
index eaba6713992..979149fc937 100644
--- a/apps/dav/lib/connector/sabre/node.php
+++ b/apps/dav/lib/connector/sabre/node.php
@@ -224,7 +224,7 @@ abstract class Node implements \Sabre\DAV\INode {
if ($storage->instanceOfStorage('\OC\Files\Storage\Shared')) {
/** @var \OC\Files\Storage\Shared $storage */
- $permissions = (int)$storage->getShare()['permissions'];
+ $permissions = (int)$storage->getShare()->getPermissions();
} else {
$permissions = $storage->getPermissions($path);
}
diff --git a/apps/encryption/appinfo/application.php b/apps/encryption/appinfo/application.php
index 6d01d3e8353..6080a29d5f4 100644
--- a/apps/encryption/appinfo/application.php
+++ b/apps/encryption/appinfo/application.php
@@ -66,6 +66,11 @@ class Application extends \OCP\AppFramework\App {
$session = $this->getContainer()->query('Session');
$session->setStatus(Session::RUN_MIGRATION);
}
+ if ($this->encryptionManager->isEnabled() && $encryptionSystemReady) {
+ /** @var Setup $setup */
+ $setup = $this->getContainer()->query('UserSetup');
+ $setup->setupSystem();
+ }
}
/**
diff --git a/apps/encryption/hooks/userhooks.php b/apps/encryption/hooks/userhooks.php
index 62acd168909..136a1832101 100644
--- a/apps/encryption/hooks/userhooks.php
+++ b/apps/encryption/hooks/userhooks.php
@@ -24,6 +24,7 @@
namespace OCA\Encryption\Hooks;
+use OC\Files\Filesystem;
use OCP\IUserManager;
use OCP\Util as OCUtil;
use OCA\Encryption\Hooks\Contracts\IHook;
@@ -117,22 +118,29 @@ class UserHooks implements IHook {
public function addHooks() {
OCUtil::connectHook('OC_User', 'post_login', $this, 'login');
OCUtil::connectHook('OC_User', 'logout', $this, 'logout');
- OCUtil::connectHook('OC_User',
- 'post_setPassword',
- $this,
- 'setPassphrase');
- OCUtil::connectHook('OC_User',
- 'pre_setPassword',
- $this,
- 'preSetPassphrase');
- OCUtil::connectHook('OC_User',
- 'post_createUser',
- $this,
- 'postCreateUser');
- OCUtil::connectHook('OC_User',
- 'post_deleteUser',
- $this,
- 'postDeleteUser');
+
+ // this hooks only make sense if no master key is used
+ if ($this->util->isMasterKeyEnabled() === false) {
+ OCUtil::connectHook('OC_User',
+ 'post_setPassword',
+ $this,
+ 'setPassphrase');
+
+ OCUtil::connectHook('OC_User',
+ 'pre_setPassword',
+ $this,
+ 'preSetPassphrase');
+
+ OCUtil::connectHook('OC_User',
+ 'post_createUser',
+ $this,
+ 'postCreateUser');
+
+ OCUtil::connectHook('OC_User',
+ 'post_deleteUser',
+ $this,
+ 'postDeleteUser');
+ }
}
@@ -151,12 +159,10 @@ class UserHooks implements IHook {
// ensure filesystem is loaded
if (!\OC\Files\Filesystem::$loaded) {
- \OC_Util::setupFS($params['uid']);
+ $this->setupFS($params['uid']);
}
-
- // setup user, if user not ready force relogin
- if (!$this->userSetup->setupUser($params['uid'], $params['password'])) {
- return false;
+ if ($this->util->isMasterKeyEnabled() === false) {
+ $this->userSetup->setupUser($params['uid'], $params['password']);
}
$this->keyManager->init($params['uid'], $params['password']);
@@ -243,6 +249,7 @@ class UserHooks implements IHook {
// used to decrypt it has changed
} else { // admin changed the password for a different user, create new keys and re-encrypt file keys
$user = $params['uid'];
+ $this->initMountPoints($user);
$recoveryPassword = isset($params['recoveryPassword']) ? $params['recoveryPassword'] : null;
// we generate new keys if...
@@ -281,6 +288,15 @@ class UserHooks implements IHook {
}
}
+ /**
+ * init mount points for given user
+ *
+ * @param string $user
+ * @throws \OC\User\NoUserException
+ */
+ protected function initMountPoints($user) {
+ Filesystem::initMountPoints($user);
+ }
/**
@@ -291,7 +307,16 @@ class UserHooks implements IHook {
public function postPasswordReset($params) {
$password = $params['password'];
- $this->keyManager->replaceUserKeys($params['uid']);
- $this->userSetup->setupServerSide($params['uid'], $password);
+ $this->keyManager->deleteUserKeys($params['uid']);
+ $this->userSetup->setupUser($params['uid'], $password);
+ }
+
+ /**
+ * setup file system for user
+ *
+ * @param string $uid user id
+ */
+ protected function setupFS($uid) {
+ \OC_Util::setupFS($uid);
}
}
diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/keymanager.php
index 0accfb7900a..5cce760fa59 100644
--- a/apps/encryption/lib/keymanager.php
+++ b/apps/encryption/lib/keymanager.php
@@ -174,6 +174,11 @@ class KeyManager {
* check if a key pair for the master key exists, if not we create one
*/
public function validateMasterKey() {
+
+ if ($this->util->isMasterKeyEnabled() === false) {
+ return;
+ }
+
$masterKey = $this->getPublicMasterKey();
if (empty($masterKey)) {
$keyPair = $this->crypt->createKeyPair();
@@ -334,7 +339,7 @@ class KeyManager {
/**
* Decrypt private key and store it
*
- * @param string $uid userid
+ * @param string $uid user id
* @param string $passPhrase users password
* @return boolean
*/
@@ -342,7 +347,6 @@ class KeyManager {
$this->session->setStatus(Session::INIT_EXECUTED);
-
try {
if($this->util->isMasterKeyEnabled()) {
$uid = $this->getMasterKeyId();
@@ -554,9 +558,11 @@ class KeyManager {
}
/**
+ * creat a backup of the users private and public key and then delete it
+ *
* @param string $uid
*/
- public function replaceUserKeys($uid) {
+ public function deleteUserKeys($uid) {
$this->backupAllKeys('password_reset');
$this->deletePublicKey($uid);
$this->deletePrivateKey($uid);
diff --git a/apps/encryption/lib/users/setup.php b/apps/encryption/lib/users/setup.php
index 0b5fb351aca..e59340c4ce2 100644
--- a/apps/encryption/lib/users/setup.php
+++ b/apps/encryption/lib/users/setup.php
@@ -66,29 +66,23 @@ class Setup {
}
/**
- * @param string $uid userid
+ * @param string $uid user id
* @param string $password user password
* @return bool
*/
public function setupUser($uid, $password) {
- return $this->setupServerSide($uid, $password);
+ if (!$this->keyManager->userHasKeys($uid)) {
+ return $this->keyManager->storeKeyPair($uid, $password,
+ $this->crypt->createKeyPair());
+ }
+ return true;
}
/**
- * check if user has a key pair, if not we create one
- *
- * @param string $uid userid
- * @param string $password user password
- * @return bool
+ * make sure that all system keys exists
*/
- public function setupServerSide($uid, $password) {
+ public function setupSystem() {
$this->keyManager->validateShareKey();
$this->keyManager->validateMasterKey();
- // Check if user already has keys
- if (!$this->keyManager->userHasKeys($uid)) {
- return $this->keyManager->storeKeyPair($uid, $password,
- $this->crypt->createKeyPair());
- }
- return true;
}
}
diff --git a/apps/encryption/tests/hooks/UserHooksTest.php b/apps/encryption/tests/hooks/UserHooksTest.php
index 08d1981266c..df3d12b3401 100644
--- a/apps/encryption/tests/hooks/UserHooksTest.php
+++ b/apps/encryption/tests/hooks/UserHooksTest.php
@@ -29,6 +29,12 @@ use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Hooks\UserHooks;
use Test\TestCase;
+/**
+ * Class UserHooksTest
+ *
+ * @group DB
+ * @package OCA\Encryption\Tests\Hooks
+ */
class UserHooksTest extends TestCase {
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -71,7 +77,7 @@ class UserHooksTest extends TestCase {
private $params = ['uid' => 'testUser', 'password' => 'password'];
public function testLogin() {
- $this->userSetupMock->expects($this->exactly(2))
+ $this->userSetupMock->expects($this->once())
->method('setupUser')
->willReturnOnConsecutiveCalls(true, false);
@@ -80,7 +86,6 @@ class UserHooksTest extends TestCase {
->with('testUser', 'password');
$this->assertNull($this->instance->login($this->params));
- $this->assertFalse($this->instance->login($this->params));
}
public function testLogout() {
@@ -190,6 +195,23 @@ class UserHooksTest extends TestCase {
->willReturnOnConsecutiveCalls(true, false);
+ $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks')
+ ->setConstructorArgs(
+ [
+ $this->keyManagerMock,
+ $this->userManagerMock,
+ $this->loggerMock,
+ $this->userSetupMock,
+ $this->userSessionMock,
+ $this->utilMock,
+ $this->sessionMock,
+ $this->cryptMock,
+ $this->recoveryMock
+ ]
+ )->setMethods(['initMountPoints'])->getMock();
+
+ $this->instance->expects($this->exactly(3))->method('initMountPoints');
+
// Test first if statement
$this->assertNull($this->instance->setPassphrase($this->params));
@@ -236,27 +258,31 @@ class UserHooksTest extends TestCase {
->with('testUser')
->willReturn(false);
- $userHooks = new UserHooks($this->keyManagerMock,
- $this->userManagerMock,
- $this->loggerMock,
- $this->userSetupMock,
- $userSessionMock,
- $this->utilMock,
- $this->sessionMock,
- $this->cryptMock,
- $this->recoveryMock
- );
+ $userHooks = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks')
+ ->setConstructorArgs(
+ [
+ $this->keyManagerMock,
+ $this->userManagerMock,
+ $this->loggerMock,
+ $this->userSetupMock,
+ $userSessionMock,
+ $this->utilMock,
+ $this->sessionMock,
+ $this->cryptMock,
+ $this->recoveryMock
+ ]
+ )->setMethods(['initMountPoints'])->getMock();
$this->assertNull($userHooks->setPassphrase($this->params));
}
public function testPostPasswordReset() {
$this->keyManagerMock->expects($this->once())
- ->method('replaceUserKeys')
+ ->method('deleteUserKeys')
->with('testUser');
$this->userSetupMock->expects($this->once())
- ->method('setupServerSide')
+ ->method('setupUser')
->with('testUser', 'password');
$this->assertNull($this->instance->postPasswordReset($this->params));
@@ -312,16 +338,22 @@ class UserHooksTest extends TestCase {
$this->sessionMock = $sessionMock;
$this->recoveryMock = $recoveryMock;
$this->utilMock = $utilMock;
- $this->instance = new UserHooks($this->keyManagerMock,
- $this->userManagerMock,
- $this->loggerMock,
- $this->userSetupMock,
- $this->userSessionMock,
- $this->utilMock,
- $this->sessionMock,
- $this->cryptMock,
- $this->recoveryMock
- );
+ $this->utilMock->expects($this->any())->method('isMasterKeyEnabled')->willReturn(false);
+
+ $this->instance = $this->getMockBuilder('OCA\Encryption\Hooks\UserHooks')
+ ->setConstructorArgs(
+ [
+ $this->keyManagerMock,
+ $this->userManagerMock,
+ $this->loggerMock,
+ $this->userSetupMock,
+ $this->userSessionMock,
+ $this->utilMock,
+ $this->sessionMock,
+ $this->cryptMock,
+ $this->recoveryMock
+ ]
+ )->setMethods(['setupFS'])->getMock();
}
diff --git a/apps/encryption/tests/lib/users/SetupTest.php b/apps/encryption/tests/lib/users/SetupTest.php
index 0cc59384b16..e7d8afbb102 100644
--- a/apps/encryption/tests/lib/users/SetupTest.php
+++ b/apps/encryption/tests/lib/users/SetupTest.php
@@ -41,26 +41,6 @@ class SetupTest extends TestCase {
*/
private $instance;
- public function testSetupServerSide() {
- $this->keyManagerMock->expects($this->exactly(2))->method('validateShareKey');
- $this->keyManagerMock->expects($this->exactly(2))->method('validateMasterKey');
- $this->keyManagerMock->expects($this->exactly(2))
- ->method('userHasKeys')
- ->with('admin')
- ->willReturnOnConsecutiveCalls(true, false);
-
- $this->assertTrue($this->instance->setupServerSide('admin',
- 'password'));
-
- $this->keyManagerMock->expects($this->once())
- ->method('storeKeyPair')
- ->with('admin', 'password')
- ->willReturn(false);
-
- $this->assertFalse($this->instance->setupServerSide('admin',
- 'password'));
- }
-
protected function setUp() {
parent::setUp();
$logMock = $this->getMock('OCP\ILogger');
@@ -81,4 +61,43 @@ class SetupTest extends TestCase {
$this->keyManagerMock);
}
+
+ public function testSetupSystem() {
+ $this->keyManagerMock->expects($this->once())->method('validateShareKey');
+ $this->keyManagerMock->expects($this->once())->method('validateMasterKey');
+
+ $this->instance->setupSystem();
+ }
+
+ /**
+ * @dataProvider dataTestSetupUser
+ *
+ * @param bool $hasKeys
+ * @param bool $expected
+ */
+ public function testSetupUser($hasKeys, $expected) {
+
+ $this->keyManagerMock->expects($this->once())->method('userHasKeys')
+ ->with('uid')->willReturn($hasKeys);
+
+ if ($hasKeys) {
+ $this->keyManagerMock->expects($this->never())->method('storeKeyPair');
+ } else {
+ $this->cryptMock->expects($this->once())->method('createKeyPair')->willReturn('keyPair');
+ $this->keyManagerMock->expects($this->once())->method('storeKeyPair')
+ ->with('uid', 'password', 'keyPair')->willReturn(true);
+ }
+
+ $this->assertSame($expected,
+ $this->instance->setupUser('uid', 'password')
+ );
+ }
+
+ public function dataTestSetupUser() {
+ return [
+ [true, true],
+ [false, true]
+ ];
+ }
+
}
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
index 6ad938101a2..2291b48e3c5 100644
--- a/apps/files/appinfo/routes.php
+++ b/apps/files/appinfo/routes.php
@@ -54,6 +54,11 @@ $application->registerRoutes(
'url' => '/api/v1/sorting',
'verb' => 'POST'
),
+ array(
+ 'name' => 'API#showHiddenFiles',
+ 'url' => '/api/v1/showhidden',
+ 'verb' => 'POST'
+ ),
[
'name' => 'view#index',
'url' => '/',
diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php
index 43d426476fe..072498c7b5f 100644
--- a/apps/files/controller/apicontroller.php
+++ b/apps/files/controller/apicontroller.php
@@ -224,4 +224,16 @@ class ApiController extends Controller {
return new Response();
}
+ /**
+ * Toggle default for showing/hiding hidden files
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $show
+ */
+ public function showHiddenFiles($show) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', (int) $show);
+ return new Response();
+ }
+
}
diff --git a/apps/files/controller/viewcontroller.php b/apps/files/controller/viewcontroller.php
index 6c5f4c6d2a0..ded6fd555df 100644
--- a/apps/files/controller/viewcontroller.php
+++ b/apps/files/controller/viewcontroller.php
@@ -67,6 +67,7 @@ class ViewController extends Controller {
* @param IL10N $l10n
* @param IConfig $config
* @param EventDispatcherInterface $eventDispatcherInterface
+ * @param IUserSession $userSession
*/
public function __construct($appName,
IRequest $request,
@@ -136,7 +137,6 @@ class ViewController extends Controller {
\OCP\Util::addscript('files', 'app');
\OCP\Util::addscript('files', 'file-upload');
\OCP\Util::addscript('files', 'newfilemenu');
- \OCP\Util::addscript('files', 'jquery.iframe-transport');
\OCP\Util::addscript('files', 'jquery.fileupload');
\OCP\Util::addscript('files', 'jquery-visibility');
\OCP\Util::addscript('files', 'fileinfomodel');
@@ -222,6 +222,8 @@ class ViewController extends Controller {
$user = $this->userSession->getUser()->getUID();
$params['defaultFileSorting'] = $this->config->getUserValue($user, 'files', 'file_sorting', 'name');
$params['defaultFileSortingDirection'] = $this->config->getUserValue($user, 'files', 'file_sorting_direction', 'asc');
+ $showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
+ $params['showHiddenFiles'] = $showHidden ? 1 : 0;
$params['appNavigation'] = $nav;
$params['appContents'] = $contentItems;
$this->navigationManager->setActiveEntry('files_index');
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index d20ab102ba5..373739071e9 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -2,6 +2,11 @@
This file is licensed under the Affero General Public License version 3 or later.
See the COPYING-README file. */
+/* SETTINGS */
+#files-setting-showhidden {
+ padding-bottom: 8px;
+}
+
/* FILE MENU */
.actions { padding:5px; height:32px; display: inline-block; float: left; }
.actions input, .actions button, .actions .button { margin:0; float:left; }
diff --git a/apps/files/js/app.js b/apps/files/js/app.js
index 4ed805d2681..eac080a009d 100644
--- a/apps/files/js/app.js
+++ b/apps/files/js/app.js
@@ -11,7 +11,7 @@
*
*/
-/* global dragOptions, folderDropOptions */
+/* global dragOptions, folderDropOptions, OC */
(function() {
if (!OCA.Files) {
@@ -41,10 +41,22 @@
fileList: null,
/**
+ * Backbone model for storing files preferences
+ */
+ _filesConfig: null,
+
+ /**
* Initializes the files app
*/
initialize: function() {
this.navigation = new OCA.Files.Navigation($('#app-navigation'));
+ this.$showHiddenFiles = $('input#showhiddenfilesToggle');
+ var showHidden = $('#showHiddenFiles').val() === "1";
+ this.$showHiddenFiles.prop('checked', showHidden);
+
+ this._filesConfig = new OC.Backbone.Model({
+ showhidden: showHidden
+ });
var urlParams = OC.Util.History.parseUrlQuery();
var fileActions = new OCA.Files.FileActions();
@@ -76,7 +88,8 @@
sorting: {
mode: $('#defaultFileSorting').val(),
direction: $('#defaultFileSortingDirection').val()
- }
+ },
+ config: this._filesConfig,
}
);
this.files.initialize();
@@ -90,6 +103,8 @@
this._setupEvents();
// trigger URL change event handlers
this._onPopState(urlParams);
+
+ this._debouncedPersistShowHiddenFilesState = _.debounce(this._persistShowHiddenFilesState, 1200);
},
/**
@@ -144,6 +159,14 @@
},
/**
+ *
+ * @returns {Backbone.Model}
+ */
+ getFilesConfig: function() {
+ return this._filesConfig;
+ },
+
+ /**
* Setup events based on URL changes
*/
_setupEvents: function() {
@@ -154,6 +177,30 @@
$('#app-content').delegate('>div', 'changeViewerMode', _.bind(this._onChangeViewerMode, this));
$('#app-navigation').on('itemChanged', _.bind(this._onNavigationChanged, this));
+ this.$showHiddenFiles.on('change', _.bind(this._onShowHiddenFilesChange, this));
+ },
+
+ /**
+ * Toggle showing hidden files according to the settings checkbox
+ *
+ * @returns {undefined}
+ */
+ _onShowHiddenFilesChange: function() {
+ var show = this.$showHiddenFiles.is(':checked');
+ this._filesConfig.set('showhidden', show);
+ this._debouncedPersistShowHiddenFilesState();
+ },
+
+ /**
+ * Persist show hidden preference on ther server
+ *
+ * @returns {undefined}
+ */
+ _persistShowHiddenFilesState: function() {
+ var show = this._filesConfig.get('showhidden');
+ $.post(OC.generateUrl('/apps/files/api/v1/showhidden'), {
+ show: show
+ });
},
/**
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index fca69064cde..b88a7031dba 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -504,7 +504,7 @@ OC.Upload = {
//fetch response from iframe
response = data.result[0].body.innerText;
}
- var result = $.parseJSON(response);
+ var result = JSON.parse(response);
delete data.jqXHR;
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 7de64f8ade3..ea0f0666b4a 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -145,6 +145,11 @@
_filter: '',
/**
+ * @type Backbone.Model
+ */
+ _filesConfig: null,
+
+ /**
* Sort attribute
* @type String
*/
@@ -198,6 +203,15 @@
return;
}
+ if (options.config) {
+ this._filesConfig = options.config;
+ } else {
+ this._filesConfig = OCA.Files.App.getFilesConfig();
+ }
+ this._filesConfig.on('change:showhidden', function() {
+ self.setFiles(self.files);
+ });
+
if (options.dragOptions) {
this._dragOptions = options.dragOptions;
}
@@ -847,6 +861,10 @@
* @return array of DOM elements of the newly added files
*/
_nextPage: function(animate) {
+ // Save full files list while rendering
+ var allFiles = this.files;
+ this.files = this._filterHiddenFiles(this.files);
+
var index = this.$fileList.children().length,
count = this.pageSize(),
hidden,
@@ -893,6 +911,10 @@
}
}, 0);
}
+
+ // Restore full files list after rendering
+ this.files = allFiles;
+
return newTrs;
},
@@ -930,18 +952,25 @@
// clear "Select all" checkbox
this.$el.find('.select-all').prop('checked', false);
+ // Save full files list while rendering
+ var allFiles = this.files;
+ this.files = this._filterHiddenFiles(this.files);
+
this.isEmpty = this.files.length === 0;
this._nextPage();
this.updateEmptyContent();
- this.fileSummary.calculate(filesArray);
+ this.fileSummary.calculate(this.files);
this._selectedFiles = {};
this._selectionSummary.clear();
this.updateSelectionSummary();
$(window).scrollTop(0);
+ // Restore full files list after rendering
+ this.files = allFiles;
+
this.$fileList.trigger(jQuery.Event('updated'));
_.defer(function() {
self.$el.closest('#app-content').trigger(jQuery.Event('apprendered'));
@@ -949,6 +978,21 @@
},
/**
+ * Filter hidden files of the given filesArray (dot-files)
+ *
+ * @param filesArray files to be filtered
+ * @returns {array}
+ */
+ _filterHiddenFiles: function(files) {
+ if (this._filesConfig.get('showhidden')) {
+ return files;
+ }
+ return _.filter(files, function(file) {
+ return file.name.indexOf('.') !== 0;
+ });
+ },
+
+ /**
* Returns the icon URL matching the given file info
*
* @param {OC.Files.FileInfo} fileInfo file info
@@ -2549,7 +2593,7 @@
// fetch response from iframe
response = data.result[0].body.innerText;
}
- var result=$.parseJSON(response);
+ var result = JSON.parse(response);
if (typeof result[0] !== 'undefined' && result[0].status === 'success') {
var file = result[0];
@@ -2862,7 +2906,7 @@ $(document).ready(function() {
OCA.Files.FileList.lastAction();
}
});
- $(window).unload(function () {
+ $(window).on('unload', function () {
$(window).trigger('beforeunload');
});
diff --git a/apps/files/js/jquery.iframe-transport.js b/apps/files/js/jquery.iframe-transport.js
deleted file mode 100644
index 5c9df77976b..00000000000
--- a/apps/files/js/jquery.iframe-transport.js
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * jQuery Iframe Transport Plugin 1.7
- * https://github.com/blueimp/jQuery-File-Upload
- *
- * Copyright 2011, Sebastian Tschan
- * https://blueimp.net
- *
- * Licensed under the MIT license:
- * http://www.opensource.org/licenses/MIT
- */
-
-/*jslint unparam: true, nomen: true */
-/*global define, window, document */
-
-(function (factory) {
- 'use strict';
- if (typeof define === 'function' && define.amd) {
- // Register as an anonymous AMD module:
- define(['jquery'], factory);
- } else {
- // Browser globals:
- factory(window.jQuery);
- }
-}(function ($) {
- 'use strict';
-
- // Helper variable to create unique names for the transport iframes:
- var counter = 0;
-
- // The iframe transport accepts three additional options:
- // options.fileInput: a jQuery collection of file input fields
- // options.paramName: the parameter name for the file form data,
- // overrides the name property of the file input field(s),
- // can be a string or an array of strings.
- // options.formData: an array of objects with name and value properties,
- // equivalent to the return data of .serializeArray(), e.g.:
- // [{name: 'a', value: 1}, {name: 'b', value: 2}]
- $.ajaxTransport('iframe', function (options) {
- if (options.async) {
- var form,
- iframe,
- addParamChar;
- return {
- send: function (_, completeCallback) {
- form = $('<form style="display:none;"></form>');
- form.attr('accept-charset', options.formAcceptCharset);
- addParamChar = /\?/.test(options.url) ? '&' : '?';
- // XDomainRequest only supports GET and POST:
- if (options.type === 'DELETE') {
- options.url = options.url + addParamChar + '_method=DELETE';
- options.type = 'POST';
- } else if (options.type === 'PUT') {
- options.url = options.url + addParamChar + '_method=PUT';
- options.type = 'POST';
- } else if (options.type === 'PATCH') {
- options.url = options.url + addParamChar + '_method=PATCH';
- options.type = 'POST';
- }
- // javascript:false as initial iframe src
- // prevents warning popups on HTTPS in IE6.
- // IE versions below IE8 cannot set the name property of
- // elements that have already been added to the DOM,
- // so we set the name along with the iframe HTML markup:
- counter += 1;
- iframe = $(
- '<iframe src="javascript:false;" name="iframe-transport-' +
- counter + '"></iframe>'
- ).bind('load', function () {
- var fileInputClones,
- paramNames = $.isArray(options.paramName) ?
- options.paramName : [options.paramName];
- iframe
- .unbind('load')
- .bind('load', function () {
- var response;
- // Wrap in a try/catch block to catch exceptions thrown
- // when trying to access cross-domain iframe contents:
- try {
- response = iframe.contents();
- // Google Chrome and Firefox do not throw an
- // exception when calling iframe.contents() on
- // cross-domain requests, so we unify the response:
- if (!response.length || !response[0].firstChild) {
- throw new Error();
- }
- } catch (e) {
- response = undefined;
- }
- // The complete callback returns the
- // iframe content document as response object:
- completeCallback(
- 200,
- 'success',
- {'iframe': response}
- );
- // Fix for IE endless progress bar activity bug
- // (happens on form submits to iframe targets):
- $('<iframe src="javascript:false;"></iframe>')
- .appendTo(form);
- window.setTimeout(function () {
- // Removing the form in a setTimeout call
- // allows Chrome's developer tools to display
- // the response result
- form.remove();
- }, 0);
- });
- form
- .prop('target', iframe.prop('name'))
- .prop('action', options.url)
- .prop('method', options.type);
- if (options.formData) {
- $.each(options.formData, function (index, field) {
- $('<input type="hidden"/>')
- .prop('name', field.name)
- .val(field.value)
- .appendTo(form);
- });
- }
- if (options.fileInput && options.fileInput.length &&
- options.type === 'POST') {
- fileInputClones = options.fileInput.clone();
- // Insert a clone for each file input field:
- options.fileInput.after(function (index) {
- return fileInputClones[index];
- });
- if (options.paramName) {
- options.fileInput.each(function (index) {
- $(this).prop(
- 'name',
- paramNames[index] || options.paramName
- );
- });
- }
- // Appending the file input fields to the hidden form
- // removes them from their original location:
- form
- .append(options.fileInput)
- .prop('enctype', 'multipart/form-data')
- // enctype must be set as encoding for IE:
- .prop('encoding', 'multipart/form-data');
- }
- form.submit();
- // Insert the file input fields at their original location
- // by replacing the clones with the originals:
- if (fileInputClones && fileInputClones.length) {
- options.fileInput.each(function (index, input) {
- var clone = $(fileInputClones[index]);
- $(input).prop('name', clone.prop('name'));
- clone.replaceWith(input);
- });
- }
- });
- form.append(iframe).appendTo(document.body);
- },
- abort: function () {
- if (iframe) {
- // javascript:false as iframe src aborts the request
- // and prevents warning popups on HTTPS in IE6.
- // concat is used to avoid the "Script URL" JSLint error:
- iframe
- .unbind('load')
- .prop('src', 'javascript'.concat(':false;'));
- }
- if (form) {
- form.remove();
- }
- }
- };
- }
- });
-
- // The iframe transport returns the iframe content document as response.
- // The following adds converters from iframe to text, json, html, xml
- // and script.
- // Please note that the Content-Type for JSON responses has to be text/plain
- // or text/html, if the browser doesn't include application/json in the
- // Accept header, else IE will show a download dialog.
- // The Content-Type for XML responses on the other hand has to be always
- // application/xml or text/xml, so IE properly parses the XML response.
- // See also
- // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
- $.ajaxSetup({
- converters: {
- 'iframe text': function (iframe) {
- return iframe && $(iframe[0].body).text();
- },
- 'iframe json': function (iframe) {
- return iframe && $.parseJSON($(iframe[0].body).text());
- },
- 'iframe html': function (iframe) {
- return iframe && $(iframe[0].body).html();
- },
- 'iframe xml': function (iframe) {
- var xmlDoc = iframe && iframe[0];
- return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
- $.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
- $(xmlDoc.body).html());
- },
- 'iframe script': function (iframe) {
- return iframe && $.globalEval($(iframe[0].body).text());
- }
- }
- });
-
-})); \ No newline at end of file
diff --git a/apps/files/l10n/en_GB.js b/apps/files/l10n/en_GB.js
index c9fd96ea507..a15c67400b7 100644
--- a/apps/files/l10n/en_GB.js
+++ b/apps/files/l10n/en_GB.js
@@ -106,6 +106,7 @@ OC.L10N.register(
"Missing permissions to edit from here." : "Missing permissions to edit from here.",
"Settings" : "Settings",
"WebDAV" : "WebDAV",
+ "Use this address to <a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">access your Files via WebDAV</a>" : "Use this address to <a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">access your Files via WebDAV</a>",
"Cancel upload" : "Cancel upload",
"No files in here" : "No files in here",
"Upload some content or sync with your devices!" : "Upload some content or sync with your devices!",
diff --git a/apps/files/l10n/en_GB.json b/apps/files/l10n/en_GB.json
index 172f49cfc38..46a71fdf049 100644
--- a/apps/files/l10n/en_GB.json
+++ b/apps/files/l10n/en_GB.json
@@ -104,6 +104,7 @@
"Missing permissions to edit from here." : "Missing permissions to edit from here.",
"Settings" : "Settings",
"WebDAV" : "WebDAV",
+ "Use this address to <a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">access your Files via WebDAV</a>" : "Use this address to <a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">access your Files via WebDAV</a>",
"Cancel upload" : "Cancel upload",
"No files in here" : "No files in here",
"Upload some content or sync with your devices!" : "Upload some content or sync with your devices!",
diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php
index 39a5875f3d0..9c79f806713 100644
--- a/apps/files/templates/appnavigation.php
+++ b/apps/files/templates/appnavigation.php
@@ -16,9 +16,13 @@
</button>
</div>
<div id="app-settings-content">
- <label for="webdavurl"><?php p($l->t('WebDAV'));?></label>
- <input id="webdavurl" type="text" readonly="readonly" value="<?php p(\OCP\Util::linkToRemote('webdav')); ?>" />
- <em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer">access your Files via WebDAV</a>', array(link_to_docs('user-webdav'))));?></em>
+ <div id="files-setting-showhidden">
+ <input class="checkbox" id="showhiddenfilesToggle" checked="checked" type="checkbox">
+ <label for="showhiddenfilesToggle"><?php p($l->t('Show hidden files')); ?></label>
+ </div>
+ <label for="webdavurl"><?php p($l->t('WebDAV'));?></label>
+ <input id="webdavurl" type="text" readonly="readonly" value="<?php p(\OCP\Util::linkToRemote('webdav')); ?>" />
+ <em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer">access your Files via WebDAV</a>', array(link_to_docs('user-webdav'))));?></em>
</div>
</div>
</div>
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index db464ad2eca..7281edd3aec 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -20,4 +20,5 @@
<input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="<?php p($_['allowShareWithLink']) ?>" />
<input type="hidden" name="defaultFileSorting" id="defaultFileSorting" value="<?php p($_['defaultFileSorting']) ?>" />
<input type="hidden" name="defaultFileSortingDirection" id="defaultFileSortingDirection" value="<?php p($_['defaultFileSortingDirection']) ?>" />
+<input type="hidden" name="showHiddenFiles" id="showHiddenFiles" value="<?php p($_['showHiddenFiles']); ?>" />
<?php endif;
diff --git a/apps/files/tests/controller/ViewControllerTest.php b/apps/files/tests/controller/ViewControllerTest.php
index 0446cc8982c..420e635b4b9 100644
--- a/apps/files/tests/controller/ViewControllerTest.php
+++ b/apps/files/tests/controller/ViewControllerTest.php
@@ -155,11 +155,12 @@ class ViewControllerTest extends TestCase {
'owner' => 'MyName',
'ownerDisplayName' => 'MyDisplayName',
]));
- $this->config->expects($this->exactly(2))
+ $this->config->expects($this->exactly(3))
->method('getUserValue')
->will($this->returnValueMap([
[$this->user->getUID(), 'files', 'file_sorting', 'name', 'name'],
- [$this->user->getUID(), 'files', 'file_sorting_direction', 'asc', 'asc']
+ [$this->user->getUID(), 'files', 'file_sorting_direction', 'asc', 'asc'],
+ [$this->user->getUID(), 'files', 'show_hidden', false, false],
]));
$this->config
@@ -244,6 +245,7 @@ class ViewControllerTest extends TestCase {
'isPublic' => false,
'defaultFileSorting' => 'name',
'defaultFileSortingDirection' => 'asc',
+ 'showHiddenFiles' => false,
'mailNotificationEnabled' => 'no',
'mailPublicNotificationEnabled' => 'no',
'allowShareWithLink' => 'yes',
diff --git a/apps/files/tests/controller/apicontrollertest.php b/apps/files/tests/controller/apicontrollertest.php
index 59f53e8ee81..2eba7d62feb 100644
--- a/apps/files/tests/controller/apicontrollertest.php
+++ b/apps/files/tests/controller/apicontrollertest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@owncloud.com>
@@ -382,4 +383,17 @@ class ApiControllerTest extends TestCase {
$this->assertEquals($expected, $result);
}
+ public function testShowHiddenFiles() {
+ $show = false;
+
+ $this->config->expects($this->once())
+ ->method('setUserValue')
+ ->with($this->user->getUID(), 'files', 'show_hidden', $show);
+
+ $expected = new Http\Response();
+ $actual = $this->apiController->showHiddenFiles($show);
+
+ $this->assertEquals($expected, $actual);
+ }
+
}
diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php
index 64c7517456d..5233b343830 100644
--- a/apps/files_sharing/appinfo/application.php
+++ b/apps/files_sharing/appinfo/application.php
@@ -111,7 +111,8 @@ class Application extends App {
/** @var \OCP\IServerContainer $server */
$server = $c->query('ServerContainer');
return new MountProvider(
- $server->getConfig()
+ $server->getConfig(),
+ $server->getShareManager()
);
});
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js
index af198208de2..6f12b3d4456 100644
--- a/apps/files_sharing/js/app.js
+++ b/apps/files_sharing/js/app.js
@@ -33,7 +33,8 @@ OCA.Sharing.App = {
id: 'shares.self',
scrollContainer: $('#app-content'),
sharedWithUser: true,
- fileActions: this._createFileActions()
+ fileActions: this._createFileActions(),
+ config: OCA.Files.App.getFilesConfig()
}
);
@@ -55,7 +56,8 @@ OCA.Sharing.App = {
id: 'shares.others',
scrollContainer: $('#app-content'),
sharedWithUser: false,
- fileActions: this._createFileActions()
+ fileActions: this._createFileActions(),
+ config: OCA.Files.App.getFilesConfig()
}
);
@@ -77,7 +79,8 @@ OCA.Sharing.App = {
id: 'shares.link',
scrollContainer: $('#app-content'),
linksOnly: true,
- fileActions: this._createFileActions()
+ fileActions: this._createFileActions(),
+ config: OCA.Files.App.getFilesConfig()
}
);
diff --git a/apps/files_sharing/lib/mountprovider.php b/apps/files_sharing/lib/mountprovider.php
index 6c8bbb62ee7..8e133951293 100644
--- a/apps/files_sharing/lib/mountprovider.php
+++ b/apps/files_sharing/lib/mountprovider.php
@@ -22,12 +22,11 @@
namespace OCA\Files_Sharing;
-use OC\Files\Filesystem;
-use OC\User\NoUserException;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
use OCP\IConfig;
use OCP\IUser;
+use OCP\Share\IManager;
class MountProvider implements IMountProvider {
/**
@@ -36,10 +35,17 @@ class MountProvider implements IMountProvider {
protected $config;
/**
+ * @var IManager
+ */
+ protected $shareManager;
+
+ /**
* @param \OCP\IConfig $config
+ * @param IManager $shareManager
*/
- public function __construct(IConfig $config) {
+ public function __construct(IConfig $config, IManager $shareManager) {
$this->config = $config;
+ $this->shareManager = $shareManager;
}
@@ -51,18 +57,21 @@ class MountProvider implements IMountProvider {
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
- $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
- $shares = array_filter($shares, function ($share) {
- return $share['permissions'] > 0;
+ $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1);
+ $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1));
+ $shares = array_filter($shares, function (\OCP\Share\IShare $share) {
+ return $share->getPermissions() > 0;
});
+
$mounts = [];
foreach ($shares as $share) {
+
$mounts[] = new SharedMount(
'\OC\Files\Storage\Shared',
$mounts,
[
- 'share' => $share,
- 'user' => $user->getUID()
+ 'user' => $user->getUID(),
+ 'newShare' => $share,
],
$storageFactory
);
diff --git a/apps/files_sharing/lib/scanner.php b/apps/files_sharing/lib/scanner.php
index 8b32d014a08..2e951423aa2 100644
--- a/apps/files_sharing/lib/scanner.php
+++ b/apps/files_sharing/lib/scanner.php
@@ -42,8 +42,10 @@ class SharedScanner extends Scanner {
*/
public function getData($path) {
$data = parent::getData($path);
- $sourcePath = $this->storage->getSourcePath($path);
- list($sourceStorage, $internalPath) = \OC\Files\Filesystem::resolvePath($sourcePath);
+ if ($data === null) {
+ return null;
+ }
+ list($sourceStorage, $internalPath) = $this->storage->resolvePath($path);
$data['permissions'] = $sourceStorage->getPermissions($internalPath);
return $data;
}
diff --git a/apps/files_sharing/lib/sharedmount.php b/apps/files_sharing/lib/sharedmount.php
index 311e81269db..4aed80b12b2 100644
--- a/apps/files_sharing/lib/sharedmount.php
+++ b/apps/files_sharing/lib/sharedmount.php
@@ -49,6 +49,9 @@ class SharedMount extends MountPoint implements MoveableMount {
*/
private $user;
+ /** @var \OCP\Share\IShare */
+ private $share;
+
/**
* @param string $storage
* @param SharedMount[] $mountpoints
@@ -58,23 +61,24 @@ class SharedMount extends MountPoint implements MoveableMount {
public function __construct($storage, array $mountpoints, $arguments = null, $loader = null) {
$this->user = $arguments['user'];
$this->recipientView = new View('/' . $this->user . '/files');
- $newMountPoint = $this->verifyMountPoint($arguments['share'], $mountpoints);
+ $this->share = $arguments['newShare'];
+ $newMountPoint = $this->verifyMountPoint($this->share, $mountpoints);
$absMountPoint = '/' . $this->user . '/files' . $newMountPoint;
- $arguments['ownerView'] = new View('/' . $arguments['share']['uid_owner'] . '/files');
+ $arguments['ownerView'] = new View('/' . $this->share->getShareOwner() . '/files');
parent::__construct($storage, $absMountPoint, $arguments, $loader);
}
/**
* check if the parent folder exists otherwise move the mount point up
*
- * @param array $share
+ * @param \OCP\Share\IShare $share
* @param SharedMount[] $mountpoints
* @return string
*/
- private function verifyMountPoint(&$share, array $mountpoints) {
+ private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints) {
- $mountPoint = basename($share['file_target']);
- $parent = dirname($share['file_target']);
+ $mountPoint = basename($share->getTarget());
+ $parent = dirname($share->getTarget());
if (!$this->recipientView->is_dir($parent)) {
$parent = Helper::getShareFolder();
@@ -86,16 +90,27 @@ class SharedMount extends MountPoint implements MoveableMount {
$mountpoints
);
- if ($newMountPoint !== $share['file_target']) {
+ if ($newMountPoint !== $share->getTarget()) {
$this->updateFileTarget($newMountPoint, $share);
- $share['file_target'] = $newMountPoint;
- $share['unique_name'] = true;
}
return $newMountPoint;
}
/**
+ * update fileTarget in the database if the mount point changed
+ *
+ * @param string $newPath
+ * @param \OCP\Share\IShare $share
+ * @return bool
+ */
+ private function updateFileTarget($newPath, &$share) {
+ $share->setTarget($newPath);
+ \OC::$server->getShareManager()->moveShare($share, $this->user);
+ }
+
+
+ /**
* @param string $path
* @param View $view
* @param SharedMount[] $mountpoints
@@ -110,7 +125,7 @@ class SharedMount extends MountPoint implements MoveableMount {
// Helper function to find existing mount points
$mountpointExists = function($path) use ($mountpoints) {
foreach ($mountpoints as $mountpoint) {
- if ($mountpoint->getShare()['file_target'] === $path) {
+ if ($mountpoint->getShare()->getTarget() === $path) {
return true;
}
}
@@ -127,38 +142,6 @@ class SharedMount extends MountPoint implements MoveableMount {
}
/**
- * update fileTarget in the database if the mount point changed
- *
- * @param string $newPath
- * @param array $share reference to the share which should be modified
- * @return bool
- */
- private function updateFileTarget($newPath, &$share) {
- // if the user renames a mount point from a group share we need to create a new db entry
- // for the unique name
- if ($share['share_type'] === \OCP\Share::SHARE_TYPE_GROUP && empty($share['unique_name'])) {
- $query = \OCP\DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`,'
- .' `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,'
- .' `file_target`, `token`, `parent`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)');
- $arguments = array($share['item_type'], $share['item_source'], $share['item_target'],
- 2, $this->user, $share['uid_owner'], $share['permissions'], $share['stime'], $share['file_source'],
- $newPath, $share['token'], $share['id']);
- } else {
- // rename mount point
- $query = \OCP\DB::prepare(
- 'Update `*PREFIX*share`
- SET `file_target` = ?
- WHERE `id` = ?'
- );
- $arguments = array($newPath, $share['id']);
- }
-
- $result = $query->execute($arguments);
-
- return $result === 1 ? true : false;
- }
-
- /**
* Format a path to be relative to the /user/files/ directory
*
* @param string $path the absolute path
@@ -197,20 +180,11 @@ class SharedMount extends MountPoint implements MoveableMount {
$result = true;
- if (!empty($share['grouped'])) {
- foreach ($share['grouped'] as $s) {
- $result = $this->updateFileTarget($relTargetPath, $s) && $result;
- }
- } else {
- $result = $this->updateFileTarget($relTargetPath, $share) && $result;
- }
-
- if ($result) {
+ try {
+ $this->updateFileTarget($relTargetPath, $share);
$this->setMountPoint($target);
- $this->storage->setUniqueName();
$this->storage->setMountPoint($relTargetPath);
-
- } else {
+ } catch (\Exception $e) {
\OCP\Util::writeLog('file sharing',
'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"',
\OCP\Util::ERROR);
@@ -235,11 +209,18 @@ class SharedMount extends MountPoint implements MoveableMount {
}
/**
- * @return array
+ * @return \OCP\Share\IShare
*/
public function getShare() {
- /** @var $storage \OC\Files\Storage\Shared */
- $storage = $this->getStorage();
- return $storage->getShare();
+ return $this->share;
+ }
+
+ /**
+ * Get the file id of the root of the storage
+ *
+ * @return int
+ */
+ public function getStorageRootId() {
+ return $this->share->getNodeId();
}
}
diff --git a/apps/files_sharing/lib/sharedpropagator.php b/apps/files_sharing/lib/sharedpropagator.php
index 29735934499..8de90b9552b 100644
--- a/apps/files_sharing/lib/sharedpropagator.php
+++ b/apps/files_sharing/lib/sharedpropagator.php
@@ -36,9 +36,8 @@ class SharedPropagator extends Propagator {
* @return \array[] all propagated entries
*/
public function propagateChange($internalPath, $time, $sizeDifference = 0) {
- $source = $this->storage->getSourcePath($internalPath);
/** @var \OC\Files\Storage\Storage $storage */
- list($storage, $sourceInternalPath) = \OC\Files\Filesystem::resolvePath($source);
+ list($storage, $sourceInternalPath) = $this->storage->resolvePath($internalPath);
return $storage->getPropagator()->propagateChange($sourceInternalPath, $time, $sizeDifference);
}
}
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 8f4888d20e2..48ab3fad5f6 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -41,21 +41,18 @@ use OCP\Lock\ILockingProvider;
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
-class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
+class Shared extends \OC\Files\Storage\Wrapper\Jail implements ISharedStorage {
private $share; // the shared resource
- private $files = array();
+
+ /** @var \OCP\Share\IShare */
+ private $newShare;
/**
* @var \OC\Files\View
*/
private $ownerView;
- /**
- * @var string
- */
- private $user;
-
private $initialized = false;
/**
@@ -68,16 +65,28 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
*/
private $sourceStorage;
+ /** @var string */
+ private $user;
+
/**
* @var \OCP\ILogger
*/
private $logger;
public function __construct($arguments) {
- $this->share = $arguments['share'];
$this->ownerView = $arguments['ownerView'];
- $this->user = $arguments['user'];
$this->logger = \OC::$server->getLogger();
+ $this->newShare = $arguments['newShare'];
+ $this->user = $arguments['user'];
+
+ Filesystem::initMountPoints($this->newShare->getShareOwner());
+ $sourcePath = $this->ownerView->getPath($this->newShare->getNodeId());
+ list($storage, $internalPath) = $this->ownerView->resolvePath($sourcePath);
+
+ parent::__construct([
+ 'storage' => $storage,
+ 'root' => $internalPath,
+ ]);
}
private function init() {
@@ -86,8 +95,8 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
}
$this->initialized = true;
try {
- Filesystem::initMountPoints($this->share['uid_owner']);
- $sourcePath = $this->ownerView->getPath($this->share['file_source']);
+ Filesystem::initMountPoints($this->newShare->getShareOwner());
+ $sourcePath = $this->ownerView->getPath($this->newShare->getNodeId());
list($this->sourceStorage, $sourceInternalPath) = $this->ownerView->resolvePath($sourcePath);
$this->sourceRootInfo = $this->sourceStorage->getCache()->get($sourceInternalPath);
} catch (\Exception $e) {
@@ -115,59 +124,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @return int
*/
public function getSourceId() {
- return (int)$this->share['file_source'];
- }
-
- /**
- * Get the source file path, permissions, and owner for a shared file
- *
- * @param string $target Shared target file path
- * @return array Returns array with the keys path, permissions, and owner or false if not found
- */
- public function getFile($target) {
- $this->init();
- if (!isset($this->files[$target])) {
- // Check for partial files
- if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
- $source = \OC_Share_Backend_File::getSource(substr($target, 0, -5), $this->getShare());
- if ($source) {
- $source['path'] .= '.part';
- // All partial files have delete permission
- $source['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
- }
- } else {
- $source = \OC_Share_Backend_File::getSource($target, $this->getShare());
- }
- $this->files[$target] = $source;
- }
- return $this->files[$target];
- }
-
- /**
- * Get the source file path for a shared file
- *
- * @param string $target Shared target file path
- * @return string|false source file path or false if not found
- */
- public function getSourcePath($target) {
- if (!$this->isValid()){
- return false;
- }
- $source = $this->getFile($target);
- if ($source) {
- if (!isset($source['fullPath'])) {
- \OC\Files\Filesystem::initMountPoints($source['fileOwner']);
- $mount = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
- if (is_array($mount) && !empty($mount)) {
- $this->files[$target]['fullPath'] = $mount[key($mount)]->getMountPoint() . $source['path'];
- } else {
- $this->files[$target]['fullPath'] = false;
- \OCP\Util::writeLog('files_sharing', "Unable to get mount for shared storage '" . $source['storage'] . "' user '" . $source['fileOwner'] . "'", \OCP\Util::ERROR);
- }
- }
- return $this->files[$target]['fullPath'];
- }
- return false;
+ return $this->newShare->getNodeId();
}
/**
@@ -180,7 +137,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
if (!$this->isValid()) {
return 0;
}
- $permissions = $this->share['permissions'];
+ $permissions = $this->newShare->getPermissions();
// part files and the mount point always have delete permissions
if ($target === '' || pathinfo($target, PATHINFO_EXTENSION) === 'part') {
$permissions |= \OCP\Constants::PERMISSION_DELETE;
@@ -193,84 +150,6 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
return $permissions;
}
- public function mkdir($path) {
- if ($path == '' || $path == '/' || !$this->isCreatable(dirname($path))) {
- return false;
- } else if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->mkdir($internalPath);
- }
- return false;
- }
-
- /**
- * Delete the directory if DELETE permission is granted
- *
- * @param string $path
- * @return boolean
- */
- public function rmdir($path) {
-
- // never delete a share mount point
- if (empty($path)) {
- return false;
- }
-
- if (($source = $this->getSourcePath($path)) && $this->isDeletable($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->rmdir($internalPath);
- }
- return false;
- }
-
- public function opendir($path) {
- $source = $this->getSourcePath($path);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->opendir($internalPath);
- }
-
- public function is_dir($path) {
- $source = $this->getSourcePath($path);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->is_dir($internalPath);
- }
-
- public function is_file($path) {
- if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->is_file($internalPath);
- }
- return false;
- }
-
- public function stat($path) {
- if ($path == '' || $path == '/') {
- $stat['size'] = $this->filesize($path);
- $stat['mtime'] = $this->filemtime($path);
- return $stat;
- } else if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->stat($internalPath);
- }
- return false;
- }
-
- public function filetype($path) {
- if ($path == '' || $path == '/') {
- return 'dir';
- } else if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->filetype($internalPath);
- }
- return false;
- }
-
- public function filesize($path) {
- $source = $this->getSourcePath($path);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->filesize($internalPath);
- }
-
public function isCreatable($path) {
return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_CREATE);
}
@@ -301,127 +180,6 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
return ($this->getPermissions($path) & \OCP\Constants::PERMISSION_SHARE);
}
- public function file_exists($path) {
- if ($path == '' || $path == '/') {
- return true;
- } else if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->file_exists($internalPath);
- }
- return false;
- }
-
- public function filemtime($path) {
- $source = $this->getSourcePath($path);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->filemtime($internalPath);
- }
-
- public function file_get_contents($path) {
- $source = $this->getSourcePath($path);
- if ($source) {
- $info = array(
- 'target' => $this->getMountPoint() . $path,
- 'source' => $source,
- );
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_get_contents', $info);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->file_get_contents($internalPath);
- }
- }
-
- public function file_put_contents($path, $data) {
- if ($source = $this->getSourcePath($path)) {
- // Check if permission is granted
- if (($this->file_exists($path) && !$this->isUpdatable($path))
- || ($this->is_dir($path) && !$this->isCreatable($path))
- ) {
- return false;
- }
- $info = array(
- 'target' => $this->getMountPoint() . '/' . $path,
- 'source' => $source,
- );
- \OCP\Util::emitHook('\OC\Files\Storage\Shared', 'file_put_contents', $info);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- $result = $storage->file_put_contents($internalPath, $data);
- return $result;
- }
- return false;
- }
-
- /**
- * Delete the file if DELETE permission is granted
- *
- * @param string $path
- * @return boolean
- */
- public function unlink($path) {
-
- // never delete a share mount point
- if (empty($path)) {
- return false;
- }
- if ($source = $this->getSourcePath($path)) {
- if ($this->isDeletable($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->unlink($internalPath);
- }
- }
- return false;
- }
-
- public function rename($path1, $path2) {
- $this->init();
- // we need the paths relative to data/user/files
- $relPath1 = $this->getMountPoint() . '/' . $path1;
- $relPath2 = $this->getMountPoint() . '/' . $path2;
- $pathinfo = pathinfo($relPath1);
-
- $isPartFile = (isset($pathinfo['extension']) && $pathinfo['extension'] === 'part');
- $targetExists = $this->file_exists($path2);
- $sameFolder = (dirname($relPath1) === dirname($relPath2));
- if ($targetExists || ($sameFolder && !$isPartFile)) {
- // note that renaming a share mount point is always allowed
- if (!$this->isUpdatable('')) {
- return false;
- }
- } else {
- if (!$this->isCreatable('')) {
- return false;
- }
- }
-
-
- /**
- * @var \OC\Files\Storage\Storage $sourceStorage
- */
- list($sourceStorage, $sourceInternalPath) = $this->resolvePath($path1);
- /**
- * @var \OC\Files\Storage\Storage $targetStorage
- */
- list($targetStorage, $targetInternalPath) = $this->resolvePath($path2);
-
- return $targetStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
- }
-
- public function copy($path1, $path2) {
- // Copy the file if CREATE permission is granted
- if ($this->isCreatable(dirname($path2))) {
- /**
- * @var \OC\Files\Storage\Storage $sourceStorage
- */
- list($sourceStorage, $sourceInternalPath) = $this->resolvePath($path1);
- /**
- * @var \OC\Files\Storage\Storage $targetStorage
- */
- list($targetStorage, $targetInternalPath) = $this->resolvePath($path2);
-
- return $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
- }
- return false;
- }
-
public function fopen($path, $mode) {
if ($source = $this->getSourcePath($path)) {
switch ($mode) {
@@ -465,43 +223,34 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
'mode' => $mode,
);
\OCP\Util::emitHook('\OC\Files\Storage\Shared', 'fopen', $info);
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->fopen($internalPath, $mode);
+ return parent::fopen($path, $mode);
}
return false;
}
- public function getMimeType($path) {
- if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->getMimeType($internalPath);
- }
- return false;
- }
-
- public function free_space($path) {
- $source = $this->getSourcePath($path);
- if ($source) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->free_space($internalPath);
- }
- return \OCP\Files\FileInfo::SPACE_UNKNOWN;
- }
+ /**
+ * see http://php.net/manual/en/function.rename.php
+ *
+ * @param string $path1
+ * @param string $path2
+ * @return bool
+ */
+ public function rename($path1, $path2) {
+ $isPartFile = pathinfo($path1, PATHINFO_EXTENSION) === 'part';
+ $targetExists = $this->file_exists($path2);
+ $sameFodler = dirname($path1) === dirname($path2);
- public function getLocalFile($path) {
- if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->getLocalFile($internalPath);
+ if ($targetExists || ($sameFodler && !$isPartFile)) {
+ if (!$this->isUpdatable('')) {
+ return false;
+ }
+ } else {
+ if (!$this->isCreatable('')) {
+ return false;
+ }
}
- return false;
- }
- public function touch($path, $mtime = null) {
- if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->touch($internalPath, $mtime);
- }
- return false;
+ return parent::rename($path1, $path2);
}
/**
@@ -510,33 +259,21 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @return string
*/
public function getMountPoint() {
- return $this->share['file_target'];
- }
-
- public function setMountPoint($path) {
- $this->share['file_target'] = $path;
- }
-
- public function getShareType() {
- return $this->share['share_type'];
+ return $this->newShare->getTarget();
}
/**
- * does the group share already has a user specific unique name
- *
- * @return bool
+ * @param string $path
*/
- public function uniqueNameSet() {
- return (isset($this->share['unique_name']) && $this->share['unique_name']);
+ public function setMountPoint($path) {
+ $this->newShare->setTarget($path);
}
/**
- * the share now uses a unique name of this user
- *
- * @brief the share now uses a unique name of this user
+ * @return int
*/
- public function setUniqueName() {
- $this->share['unique_name'] = true;
+ public function getShareType() {
+ return $this->newShare->getShareType();
}
/**
@@ -545,7 +282,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @return integer unique share ID
*/
public function getShareId() {
- return $this->share['id'];
+ return $this->newShare->getId();
}
/**
@@ -554,14 +291,14 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @return string
*/
public function getSharedFrom() {
- return $this->share['uid_owner'];
+ return $this->newShare->getShareOwner();
}
/**
- * @return array
+ * @return \OCP\Share\IShare
*/
public function getShare() {
- return $this->share;
+ return $this->newShare;
}
/**
@@ -570,11 +307,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @return string
*/
public function getItemType() {
- return $this->share['item_type'];
- }
-
- public function hasUpdated($path, $time) {
- return $this->filemtime($path) > $time;
+ return $this->newShare->getNodeType();
}
public function getCache($path = '', $storage = null) {
@@ -603,22 +336,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
}
public function getOwner($path) {
- if ($path == '') {
- $path = $this->getMountPoint();
- }
- $source = $this->getFile($path);
- if ($source) {
- return $source['fileOwner'];
- }
- return false;
- }
-
- public function getETag($path) {
- if ($source = $this->getSourcePath($path)) {
- list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
- return $storage->getETag($internalPath);
- }
- return null;
+ return $this->newShare->getShareOwner();
}
/**
@@ -627,50 +345,8 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
* @return bool
*/
public function unshareStorage() {
- $result = true;
- if (!empty($this->share['grouped'])) {
- foreach ($this->share['grouped'] as $share) {
- $result = $result && \OCP\Share::unshareFromSelf($share['item_type'], $share['file_target']);
- }
- }
- $result = $result && \OCP\Share::unshareFromSelf($this->getItemType(), $this->getMountPoint());
-
- return $result;
- }
-
- /**
- * Resolve the path for the source of the share
- *
- * @param string $path
- * @return array
- */
- public function resolvePath($path) {
- $source = $this->getSourcePath($path);
- return \OC\Files\Filesystem::resolvePath($source);
- }
-
- /**
- * @param \OCP\Files\Storage $sourceStorage
- * @param string $sourceInternalPath
- * @param string $targetInternalPath
- * @return bool
- */
- public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
- /** @var \OCP\Files\Storage $targetStorage */
- list($targetStorage, $targetInternalPath) = $this->resolvePath($targetInternalPath);
- return $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
- }
-
- /**
- * @param \OCP\Files\Storage $sourceStorage
- * @param string $sourceInternalPath
- * @param string $targetInternalPath
- * @return bool
- */
- public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
- /** @var \OCP\Files\Storage $targetStorage */
- list($targetStorage, $targetInternalPath) = $this->resolvePath($targetInternalPath);
- return $targetStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
+ \OC::$server->getShareManager()->deleteFromSelf($this->newShare, $this->user);
+ return true;
}
/**
@@ -685,7 +361,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
$targetStorage->acquireLock($targetInternalPath, $type, $provider);
// lock the parent folders of the owner when locking the share as recipient
if ($path === '') {
- $sourcePath = $this->ownerView->getPath($this->share['file_source']);
+ $sourcePath = $this->ownerView->getPath($this->newShare->getNodeId());
$this->ownerView->lockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
}
}
@@ -701,7 +377,7 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
$targetStorage->releaseLock($targetInternalPath, $type, $provider);
// unlock the parent folders of the owner when unlocking the share as recipient
if ($path === '') {
- $sourcePath = $this->ownerView->getPath($this->share['file_source']);
+ $sourcePath = $this->ownerView->getPath($this->newShare->getNodeId());
$this->ownerView->unlockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
}
}
@@ -735,14 +411,8 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
// shares do not participate in availability logic
}
- public function isLocal() {
- $this->init();
- $ownerPath = $this->ownerView->getPath($this->share['item_source']);
- list($targetStorage) = $this->ownerView->resolvePath($ownerPath);
- return $targetStorage->isLocal();
- }
-
public function getSourceStorage() {
return $this->sourceStorage;
}
+
}
diff --git a/apps/files_sharing/lib/updater.php b/apps/files_sharing/lib/updater.php
index 10da2462807..0e6433b1122 100644
--- a/apps/files_sharing/lib/updater.php
+++ b/apps/files_sharing/lib/updater.php
@@ -81,8 +81,10 @@ class Shared_Updater {
$src = $userFolder->get($path);
- $type = $src instanceof \OCP\Files\File ? 'file' : 'folder';
- $shares = \OCP\Share::getItemShared($type, $src->getId());
+ $shareManager = \OC::$server->getShareManager();
+
+ $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1);
+ $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1));
// If the path we move is not a share we don't care
if (empty($shares)) {
@@ -96,14 +98,13 @@ class Shared_Updater {
return;
}
- $parenShare = $dstMount->getShare();
+ $newOwner = $dstMount->getShare()->getShareOwner();
+ //Ownership is moved over
foreach ($shares as $share) {
- $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $qb->update('share')
- ->set('parent', $qb->createNamedParameter($parenShare['id']))
- ->where($qb->expr()->eq('id', $qb->createNamedParameter($share['id'])))
- ->execute();
+ /** @var \OCP\Share\IShare $share */
+ $share->setShareOwner($newOwner);
+ $shareManager->updateShare($share);
}
}
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index ae00b01dca2..cb7fe1103b5 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -8,7 +8,6 @@ OCP\Util::addStyle('files_sharing', 'mobile');
OCP\Util::addScript('files_sharing', 'public');
OCP\Util::addScript('files', 'fileactions');
OCP\Util::addScript('files', 'fileactionsmenu');
-OCP\Util::addScript('files', 'jquery.iframe-transport');
OCP\Util::addScript('files', 'jquery.fileupload');
// JS required for folders
diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php
index 08f8b6f243d..0a61e9a9fa2 100644
--- a/apps/files_sharing/tests/api.php
+++ b/apps/files_sharing/tests/api.php
@@ -40,9 +40,6 @@ class Test_Files_Sharing_Api extends TestCase {
private static $tempStorage;
- /** @var \OCP\Share\IManager */
- private $shareManager;
-
/** @var \OCP\Files\Folder */
private $userFolder;
@@ -66,7 +63,6 @@ class Test_Files_Sharing_Api extends TestCase {
$this->view->file_put_contents($this->folder.$this->filename, $this->data);
$this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
- $this->shareManager = \OC::$server->getShareManager();
$this->userFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
}
@@ -1195,10 +1191,13 @@ class Test_Files_Sharing_Api extends TestCase {
$fileInfo = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
-
- $this->assertTrue($result);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
// user2 shares a file from the folder as link
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
@@ -1215,14 +1214,20 @@ class Test_Files_Sharing_Api extends TestCase {
$this->assertTrue($fileInfo2 instanceof \OC\Files\FileInfo);
+ $pass = true;
try {
- $result2 = \OCP\Share::shareItem('folder', $fileInfo2['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER3, 31);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ 'localDir',
+ self::TEST_FILES_SHARING_API_USER2,
+ self::TEST_FILES_SHARING_API_USER3,
+ \OCP\Constants::PERMISSION_ALL
+ );
} catch (\Exception $e) {
- $result2 = false;
+ $pass = false;
}
- $this->assertFalse($result2);
+ $this->assertFalse($pass);
//cleanup
@@ -1232,8 +1237,7 @@ class Test_Files_Sharing_Api extends TestCase {
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+ $this->shareManager->deleteShare($share);
}
/**
@@ -1264,10 +1268,13 @@ class Test_Files_Sharing_Api extends TestCase {
$fileInfo = $this->view->getFileInfo($this->folder);
// user 1 shares the mount point folder with user2
- $result = \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2, 31);
-
- $this->assertTrue($result);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
// user2: check that mount point name appears correctly
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
@@ -1279,8 +1286,7 @@ class Test_Files_Sharing_Api extends TestCase {
\Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER2);
+ $this->shareManager->deleteShare($share);
\OC_Hook::clear('OC_Filesystem', 'post_initMountPoints', '\Test_Files_Sharing_Api', 'initTestMountPointsHook');
}
diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php
index fcc5a343a03..dd727c1c6f2 100644
--- a/apps/files_sharing/tests/cache.php
+++ b/apps/files_sharing/tests/cache.php
@@ -26,27 +26,6 @@
*/
use OCA\Files_sharing\Tests\TestCase;
-/**
- * ownCloud
- *
- * @author Vincent Petry, Bjoern Schiessle
- * @copyright 2014 Vincent Petry <pvince81@owncloud.com>
- * 2014 Bjoern Schiessle <schiessle@owncloud.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU Affero General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- *
- */
/**
* Class Test_Files_Sharing_Cache
@@ -72,9 +51,14 @@ class Test_Files_Sharing_Cache extends TestCase {
/** @var \OC\Files\Storage\Storage */
protected $sharedStorage;
+ /** @var \OCP\Share\IManager */
+ protected $shareManager;
+
protected function setUp() {
parent::setUp();
+ $this->shareManager = \OC::$server->getShareManager();
+
\OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER1, 'User One');
\OC_User::setDisplayName(self::TEST_FILES_SHARING_API_USER2, 'User Two');
@@ -101,13 +85,25 @@ class Test_Files_Sharing_Cache extends TestCase {
$this->ownerStorage->getScanner()->scan('');
// share "shareddir" with user2
- $fileinfo = $this->view->getFileInfo('container/shareddir');
- \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
-
- $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
- \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+
+ $node = $rootFolder->get('container/shareddir');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $this->shareManager->createShare($share);
+
+ $node = $rootFolder->get('container/shared single file.txt');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE));
+ $this->shareManager->createShare($share);
// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -125,13 +121,10 @@ class Test_Files_Sharing_Cache extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $fileinfo = $this->view->getFileInfo('container/shareddir');
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
-
- $fileinfo = $this->view->getFileInfo('container/shared single file.txt');
- \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
+ $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER);
+ foreach ($shares as $share) {
+ $this->shareManager->deleteShare($share);
+ }
$this->view->deleteAll('container');
@@ -392,9 +385,15 @@ class Test_Files_Sharing_Cache extends TestCase {
function testGetFolderContentsWhenSubSubdirShared() {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $fileinfo = $this->view->getFileInfo('container/shareddir/subdir');
- \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER3, 31);
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $rootFolder->get('container/shareddir/subdir');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = $this->shareManager->createShare($share);
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
@@ -430,8 +429,7 @@ class Test_Files_Sharing_Cache extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER3);
+ $this->shareManager->deleteShare($share);
}
/**
@@ -470,7 +468,17 @@ class Test_Files_Sharing_Cache extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OC\Files\Filesystem::file_put_contents('test.txt', 'foo');
$info = \OC\Files\Filesystem::getFileInfo('test.txt');
- \OCP\Share::shareItem('file', $info->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
+
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $rootFolder->get('test.txt');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ $this->shareManager->createShare($share);
+
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -491,7 +499,16 @@ class Test_Files_Sharing_Cache extends TestCase {
\OC\Files\Filesystem::touch('foo/bar/test.txt');
$folderInfo = \OC\Files\Filesystem::getFileInfo('foo');
$fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt');
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
+
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $rootFolder->get('foo');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $this->shareManager->createShare($share);
\OC_Util::tearDownFS();
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
diff --git a/apps/files_sharing/tests/etagpropagation.php b/apps/files_sharing/tests/etagpropagation.php
index 55972dd9221..2f3604e63cd 100644
--- a/apps/files_sharing/tests/etagpropagation.php
+++ b/apps/files_sharing/tests/etagpropagation.php
@@ -50,13 +50,15 @@ class EtagPropagation extends PropagationTestCase {
$this->fileIds[self::TEST_FILES_SHARING_API_USER3] = [];
$this->fileIds[self::TEST_FILES_SHARING_API_USER4] = [];
+ $rootFolder = \OC::$server->getRootFolder();
+ $shareManager = \OC::$server->getShareManager();
+
$this->rootView = new View('');
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
$view1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
$view1->mkdir('/sub1/sub2/folder/inside');
$view1->mkdir('/directReshare');
$view1->mkdir('/sub1/sub2/folder/other');
- $view1->mkdir('/sub1/sub2/folder/other');
$view1->file_put_contents('/foo.txt', 'foobar');
$view1->file_put_contents('/sub1/sub2/folder/file.txt', 'foobar');
$view1->file_put_contents('/sub1/sub2/folder/inside/file.txt', 'foobar');
@@ -64,30 +66,90 @@ class EtagPropagation extends PropagationTestCase {
$this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo);
$fileInfo = $view1->getFileInfo('/foo.txt');
$this->assertInstanceOf('\OC\Files\FileInfo', $fileInfo);
- \OCP\Share::shareItem('file', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31);
+
+ $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1)
+ ->get('/foo.txt');
+ $share = $shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ $shareManager->createShare($share);
+ $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1)
+ ->get('/sub1/sub2/folder');
+ $share = $shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $shareManager->createShare($share);
+ $share = $shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $shareManager->createShare($share);
+
$folderInfo = $view1->getFileInfo('/directReshare');
$this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo);
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
+
+ $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1)
+ ->get('/directReshare');
+ $share = $shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $shareManager->createShare($share);
+
$this->fileIds[self::TEST_FILES_SHARING_API_USER1][''] = $view1->getFileInfo('')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER1]['sub1'] = $view1->getFileInfo('sub1')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER1]['sub1/sub2'] = $view1->getFileInfo('sub1/sub2')->getId();
+ /*
+ * User 2
+ */
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
$view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$view2->mkdir('/sub1/sub2');
$view2->rename('/folder', '/sub1/sub2/folder');
$insideInfo = $view2->getFileInfo('/sub1/sub2/folder/inside');
$this->assertInstanceOf('\OC\Files\FileInfo', $insideInfo);
- \OCP\Share::shareItem('folder', $insideInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER4, 31);
+
+ $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER2)
+ ->get('/sub1/sub2/folder/inside');
+ $share = $shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER4)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $shareManager->createShare($share);
+
$folderInfo = $view2->getFileInfo('/directReshare');
$this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo);
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER4, 31);
+
+ $node = $rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER2)
+ ->get('/directReshare');
+ $share = $shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER4)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $shareManager->createShare($share);
+
$this->fileIds[self::TEST_FILES_SHARING_API_USER2][''] = $view2->getFileInfo('')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER2]['sub1'] = $view2->getFileInfo('sub1')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER2]['sub1/sub2'] = $view2->getFileInfo('sub1/sub2')->getId();
+ /*
+ * User 3
+ */
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER3);
$view3 = new View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$view3->mkdir('/sub1/sub2');
@@ -96,6 +158,9 @@ class EtagPropagation extends PropagationTestCase {
$this->fileIds[self::TEST_FILES_SHARING_API_USER3]['sub1'] = $view3->getFileInfo('sub1')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER3]['sub1/sub2'] = $view3->getFileInfo('sub1/sub2')->getId();
+ /*
+ * User 4
+ */
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER4);
$view4 = new View('/' . self::TEST_FILES_SHARING_API_USER4 . '/files');
$view4->mkdir('/sub1/sub2');
@@ -108,6 +173,7 @@ class EtagPropagation extends PropagationTestCase {
$this->loginAsUser($user);
foreach ($ids as $id) {
$path = $this->rootView->getPath($id);
+ $ls = $this->rootView->getDirectoryContent($path);
$this->fileEtags[$id] = $this->rootView->getFileInfo($path)->getEtag();
}
}
@@ -202,19 +268,40 @@ class EtagPropagation extends PropagationTestCase {
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
$folderInfo = $this->rootView->getFileInfo('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/sub1/sub2/folder');
$this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo);
- $folderId = $folderInfo->getId();
- $this->assertTrue(
- \OCP\Share::unshare(
- 'folder',
- $folderId,
- \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2
- )
- );
+
+ $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder');
+ $shareManager = \OC::$server->getShareManager();
+ $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true);
+
+ foreach ($shares as $share) {
+ if ($share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2) {
+ $shareManager->deleteShare($share);
+ }
+ }
+
$this->assertEtagsForFoldersChanged([
// direct recipient affected
self::TEST_FILES_SHARING_API_USER2,
- // reshare recipient affected
+ ]);
+
+ $this->assertAllUnchanged();
+ }
+
+ public function testOwnerUnsharesFlatReshares() {
+ $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
+ $folderInfo = $this->rootView->getFileInfo('/' . self::TEST_FILES_SHARING_API_USER1 . '/files/sub1/sub2/folder/inside');
+ $this->assertInstanceOf('\OC\Files\FileInfo', $folderInfo);
+
+ $node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder/inside');
+ $shareManager = \OC::$server->getShareManager();
+ $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true);
+
+ foreach ($shares as $share) {
+ $shareManager->deleteShare($share);
+ }
+
+ $this->assertEtagsForFoldersChanged([
+ // direct recipient affected
self::TEST_FILES_SHARING_API_USER4,
]);
@@ -223,14 +310,13 @@ class EtagPropagation extends PropagationTestCase {
public function testRecipientUnsharesFromSelf() {
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
+ $ls = $this->rootView->getDirectoryContent('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub1/sub2/');
$this->assertTrue(
$this->rootView->unlink('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/sub1/sub2/folder')
);
$this->assertEtagsForFoldersChanged([
// direct recipient affected
self::TEST_FILES_SHARING_API_USER2,
- // reshare recipient affected
- self::TEST_FILES_SHARING_API_USER4,
]);
$this->assertAllUnchanged();
@@ -240,8 +326,11 @@ class EtagPropagation extends PropagationTestCase {
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
Filesystem::file_put_contents('/sub1/sub2/folder/asd.txt', 'bar');
$this->assertEtagsNotChanged([self::TEST_FILES_SHARING_API_USER4]);
- $this->assertEtagsForFoldersChanged([self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2,
- self::TEST_FILES_SHARING_API_USER3]);
+ $this->assertEtagsForFoldersChanged([
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ self::TEST_FILES_SHARING_API_USER3
+ ]);
$this->assertAllUnchanged();
}
@@ -350,14 +439,21 @@ class EtagPropagation extends PropagationTestCase {
}
public function testEtagChangeOnPermissionsChange() {
- $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
+ $userFolder = $this->rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+ $node = $userFolder->get('/sub1/sub2/folder');
- $view = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
- $folderInfo = $view->getFileInfo('/sub1/sub2/folder');
+ $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node);
+ /** @var \OCP\Share\IShare[] $shares */
+ $shares = array_filter($shares, function(\OCP\Share\IShare $share) {
+ return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2;
+ });
+ $this->assertCount(1, $shares);
- \OCP\Share::setPermissions('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 17);
+ $share = $shares[0];
+ $share->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE);
+ $this->shareManager->updateShare($share);
- $this->assertEtagsForFoldersChanged([self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_USER4]);
+ $this->assertEtagsForFoldersChanged([self::TEST_FILES_SHARING_API_USER2]);
$this->assertAllUnchanged();
}
diff --git a/apps/files_sharing/tests/groupetagpropagation.php b/apps/files_sharing/tests/groupetagpropagation.php
index 9f6b1e2f720..aaa81135279 100644
--- a/apps/files_sharing/tests/groupetagpropagation.php
+++ b/apps/files_sharing/tests/groupetagpropagation.php
@@ -46,18 +46,36 @@ class GroupEtagPropagation extends PropagationTestCase {
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
$view1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
$view1->mkdir('/test/sub');
- $folderInfo = $view1->getFileInfo('/test');
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_GROUP, 'group1', 31);
+
+ $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ '/test',
+ self::TEST_FILES_SHARING_API_USER1,
+ 'group1',
+ \OCP\Constants::PERMISSION_ALL
+ );
$this->fileIds[self::TEST_FILES_SHARING_API_USER1][''] = $view1->getFileInfo('')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER1]['test'] = $view1->getFileInfo('test')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER1]['test/sub'] = $view1->getFileInfo('test/sub')->getId();
$this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
$view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
- $folderInfo = $view2->getFileInfo('/test');
- $subFolderInfo = $view2->getFileInfo('/test/sub');
- \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_GROUP, 'group2', 31);
- \OCP\Share::shareItem('folder', $subFolderInfo->getId(), \OCP\Share::SHARE_TYPE_GROUP, 'group3', 31);
+
+ $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ '/test',
+ self::TEST_FILES_SHARING_API_USER2,
+ 'group2',
+ \OCP\Constants::PERMISSION_ALL
+ );
+ $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ '/test/sub',
+ self::TEST_FILES_SHARING_API_USER2,
+ 'group3',
+ \OCP\Constants::PERMISSION_ALL
+ );
+
$this->fileIds[self::TEST_FILES_SHARING_API_USER2][''] = $view2->getFileInfo('')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER2]['test'] = $view2->getFileInfo('test')->getId();
$this->fileIds[self::TEST_FILES_SHARING_API_USER2]['test/sub'] = $view2->getFileInfo('test/sub')->getId();
diff --git a/apps/files_sharing/tests/locking.php b/apps/files_sharing/tests/locking.php
index ef8b2bb1cd4..932afe006f9 100644
--- a/apps/files_sharing/tests/locking.php
+++ b/apps/files_sharing/tests/locking.php
@@ -59,7 +59,13 @@ class Locking extends TestCase {
Filesystem::file_put_contents('/foo/bar.txt', 'asd');
$fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId();
- \OCP\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->recipientUid, 31);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ '/foo/bar.txt',
+ $this->ownerUid,
+ $this->recipientUid,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
$this->loginAsUser($this->recipientUid);
$this->assertTrue(Filesystem::file_exists('bar.txt'));
diff --git a/apps/files_sharing/tests/permissions.php b/apps/files_sharing/tests/permissions.php
index 43a57266851..c1568ceab0a 100644
--- a/apps/files_sharing/tests/permissions.php
+++ b/apps/files_sharing/tests/permissions.php
@@ -33,39 +33,25 @@ use OC\Files\View;
*/
class Test_Files_Sharing_Permissions extends OCA\Files_sharing\Tests\TestCase {
- /**
- * @var Storage
- */
+ /** @var Storage */
private $sharedStorageRestrictedShare;
- /**
- * @var Storage
- */
+ /** @var Storage */
private $sharedCacheRestrictedShare;
- /**
- * @var View
- */
+ /** @var View */
private $secondView;
- /**
- * @var Storage
- */
+ /** @var Storage */
private $ownerStorage;
- /**
- * @var Storage
- */
+ /** @var Storage */
private $sharedStorage;
- /**
- * @var Cache
- */
+ /** @var Cache */
private $sharedCache;
- /**
- * @var Cache
- */
+ /** @var Cache */
private $ownerCache;
protected function setUp() {
@@ -88,12 +74,25 @@ class Test_Files_Sharing_Permissions extends OCA\Files_sharing\Tests\TestCase {
$this->ownerStorage->getScanner()->scan('');
// share "shareddir" with user2
- $fileinfo = $this->view->getFileInfo('container/shareddir');
- \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
- $fileinfo2 = $this->view->getFileInfo('container/shareddirrestricted');
- \OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 7);
+ $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
+
+ $node = $rootFolder->get('container/shareddir');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $this->shareManager->createShare($share);
+
+ $node = $rootFolder->get('container/shareddirrestricted');
+ $share = $this->shareManager->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
+ ->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
+ $this->shareManager->createShare($share);
// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -113,12 +112,10 @@ class Test_Files_Sharing_Permissions extends OCA\Files_sharing\Tests\TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $fileinfo = $this->view->getFileInfo('container/shareddir');
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $fileinfo2 = $this->view->getFileInfo('container/shareddirrestricted');
- \OCP\Share::unshare('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
+ $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER);
+ foreach ($shares as $share) {
+ $this->shareManager->deleteShare($share);
+ }
$this->view->deleteAll('container');
diff --git a/apps/files_sharing/tests/share.php b/apps/files_sharing/tests/share.php
index aad698bcdba..7707cca190f 100644
--- a/apps/files_sharing/tests/share.php
+++ b/apps/files_sharing/tests/share.php
@@ -75,17 +75,21 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
- $fileinfo = $this->view->getFileInfo($this->filename);
-
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
-
- $this->assertTrue($result);
-
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
- 'testGroup', 31);
+ $share1 = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
- $this->assertTrue($result);
+ $share2 = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ 'testGroup',
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
@@ -102,123 +106,9 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
// for user3 nothing should change
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
- }
-
- /**
- * if a file was shared as group share and as individual share they should be grouped
- */
- public function testGroupingOfShares() {
-
- $fileinfo = $this->view->getFileInfo($this->filename);
-
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
- \Test_Files_Sharing::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_READ);
-
- $this->assertTrue($result);
-
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_UPDATE);
-
- $this->assertTrue($result);
-
- self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
-
- $result = \OCP\Share::getItemSharedWith('file', null);
-
- $this->assertTrue(is_array($result));
-
- // test should return exactly one shares created from testCreateShare()
- $this->assertSame(1, count($result));
-
- $share = reset($result);
- $this->assertSame(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, $share['permissions']);
-
- \OC\Files\Filesystem::rename($this->filename, $this->filename . '-renamed');
-
- $result = \OCP\Share::getItemSharedWith('file', null);
-
- $this->assertTrue(is_array($result));
-
- // test should return exactly one shares created from testCreateShare()
- $this->assertSame(1, count($result));
-
- $share = reset($result);
- $this->assertSame(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, $share['permissions']);
- $this->assertSame($this->filename . '-renamed', $share['file_target']);
-
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
-
- // unshare user share
- $result = \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
-
- self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
-
- $result = \OCP\Share::getItemSharedWith('file', null);
-
- $this->assertTrue(is_array($result));
-
- // test should return the remaining group share
- $this->assertSame(1, count($result));
-
- $share = reset($result);
- // only the group share permissions should be available now
- $this->assertSame(\OCP\Constants::PERMISSION_READ, $share['permissions']);
- $this->assertSame($this->filename . '-renamed', $share['file_target']);
-
- }
-
- /**
- * user1 share file to a group and to a user2 in the same group. Then user2
- * unshares the file from self. Afterwards user1 should no longer see the
- * single user share to user2. If he re-shares the file to user2 the same target
- * then the group share should be used to group the item
- */
- public function testShareAndUnshareFromSelf() {
- $fileinfo = $this->view->getFileInfo($this->filename);
-
- // share the file to group1 (user2 is a member of this group) and explicitely to user2
- \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_ALL);
- \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
-
- // user1 should have to shared files
- $shares = \OCP\Share::getItemsShared('file');
- $this->assertSame(2, count($shares));
-
- // user2 should have two files "welcome.txt" and the shared file,
- // both the group share and the single share of the same file should be
- // grouped to one file
- \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
- $this->assertSame(2, count($dirContent));
- $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
-
- // now user2 deletes the share (= unshare from self)
- \OC\Files\Filesystem::unlink($this->filename);
-
- // only welcome.txt should exists
- $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
- $this->assertSame(1, count($dirContent));
- $this->verifyDirContent($dirContent, array('welcome.txt'));
-
- // login as user1...
- \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER1);
-
- // ... now user1 should have only one shared file, the group share
- $shares = \OCP\Share::getItemsShared('file');
- $this->assertSame(1, count($shares));
-
- // user1 shares a gain the file directly to user2
- \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
-
- // user2 should see again welcome.txt and the shared file
- \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
- $this->assertSame(2, count($dirContent));
- $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
-
+ $this->shareManager->deleteShare($share1);
+ $this->shareManager->deleteShare($share2);
}
/**
@@ -238,15 +128,23 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
$fileinfo = $this->view->getFileInfo($this->filename);
$folderinfo = $this->view->getFileInfo($this->folder);
- $fileShare = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($fileShare);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
\OCA\Files_Sharing\Helper::setShareFolder('/Shared/subfolder');
- $folderShare = \OCP\Share::shareItem('folder', $folderinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($folderShare);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -261,56 +159,59 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
\OC\Files\Filesystem::file_put_contents('test.txt', 'test');
- $fileInfo = \OC\Files\Filesystem::getFileInfo('test.txt');
-
- $this->assertTrue(
- \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, 23)
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ 'test.txt',
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_GROUP1,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $items = \OCP\Share::getItemsSharedWith('file');
- $this->assertSame('/test.txt' ,$items[0]['file_target']);
- $this->assertSame(23, $items[0]['permissions']);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP);
+ $share = $shares[0];
+ $this->assertSame('/test.txt' ,$share->getTarget());
+ $this->assertSame(19, $share->getPermissions());
\OC\Files\Filesystem::rename('test.txt', 'new test.txt');
- $items = \OCP\Share::getItemsSharedWith('file');
- $this->assertSame('/new test.txt' ,$items[0]['file_target']);
- $this->assertSame(23, $items[0]['permissions']);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP);
+ $share = $shares[0];
+ $this->assertSame('/new test.txt' ,$share->getTarget());
+ $this->assertSame(19, $share->getPermissions());
- $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::setPermissions('file', $items[0]['item_source'], $items[0]['share_type'], $items[0]['share_with'], 3);
+ $share->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE);
+ $this->shareManager->updateShare($share);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $items = \OCP\Share::getItemsSharedWith('file');
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP);
+ $share = $shares[0];
- $this->assertSame('/new test.txt' ,$items[0]['file_target']);
- $this->assertSame(3, $items[0]['permissions']);
+ $this->assertSame('/new test.txt' ,$share->getTarget());
+ $this->assertSame(3, $share->getPermissions());
}
/**
* shared files should never have delete permissions
* @dataProvider dataProviderTestFileSharePermissions
*/
- public function testFileSharePermissions($permission, $expectedPermissions) {
-
- $fileinfo = $this->view->getFileInfo($this->filename);
-
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, $permission);
-
- $this->assertTrue($result);
-
- $result = \OCP\Share::getItemShared('file', null);
-
- $this->assertTrue(is_array($result));
-
- // test should return exactly one shares created from testCreateShare()
- $this->assertSame(1, count($result), 'more then one share found');
+ public function testFileSharePermissions($permission, $expectedvalid) {
+
+ $pass = true;
+ try {
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ $permission
+ );
+ } catch (\Exception $e) {
+ $pass = false;
+ }
- $share = reset($result);
- $this->assertSame($expectedPermissions, $share['permissions']);
+ $this->assertEquals($expectedvalid, $pass);
}
public function dataProviderTestFileSharePermissions() {
@@ -321,22 +222,23 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
$permission6 = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE;
return array(
- array($permission1, \OCP\Constants::PERMISSION_ALL & ~\OCP\Constants::PERMISSION_DELETE),
- array($permission3, $permission3),
- array($permission4, $permission4),
- array($permission5, $permission3),
- array($permission6, $permission4),
+ array($permission1, false),
+ array($permission3, true),
+ array($permission4, true),
+ array($permission5, false),
+ array($permission6, false),
);
}
public function testFileOwner() {
- $fileinfo = $this->view->getFileInfo($this->filename);
-
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
-
- $this->assertTrue($result);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ
+ );
$this->loginHelper(\Test_Files_Sharing::TEST_FILES_SHARING_API_USER2);
@@ -344,135 +246,4 @@ class Test_Files_Sharing extends OCA\Files_sharing\Tests\TestCase {
$this->assertSame(\Test_Files_Sharing::TEST_FILES_SHARING_API_USER1, $info->getOwner()->getUID());
}
-
- /**
- * @dataProvider dataProviderGetUsersSharingFile
- *
- * @param string $groupName name of group to share with
- * @param bool $includeOwner whether to include the owner in the result
- * @param bool $includePaths whether to include paths in the result
- * @param array $expectedResult expected result of the API call
- */
- public function testGetUsersSharingFile($groupName, $includeOwner, $includePaths, $expectedResult) {
-
- $fileinfo = $this->view->getFileInfo($this->folder);
-
- $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
- $groupName, \OCP\Constants::PERMISSION_READ);
- $this->assertTrue($result);
-
- // public share
- $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_LINK,
- null, \OCP\Constants::PERMISSION_READ);
- $this->assertNotNull($result); // returns the token!
-
- // owner renames after sharing
- $this->view->rename($this->folder, $this->folder . '_owner_renamed');
-
- self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
-
- $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
- $user2View->rename($this->folder, $this->folder . '_renamed');
-
- $ownerPath = $this->folder . '_owner_renamed';
- $owner = self::TEST_FILES_SHARING_API_USER1;
-
- $result = \OCP\Share::getUsersSharingFile($ownerPath, $owner, $includeOwner, $includePaths);
-
- // sort users to make sure it matches
- if ($includePaths) {
- ksort($result);
- } else {
- sort($result['users']);
- }
-
- $this->assertEquals(
- $expectedResult,
- $result
- );
- }
-
- public function dataProviderGetUsersSharingFile() {
- // note: "group" contains user1 (the owner), user2 and user3
- // and self::TEST_FILES_SHARING_API_GROUP1 contains only user2
- return [
- // share with group that contains owner
- [
- 'group',
- false,
- false,
- [
- 'users' =>
- [
- // because user1 was in group
- self::TEST_FILES_SHARING_API_USER1,
- self::TEST_FILES_SHARING_API_USER2,
- self::TEST_FILES_SHARING_API_USER3,
- ],
- 'public' => true,
- 'remote' => false,
- ],
- ],
- // share with group that does not contain owner
- [
- self::TEST_FILES_SHARING_API_GROUP1,
- false,
- false,
- [
- 'users' =>
- [
- self::TEST_FILES_SHARING_API_USER2,
- ],
- 'public' => true,
- 'remote' => false,
- ],
- ],
- // share with group that does not contain owner, include owner
- [
- self::TEST_FILES_SHARING_API_GROUP1,
- true,
- false,
- [
- 'users' =>
- [
- self::TEST_FILES_SHARING_API_USER1,
- self::TEST_FILES_SHARING_API_USER2,
- ],
- 'public' => true,
- 'remote' => false,
- ],
- ],
- // include paths, with owner
- [
- 'group',
- true,
- true,
- [
- self::TEST_FILES_SHARING_API_USER1 => self::TEST_FOLDER_NAME . '_owner_renamed',
- self::TEST_FILES_SHARING_API_USER2 => self::TEST_FOLDER_NAME . '_renamed',
- self::TEST_FILES_SHARING_API_USER3 => self::TEST_FOLDER_NAME,
- ],
- ],
- // include paths, group without owner
- [
- self::TEST_FILES_SHARING_API_GROUP1,
- false,
- true,
- [
- self::TEST_FILES_SHARING_API_USER2 => self::TEST_FOLDER_NAME. '_renamed',
- ],
- ],
- // include paths, include owner, group without owner
- [
- self::TEST_FILES_SHARING_API_GROUP1,
- true,
- true,
- [
- self::TEST_FILES_SHARING_API_USER1 => self::TEST_FOLDER_NAME . '_owner_renamed',
- self::TEST_FILES_SHARING_API_USER2 => self::TEST_FOLDER_NAME . '_renamed',
- ],
- ],
- ];
- }
-
}
diff --git a/apps/files_sharing/tests/sharedmount.php b/apps/files_sharing/tests/sharedmount.php
index e01deeb60f4..48040ab8dc9 100644
--- a/apps/files_sharing/tests/sharedmount.php
+++ b/apps/files_sharing/tests/sharedmount.php
@@ -49,8 +49,12 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
protected function tearDown() {
if ($this->view) {
- $this->view->unlink($this->folder);
- $this->view->unlink($this->filename);
+ if ($this->view->file_exists($this->folder)) {
+ $this->view->unlink($this->folder);
+ }
+ if ($this->view->file_exists($this->filename)) {
+ $this->view->unlink($this->filename);
+ }
}
parent::tearDown();
@@ -59,59 +63,46 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
/**
* test if the mount point moves up if the parent folder no longer exists
*/
- function testShareMountLoseParentFolder() {
+ public function testShareMountLoseParentFolder() {
// share to user
- $fileinfo = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
-
- $statement = "UPDATE `*PREFIX*share` SET `file_target` = ? where `share_with` = ?";
- $query = \OCP\DB::prepare($statement);
- $arguments = array('/foo/bar' . $this->folder, self::TEST_FILES_SHARING_API_USER2);
- $query->execute($arguments);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL);
- $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
- $result = $query->execute();
+ $share->setTarget('/foo/bar' . $this->folder);
+ $this->shareManager->moveShare($share, self::TEST_FILES_SHARING_API_USER2);
- $shares = $result->fetchAll();
-
- $this->assertSame(1, count($shares));
-
- $share = reset($shares);
- $this->assertSame('/foo/bar' . $this->folder, $share['file_target']);
+ $share = $this->shareManager->getShareById($share->getFullId());
+ $this->assertSame('/foo/bar' . $this->folder, $share->getTarget());
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
-
// share should have moved up
- $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
- $result = $query->execute();
-
- $shares = $result->fetchAll();
-
- $this->assertSame(1, count($shares));
-
- $share = reset($shares);
- $this->assertSame($this->folder, $share['file_target']);
+ $share = $this->shareManager->getShareById($share->getFullId());
+ $this->assertSame($this->folder, $share->getTarget());
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $this->shareManager->deleteShare($share);
$this->view->unlink($this->folder);
}
/**
* @medium
*/
- function testDeleteParentOfMountPoint() {
-
+ public function testDeleteParentOfMountPoint() {
// share to user
- $fileinfo = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
-
- $this->assertTrue($result);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -143,10 +134,14 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
$this->view->unlink($this->folder);
}
- function testMoveSharedFile() {
- $fileinfo = $this->view->getFileInfo($this->filename);
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ public function testMoveSharedFile() {
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -166,22 +161,27 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
//cleanup
- \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $this->shareManager->deleteShare($share);
}
/**
* share file with a group if a user renames the file the filename should not change
* for the other users
*/
- function testMoveGroupShare () {
+ public function testMoveGroupShare () {
\OC_Group::createGroup('testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
$fileinfo = $this->view->getFileInfo($this->filename);
- $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
- "testGroup", 31);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ 'testGroup',
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -202,7 +202,7 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
+ $this->shareManager->deleteShare($share);
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
@@ -214,7 +214,7 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
* @param string $expectedResult
* @param bool $exception if a exception is expected
*/
- function testStripUserFilesPath($path, $expectedResult, $exception) {
+ public function testStripUserFilesPath($path, $expectedResult, $exception) {
$testClass = new DummyTestClassSharedMount(null, null);
try {
$result = $testClass->stripUserFilesPathDummy($path);
@@ -228,7 +228,7 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
}
}
- function dataProviderTestStripUserFilesPath() {
+ public function dataProviderTestStripUserFilesPath() {
return array(
array('/user/files/foo.txt', '/foo.txt', false),
array('/user/files/folder/foo.txt', '/folder/foo.txt', false),
@@ -239,7 +239,7 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
);
}
- function dataPermissionMovedGroupShare() {
+ public function dataPermissionMovedGroupShare() {
$data = [];
$powerset = function($permissions) {
@@ -256,7 +256,6 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
//Generate file permissions
$permissions = [
\OCP\Constants::PERMISSION_UPDATE,
- \OCP\Constants::PERMISSION_CREATE,
\OCP\Constants::PERMISSION_SHARE,
];
@@ -321,54 +320,45 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
\OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
// Share item with group
- $fileinfo = $this->view->getFileInfo($path);
- $this->assertTrue(
- \OCP\Share::shareItem($type, $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, "testGroup", $beforePerm)
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ $path,
+ self::TEST_FILES_SHARING_API_USER1,
+ 'testGroup',
+ $beforePerm
);
// Login as user 2 and verify the item exists
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists($path));
- $result = \OCP\Share::getItemSharedWithBySource($type, $fileinfo['fileid']);
- $this->assertNotEmpty($result);
- $this->assertEquals($beforePerm, $result['permissions']);
+ $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
+ $this->assertEquals($beforePerm, $result->getPermissions());
// Now move the item forcing a new entry in the share table
\OC\Files\Filesystem::rename($path, "newPath");
$this->assertTrue(\OC\Files\Filesystem::file_exists('newPath'));
$this->assertFalse(\OC\Files\Filesystem::file_exists($path));
- // Login as user 1 again and change permissions
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $this->assertTrue(
- \OCP\Share::setPermissions($type, $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, "testGroup", $afterPerm)
- );
+ // change permissions
+ $share->setPermissions($afterPerm);
+ $this->shareManager->updateShare($share);
// Login as user 3 and verify that the permissions are changed
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- $result = \OCP\Share::getItemSharedWithBySource($type, $fileinfo['fileid']);
+ $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER3);
$this->assertNotEmpty($result);
- $this->assertEquals($afterPerm, $result['permissions']);
- $groupShareId = $result['id'];
+ $this->assertEquals($afterPerm, $result->getPermissions());
// Login as user 2 and verify that the permissions are changed
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $result = \OCP\Share::getItemSharedWithBySource($type, $fileinfo['fileid']);
+ $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
$this->assertNotEmpty($result);
- $this->assertEquals($afterPerm, $result['permissions']);
- $this->assertNotEquals($groupShareId, $result['id']);
-
- // Also verify in the DB
- $statement = "SELECT `permissions` FROM `*PREFIX*share` WHERE `id`=?";
- $query = \OCP\DB::prepare($statement);
- $result = $query->execute([$result['id']]);
- $shares = $result->fetchAll();
- $this->assertCount(1, $shares);
- $this->assertEquals($afterPerm, $shares[0]['permissions']);
+ $this->assertEquals($afterPerm, $result->getPermissions());
+ $this->assertEquals('/newPath', $result->getTarget());
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare($type, $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
+ $this->shareManager->deleteShare($share);
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
@@ -388,66 +378,44 @@ class Test_Files_Sharing_Mount extends OCA\Files_sharing\Tests\TestCase {
// Share item with group
$fileinfo = $this->view->getFileInfo($this->folder);
- $this->assertTrue(
- \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, "testGroup", \OCP\Constants::PERMISSION_READ)
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ 'testGroup',
+ \OCP\Constants::PERMISSION_READ
);
// Login as user 2 and verify the item exists
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
- $result = \OCP\Share::getItemSharedWithBySource('folder', $fileinfo['fileid']);
+ $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
$this->assertNotEmpty($result);
- $this->assertEquals(\OCP\Constants::PERMISSION_READ, $result['permissions']);
+ $this->assertEquals(\OCP\Constants::PERMISSION_READ, $result->getPermissions());
// Delete the share
$this->assertTrue(\OC\Files\Filesystem::rmdir($this->folder));
$this->assertFalse(\OC\Files\Filesystem::file_exists($this->folder));
// Verify we do not get a share
- $result = \OCP\Share::getItemSharedWithBySource('folder', $fileinfo['fileid']);
- $this->assertEmpty($result);
-
- // Verify that the permission is correct in the DB
- $qb = $connection->getQueryBuilder();
- $qb->select('*')
- ->from('share')
- ->where($qb->expr()->eq('file_source', $qb->createParameter('fileSource')))
- ->andWhere($qb->expr()->eq('share_type', $qb->createParameter('shareType')))
- ->setParameter(':fileSource', $fileinfo['fileid'])
- ->setParameter(':shareType', 2);
- $res = $qb->execute()->fetchAll();
-
- $this->assertCount(1, $res);
- $this->assertEquals(0, $res[0]['permissions']);
+ $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
+ $this->assertEquals(0, $result->getPermissions());
// Login as user 1 again and change permissions
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $this->assertTrue(
- \OCP\Share::setPermissions('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, "testGroup", \OCP\Constants::PERMISSION_ALL)
- );
+ $share->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = $this->shareManager->updateShare($share);
// Login as user 2 and verify
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertFalse(\OC\Files\Filesystem::file_exists($this->folder));
- $result = \OCP\Share::getItemSharedWithBySource('folder', $fileinfo['fileid']);
- $this->assertEmpty($result);
+ $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
+ $this->assertEquals(0, $result->getPermissions());
- $connection = \OC::$server->getDatabaseConnection();
- $qb = $connection->getQueryBuilder();
- $qb->select('*')
- ->from('share')
- ->where($qb->expr()->eq('file_source', $qb->createParameter('fileSource')))
- ->andWhere($qb->expr()->eq('share_type', $qb->createParameter('shareType')))
- ->setParameter(':fileSource', $fileinfo['fileid'])
- ->setParameter(':shareType', 2);
- $res = $qb->execute()->fetchAll();
-
- $this->assertCount(1, $res);
- $this->assertEquals(0, $res[0]['permissions']);
+ $this->shareManager->deleteShare($share);
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
\OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
diff --git a/apps/files_sharing/tests/sharedstorage.php b/apps/files_sharing/tests/sharedstorage.php
index 63f4334103f..19edc44f9b4 100644
--- a/apps/files_sharing/tests/sharedstorage.php
+++ b/apps/files_sharing/tests/sharedstorage.php
@@ -50,8 +50,12 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
protected function tearDown() {
if ($this->view) {
- $this->view->unlink($this->folder);
- $this->view->unlink($this->filename);
+ if ($this->view->file_exists($this->folder)) {
+ $this->view->unlink($this->folder);
+ }
+ if ($this->view->file_exists($this->filename)) {
+ $this->view->unlink($this->filename);
+ }
}
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
@@ -64,14 +68,16 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
*
* @medium
*/
- function testParentOfMountPointIsGone() {
+ public function testParentOfMountPointIsGone() {
// share to user
- $fileinfo = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
-
- $this->assertTrue($result);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -107,14 +113,17 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
/**
* @medium
*/
- function testRenamePartFile() {
+ public function testRenamePartFile() {
// share to user
- $fileinfo = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
- $this->assertTrue($result);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -139,26 +148,30 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
$this->assertTrue($this->view->file_exists($this->folder . '/foo.txt'));
//cleanup
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
+ $this->shareManager->deleteShare($share);
}
public function testFilesize() {
-
- $fileinfoFolder = $this->view->getFileInfo($this->folder);
- $fileinfoFile = $this->view->getFileInfo($this->filename);
-
$folderSize = $this->view->filesize($this->folder);
$file1Size = $this->view->filesize($this->folder . $this->filename);
$file2Size = $this->view->filesize($this->filename);
- $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($result);
+ $share1 = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
+
+ $share2 = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
- $result = \OCP\Share::shareItem('file', $fileinfoFile['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($result);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -168,21 +181,19 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
$this->assertSame($file2Size, \OC\Files\Filesystem::filesize($this->filename));
//cleanup
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
- $result = \OCP\Share::unshare('file', $fileinfoFile['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share1);
+ $this->shareManager->deleteShare($share2);
}
- function testGetPermissions() {
- $fileinfoFolder = $this->view->getFileInfo($this->folder);
+ public function testGetPermissions() {
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ
+ );
- $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 1);
- $this->assertTrue($result);
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -201,18 +212,19 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
//cleanup
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share);
}
public function testFopenWithReadOnlyPermission() {
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
- $fileinfoFolder = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ);
- $this->assertTrue($result);
+
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -232,18 +244,20 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
$this->assertFalse($user2View->unlink($this->folder . '/existing.txt'));
//cleanup
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share);
}
public function testFopenWithCreateOnlyPermission() {
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
$fileinfoFolder = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE);
- $this->assertTrue($result);
+
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -284,11 +298,14 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
public function testFopenWithUpdateOnlyPermission() {
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
- $fileinfoFolder = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE);
- $this->assertTrue($result);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -322,18 +339,19 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
$this->assertFalse($user2View->unlink($this->folder . '/existing-renamed.txt'));
//cleanup
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share);
}
public function testFopenWithDeleteOnlyPermission() {
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
- $fileinfoFolder = $this->view->getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
- $this->assertTrue($result);
+
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -353,23 +371,28 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
$this->assertTrue($user2View->unlink($this->folder . '/existing.txt'));
//cleanup
- self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share);
}
- function testMountSharesOtherUser() {
- $folderInfo = $this->view->getFileInfo($this->folder);
- $fileInfo = $this->view->getFileInfo($this->filename);
+ public function testMountSharesOtherUser() {
$rootView = new \OC\Files\View('');
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
// share 2 different files with 2 different users
- \OCP\Share::shareItem('folder', $folderInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
- \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER3, 31);
+ $share1 = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
+ $share2 = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->filename,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER3,
+ \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue($rootView->file_exists('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/' . $this->folder));
@@ -387,15 +410,21 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->view->unlink($this->folder);
+
+ $this->shareManager->deleteShare($share1);
+ $this->shareManager->deleteShare($share2);
}
public function testCopyFromStorage() {
- $folderInfo = $this->view->getFileInfo($this->folder);
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- // share 2 different files with 2 different users
- \OCP\Share::shareItem('folder', $folderInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -416,15 +445,19 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->view->unlink($this->folder);
+ $this->shareManager->deleteShare($share);
}
public function testMoveFromStorage() {
- $folderInfo = $this->view->getFileInfo($this->folder);
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- // share 2 different files with 2 different users
- \OCP\Share::shareItem('folder', $folderInfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -445,31 +478,40 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->view->unlink($this->folder);
+ $this->shareManager->deleteShare($share);
}
public function testNameConflict() {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$view1 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
$view1->mkdir('foo');
- $folderInfo1 = $view1->getFileInfo('foo');
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$view3 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
$view3->mkdir('foo');
- $folderInfo2 = $view3->getFileInfo('foo');
// share a folder with the same name from two different users to the same user
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- \OCP\Share::shareItem('folder', $folderInfo1['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
- self::TEST_FILES_SHARING_API_GROUP1, 31);
+ $share1 = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ 'foo',
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_GROUP1,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
- \OCP\Share::shareItem('folder', $folderInfo2['fileid'], \OCP\Share::SHARE_TYPE_GROUP,
- self::TEST_FILES_SHARING_API_GROUP1, 31);
+ $share2 = $this->share(
+ \OCP\Share::SHARE_TYPE_GROUP,
+ 'foo',
+ self::TEST_FILES_SHARING_API_USER3,
+ self::TEST_FILES_SHARING_API_GROUP1,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
$view2 = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -482,7 +524,9 @@ class Test_Files_Sharing_Storage extends OCA\Files_sharing\Tests\TestCase {
/** @var \OC\Files\Storage\Shared $storage */
$storage = $mount->getStorage();
- $source = $storage->getFile('');
- $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $source['uid_owner']);
+ $this->assertEquals(self::TEST_FILES_SHARING_API_USER1, $storage->getOwner(''));
+
+ $this->shareManager->deleteShare($share1);
+ $this->shareManager->deleteShare($share2);
}
}
diff --git a/apps/files_sharing/tests/sizepropagation.php b/apps/files_sharing/tests/sizepropagation.php
index 7b7884f3f96..d4062e3a38c 100644
--- a/apps/files_sharing/tests/sizepropagation.php
+++ b/apps/files_sharing/tests/sizepropagation.php
@@ -43,9 +43,13 @@ class SizePropagation extends TestCase {
$ownerView->mkdir('/sharedfolder/subfolder');
$ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
- $sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
- $this->assertInstanceOf('\OC\Files\FileInfo', $sharedFolderInfo);
- \OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ '/sharedfolder',
+ self::TEST_FILES_SHARING_API_USER2,
+ self::TEST_FILES_SHARING_API_USER1,
+ \OCP\Constants::PERMISSION_ALL
+ );
$ownerRootInfo = $ownerView->getFileInfo('', false);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
@@ -76,9 +80,13 @@ class SizePropagation extends TestCase {
$ownerView->mkdir('/sharedfolder/subfolder');
$ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
- $sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
- $this->assertInstanceOf('\OC\Files\FileInfo', $sharedFolderInfo);
- \OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ '/sharedfolder',
+ self::TEST_FILES_SHARING_API_USER2,
+ self::TEST_FILES_SHARING_API_USER1,
+ \OCP\Constants::PERMISSION_ALL
+ );
$ownerRootInfo = $ownerView->getFileInfo('', false);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
diff --git a/apps/files_sharing/tests/testcase.php b/apps/files_sharing/tests/testcase.php
index ce0a8beeec8..0950c2a62f5 100644
--- a/apps/files_sharing/tests/testcase.php
+++ b/apps/files_sharing/tests/testcase.php
@@ -59,6 +59,11 @@ abstract class TestCase extends \Test\TestCase {
public $folder;
public $subfolder;
+ /** @var \OCP\Share\IManager */
+ protected $shareManager;
+ /** @var \OCP\Files\IRootFolder */
+ protected $rootFolder;
+
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
@@ -82,7 +87,7 @@ abstract class TestCase extends \Test\TestCase {
$backend->createUser(self::TEST_FILES_SHARING_API_USER4, self::TEST_FILES_SHARING_API_USER4);
// create group
- $groupBackend = new \OC_Group_Dummy();
+ $groupBackend = new \Test\Util\Group\Dummy();
$groupBackend->createGroup(self::TEST_FILES_SHARING_API_GROUP1);
$groupBackend->createGroup('group');
$groupBackend->createGroup('group1');
@@ -96,7 +101,6 @@ abstract class TestCase extends \Test\TestCase {
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER4, 'group3');
$groupBackend->addToGroup(self::TEST_FILES_SHARING_API_USER2, self::TEST_FILES_SHARING_API_GROUP1);
\OC_Group::useBackend($groupBackend);
-
}
protected function setUp() {
@@ -107,6 +111,9 @@ abstract class TestCase extends \Test\TestCase {
$this->data = 'foobar';
$this->view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
+
+ $this->shareManager = \OC::$server->getShareManager();
+ $this->rootFolder = \OC::$server->getRootFolder();
}
protected function tearDown() {
@@ -201,4 +208,26 @@ abstract class TestCase extends \Test\TestCase {
}
+ /**
+ * @param int $type The share type
+ * @param string $path The path to share relative to $initiators root
+ * @param string $initiator
+ * @param string $recipient
+ * @param int $permissions
+ * @return \OCP\Share\IShare
+ */
+ protected function share($type, $path, $initiator, $recipient, $permissions) {
+ $userFolder = $this->rootFolder->getUserFolder($initiator);
+ $node = $userFolder->get($path);
+
+ $share = $this->shareManager->newShare();
+ $share->setShareType($type)
+ ->setSharedWith($recipient)
+ ->setSharedBy($initiator)
+ ->setNode($node)
+ ->setPermissions($permissions);
+ $share = $this->shareManager->createShare($share);
+
+ return $share;
+ }
}
diff --git a/apps/files_sharing/tests/unsharechildren.php b/apps/files_sharing/tests/unsharechildren.php
index 1968007be4e..6104dc98080 100644
--- a/apps/files_sharing/tests/unsharechildren.php
+++ b/apps/files_sharing/tests/unsharechildren.php
@@ -78,14 +78,19 @@ class UnshareChildren extends TestCase {
$fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileInfo2->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($result);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// one folder should be shared with the user
- $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
- $this->assertSame(1, count($sharedFolders));
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER);
+ $this->assertCount(1, $shares);
// move shared folder to 'localDir'
\OC\Files\Filesystem::mkdir('localDir');
@@ -97,8 +102,8 @@ class UnshareChildren extends TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// after the parent directory was deleted the share should be unshared
- $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
- $this->assertTrue(empty($sharedFolders));
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER);
+ $this->assertEmpty($shares);
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
diff --git a/apps/files_sharing/tests/updater.php b/apps/files_sharing/tests/updater.php
index 67c1642cdd0..53e7fc47665 100644
--- a/apps/files_sharing/tests/updater.php
+++ b/apps/files_sharing/tests/updater.php
@@ -75,7 +75,13 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
$fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
$this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);
- \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
+ $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
$view = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
@@ -152,9 +158,14 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
$etagBeforeShareDir = $beforeShareDir->getEtag();
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($result);
+
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -173,8 +184,7 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
// cleanup
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share);
$config->setSystemValue('share_folder', $oldShareFolder);
}
@@ -185,8 +195,14 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
function testRename() {
$fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
- $result = \OCP\Share::shareItem('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
- $this->assertTrue($result);
+
+ $share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ $this->folder,
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -210,9 +226,7 @@ class Test_Files_Sharing_Updater extends OCA\Files_Sharing\Tests\TestCase {
$this->assertTrue(\OC\Files\Filesystem::file_exists('/newTarget/oldTarget/subfolder/' . $this->folder));
// cleanup
- $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OCP\Share::unshare('folder', $fileinfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
- $this->assertTrue($result);
+ $this->shareManager->deleteShare($share);
}
}
diff --git a/apps/files_sharing/tests/watcher.php b/apps/files_sharing/tests/watcher.php
index 247fb59f351..19e1bc0b615 100644
--- a/apps/files_sharing/tests/watcher.php
+++ b/apps/files_sharing/tests/watcher.php
@@ -32,33 +32,27 @@
*/
class Test_Files_Sharing_Watcher extends OCA\Files_sharing\Tests\TestCase {
- /**
- * @var \OC\Files\Storage\Storage
- */
+ /** @var \OC\Files\Storage\Storage */
private $ownerStorage;
- /**
- * @var \OC\Files\Cache\Cache
- */
+ /** @var \OC\Files\Cache\Cache */
private $ownerCache;
- /**
- * @var \OC\Files\Storage\Storage
- */
+ /** @var \OC\Files\Storage\Storage */
private $sharedStorage;
- /**
- * @var \OC\Files\Cache\Cache
- */
+ /** @var \OC\Files\Cache\Cache */
private $sharedCache;
+ /** @var \OCP\Share\IShare */
+ private $_share;
+
protected function setUp() {
parent::setUp();
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
// prepare user1's dir structure
- $textData = "dummy file data\n";
$this->view->mkdir('container');
$this->view->mkdir('container/shareddir');
$this->view->mkdir('container/shareddir/subdir');
@@ -68,9 +62,13 @@ class Test_Files_Sharing_Watcher extends OCA\Files_sharing\Tests\TestCase {
$this->ownerStorage->getScanner()->scan('');
// share "shareddir" with user2
- $fileinfo = $this->view->getFileInfo('container/shareddir');
- \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2, 31);
+ $this->_share = $this->share(
+ \OCP\Share::SHARE_TYPE_USER,
+ 'container/shareddir',
+ self::TEST_FILES_SHARING_API_USER1,
+ self::TEST_FILES_SHARING_API_USER2,
+ \OCP\Constants::PERMISSION_ALL
+ );
// login as user2
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
@@ -89,9 +87,7 @@ class Test_Files_Sharing_Watcher extends OCA\Files_sharing\Tests\TestCase {
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
if ($this->view) {
- $fileinfo = $this->view->getFileInfo('container/shareddir');
- \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- self::TEST_FILES_SHARING_API_USER2);
+ $this->shareManager->deleteShare($this->_share);
$this->view->deleteAll('container');
diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js
index 771ea90bc16..fd3d5db32ff 100644
--- a/apps/files_trashbin/js/app.js
+++ b/apps/files_trashbin/js/app.js
@@ -29,7 +29,8 @@ OCA.Trashbin.App = {
scrollContainer: $('#app-content'),
fileActions: this._createFileActions(),
detailsViewEnabled: false,
- scrollTo: urlParams.scrollto
+ scrollTo: urlParams.scrollto,
+ config: OCA.Files.App.getFilesConfig()
}
);
},
diff --git a/apps/files_trashbin/tests/storage.php b/apps/files_trashbin/tests/storage.php
index afc07ff36c8..5c631770da3 100644
--- a/apps/files_trashbin/tests/storage.php
+++ b/apps/files_trashbin/tests/storage.php
@@ -261,9 +261,14 @@ class Storage extends \Test\TestCase {
$recipientUser = $this->getUniqueId('recipient_');
\OC::$server->getUserManager()->createUser($recipientUser, $recipientUser);
- $fileinfo = $this->userView->getFileInfo('share');
- $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- $recipientUser, 31));
+ $node = \OC::$server->getUserFolder($this->user)->get('share');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy($this->user)
+ ->setSharedWith($recipientUser)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ \OC::$server->getShareManager()->createShare($share);
$this->loginAsUser($recipientUser);
@@ -309,9 +314,14 @@ class Storage extends \Test\TestCase {
$recipientUser = $this->getUniqueId('recipient_');
\OC::$server->getUserManager()->createUser($recipientUser, $recipientUser);
- $fileinfo = $this->userView->getFileInfo('share');
- $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER,
- $recipientUser, 31));
+ $node = \OC::$server->getUserFolder($this->user)->get('share');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy($this->user)
+ ->setSharedWith($recipientUser)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ \OC::$server->getShareManager()->createShare($share);
$this->loginAsUser($recipientUser);
diff --git a/apps/files_trashbin/tests/trashbin.php b/apps/files_trashbin/tests/trashbin.php
index 8d616b6e8e2..7087da37266 100644
--- a/apps/files_trashbin/tests/trashbin.php
+++ b/apps/files_trashbin/tests/trashbin.php
@@ -211,9 +211,14 @@ class Test_Trashbin extends \Test\TestCase {
\OC\Files\Filesystem::file_put_contents($folder . 'user1-4.txt', 'file4');
//share user1-4.txt with user2
- $fileInfo = \OC\Files\Filesystem::getFileInfo($folder);
- $result = \OCP\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_TRASHBIN_USER2, 31);
- $this->assertTrue($result);
+ $node = \OC::$server->getUserFolder(self::TEST_TRASHBIN_USER1)->get($folder);
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setNode($node)
+ ->setSharedBy(self::TEST_TRASHBIN_USER1)
+ ->setSharedWith(self::TEST_TRASHBIN_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ \OC::$server->getShareManager()->createShare($share);
// delete them so that they end up in the trash bin
\OC\Files\Filesystem::unlink($folder . 'user1-1.txt');
diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php
index 9d0ffb87946..b8e68cfadf7 100644
--- a/apps/files_versions/tests/versions.php
+++ b/apps/files_versions/tests/versions.php
@@ -297,8 +297,6 @@ class Test_Files_Versioning extends \Test\TestCase {
\OC\Files\Filesystem::mkdir('folder1/folder2');
\OC\Files\Filesystem::file_put_contents("folder1/test.txt", "test file");
- $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1');
-
$t1 = time();
// second version is two weeks older, this way we make sure that no
// version will be expired
@@ -314,7 +312,14 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->rootView->file_put_contents($v1, 'version1');
$this->rootView->file_put_contents($v2, 'version2');
- \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL);
+ $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy(self::TEST_VERSIONS_USER)
+ ->setSharedWith(self::TEST_VERSIONS_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = \OC::$server->getShareManager()->createShare($share);
self::loginHelper(self::TEST_VERSIONS_USER2);
@@ -332,6 +337,8 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->assertTrue($this->rootView->file_exists($v1Renamed));
$this->assertTrue($this->rootView->file_exists($v2Renamed));
+
+ \OC::$server->getShareManager()->deleteShare($share);
}
public function testMoveFolder() {
@@ -373,13 +380,14 @@ class Test_Files_Versioning extends \Test\TestCase {
\OC\Files\Filesystem::mkdir('folder1');
$fileInfo = \OC\Files\Filesystem::getFileInfo('folder1');
- \OCP\Share::shareItem(
- 'folder',
- $fileInfo['fileid'],
- \OCP\Share::SHARE_TYPE_USER,
- self::TEST_VERSIONS_USER2,
- \OCP\Constants::PERMISSION_ALL
- );
+ $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy(self::TEST_VERSIONS_USER)
+ ->setSharedWith(self::TEST_VERSIONS_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = \OC::$server->getShareManager()->createShare($share);
self::loginHelper(self::TEST_VERSIONS_USER2);
$versionsFolder2 = '/' . self::TEST_VERSIONS_USER2 . '/files_versions';
@@ -413,20 +421,22 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->assertTrue($this->rootView->file_exists($v1Renamed));
$this->assertTrue($this->rootView->file_exists($v2Renamed));
+
+ \OC::$server->getShareManager()->deleteShare($share);
}
public function testMoveFolderIntoSharedFolderAsRecipient() {
\OC\Files\Filesystem::mkdir('folder1');
- $fileInfo = \OC\Files\Filesystem::getFileInfo('folder1');
- \OCP\Share::shareItem(
- 'folder',
- $fileInfo['fileid'],
- \OCP\Share::SHARE_TYPE_USER,
- self::TEST_VERSIONS_USER2,
- \OCP\Constants::PERMISSION_ALL
- );
+ $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy(self::TEST_VERSIONS_USER)
+ ->setSharedWith(self::TEST_VERSIONS_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = \OC::$server->getShareManager()->createShare($share);
self::loginHelper(self::TEST_VERSIONS_USER2);
$versionsFolder2 = '/' . self::TEST_VERSIONS_USER2 . '/files_versions';
@@ -462,14 +472,14 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->assertTrue($this->rootView->file_exists($v1Renamed));
$this->assertTrue($this->rootView->file_exists($v2Renamed));
+
+ \OC::$server->getShareManager()->deleteShare($share);
}
public function testRenameSharedFile() {
\OC\Files\Filesystem::file_put_contents("test.txt", "test file");
- $fileInfo = \OC\Files\Filesystem::getFileInfo('test.txt');
-
$t1 = time();
// second version is two weeks older, this way we make sure that no
// version will be expired
@@ -486,7 +496,14 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->rootView->file_put_contents($v1, 'version1');
$this->rootView->file_put_contents($v2, 'version2');
- \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL);
+ $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('test.txt');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy(self::TEST_VERSIONS_USER)
+ ->setSharedWith(self::TEST_VERSIONS_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
+ $share = \OC::$server->getShareManager()->createShare($share);
self::loginHelper(self::TEST_VERSIONS_USER2);
@@ -504,6 +521,8 @@ class Test_Files_Versioning extends \Test\TestCase {
$this->assertFalse($this->rootView->file_exists($v1Renamed));
$this->assertFalse($this->rootView->file_exists($v2Renamed));
+
+ \OC::$server->getShareManager()->deleteShare($share);
}
public function testCopy() {
@@ -744,15 +763,15 @@ class Test_Files_Versioning extends \Test\TestCase {
\OC\Files\Filesystem::mkdir('folder');
\OC\Files\Filesystem::file_put_contents('folder/test.txt', 'test file');
- $fileInfo = \OC\Files\Filesystem::getFileInfo('folder');
-
- \OCP\Share::shareItem(
- 'folder',
- $fileInfo['fileid'],
- \OCP\Share::SHARE_TYPE_USER,
- self::TEST_VERSIONS_USER2,
- \OCP\Constants::PERMISSION_ALL
- );
+
+ $node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder');
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setNode($node)
+ ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setSharedBy(self::TEST_VERSIONS_USER)
+ ->setSharedWith(self::TEST_VERSIONS_USER2)
+ ->setPermissions(\OCP\Constants::PERMISSION_ALL);
+ $share = \OC::$server->getShareManager()->createShare($share);
$this->loginAsUser(self::TEST_VERSIONS_USER2);
@@ -760,6 +779,8 @@ class Test_Files_Versioning extends \Test\TestCase {
\OC\Files\Filesystem::getView(),
'folder/test.txt'
);
+
+ \OC::$server->getShareManager()->deleteShare($share);
}
/**
diff --git a/apps/systemtags/js/app.js b/apps/systemtags/js/app.js
index d28514358c1..e027c0be123 100644
--- a/apps/systemtags/js/app.js
+++ b/apps/systemtags/js/app.js
@@ -28,7 +28,8 @@
{
id: 'systemtags',
scrollContainer: $('#app-content'),
- fileActions: this._createFileActions()
+ fileActions: this._createFileActions(),
+ config: OCA.Files.App.getFilesConfig()
}
);
diff --git a/apps/user_ldap/js/wizard/wizardTabGeneric.js b/apps/user_ldap/js/wizard/wizardTabGeneric.js
index 21085e3a584..4415172a18c 100644
--- a/apps/user_ldap/js/wizard/wizardTabGeneric.js
+++ b/apps/user_ldap/js/wizard/wizardTabGeneric.js
@@ -391,7 +391,7 @@ OCA = OCA || {};
*/
_setCheckBox: function($element, value) {
if(parseInt(value, 10) === 1) {
- $element.attr('checked', 'checked');
+ $element.prop('checked', 'checked');
} else {
$element.removeAttr('checked');
}