⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sectioneditcontrol.ascx.cs

📁 community server 源码
💻 CS
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.ControlPanel.Controls;
using CommunityServer.ControlPanel.UI;
using CommunityServer.Controls;
using CommunityServer.Discussions.Components;
using CommunityServer.Discussions.Controls;
using CommunityServer.Mail.Common.Components;
using TWC = Telligent.Web.UI;
using Telligent.Registration;
using ResourceControl = CommunityServer.ControlPanel.Controls.ResourceControl;
using StatusMessage = CommunityServer.ControlPanel.Controls.StatusMessage;
using ResourceManager = CommunityServer.ControlPanel.Components.ResourceManager;

namespace CommunityServer.ControlPanel.Forums
{
	/// <summary>
	/// Summary description for ForumsHome.
	/// </summary>
	public class SectionEditControl : BaseForumControl
	{
		CSContext csContext = CSContext.Current;

		#region Child Controls

		protected TWC.TabbedPanes TabStrip;
		protected ResourceControl AddSectionHelpResource;

		protected Literal GroupValue;
		protected Hyperlink ParentForumName;
		protected TextBox Name;
		protected TextBox Url;
		protected RequiredFieldValidator NameRequired;
		protected TextBox Description;
		protected CustomValidator DescriptionRequired;
		protected YesNoRadioButtonList IsActive;
		protected YesNoRadioButtonList IsSearchable;
		protected YesNoRadioButtonList IsModerated;
		protected YesNoRadioButtonList EnablePostStatistics;
		protected YesNoRadioButtonList EnablePostPoints;
		protected YesNoRadioButtonList EnableAutoDelete;
		protected TextBox AutoDeleteThreshold;
		protected RequiredFieldValidator AutoDeleteThresholdValidator;
		protected YesNoRadioButtonList EnableAnonymousPosting;
		protected YesNoRadioButtonList EnableAnonymousPostingForUsers;
		protected YesNoRadioButtonList EnableThreadStatusTracking;
		protected StatusDropDownList DefaultThreadStatusValue;
		protected DropDownList AdminGroupList;
		protected DropDownList ForumList;

		protected HtmlTableRow EnableAnonymousPostingRow;
		protected HtmlTableRow EnableAnonymousPostingForUsersRow;
		protected HtmlTableRow EnableThreadStatusTrackingRow;
		protected HtmlTableRow EnableThreadStatusDefaultValueRow;
		protected HtmlTableRow ParentForumRow;

		protected SectionPermissionListControl SectionPermissionListControl1;
		protected SectionPermissionListAdminControl SectionPermissionListAdminControl1;
		protected Control LicenseMaxed;
		protected YesNoRadioButtonList LEEnableMailingList;
		protected TextBox LEListName;
		protected TextBox LEEmailAddress;
		protected TextBox LEFooterMessage;
		protected CustomValidator LEEmailValidator;
		protected YesNoRadioButtonList LEPassiveMode;
		protected TextBox LEPassiveModeAddress;
		protected Literal LEEmailDomain;

		protected FilterLanguageDropDownList DefaultLanguage;

		protected StatusMessage Status;

		#endregion

		#region Public Properties

		private int sectionID = -1;
		public int SectionID
		{
			get { return sectionID; }
			set { sectionID = value;}
		}

		private int parentSectionID = -1;
		public int ParentSectionID
		{
			get { return parentSectionID; }
			set { parentSectionID = value;}
		}
		
		private int groupID = -1;
		public int GroupID
		{
			get { return groupID; }
			set { groupID = value;}
		}

		private Forum section;
		public Forum Section
		{
			get {return section;}
			set {section = value;}
		}

		private bool allowDelete = true;
		public bool AllowDelete
		{
			get {return allowDelete;}
			set {allowDelete = value;}
		}

		#endregion

		private bool isNewForum
		{
			get{return SectionID == -1;}
		}


		override protected void OnInit(EventArgs e)
		{
			this.AdminGroupList.SelectedIndexChanged +=new EventHandler(AdminGroupList_SelectedIndexChanged);
			this.Load += new EventHandler(this.Page_Load);

			DefaultThreadStatusValue.DataBind();
			DefaultThreadStatusValue.AutoPostBack = false;
			DefaultThreadStatusValue.Visible = true;

			foreach(TWC.TabbedPane tab in TabStrip.Panes)
				if(tab.ID == "MailingList")
					tab.Visible = csContext.SiteSettings.EnableMailGateway;

			base.OnInit(e);
		}


