diff options
author | Robin Appelman <robin@icewind.nl> | 2017-04-26 14:53:11 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-28 09:38:21 +0200 |
commit | ab9a36e872173b34be2e678de0c452885e3b48d8 (patch) | |
tree | 76e34c578bfdde6ab46164f9e4227e4fe0cc351e /apps | |
parent | 9da697b11af2928a1470dcedc7ebf77e4a5f0730 (diff) | |
download | nextcloud-server-ab9a36e872173b34be2e678de0c452885e3b48d8.tar.gz nextcloud-server-ab9a36e872173b34be2e678de0c452885e3b48d8.zip |
allow apps to set custom mount types
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/FilesPlugin.php | 6 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 2 | ||||
-rw-r--r-- | apps/files/lib/Helper.php | 9 | ||||
-rw-r--r-- | apps/files_external/lib/Config/ExternalMountPoint.php | 30 | ||||
-rw-r--r-- | apps/files_sharing/lib/SharedMount.php | 4 |
5 files changed, 45 insertions, 6 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php index a4f3f363a5f..4c426dd1052 100644 --- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php +++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php @@ -65,6 +65,7 @@ class FilesPlugin extends ServerPlugin { const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums'; const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint'; const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview'; + const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type'; /** * Reference to main server object @@ -159,6 +160,7 @@ class FilesPlugin extends ServerPlugin { $server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME; $server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME; $server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME; + $server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME; // normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH $allowedProperties = ['{DAV:}getetag']; @@ -381,6 +383,10 @@ class FilesPlugin extends ServerPlugin { return $node->getSize(); }); } + + $propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) { + return $node->getFileInfo()->getMountPoint()->getMountType(); + }); } /** diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 6b5b5a2daef..047131f3d78 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1069,6 +1069,8 @@ return OC.MimeType.getIconUrl('dir-shared'); } else if (fileInfo.mountType === 'external-root') { return OC.MimeType.getIconUrl('dir-external'); + } else if (fileInfo.mountType !== '') { + return OC.MimeType.getIconUrl('dir-' + fileInfo.mountType); } return OC.MimeType.getIconUrl('dir'); } diff --git a/apps/files/lib/Helper.php b/apps/files/lib/Helper.php index c3d80957913..d2cebce5ddc 100644 --- a/apps/files/lib/Helper.php +++ b/apps/files/lib/Helper.php @@ -157,12 +157,9 @@ class Helper { $entry['isShareMountPoint'] = $i['is_share_mount_point']; } $mountType = null; - if ($i->isShared()) { - $mountType = 'shared'; - } else if ($i->isMounted()) { - $mountType = 'external'; - } - if ($mountType !== null) { + $mount = $i->getMountPoint(); + $mountType = $mount->getMountType(); + if ($mountType !== '') { if ($i->getInternalPath() === '') { $mountType .= '-root'; } diff --git a/apps/files_external/lib/Config/ExternalMountPoint.php b/apps/files_external/lib/Config/ExternalMountPoint.php new file mode 100644 index 00000000000..76a090b7ec4 --- /dev/null +++ b/apps/files_external/lib/Config/ExternalMountPoint.php @@ -0,0 +1,30 @@ +<?php +/** + * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Files_External\Config; + +use OC\Files\Mount\MountPoint; + +class ExternalMountPoint extends MountPoint { + public function getMountType() { + return 'external'; + } +} diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php index d5ae303390f..b42682ab2a8 100644 --- a/apps/files_sharing/lib/SharedMount.php +++ b/apps/files_sharing/lib/SharedMount.php @@ -258,4 +258,8 @@ class SharedMount extends MountPoint implements MoveableMount { return -1; } } + + public function getMountType() { + return 'shared'; + } } |