/// <summary> /// Processes the specified file. /// </summary> /// <param name="fileGuid">File guid</param> protected void ProcessFile(Guid fileGuid) { // Get the file ForumAttachmentInfo fileInfo = ForumAttachmentInfoProvider.GetForumAttachmentInfoWithoutBinary(fileGuid, CMSContext.CurrentSiteName); if (fileInfo != null) { #region "Security" // Indicates whether current user is granted to see this attachment bool attachmentAllowed = false; // Get forum ForumInfo fi = ForumInfoProvider.GetForumInfo(fileInfo.AttachmentForumID); if (fi != null) { // Check acess if (ForumViewer.CheckPermission("AccessToForum", SecurityHelper.GetSecurityAccessEnum(fi.ForumAccess, 6), fi.ForumGroupID, fi.ForumID)) { attachmentAllowed = true; } } // If attachment is not allowed for current user, redirect to the access denied page if (!attachmentAllowed) { URLHelper.Redirect(URLRewriter.AccessDeniedPageURL(CurrentSiteName)); } #endregion bool resizeImage = (ImageHelper.IsMimeImage(fileInfo.AttachmentMimeType) && ForumAttachmentInfoProvider.CanResizeImage(fileInfo, Width, Height, MaxSideSize)); // Get the data if ((outputFile == null) || (outputFile.ForumAttachment == null)) { outputFile = new CMSOutputForumAttachment(fileInfo, fileInfo.AttachmentBinary); outputFile.Width = Width; outputFile.Height = Height; outputFile.MaxSideSize = MaxSideSize; outputFile.Resized = resizeImage; } } }
/// <summary> /// Processes the file. /// </summary> protected void ProcessFile() { if (fileGuid == Guid.Empty) { return; } // Get the file ForumAttachmentInfo fileInfo = ForumAttachmentInfoProvider.GetForumAttachmentInfoWithoutBinary(fileGuid, SiteContext.CurrentSiteName); if (fileInfo == null) { return; } // Check forum access var forum = ForumInfoProvider.GetForumInfo(fileInfo.AttachmentForumID); if ((forum == null) || !ForumViewer.CheckPermission("AccessToForum", SecurityHelper.GetSecurityAccessEnum(forum.ForumAccess, 6), forum.ForumGroupID, forum.ForumID, CurrentUser)) { // If attachment is not allowed for current user, redirect to the access denied page URLHelper.Redirect(PageSecurityHelper.AccessDeniedPageURL(CurrentSiteName)); } bool resizeImage = (ImageHelper.IsMimeImage(fileInfo.AttachmentMimeType) && ForumAttachmentInfoProvider.CanResizeImage(fileInfo, Width, Height, MaxSideSize)); // Get the data if ((outputFile == null) || (outputFile.ForumAttachment == null)) { outputFile = new CMSOutputForumAttachment(fileInfo, fileInfo.AttachmentBinary); outputFile.Width = Width; outputFile.Height = Height; outputFile.MaxSideSize = MaxSideSize; outputFile.Resized = resizeImage; } }