Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-08-29 11:37:08 +0300
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-08-29 14:55:08 +0300
commitb3cd9b557358a3aa506d7ad24883650d4449bb8c (patch)
tree8755c47a3fd92ea7a7444675dad8b591622d0cdf /lib
parente34f2c4799b271ac1b1c412af4bf2fa1f6279359 (diff)
Move Dav fileid and permissions logic into OCP\Util to be able to use it for BulkUpload
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/public/Util.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/public/Util.php b/lib/public/Util.php
index 6cd3eaa7f85..ad8818df3ca 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -628,4 +628,45 @@ class Util {
}
return true;
}
+
+ /**
+ * @param int $id Id of the file returned by FileInfo::getId
+ */
+ public static function getDavFileId(int $id): string {
+ $instanceId = \OC_Util::getInstanceId();
+ $id = sprintf('%08d', $id);
+ return $id . $instanceId;
+ }
+
+ public static function getDavPermissions(\OCP\Files\FileInfo $info): string {
+ $p = '';
+ if ($info->isShared()) {
+ $p .= 'S';
+ }
+ if ($info->isShareable()) {
+ $p .= 'R';
+ }
+ if ($info->isMounted()) {
+ $p .= 'M';
+ }
+ if ($info->isReadable()) {
+ $p .= 'G';
+ }
+ if ($info->isDeletable()) {
+ $p .= 'D';
+ }
+ if ($info->isUpdateable()) {
+ $p .= 'NV'; // Renameable, Moveable
+ }
+ if ($info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
+ if ($info->isUpdateable()) {
+ $p .= 'W';
+ }
+ } else {
+ if ($info->isCreatable()) {
+ $p .= 'CK';
+ }
+ }
+ return $p;
+ }
}