diff --git a/api/src/CalDAV/JsBase.php b/api/src/CalDAV/JsBase.php index 453f66e918..827a09c82a 100644 --- a/api/src/CalDAV/JsBase.php +++ b/api/src/CalDAV/JsBase.php @@ -370,6 +370,11 @@ class JsBase $target = $value; } } + // if we unset fields stored directly in the database, they will NOT be updated :( + elseif (!$n) + { + $target = null; + } else { unset($parent[$part]); diff --git a/api/src/MimeMagic.php b/api/src/MimeMagic.php index aaa93aafb2..9f8e0d6a56 100644 --- a/api/src/MimeMagic.php +++ b/api/src/MimeMagic.php @@ -115,6 +115,25 @@ class MimeMagic return $key; } + /** + * Convert a MIME type to all known file extensions + * + * If we cannot map the type to any file extension, we return an empty array. + * + * @param string $_type The MIME type to be mapped to a file extension. + * @return array with possible file extensions + */ + public static function mime2extensions($_type) + { + $type = strtolower($_type); + if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type]; + + return array_keys(array_filter(self::$mime_extension_map, static function($mime) use ($type) + { + return $mime == $type; + })); + } + /** * Fix old / aliased mime-types by returning valid/default mime-type *