Example #1
0
        public static bool CanManageMediaFolder(this IMediaLibraryService service, string folderPath)
        {
            // The current user can manage a media if he has access to the whole hierarchy
            // or the media is under his personal storage folder.

            var rootMediaFolder = service.GetRootMediaFolder();

            if (rootMediaFolder == null)
            {
                return(true);
            }

            var mediaPath = service.Combine(folderPath, " ").Trim();
            var rootPath  = service.Combine(rootMediaFolder.MediaPath, " ").Trim();

            return(mediaPath.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase));
        }
Example #2
0
        public static string GetRootedFolderPath(this IMediaLibraryService service, string folderPath)
        {
            var rootMediaFolder = service.GetRootMediaFolder();

            if (rootMediaFolder != null)
            {
                return(service.Combine(rootMediaFolder.MediaPath, folderPath ?? ""));
            }

            return(folderPath);
        }