downloadpostattachment.cs

来自「community server 源码」· CS 代码 · 共 51 行

CS
51
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System.Web;
using System.Web.UI;

using CommunityServer.Components;
using CommunityServer.Discussions.Components;

namespace CommunityServer.Discussions.Controls 
{
    /// <summary>
    /// Summary description for PostAttachment.
    /// </summary>
    public class DownloadPostAttachment : Control 
    {
        CSContext csContext = CSContext.Current;

        protected override void OnLoad(System.EventArgs e)
        {
            // Get the forum the attachment is in
            //
            Forum forum = Forums.GetForumByPostID(csContext.PostID, csContext.User.UserID, false);

            if (forum == null) 
            {
                throw new CSException(CSExceptionType.SectionNotFound, csContext.SectionID.ToString());
            }

            // Get the ForumPermission
            //
            ForumPermission permission = forum.ResolvePermission( csContext.User ) as ForumPermission;

            // if user is not allowed to read this post, return
            //
            if (!permission.Read ) 
            {
                throw new CSException(CSExceptionType.GeneralAccessDenied, csContext.SectionID.ToString());
            }

			ForumAttachmentSettings fas = ForumConfiguration.Instance().AttachmentSettings;
			fas.HandleHttpRequest(this.Context, forum);
            System.Web.HttpContext.Current.Response.End();
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?