		private void Page_Load(object sender, EventArgs e)
		{
			if ( !Page.IsPostBack ) 
			{
				this.Bind();
			}
		}

		
		protected void Bind()
		{
			Status.Visible = false;
			AddSectionHelpResource.Visible = false;

			if (this.isNewForum)
			{
				AllowDelete = false;
			}
			else
			{
				SectionPermissionListControl1.SectionID = SectionID;
				SectionPermissionListAdminControl1.SectionID = SectionID;
			}
		
			this.LoadForum(this.Section);

		}

		private void BindGroupList()
		{
			ArrayList groups = ForumGroups.GetForumGroups(true, true, true);
			foreach(Group group in groups)
			{
				AdminGroupList.Items.Add(new ListItem(group.Name, group.GroupID.ToString()));
			}
		}
		
		private void BindForumList()
		{
			this.GroupID = int.Parse(AdminGroupList.SelectedValue);
			ForumList.Items.Clear();
			ForumList.Items.Add(new ListItem("----", "0"));
			foreach(Forum f in GetForums())
			{
				ForumList.Items.Add(new ListItem(f.Name, f.SectionID.ToString()));
			}
		}

		protected virtual void LoadForum( Forum forum ) 
		{
			if ( forum != null ) 
			{
				// Retrieve ParentID
				if (forum.ParentID > 0)
					ParentSectionID = forum.ParentID;


				if (csContext.User.ControlPanelManageView == ControlPanelManageView.Grid)
				{

					// Do not allow move of special forum types
					if ((forum.ForumType == ForumType.Deleted) || (forum.ForumType == ForumType.Reporting)) 
					{
						GroupValue.Text = forum.GroupName;
						GroupValue.Visible = true;
						AdminGroupList.Visible = false;
						ForumList.Visible = false;
						ParentForumRow.Visible = false;
					}
					else
					{

						BindGroupList();
						GroupValue.Visible = false;
						AdminGroupList.Visible = true;

						if (!this.isNewForum)
							AdminGroupList.SelectedIndex = AdminGroupList.Items.IndexOf(AdminGroupList.Items.FindByValue(this.GroupID.ToString()));
					
						BindForumList();
						ParentForumRow.Visible = true;
						ForumList.Visible = true;
						ParentForumName.Visible = false;

						if (!this.isNewForum)
							ForumList.SelectedIndex = ForumList.Items.IndexOf(ForumList.Items.FindByValue(this.ParentSectionID.ToString()));
					}

				}
				else
				{
					GroupValue.Text = forum.GroupName;
					GroupValue.Visible = true;
					AdminGroupList.Visible = false;
					ForumList.Visible = false;
			
					if (ParentSectionID > 0)
					{
						Forum parentForum = Discussions.Components.Forums.GetForum( ParentSectionID, false, true );
						ParentForumName.Text = parentForum.Name;
						ParentForumName.NavigateUrl = String.Format("IFrameHost.aspx?GroupID={0}&SectionID={1}", forum.GroupID, ParentSectionID);
						ParentForumRow.Visible = true;
					}
					else
					{
						ParentForumRow.Visible = false;
					}
				}

				IsActive.Items.FindByValue( forum.IsActive.ToString() ).Selected = true;
				Name.Text = forum.Name.ToString();
				Url.Text = forum.NavigateUrl;
				Description.Text = forum.Description.ToString();
				IsModerated.Items.FindByValue( forum.IsModerated.ToString()	).Selected = true;
				EnablePostStatistics.Items.FindByValue( forum.EnablePostStatistics.ToString() ).Selected = true;
				EnablePostPoints.Items.FindByValue( forum.EnablePostPoints.ToString() ).Selected = true;
				EnableAutoDelete.Items.FindByValue( forum.EnableAutoDelete.ToString() ).Selected = true;
				EnableAnonymousPosting.Items.FindByValue( forum.EnableAnonymousPosting.ToString() ).Selected = true;
				AutoDeleteThreshold.Text = forum.AutoDeleteThreshold.ToString();
				IsSearchable.Items.FindByValue( forum.IsSearchable.ToString() ).Selected = true;
				EnableAnonymousPostingForUsers.Items.FindByValue( forum.EnableAnonymousPostingForUsers.ToString() ).Selected = true;
				EnableThreadStatusTracking.Items.FindByValue( forum.EnableThreadStatus.ToString() ).Selected = true;
				DefaultThreadStatusValue.SelectedValue = forum.DefaultThreadStatusValue;
				DefaultLanguage.SelectedValue = forum.DefaultLanguage;

⌨️ 快捷键说明

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