summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-06-12 17:53:56 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-06-14 10:14:08 +0200
commite7b58ed2bdfe4bb56866e76b8fdd618946fa3c51 (patch)
treee2c42d3c7c5f08a4094aa61408d5dcf274d881f7 /apps/files_sharing/lib
parent87e311b99628858ddb974cd35ae381a26b4bcdb5 (diff)
downloadnextcloud-server-e7b58ed2bdfe4bb56866e76b8fdd618946fa3c51.tar.gz
nextcloud-server-e7b58ed2bdfe4bb56866e76b8fdd618946fa3c51.zip
Properly expose read only public shares as read only
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/external/scanner.php4
-rw-r--r--apps/files_sharing/lib/readonlycache.php27
-rw-r--r--apps/files_sharing/lib/readonlywrapper.php56
3 files changed, 87 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/external/scanner.php b/apps/files_sharing/lib/external/scanner.php
index 1f32d79b149..8fb8683ed92 100644
--- a/apps/files_sharing/lib/external/scanner.php
+++ b/apps/files_sharing/lib/external/scanner.php
@@ -14,6 +14,10 @@ class Scanner extends \OC\Files\Cache\Scanner {
*/
protected $storage;
+ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1) {
+ $this->scanAll();
+ }
+
public function scanAll() {
$remote = $this->storage->getRemote();
$token = $this->storage->getToken();
diff --git a/apps/files_sharing/lib/readonlycache.php b/apps/files_sharing/lib/readonlycache.php
new file mode 100644
index 00000000000..f129ca49433
--- /dev/null
+++ b/apps/files_sharing/lib/readonlycache.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCA\Files_Sharing;
+
+use OC\Files\Cache\Cache;
+
+class ReadOnlyCache extends Cache {
+ public function get($path) {
+ $data = parent::get($path);
+ $data['permissions'] &= (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE);
+ return $data;
+ }
+
+ public function getFolderContents($path) {
+ $content = parent::getFolderContents($path);
+ foreach ($content as &$data) {
+ $data['permissions'] &= (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE);
+ }
+ return $content;
+ }
+}
diff --git a/apps/files_sharing/lib/readonlywrapper.php b/apps/files_sharing/lib/readonlywrapper.php
new file mode 100644
index 00000000000..45ed3fd68bb
--- /dev/null
+++ b/apps/files_sharing/lib/readonlywrapper.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCA\Files_Sharing;
+
+use OC\Files\Storage\Wrapper\Wrapper;
+
+class ReadOnlyWrapper extends Wrapper {
+ public function isUpdatable($path) {
+ return false;
+ }
+
+ public function isCreatable($path) {
+ return false;
+ }
+
+ public function isDeletable($path) {
+ return false;
+ }
+
+ public function getPermissions($path) {
+ return $this->storage->getPermissions($path) & (\OCP\PERMISSION_READ | \OCP\PERMISSION_SHARE);
+ }
+
+ public function rename($path1, $path2) {
+ return false;
+ }
+
+ public function touch($path, $mtime = null) {
+ return false;
+ }
+
+ public function mkdir($path) {
+ return false;
+ }
+
+ public function rmdir($path) {
+ return false;
+ }
+
+ public function unlink($path) {
+ return false;
+ }
+
+ public function getCache($path = '', $storage = null) {
+ if (!$storage) {
+ $storage = $this;
+ }
+ return new ReadOnlyCache($storage);
+ }
+}