diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-07-05 17:39:41 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-07-05 17:39:41 +0200 |
commit | e159cbf527822edc28522df48b0526419835ca29 (patch) | |
tree | e1e64ac3cb2727a8157b2f893016e01e7422195c /apps | |
parent | 0202d47f7ad4a65d4e539421c4f5899404b22bf4 (diff) | |
download | nextcloud-server-e159cbf527822edc28522df48b0526419835ca29.tar.gz nextcloud-server-e159cbf527822edc28522df48b0526419835ca29.zip |
on reshares we now recursively move to the root of all reshares - therefore some code has been refactured and added as a new public function
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/upload.php | 29 | ||||
-rw-r--r-- | apps/files_sharing/public.php | 18 |
2 files changed, 16 insertions, 31 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index fd6aa981542..0a61ff72d41 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -27,25 +27,24 @@ if (empty($_POST['dirToken'])) { if (!($linkItem['permissions'] & OCP\PERMISSION_CREATE)) { OCP\JSON::checkLoggedIn(); } else { + // resolve reshares + $rootLinkItem = OCP\Share::resolveReShare($linkItem); + + // Setup FS with owner + OC_Util::setupFS($rootLinkItem['uid_owner']); // The token defines the target directory (security reasons) + $path = \OC\Files\Filesystem::getPath($linkItem['file_source']); $dir = sprintf( "/%s/%s", - $linkItem['file_target'], + $path, isset($_POST['subdir']) ? $_POST['subdir'] : '' ); - // handle reshare - if (!empty($linkItem['parent'])) { - $dir = '/Shared'.$dir; - } - if (!$dir || empty($dir) || $dir === false) { OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Unable to set upload directory.'))))); die(); } - // Setup FS with owner - OC_Util::setupFS($linkItem['uid_owner']); } } @@ -81,17 +80,17 @@ $files = $_FILES['files']; $error = ''; -$maxUploadFilesize = OCP\Util::maxUploadFilesize($dir); -$maxHumanFilesize = OCP\Util::humanFileSize($maxUploadFilesize); +$maxUploadFileSize = $storageStats['uploadMaxFilesize']; +$maxHumanFileSize = OCP\Util::humanFileSize($maxUploadFileSize); $totalSize = 0; foreach ($files['size'] as $size) { $totalSize += $size; } -if ($maxUploadFilesize >= 0 and $totalSize > $maxUploadFilesize) { +if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) { OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'), - 'uploadMaxFilesize' => $maxUploadFilesize, - 'maxHumanFilesize' => $maxHumanFilesize))); + 'uploadMaxFilesize' => $maxUploadFileSize, + 'maxHumanFilesize' => $maxHumanFileSize))); exit(); } @@ -113,8 +112,8 @@ if (strpos($dir, '..') === false) { 'id' => $meta['fileid'], 'name' => basename($target), 'originalname' => $files['name'][$i], - 'uploadMaxFilesize' => $maxUploadFilesize, - 'maxHumanFilesize' => $maxHumanFilesize + 'uploadMaxFilesize' => $maxUploadFileSize, + 'maxHumanFilesize' => $maxHumanFileSize ); } } diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index fb18bc26248..7c9158d8002 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -27,23 +27,9 @@ if (isset($_GET['t'])) { $type = $linkItem['item_type']; $fileSource = $linkItem['file_source']; $shareOwner = $linkItem['uid_owner']; - $fileOwner = null; $path = null; - if (isset($linkItem['parent'])) { - $parent = $linkItem['parent']; - while (isset($parent)) { - $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1); - $item = $query->execute(array($parent))->fetchRow(); - if (isset($item['parent'])) { - $parent = $item['parent']; - } else { - $fileOwner = $item['uid_owner']; - break; - } - } - } else { - $fileOwner = $shareOwner; - } + $rootLinkItem = OCP\Share::resolveReShare($linkItem); + $fileOwner = $rootLinkItem['uid_owner']; if (isset($fileOwner)) { OC_Util::tearDownFS(); OC_Util::setupFS($fileOwner); |