diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-01-29 13:09:44 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-01-29 14:23:14 +0100 |
commit | c78e3c4a7fa1d2f474ab58551e67a50e093f6ed8 (patch) | |
tree | 3229c2bda95ffb3091dbf4a5fd85c82f429dd5c4 /lib/private/share | |
parent | 55142186deb9e163ce3519453ebfe93f6a446666 (diff) | |
download | nextcloud-server-c78e3c4a7fa1d2f474ab58551e67a50e093f6ed8.tar.gz nextcloud-server-c78e3c4a7fa1d2f474ab58551e67a50e093f6ed8.zip |
make sure that we always create a public share key for remote shares
Diffstat (limited to 'lib/private/share')
-rw-r--r-- | lib/private/share/share.php | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index c9f9654203e..6901e1cfecf 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -103,6 +103,7 @@ class Share extends \OC\Share\Constants { $shares = $sharePaths = $fileTargets = array(); $publicShare = false; + $remoteShare = false; $source = -1; $cache = false; @@ -170,18 +171,16 @@ class Share extends \OC\Share\Constants { //check for public link shares if (!$publicShare) { - $query = \OC_DB::prepare( - 'SELECT `share_with` - FROM - `*PREFIX*share` - WHERE - `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')' + $query = \OC_DB::prepare(' + SELECT `share_with` + FROM `*PREFIX*share` + WHERE `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')', 1 ); $result = $query->execute(array($source, self::SHARE_TYPE_LINK)); if (\OCP\DB::isError($result)) { - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR); + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); } else { if ($result->fetchRow()) { $publicShare = true; @@ -189,6 +188,25 @@ class Share extends \OC\Share\Constants { } } + //check for remote share + if (!$remoteShare) { + $query = \OC_DB::prepare(' + SELECT `share_with` + FROM `*PREFIX*share` + WHERE `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')', 1 + ); + + $result = $query->execute(array($source, self::SHARE_TYPE_REMOTE)); + + if (\OCP\DB::isError($result)) { + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR); + } else { + if ($result->fetchRow()) { + $remoteShare = true; + } + } + } + // let's get the parent for the next round $meta = $cache->get((int)$source); if($meta !== false) { @@ -234,7 +252,7 @@ class Share extends \OC\Share\Constants { return $sharePaths; } - return array("users" => array_unique($shares), "public" => $publicShare); + return array('users' => array_unique($shares), 'public' => $publicShare, 'remote' => $remoteShare); } /** @@ -2280,7 +2298,7 @@ class Share extends \OC\Share\Constants { if ($user && $remote) { $url = $remote . self::BASE_PATH_TO_SHARE_API . '?format=' . self::RESPONSE_FORMAT; - $local = \OC::$server->getURLGenerator()->getAbsoluteURL(''); + $local = \OC::$server->getURLGenerator()->getAbsoluteURL('/'); $fields = array( 'shareWith' => $user, |