aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/api.php10
-rw-r--r--apps/files_sharing/lib/cache.php23
2 files changed, 22 insertions, 11 deletions
diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php
index 84e90c71681..cb3d3e42c34 100644
--- a/apps/files_sharing/lib/api.php
+++ b/apps/files_sharing/lib/api.php
@@ -162,7 +162,7 @@ class Api {
$view = new \OC\Files\View('/'.\OCP\User::getUser().'/files');
if(!$view->is_dir($path)) {
- return new \OC_OCS_Result(null, 404, "not a directory");
+ return new \OC_OCS_Result(null, 400, "not a directory");
}
$content = $view->getDirectoryContent($path);
@@ -223,7 +223,7 @@ class Api {
$encryptionEnabled = \OC_App::isEnabled('files_encryption');
if(isset($_POST['publicUpload']) &&
($encryptionEnabled || $publicUploadEnabled !== 'yes')) {
- return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator");
+ return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator");
}
$publicUpload = isset($_POST['publicUpload']) ? $_POST['publicUpload'] : 'false';
// read, create, update (7) if public upload is enabled or
@@ -231,7 +231,7 @@ class Api {
$permissions = $publicUpload === 'true' ? 7 : 1;
break;
default:
- return new \OC_OCS_Result(null, 404, "unknown share type");
+ return new \OC_OCS_Result(null, 400, "unknown share type");
}
try {
@@ -243,7 +243,7 @@ class Api {
$permissions
);
} catch (\Exception $e) {
- return new \OC_OCS_Result(null, 404, $e->getMessage());
+ return new \OC_OCS_Result(null, 403, $e->getMessage());
}
if ($token) {
@@ -365,7 +365,7 @@ class Api {
$publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes');
$encryptionEnabled = \OC_App::isEnabled('files_encryption');
if($encryptionEnabled || $publicUploadEnabled !== 'yes') {
- return new \OC_OCS_Result(null, 404, "public upload disabled by the administrator");
+ return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator");
}
if ($share['item_type'] !== 'folder' ||
diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php
index 90440d08f4e..425d51113b1 100644
--- a/apps/files_sharing/lib/cache.php
+++ b/apps/files_sharing/lib/cache.php
@@ -127,7 +127,18 @@ class Shared_Cache extends Cache {
return $files;
} else {
if ($cache = $this->getSourceCache($folder)) {
- return $cache->getFolderContents($this->files[$folder]);
+ $sourceFolderContent = $cache->getFolderContents($this->files[$folder]);
+ foreach ($sourceFolderContent as $key => $c) {
+ $ownerPathParts = explode('/', \OC_Filesystem::normalizePath($c['path']));
+ $userPathParts = explode('/', \OC_Filesystem::normalizePath($folder));
+ $usersPath = 'files/Shared/'.$userPathParts[1];
+ foreach (array_slice($ownerPathParts, 3) as $part) {
+ $usersPath .= '/'.$part;
+ }
+ $sourceFolderContent[$key]['usersPath'] = $usersPath;
+ }
+
+ return $sourceFolderContent;
}
}
return false;
@@ -260,7 +271,7 @@ class Shared_Cache extends Cache {
return $this->searchWithWhere($where, $value);
}
-
+
/**
* The maximum number of placeholders that can be used in an SQL query.
* Value MUST be <= 1000 for oracle:
@@ -268,7 +279,7 @@ class Shared_Cache extends Cache {
* FIXME we should get this from doctrine as other DBs allow a lot more placeholders
*/
const MAX_SQL_CHUNK_SIZE = 1000;
-
+
/**
* search for files with a custom where clause and value
* the $wherevalue will be array_merge()d with the file id chunks
@@ -282,16 +293,16 @@ class Shared_Cache extends Cache {
$ids = $this->getAll();
$files = array();
-
+
// divide into chunks
$chunks = array_chunk($ids, $chunksize);
-
+
foreach ($chunks as $chunk) {
$placeholders = join(',', array_fill(0, count($chunk), '?'));
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`,
`encrypted`, `unencrypted_size`, `etag`
FROM `*PREFIX*filecache` WHERE ' . $sqlwhere . ' `fileid` IN (' . $placeholders . ')';
-
+
$stmt = \OC_DB::prepare($sql);
$result = $stmt->execute(array_merge(array($wherevalue), $chunk));