aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/ajax/external.php107
-rw-r--r--apps/files_sharing/ajax/publicpreview.php2
-rw-r--r--apps/files_sharing/api/local.php9
-rw-r--r--apps/files_sharing/api/remote.php91
-rw-r--r--apps/files_sharing/api/server2server.php24
-rw-r--r--apps/files_sharing/appinfo/info.xml1
-rw-r--r--apps/files_sharing/appinfo/routes.php15
-rw-r--r--apps/files_sharing/appinfo/version2
-rw-r--r--apps/files_sharing/js/share.js6
-rw-r--r--apps/files_sharing/l10n/da.js4
-rw-r--r--apps/files_sharing/l10n/da.json4
-rw-r--r--apps/files_sharing/l10n/fr.js4
-rw-r--r--apps/files_sharing/l10n/fr.json4
-rw-r--r--apps/files_sharing/l10n/id.js11
-rw-r--r--apps/files_sharing/l10n/id.json11
-rw-r--r--apps/files_sharing/l10n/ja.js3
-rw-r--r--apps/files_sharing/l10n/ja.json3
-rw-r--r--apps/files_sharing/l10n/uk.js5
-rw-r--r--apps/files_sharing/l10n/uk.json5
-rw-r--r--apps/files_sharing/l10n/zh_CN.js5
-rw-r--r--apps/files_sharing/l10n/zh_CN.json5
-rw-r--r--apps/files_sharing/lib/activity.php15
-rw-r--r--apps/files_sharing/lib/external/manager.php10
-rw-r--r--apps/files_sharing/lib/external/scanner.php3
-rw-r--r--apps/files_sharing/lib/sharedmount.php27
-rw-r--r--apps/files_sharing/lib/sharedstorage.php16
-rw-r--r--apps/files_sharing/templates/public.php2
-rw-r--r--apps/files_sharing/tests/js/shareSpec.js17
-rw-r--r--apps/files_sharing/tests/locking.php101
-rw-r--r--apps/files_sharing/tests/unsharechildren.php8
30 files changed, 422 insertions, 98 deletions
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php
index 7bef0c3197a..d26a64d3aec 100644
--- a/apps/files_sharing/ajax/external.php
+++ b/apps/files_sharing/ajax/external.php
@@ -56,71 +56,76 @@ $externalManager = new \OCA\Files_Sharing\External\Manager(
);
// check for ssl cert
-if (substr($remote, 0, 5) === 'https' and !OC_Util::getUrlContent($remote)) {
- \OCP\JSON::error(array('data' => array('message' => $l->t('Invalid or untrusted SSL certificate'))));
- exit;
-} else {
- $mount = $externalManager->addShare($remote, $token, $password, $name, $owner, true);
+if (substr($remote, 0, 5) === 'https') {
+ try {
+ \OC::$server->getHTTPClientService()->newClient()->get($remote)->getBody();
+ } catch (\Exception $e) {
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Invalid or untrusted SSL certificate'))));
+ exit;
+ }
+}
+
+$mount = $externalManager->addShare($remote, $token, $password, $name, $owner, true);
- /**
- * @var \OCA\Files_Sharing\External\Storage $storage
- */
- $storage = $mount->getStorage();
+/**
+ * @var \OCA\Files_Sharing\External\Storage $storage
+ */
+$storage = $mount->getStorage();
+try {
+ // check if storage exists
+ $storage->checkStorageAvailability();
+} catch (\OCP\Files\StorageInvalidException $e) {
+ // note: checkStorageAvailability will already remove the invalid share
+ \OCP\Util::writeLog(
+ 'files_sharing',
+ 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
+ \OCP\Util::DEBUG
+ );
+ \OCP\JSON::error(
+ array(
+ 'data' => array(
+ 'message' => $l->t('Could not authenticate to remote share, password might be wrong')
+ )
+ )
+ );
+ exit();
+} catch (\Exception $e) {
+ \OCP\Util::writeLog(
+ 'files_sharing',
+ 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
+ \OCP\Util::DEBUG
+ );
+ $externalManager->removeShare($mount->getMountPoint());
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
+ exit();
+}
+$result = $storage->file_exists('');
+if ($result) {
try {
- // check if storage exists
- $storage->checkStorageAvailability();
+ $storage->getScanner()->scanAll();
+ \OCP\JSON::success();
} catch (\OCP\Files\StorageInvalidException $e) {
- // note: checkStorageAvailability will already remove the invalid share
\OCP\Util::writeLog(
'files_sharing',
'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
\OCP\Util::DEBUG
);
- \OCP\JSON::error(
- array(
- 'data' => array(
- 'message' => $l->t('Could not authenticate to remote share, password might be wrong')
- )
- )
- );
- exit();
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
} catch (\Exception $e) {
\OCP\Util::writeLog(
'files_sharing',
'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
\OCP\Util::DEBUG
);
- $externalManager->removeShare($mount->getMountPoint());
- \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
- exit();
- }
- $result = $storage->file_exists('');
- if ($result) {
- try {
- $storage->getScanner()->scanAll();
- \OCP\JSON::success();
- } catch (\OCP\Files\StorageInvalidException $e) {
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- \OCP\Util::DEBUG
- );
- \OCP\JSON::error(array('data' => array('message' => $l->t('Storage not valid'))));
- } catch (\Exception $e) {
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(),
- \OCP\Util::DEBUG
- );
- \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
- }
- } else {
- $externalManager->removeShare($mount->getMountPoint());
- \OCP\Util::writeLog(
- 'files_sharing',
- 'Couldn\'t add remote share',
- \OCP\Util::DEBUG
- );
\OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
}
+} else {
+ $externalManager->removeShare($mount->getMountPoint());
+ \OCP\Util::writeLog(
+ 'files_sharing',
+ 'Couldn\'t add remote share',
+ \OCP\Util::DEBUG
+ );
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t add remote share'))));
}
+
diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php
index 99a5bdaa859..6ddd4786c2a 100644
--- a/apps/files_sharing/ajax/publicpreview.php
+++ b/apps/files_sharing/ajax/publicpreview.php
@@ -66,7 +66,7 @@ $path = $view->getPath($pathId);
if($path === null) {
\OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
- \OC_Log::write('core-preview', 'Could not resolve file for shared item', OC_Log::WARN);
+ \OCP\Util::writeLog('core-preview', 'Could not resolve file for shared item', \OCP\Util::WARN);
exit;
}
diff --git a/apps/files_sharing/api/local.php b/apps/files_sharing/api/local.php
index 84a789f26e4..b0ddba9fa11 100644
--- a/apps/files_sharing/api/local.php
+++ b/apps/files_sharing/api/local.php
@@ -260,6 +260,7 @@ class Local {
return new \OC_OCS_Result(null, 400, "please specify a file or folder path");
}
$itemSource = self::getFileId($path);
+ $itemSourceName = $itemSource;
$itemType = self::getItemType($path);
if($itemSource === null) {
@@ -270,9 +271,10 @@ class Local {
$shareType = isset($_POST['shareType']) ? (int)$_POST['shareType'] : null;
switch($shareType) {
+ case \OCP\Share::SHARE_TYPE_REMOTE:
+ $shareWith = rtrim($shareWith, '/');
+ $itemSourceName = basename($path);
case \OCP\Share::SHARE_TYPE_USER:
- $permissions = isset($_POST['permissions']) ? (int)$_POST['permissions'] : 31;
- break;
case \OCP\Share::SHARE_TYPE_GROUP:
$permissions = isset($_POST['permissions']) ? (int)$_POST['permissions'] : 31;
break;
@@ -303,7 +305,8 @@ class Local {
$itemSource,
$shareType,
$shareWith,
- $permissions
+ $permissions,
+ $itemSourceName
);
} catch (HintException $e) {
return new \OC_OCS_Result(null, 400, $e->getHint());
diff --git a/apps/files_sharing/api/remote.php b/apps/files_sharing/api/remote.php
new file mode 100644
index 00000000000..f6cb0a29d8b
--- /dev/null
+++ b/apps/files_sharing/api/remote.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_Sharing\API;
+
+use OC\Files\Filesystem;
+use OCA\Files_Sharing\External\Manager;
+
+class Remote {
+
+ /**
+ * Accept a remote share
+ *
+ * @param array $params contains the shareID 'id' which should be accepted
+ * @return \OC_OCS_Result
+ */
+ public static function getOpenShares($params) {
+ $externalManager = new Manager(
+ \OC::$server->getDatabaseConnection(),
+ Filesystem::getMountManager(),
+ Filesystem::getLoader(),
+ \OC::$server->getHTTPHelper(),
+ \OC_User::getUser()
+ );
+
+ return new \OC_OCS_Result($externalManager->getOpenShares());
+ }
+
+ /**
+ * Accept a remote share
+ *
+ * @param array $params contains the shareID 'id' which should be accepted
+ * @return \OC_OCS_Result
+ */
+ public static function acceptShare($params) {
+ $externalManager = new Manager(
+ \OC::$server->getDatabaseConnection(),
+ Filesystem::getMountManager(),
+ Filesystem::getLoader(),
+ \OC::$server->getHTTPHelper(),
+ \OC_User::getUser()
+ );
+
+ if ($externalManager->acceptShare($params['id'])) {
+ return new \OC_OCS_Result();
+ }
+
+ return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
+ }
+
+ /**
+ * Decline a remote share
+ *
+ * @param array $params contains the shareID 'id' which should be declined
+ * @return \OC_OCS_Result
+ */
+ public static function declineShare($params) {
+ $externalManager = new Manager(
+ \OC::$server->getDatabaseConnection(),
+ Filesystem::getMountManager(),
+ Filesystem::getLoader(),
+ \OC::$server->getHTTPHelper(),
+ \OC_User::getUser()
+ );
+
+ if ($externalManager->declineShare($params['id'])) {
+ return new \OC_OCS_Result();
+ }
+
+ return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
+ }
+
+}
diff --git a/apps/files_sharing/api/server2server.php b/apps/files_sharing/api/server2server.php
index 3ecdf65dc74..8bda0bb8749 100644
--- a/apps/files_sharing/api/server2server.php
+++ b/apps/files_sharing/api/server2server.php
@@ -22,6 +22,8 @@
namespace OCA\Files_Sharing\API;
+use OCA\Files_Sharing\Activity;
+
class Server2Server {
/**
@@ -69,8 +71,8 @@ class Server2Server {
$user = $owner . '@' . $this->cleanupRemote($remote);
\OC::$server->getActivityManager()->publishActivity(
- 'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user), '', array(),
- '', '', $shareWith, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW);
+ Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_RECEIVED, array($user, trim($name, '/')), '', array(),
+ '', '', $shareWith, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
return new \OC_OCS_Result();
} catch (\Exception $e) {
@@ -102,8 +104,8 @@ class Server2Server {
list($file, $link) = self::getFile($share['uid_owner'], $share['file_source']);
\OC::$server->getActivityManager()->publishActivity(
- 'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_ACCEPTED, array($share['share_with'], basename($file)), '', array(),
- $file, $link, $share['uid_owner'], \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW);
+ Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_ACCEPTED, array($share['share_with'], basename($file)), '', array(),
+ $file, $link, $share['uid_owner'], Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
}
return new \OC_OCS_Result();
@@ -133,8 +135,8 @@ class Server2Server {
list($file, $link) = $this->getFile($share['uid_owner'], $share['file_source']);
\OC::$server->getActivityManager()->publishActivity(
- 'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_DECLINED, array($share['share_with'], basename($file)), '', array(),
- $file, $link, $share['uid_owner'], \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_LOW);
+ Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_DECLINED, array($share['share_with'], basename($file)), '', array(),
+ $file, $link, $share['uid_owner'], Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_LOW);
}
return new \OC_OCS_Result();
@@ -170,9 +172,15 @@ class Server2Server {
$query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share_external` WHERE `remote_id` = ? AND `share_token` = ?');
$query->execute(array($id, $token));
+ if ($share['accepted']) {
+ $path = trim($mountpoint, '/');
+ } else {
+ $path = trim($share['name'], '/');
+ }
+
\OC::$server->getActivityManager()->publishActivity(
- 'files_sharing', \OCA\Files_Sharing\Activity::SUBJECT_REMOTE_SHARE_UNSHARED, array($owner, $mountpoint), '', array(),
- '', '', $user, \OCA\Files_Sharing\Activity::TYPE_REMOTE_SHARE, \OCA\Files_Sharing\Activity::PRIORITY_MEDIUM);
+ Activity::FILES_SHARING_APP, Activity::SUBJECT_REMOTE_SHARE_UNSHARED, array($owner, $path), '', array(),
+ '', '', $user, Activity::TYPE_REMOTE_SHARE, Activity::PRIORITY_MEDIUM);
}
return new \OC_OCS_Result();
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index d6f7e4b1320..28c64cbb1b4 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -19,5 +19,4 @@ Turning the feature off removes shared files and folders on the server for all s
<files>public.php</files>
<webdav>publicwebdav.php</webdav>
</public>
- <ocsid>166050</ocsid>
</info>
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php
index 2686abed0ae..21d21a83441 100644
--- a/apps/files_sharing/appinfo/routes.php
+++ b/apps/files_sharing/appinfo/routes.php
@@ -82,6 +82,21 @@ API::register('delete',
array('\OCA\Files_Sharing\API\Local', 'deleteShare'),
'files_sharing');
+API::register('get',
+ '/apps/files_sharing/api/v1/remote_shares',
+ array('\OCA\Files_Sharing\API\Remote', 'getOpenShares'),
+ 'files_sharing');
+
+API::register('post',
+ '/apps/files_sharing/api/v1/remote_shares/{id}',
+ array('\OCA\Files_Sharing\API\Remote', 'acceptShare'),
+ 'files_sharing');
+
+API::register('delete',
+ '/apps/files_sharing/api/v1/remote_shares/{id}',
+ array('\OCA\Files_Sharing\API\Remote', 'declineShare'),
+ 'files_sharing');
+
// Register with the capabilities API
API::register('get',
'/cloud/capabilities',
diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version
index ee6cdce3c29..b6160487433 100644
--- a/apps/files_sharing/appinfo/version
+++ b/apps/files_sharing/appinfo/version
@@ -1 +1 @@
-0.6.1
+0.6.2
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 11c3170c2f0..e7823454c53 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -25,6 +25,10 @@
* @param {OCA.Files.FileList} fileList file list to be extended
*/
attach: function(fileList) {
+ // core sharing is disabled/not loaded
+ if (!OC.Share) {
+ return;
+ }
if (fileList.id === 'trashbin' || fileList.id === 'files.public') {
return;
}
@@ -151,7 +155,7 @@
var permissions = $tr.data('permissions');
var hasLink = !!(shareStatus && shareStatus.link);
OC.Share.markFileAsShared($tr, true, hasLink);
- if ((permissions & OC.PERMISSION_SHARE) === 0) {
+ if ((permissions & OC.PERMISSION_SHARE) === 0 && $tr.attr('data-share-owner')) {
// if no share action exists because the admin disabled sharing for this user
// we create a share notification action to inform the user about files
// shared with him otherwise we just update the existing share action.
diff --git a/apps/files_sharing/l10n/da.js b/apps/files_sharing/l10n/da.js
index a31e6363f25..d066f010f53 100644
--- a/apps/files_sharing/l10n/da.js
+++ b/apps/files_sharing/l10n/da.js
@@ -40,6 +40,8 @@ OC.L10N.register(
"%2$s shared %1$s with you" : "%2$s delt %1$s med dig",
"You shared %1$s via link" : "Du delte %1$s via link",
"Shares" : "Delt",
+ "Share with me through my #ownCloud Federated Cloud ID, see %s" : "Del med mig gennem min #ownCloud Federated Cloud ID, se %s",
+ "Share with me through my #ownCloud Federated Cloud ID" : "Del med mig gennem min #ownCloud Federated Cloud ID",
"This share is password-protected" : "Delingen er beskyttet af kodeord",
"The password is wrong. Try again." : "Kodeordet er forkert. Prøv igen.",
"Password" : "Kodeord",
@@ -61,8 +63,10 @@ OC.L10N.register(
"Allow users on this server to send shares to other servers" : "Tillad brugere på denne server, at sende delinger til andre servere",
"Allow users on this server to receive shares from other servers" : "Tillad brugere på denne server, at modtage delinger fra andre servere",
"Federated Cloud" : "Federated Cloud",
+ "Your Federated Cloud ID:" : "Din Federated Cloud ID:",
"Share it:" : "Del:",
"Add it to your website:" : "Tilføj den til din hjemmeside:",
+ "Share with me via ownCloud" : "Del med mig gennem ownCloud",
"HTML Code:" : "HTMLkode:"
},
"nplurals=2; plural=(n != 1);");
diff --git a/apps/files_sharing/l10n/da.json b/apps/files_sharing/l10n/da.json
index b91fbf21eb0..7f4ac9290d0 100644
--- a/apps/files_sharing/l10n/da.json
+++ b/apps/files_sharing/l10n/da.json
@@ -38,6 +38,8 @@
"%2$s shared %1$s with you" : "%2$s delt %1$s med dig",
"You shared %1$s via link" : "Du delte %1$s via link",
"Shares" : "Delt",
+ "Share with me through my #ownCloud Federated Cloud ID, see %s" : "Del med mig gennem min #ownCloud Federated Cloud ID, se %s",
+ "Share with me through my #ownCloud Federated Cloud ID" : "Del med mig gennem min #ownCloud Federated Cloud ID",
"This share is password-protected" : "Delingen er beskyttet af kodeord",
"The password is wrong. Try again." : "Kodeordet er forkert. Prøv igen.",
"Password" : "Kodeord",
@@ -59,8 +61,10 @@
"Allow users on this server to send shares to other servers" : "Tillad brugere på denne server, at sende delinger til andre servere",
"Allow users on this server to receive shares from other servers" : "Tillad brugere på denne server, at modtage delinger fra andre servere",
"Federated Cloud" : "Federated Cloud",
+ "Your Federated Cloud ID:" : "Din Federated Cloud ID:",
"Share it:" : "Del:",
"Add it to your website:" : "Tilføj den til din hjemmeside:",
+ "Share with me via ownCloud" : "Del med mig gennem ownCloud",
"HTML Code:" : "HTMLkode:"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
} \ No newline at end of file
diff --git a/apps/files_sharing/l10n/fr.js b/apps/files_sharing/l10n/fr.js
index 61ee5c1a61b..b866739e148 100644
--- a/apps/files_sharing/l10n/fr.js
+++ b/apps/files_sharing/l10n/fr.js
@@ -63,10 +63,10 @@ OC.L10N.register(
"Allow users on this server to send shares to other servers" : "Autoriser les utilisateurs de ce serveur à envoyer des partages vers d'autres serveurs",
"Allow users on this server to receive shares from other servers" : "Autoriser les utilisateurs de ce serveur à recevoir des partages d'autres serveurs",
"Federated Cloud" : "Federated Cloud",
- "Your Federated Cloud ID:" : "Votre ID Federated Cloud :",
+ "Your Federated Cloud ID:" : "Votre identifiant Federated Cloud :",
"Share it:" : "Partager :",
"Add it to your website:" : "Ajouter à votre site web :",
"Share with me via ownCloud" : "Partagez avec moi via ownCloud",
- "HTML Code:" : "Code HTML:"
+ "HTML Code:" : "Code HTML :"
},
"nplurals=2; plural=(n > 1);");
diff --git a/apps/files_sharing/l10n/fr.json b/apps/files_sharing/l10n/fr.json
index a57b1befbcc..b4592edcdcc 100644
--- a/apps/files_sharing/l10n/fr.json
+++ b/apps/files_sharing/l10n/fr.json
@@ -61,10 +61,10 @@
"Allow users on this server to send shares to other servers" : "Autoriser les utilisateurs de ce serveur à envoyer des partages vers d'autres serveurs",
"Allow users on this server to receive shares from other servers" : "Autoriser les utilisateurs de ce serveur à recevoir des partages d'autres serveurs",
"Federated Cloud" : "Federated Cloud",
- "Your Federated Cloud ID:" : "Votre ID Federated Cloud :",
+ "Your Federated Cloud ID:" : "Votre identifiant Federated Cloud :",
"Share it:" : "Partager :",
"Add it to your website:" : "Ajouter à votre site web :",
"Share with me via ownCloud" : "Partagez avec moi via ownCloud",
- "HTML Code:" : "Code HTML:"
+ "HTML Code:" : "Code HTML :"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
} \ No newline at end of file
diff --git a/apps/files_sharing/l10n/id.js b/apps/files_sharing/l10n/id.js
index fd8b3dd810e..6322747c9c1 100644
--- a/apps/files_sharing/l10n/id.js
+++ b/apps/files_sharing/l10n/id.js
@@ -21,6 +21,7 @@ OC.L10N.register(
"Remote share password" : "Sandi berbagi remote",
"Cancel" : "Batal",
"Add remote share" : "Tambah berbagi remote",
+ "You can upload into this folder" : "Anda dapat mengunggah kedalam folder ini",
"No ownCloud installation (7 or higher) found at {remote}" : "Tidak ditemukan instalasi ownCloud (7 atau lebih tinggi) pada {remote}",
"Invalid ownCloud url" : "URL ownCloud tidak sah",
"Share" : "Bagikan",
@@ -39,6 +40,8 @@ OC.L10N.register(
"%2$s shared %1$s with you" : "%2$s membagikan %1$s dengan Anda",
"You shared %1$s via link" : "Anda membagikan %1$s via tautan",
"Shares" : "Dibagikan",
+ "Share with me through my #ownCloud Federated Cloud ID, see %s" : "Dibagikan pada saya melalui #ownCloud Federated Cloud ID saya, lihat %s",
+ "Share with me through my #ownCloud Federated Cloud ID" : "Dibagikan pada saya melalui #ownCloud Federated Cloud ID saya",
"This share is password-protected" : "Berbagi ini dilindungi sandi",
"The password is wrong. Try again." : "Sandi salah. Coba lagi",
"Password" : "Sandi",
@@ -58,6 +61,12 @@ OC.L10N.register(
"Federated Cloud Sharing" : "Federated Cloud Sharing",
"Open documentation" : "Buka dokumentasi",
"Allow users on this server to send shares to other servers" : "Izinkan para pengguna di server ini untuk mengirimkan berbagi ke server lainnya.",
- "Allow users on this server to receive shares from other servers" : "Izinkan para pengguna di server ini untuk menerima berbagi ke server lainnya."
+ "Allow users on this server to receive shares from other servers" : "Izinkan para pengguna di server ini untuk menerima berbagi ke server lainnya.",
+ "Federated Cloud" : "Federated Cloud",
+ "Your Federated Cloud ID:" : "Federated Cloud ID Anda:",
+ "Share it:" : "Bagikan:",
+ "Add it to your website:" : "Tambahkan ke situs web Anda:",
+ "Share with me via ownCloud" : "Dibagikan pada saya via ownCloud",
+ "HTML Code:" : "Kode HTML:"
},
"nplurals=1; plural=0;");
diff --git a/apps/files_sharing/l10n/id.json b/apps/files_sharing/l10n/id.json
index e82b6966d24..ed1a6fb7bca 100644
--- a/apps/files_sharing/l10n/id.json
+++ b/apps/files_sharing/l10n/id.json
@@ -19,6 +19,7 @@
"Remote share password" : "Sandi berbagi remote",
"Cancel" : "Batal",
"Add remote share" : "Tambah berbagi remote",
+ "You can upload into this folder" : "Anda dapat mengunggah kedalam folder ini",
"No ownCloud installation (7 or higher) found at {remote}" : "Tidak ditemukan instalasi ownCloud (7 atau lebih tinggi) pada {remote}",
"Invalid ownCloud url" : "URL ownCloud tidak sah",
"Share" : "Bagikan",
@@ -37,6 +38,8 @@
"%2$s shared %1$s with you" : "%2$s membagikan %1$s dengan Anda",
"You shared %1$s via link" : "Anda membagikan %1$s via tautan",
"Shares" : "Dibagikan",
+ "Share with me through my #ownCloud Federated Cloud ID, see %s" : "Dibagikan pada saya melalui #ownCloud Federated Cloud ID saya, lihat %s",
+ "Share with me through my #ownCloud Federated Cloud ID" : "Dibagikan pada saya melalui #ownCloud Federated Cloud ID saya",
"This share is password-protected" : "Berbagi ini dilindungi sandi",
"The password is wrong. Try again." : "Sandi salah. Coba lagi",
"Password" : "Sandi",
@@ -56,6 +59,12 @@
"Federated Cloud Sharing" : "Federated Cloud Sharing",
"Open documentation" : "Buka dokumentasi",
"Allow users on this server to send shares to other servers" : "Izinkan para pengguna di server ini untuk mengirimkan berbagi ke server lainnya.",
- "Allow users on this server to receive shares from other servers" : "Izinkan para pengguna di server ini untuk menerima berbagi ke server lainnya."
+ "Allow users on this server to receive shares from other servers" : "Izinkan para pengguna di server ini untuk menerima berbagi ke server lainnya.",
+ "Federated Cloud" : "Federated Cloud",
+ "Your Federated Cloud ID:" : "Federated Cloud ID Anda:",
+ "Share it:" : "Bagikan:",
+ "Add it to your website:" : "Tambahkan ke situs web Anda:",
+ "Share with me via ownCloud" : "Dibagikan pada saya via ownCloud",
+ "HTML Code:" : "Kode HTML:"
},"pluralForm" :"nplurals=1; plural=0;"
} \ No newline at end of file
diff --git a/apps/files_sharing/l10n/ja.js b/apps/files_sharing/l10n/ja.js
index dde011c8b4d..2e82cc5f403 100644
--- a/apps/files_sharing/l10n/ja.js
+++ b/apps/files_sharing/l10n/ja.js
@@ -59,6 +59,7 @@ OC.L10N.register(
"Federated Cloud Sharing" : "統合されたクラウド共有",
"Open documentation" : "ドキュメントを開く",
"Allow users on this server to send shares to other servers" : "ユーザーがこのサーバーから他のサーバーに共有することを許可する",
- "Allow users on this server to receive shares from other servers" : "ユーザーが他のサーバーからこのサーバーに共有することを許可する"
+ "Allow users on this server to receive shares from other servers" : "ユーザーが他のサーバーからこのサーバーに共有することを許可する",
+ "HTML Code:" : "HTMLコード:"
},
"nplurals=1; plural=0;");
diff --git a/apps/files_sharing/l10n/ja.json b/apps/files_sharing/l10n/ja.json
index 76d8d8e8968..33583797263 100644
--- a/apps/files_sharing/l10n/ja.json
+++ b/apps/files_sharing/l10n/ja.json
@@ -57,6 +57,7 @@
"Federated Cloud Sharing" : "統合されたクラウド共有",
"Open documentation" : "ドキュメントを開く",
"Allow users on this server to send shares to other servers" : "ユーザーがこのサーバーから他のサーバーに共有することを許可する",
- "Allow users on this server to receive shares from other servers" : "ユーザーが他のサーバーからこのサーバーに共有することを許可する"
+ "Allow users on this server to receive shares from other servers" : "ユーザーが他のサーバーからこのサーバーに共有することを許可する",
+ "HTML Code:" : "HTMLコード:"
},"pluralForm" :"nplurals=1; plural=0;"
} \ No newline at end of file
diff --git a/apps/files_sharing/l10n/uk.js b/apps/files_sharing/l10n/uk.js
index 18a6dde9e3a..76e9b885257 100644
--- a/apps/files_sharing/l10n/uk.js
+++ b/apps/files_sharing/l10n/uk.js
@@ -59,6 +59,9 @@ OC.L10N.register(
"Federated Cloud Sharing" : "Об’єднання хмарних сховищ",
"Open documentation" : "Відкрити документацію",
"Allow users on this server to send shares to other servers" : "Дозволити користувачам цього сервера публікувати на інших серверах",
- "Allow users on this server to receive shares from other servers" : "Дозволити користувачам на цьому сервері отримувати публікації з інших серверів"
+ "Allow users on this server to receive shares from other servers" : "Дозволити користувачам на цьому сервері отримувати публікації з інших серверів",
+ "Share it:" : "Поділитися цим:",
+ "Add it to your website:" : "Додати до вашого сайту:",
+ "HTML Code:" : "HTML код:"
},
"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);");
diff --git a/apps/files_sharing/l10n/uk.json b/apps/files_sharing/l10n/uk.json
index de200a1fe8f..74cccc1901c 100644
--- a/apps/files_sharing/l10n/uk.json
+++ b/apps/files_sharing/l10n/uk.json
@@ -57,6 +57,9 @@
"Federated Cloud Sharing" : "Об’єднання хмарних сховищ",
"Open documentation" : "Відкрити документацію",
"Allow users on this server to send shares to other servers" : "Дозволити користувачам цього сервера публікувати на інших серверах",
- "Allow users on this server to receive shares from other servers" : "Дозволити користувачам на цьому сервері отримувати публікації з інших серверів"
+ "Allow users on this server to receive shares from other servers" : "Дозволити користувачам на цьому сервері отримувати публікації з інших серверів",
+ "Share it:" : "Поділитися цим:",
+ "Add it to your website:" : "Додати до вашого сайту:",
+ "HTML Code:" : "HTML код:"
},"pluralForm" :"nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);"
} \ No newline at end of file
diff --git a/apps/files_sharing/l10n/zh_CN.js b/apps/files_sharing/l10n/zh_CN.js
index 11e71ab4819..f3bbbbcfcb9 100644
--- a/apps/files_sharing/l10n/zh_CN.js
+++ b/apps/files_sharing/l10n/zh_CN.js
@@ -23,6 +23,7 @@ OC.L10N.register(
"This share is password-protected" : "这是一个密码保护的共享",
"The password is wrong. Try again." : "用户名或密码错误!请重试",
"Password" : "密码",
+ "No entries found in this folder" : "此文件夹中无项目",
"Name" : "名称",
"Share time" : "分享时间",
"Sorry, this link doesn’t seem to work anymore." : "抱歉,此链接已失效",
@@ -34,6 +35,8 @@ OC.L10N.register(
"Add to your ownCloud" : "添加到您的 ownCloud",
"Download" : "下载",
"Download %s" : "下载 %s",
- "Direct link" : "直接链接"
+ "Direct link" : "直接链接",
+ "Federated Cloud Sharing" : "联合云共享",
+ "Open documentation" : "打开文档"
},
"nplurals=1; plural=0;");
diff --git a/apps/files_sharing/l10n/zh_CN.json b/apps/files_sharing/l10n/zh_CN.json
index bc26e501a06..a8b4d45a62d 100644
--- a/apps/files_sharing/l10n/zh_CN.json
+++ b/apps/files_sharing/l10n/zh_CN.json
@@ -21,6 +21,7 @@
"This share is password-protected" : "这是一个密码保护的共享",
"The password is wrong. Try again." : "用户名或密码错误!请重试",
"Password" : "密码",
+ "No entries found in this folder" : "此文件夹中无项目",
"Name" : "名称",
"Share time" : "分享时间",
"Sorry, this link doesn’t seem to work anymore." : "抱歉,此链接已失效",
@@ -32,6 +33,8 @@
"Add to your ownCloud" : "添加到您的 ownCloud",
"Download" : "下载",
"Download %s" : "下载 %s",
- "Direct link" : "直接链接"
+ "Direct link" : "直接链接",
+ "Federated Cloud Sharing" : "联合云共享",
+ "Open documentation" : "打开文档"
},"pluralForm" :"nplurals=1; plural=0;"
} \ No newline at end of file
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php
index a21f57235c9..e531674ddc2 100644
--- a/apps/files_sharing/lib/activity.php
+++ b/apps/files_sharing/lib/activity.php
@@ -150,6 +150,10 @@ class Activity implements IExtension {
if ($app === self::FILES_SHARING_APP) {
switch ($text) {
case self::SUBJECT_REMOTE_SHARE_RECEIVED:
+ if (sizeof($params) === 2) {
+ // New activity ownCloud 8.2+
+ return (string) $l->t('You received a new remote share %2$s from %1$s', $params);
+ }
return (string) $l->t('You received a new remote share from %s', $params);
case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
return (string) $l->t('%1$s accepted remote share %2$s', $params);
@@ -190,14 +194,15 @@ class Activity implements IExtension {
if ($app === self::FILES_SHARING_APP) {
switch ($text) {
case self::SUBJECT_REMOTE_SHARE_RECEIVED:
+ case self::SUBJECT_REMOTE_SHARE_UNSHARED:
return array(
- 0 => '',// We can not use 'username' since the user is in a different ownCloud
+ 0 => 'federated_cloud_id',
+ //1 => 'file', in theory its a file, but it does not exist yet/anymore
);
case self::SUBJECT_REMOTE_SHARE_ACCEPTED:
case self::SUBJECT_REMOTE_SHARE_DECLINED:
- case self::SUBJECT_REMOTE_SHARE_UNSHARED:
return array(
- 0 => '',// We can not use 'username' since the user is in a different ownCloud
+ 0 => 'federated_cloud_id',
1 => 'file',
);
case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
@@ -214,7 +219,7 @@ class Activity implements IExtension {
case self::SUBJECT_SHARED_GROUP_SELF:
return [
0 => 'file',
- //1 => 'group', Group does not exist yet
+ 1 => 'group',
];
}
}
@@ -230,7 +235,7 @@ class Activity implements IExtension {
* @return integer|false
*/
public function getGroupParameter($activity) {
- if ($activity['app'] === 'files') {
+ if ($activity['app'] === self::FILES_SHARING_APP) {
switch ($activity['subject']) {
case self::SUBJECT_SHARED_LINK_SELF:
case self::SUBJECT_SHARED_WITH_BY:
diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php
index 0246e2d9c80..67a26c096c2 100644
--- a/apps/files_sharing/lib/external/manager.php
+++ b/apps/files_sharing/lib/external/manager.php
@@ -186,6 +186,7 @@ class Manager {
* accept server-to-server share
*
* @param int $id
+ * @return bool True if the share could be accepted, false otherwise
*/
public function acceptShare($id) {
@@ -204,13 +205,18 @@ class Manager {
WHERE `id` = ? AND `user` = ?');
$acceptShare->execute(array(1, $mountPoint, $hash, $id, $this->uid));
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
+
+ return true;
}
+
+ return false;
}
/**
* decline server-to-server share
*
* @param int $id
+ * @return bool True if the share could be declined, false otherwise
*/
public function declineShare($id) {
@@ -221,7 +227,11 @@ class Manager {
DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
$removeShare->execute(array($id, $this->uid));
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
+
+ return true;
}
+
+ return false;
}
/**
diff --git a/apps/files_sharing/lib/external/scanner.php b/apps/files_sharing/lib/external/scanner.php
index dd2c086e84c..60eb7c8dacd 100644
--- a/apps/files_sharing/lib/external/scanner.php
+++ b/apps/files_sharing/lib/external/scanner.php
@@ -48,9 +48,10 @@ class Scanner extends \OC\Files\Cache\Scanner {
* @param int $reuseExisting
* @param int $parentId
* @param array | null $cacheData existing data in the cache for the file to be scanned
+ * @param bool $lock set to false to disable getting an additional read lock during scanning
* @return array an array of metadata of the scanned file
*/
- public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null) {
+ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true) {
try {
return parent::scanFile($file, $reuseExisting);
} catch (ForbiddenException $e) {
diff --git a/apps/files_sharing/lib/sharedmount.php b/apps/files_sharing/lib/sharedmount.php
index 2afc0f1f270..fd672d0500c 100644
--- a/apps/files_sharing/lib/sharedmount.php
+++ b/apps/files_sharing/lib/sharedmount.php
@@ -41,34 +41,40 @@ class SharedMount extends MountPoint implements MoveableMount {
*/
protected $ownerPropagator;
+ /**
+ * @var \OC\Files\View
+ */
+ private $recipientView;
+
public function __construct($storage, $mountpoint, $arguments = null, $loader = null) {
// first update the mount point before creating the parent
$this->ownerPropagator = $arguments['propagator'];
- $newMountPoint = $this->verifyMountPoint($arguments['share'], $arguments['user']);
+ $this->recipientView = new View('/' . $arguments['user'] . '/files');
+ $newMountPoint = $this->verifyMountPoint($arguments['share']);
$absMountPoint = '/' . $arguments['user'] . '/files' . $newMountPoint;
+ $arguments['ownerView'] = new View('/' . $arguments['share']['uid_owner'] . '/files');
parent::__construct($storage, $absMountPoint, $arguments, $loader);
}
/**
* check if the parent folder exists otherwise move the mount point up
*/
- private function verifyMountPoint(&$share, $user) {
+ private function verifyMountPoint(&$share) {
$mountPoint = basename($share['file_target']);
$parent = dirname($share['file_target']);
- $view = new View('/' . $user . '/files');
- if (!$view->is_dir($parent)) {
+ if (!$this->recipientView->is_dir($parent)) {
$parent = Helper::getShareFolder();
}
$newMountPoint = \OCA\Files_Sharing\Helper::generateUniqueTarget(
- \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint),
- array(),
- new \OC\Files\View('/' . $user . '/files')
- );
+ \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint),
+ [],
+ $this->recipientView
+ );
- if($newMountPoint !== $share['file_target']) {
+ if ($newMountPoint !== $share['file_target']) {
self::updateFileTarget($newMountPoint, $share);
$share['file_target'] = $newMountPoint;
$share['unique_name'] = true;
@@ -79,6 +85,7 @@ 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
@@ -99,7 +106,7 @@ class SharedMount extends MountPoint implements MoveableMount {
'Update `*PREFIX*share`
SET `file_target` = ?
WHERE `id` = ?'
- );
+ );
$arguments = array($newPath, $share['id']);
}
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 50957663b34..ff01489d77b 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -45,8 +45,14 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
private $files = array();
private static $isInitialized = array();
+ /**
+ * @var \OC\Files\View
+ */
+ private $ownerView;
+
public function __construct($arguments) {
$this->share = $arguments['share'];
+ $this->ownerView = $arguments['ownerView'];
}
/**
@@ -623,6 +629,11 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
/** @var \OCP\Files\Storage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
$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']);
+ $this->ownerView->lockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
+ }
}
/**
@@ -634,6 +645,11 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
/** @var \OCP\Files\Storage $targetStorage */
list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
$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']);
+ $this->ownerView->unlockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
+ }
}
/**
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index dd0b2eebe21..ffe0472b2b1 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -100,7 +100,7 @@ $thumbSize = 1024;
<div id="imgframe"></div>
<?php endif; ?>
<div class="directDownload">
- <a href="<?php p($_['downloadURL']); ?>" id="download" class="button">
+ <a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button">
<img class="svg" alt="" src="<?php print_unescaped(OCP\image_path("core", "actions/download.svg")); ?>"/>
<?php p($l->t('Download %s', array($_['filename'])))?> (<?php p($_['fileSize']) ?>)
</a>
diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js
index 1b1e363b792..1bbf4ffca09 100644
--- a/apps/files_sharing/tests/js/shareSpec.js
+++ b/apps/files_sharing/tests/js/shareSpec.js
@@ -206,6 +206,23 @@ describe('OCA.Sharing.Util tests', function() {
expect(OC.basename(getImageUrl($tr.find('.filename .thumbnail')))).toEqual('folder-shared.svg');
expect($action.find('img').length).toEqual(1);
});
+ it('do not show static share text when share exists but neither permission nor owner is available', function() {
+ var $action, $tr;
+ fileList.setFiles([{
+ id: 1,
+ type: 'dir',
+ name: 'One',
+ path: '/subdir',
+ mimetype: 'text/plain',
+ size: 12,
+ permissions: OC.PERMISSION_CREATE,
+ etag: 'abc'
+ }]);
+ $tr = fileList.$el.find('tbody tr:first');
+ expect($tr.find('.action-share').length).toEqual(0);
+ $action = $tr.find('.action-share-notification');
+ expect($action.length).toEqual(0);
+ });
});
describe('Share action', function() {
var showDropDownStub;
diff --git a/apps/files_sharing/tests/locking.php b/apps/files_sharing/tests/locking.php
new file mode 100644
index 00000000000..6d13fc1cda5
--- /dev/null
+++ b/apps/files_sharing/tests/locking.php
@@ -0,0 +1,101 @@
+<?php
+/**
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Robin Appelman <icewind@owncloud.com>
+ * @author Vincent Petry <pvince81@owncloud.com>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_sharing\Tests;
+
+use OC\Files\Filesystem;
+use OC\Files\View;
+use OC\Lock\MemcacheLockingProvider;
+use OCP\Lock\ILockingProvider;
+
+class Locking extends TestCase {
+ /**
+ * @var \OC_User_Dummy
+ */
+ private $userBackend;
+
+ private $ownerUid;
+ private $recipientUid;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->userBackend = new \OC_User_Dummy();
+ \OC::$server->getUserManager()->registerBackend($this->userBackend);
+
+ $this->ownerUid = $this->getUniqueID('owner_');
+ $this->recipientUid = $this->getUniqueID('recipient_');
+ $this->userBackend->createUser($this->ownerUid, '');
+ $this->userBackend->createUser($this->recipientUid, '');
+
+ $this->loginAsUser($this->ownerUid);
+ Filesystem::mkdir('/foo');
+ 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->loginAsUser($this->recipientUid);
+ $this->assertTrue(Filesystem::file_exists('bar.txt'));
+ }
+
+ public function tearDown() {
+ \OC::$server->getUserManager()->removeBackend($this->userBackend);
+ parent::tearDown();
+ }
+
+ /**
+ * @expectedException \OCP\Lock\LockedException
+ */
+ public function testLockAsRecipient() {
+ $this->loginAsUser($this->ownerUid);
+
+ Filesystem::initMountPoints($this->recipientUid);
+ $recipientView = new View('/' . $this->recipientUid . '/files');
+ $recipientView->lockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
+
+ Filesystem::rename('/foo', '/asd');
+ }
+
+ public function testUnLockAsRecipient() {
+ $this->loginAsUser($this->ownerUid);
+
+ Filesystem::initMountPoints($this->recipientUid);
+ $recipientView = new View('/' . $this->recipientUid . '/files');
+ $recipientView->lockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
+ $recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
+
+ $this->assertTrue(Filesystem::rename('/foo', '/asd'));
+ }
+
+ public function testChangeLock() {
+
+ Filesystem::initMountPoints($this->recipientUid);
+ $recipientView = new View('/' . $this->recipientUid . '/files');
+ $recipientView->lockFile('bar.txt', ILockingProvider::LOCK_SHARED);
+ $recipientView->changeLock('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
+ $recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
+
+ $this->assertTrue(true);
+ }
+}
diff --git a/apps/files_sharing/tests/unsharechildren.php b/apps/files_sharing/tests/unsharechildren.php
index 0cf551c0500..c57070ba641 100644
--- a/apps/files_sharing/tests/unsharechildren.php
+++ b/apps/files_sharing/tests/unsharechildren.php
@@ -40,7 +40,7 @@ class UnshareChildren extends TestCase {
\OCP\Util::connectHook('OC_Filesystem', 'post_delete', '\OCA\Files_Sharing\Hooks', 'unshareChildren');
$this->folder = self::TEST_FOLDER_NAME;
- $this->subfolder = '/subfolder_share_api_test';
+ $this->subfolder = '/subfolder_share_api_test';
$this->subsubfolder = '/subsubfolder_share_api_test';
$this->filename = '/share-api-test';
@@ -49,12 +49,14 @@ class UnshareChildren extends TestCase {
$this->view->mkdir($this->folder);
$this->view->mkdir($this->folder . $this->subfolder);
$this->view->mkdir($this->folder . $this->subfolder . $this->subsubfolder);
- $this->view->file_put_contents($this->folder.$this->filename, $this->data);
+ $this->view->file_put_contents($this->folder . $this->filename, $this->data);
$this->view->file_put_contents($this->folder . $this->subfolder . $this->filename, $this->data);
}
protected function tearDown() {
- $this->view->deleteAll($this->folder);
+ if ($this->view) {
+ $this->view->deleteAll($this->folder);
+ }
self::$tempStorage = null;