예제 #1
0
        private FileItem[] IncludeFilesForCurrentFolder(IFolderInfo dnnParentFolder)
        {
            var files             = FolderManager.Instance.GetFiles(dnnParentFolder).Where(f => CheckSearchPatterns(f.FileName, SearchPatterns));
            var folderPermissions = FileSystemValidation.TelerikPermissions(dnnParentFolder);

            return((from file in files
                    select new FileItem(file.FileName, file.Extension, file.Size, "", GetFileUrl(file), "", folderPermissions)).ToArray());
        }
예제 #2
0
        private DirectoryItem AddChildDirectoriesToList(DirectoryItem radDirectory)
        {
            var parentFolderPath = radDirectory.FullPath.EndsWith("/") ? radDirectory.FullPath : radDirectory.FullPath + "/";

            if (parentFolderPath.StartsWith(PortalSettings.HomeDirectory))
            {
                parentFolderPath = parentFolderPath.Remove(0, PortalSettings.HomeDirectory.Length);
            }

            var dnnParentFolder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, parentFolderPath);

            if (!DNNValidator.CanViewFilesInFolder(dnnParentFolder.FolderPath))
            {
                return(null);
            }

            var dnnChildFolders = FolderManager.Instance.GetFolders(dnnParentFolder).Where(folder => (FileSystemValidation.HasPermission(folder, "BROWSE,READ")));
            var radDirectories  = new List <DirectoryItem>();

            foreach (var dnnChildFolder in dnnChildFolders)
            {
                if (!dnnChildFolder.FolderPath.ToLowerInvariant().StartsWith("cache/") &&
                    !dnnChildFolder.FolderPath.ToLowerInvariant().StartsWith("users/") &&
                    !dnnChildFolder.FolderPath.ToLowerInvariant().StartsWith("groups/"))
                {
                    var radSubDirectory =
                        TelerikContent.ResolveDirectory(FileSystemValidation.ToVirtualPath(dnnChildFolder.FolderPath));
                    radSubDirectory.Permissions = FileSystemValidation.TelerikPermissions(dnnChildFolder);
                    radDirectories.Add(radSubDirectory);
                }
            }

            radDirectory.Files = IncludeFilesForCurrentFolder(dnnParentFolder);

            if (parentFolderPath == "")
            {
                var userFolder = FolderManager.Instance.GetUserFolder(PortalSettings.UserInfo);
                if (userFolder.PortalID == PortalSettings.PortalId)
                {
                    var radUserFolder = TelerikContent.ResolveDirectory(FileSystemValidation.ToVirtualPath(userFolder.FolderPath));
                    radUserFolder.Name        = DNNValidator.GetString("MyFolder");
                    radUserFolder.Permissions = FileSystemValidation.TelerikPermissions(userFolder);
                    radDirectories.Add(radUserFolder);
                }
            }

            radDirectory.Directories = radDirectories.ToArray();
            return(radDirectory);
        }