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

📄 memberconfigurationadmin.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CommunityServer;
using CommunityServer.Components;


namespace CommunityServer.Controls {

	public class MemberConfigurationAdmin : TemplatedWebControl {

		#region Child Controls
		//protected DomainDropDownList ddlDomain;

		#region Registration
		protected YesNoRadioButtonList optAllowLogin;
		protected YesNoRadioButtonList optAllowNewUserRegistration;
		protected ModerationLevelDropDownList ddlNewUserModerationLevel;
		protected TextBox txtUsernameMinLength;
		protected TextBox txtUsernameMaxLength;
		protected TextBox txtUserNameRegEx;
		protected TextBox txtPasswordRegEx;
		protected YesNoRadioButtonList optAutoRegisterForWindowsAuthentication;
		protected AccountActivationRadioButtonList optAccountActivation;
		protected PasswordRecoveryRadioButtonList optPasswordRecovery;
		protected PasswordFormatDropDownList ddlPasswordFormat;
		protected YesNoRadioButtonList optEnableCOPPA;
        protected YesNoRadioButtonList optEnableBannedUsersToLogin;

		#endregion

		#region User Profile

		protected YesNoRadioButtonList optAllowSignatures;
		protected YesNoRadioButtonList optEnableSignatures;
		protected TextBox txtSignatureMaxLength;
		protected YesNoRadioButtonList optAllowGender;
		protected YesNoRadioButtonList optAllowUserToSelectTheme;
		protected YesNoRadioButtonList optEnableUserReferrer;

		#endregion

		#region Avatar

		protected YesNoRadioButtonList optEnableAvatars;
		protected YesNoRadioButtonList optEnableRemoteAvatars;
		protected TextBox txtAvatarHeight;
		protected TextBox txtAvatarWidth;

		#endregion
        
        #region Misc
        
        protected YesNoRadioButtonList optEnableUserModerationCounters;

        #endregion

		protected Button btnSave;
		protected Button btnReset;
		#endregion

		#region Skin
		protected override void AttachChildControls() {

			#region Registration

			optAllowLogin = (YesNoRadioButtonList)FindControl( "optAllowLogin" );
			optAllowNewUserRegistration = (YesNoRadioButtonList)FindControl( "optAllowNewUserRegistration" );
			ddlNewUserModerationLevel = (ModerationLevelDropDownList)FindControl( "ddlNewUserModerationLevel" );
			txtUsernameMinLength = (TextBox)FindControl( "txtUsernameMinLength" );
			txtUsernameMaxLength = (TextBox)FindControl( "txtUsernameMaxLength" );
			txtUserNameRegEx = FindControl("txtUserNameRegEx") as TextBox;
			txtPasswordRegEx = FindControl("txtPasswordRegEx") as TextBox;
			optAutoRegisterForWindowsAuthentication = (YesNoRadioButtonList)FindControl( "optAutoRegisterForWindowsAuthentication" );
			optAccountActivation = (AccountActivationRadioButtonList)FindControl( "optAccountActivation" );
			optPasswordRecovery = (PasswordRecoveryRadioButtonList)FindControl( "optPasswordRecovery" );
			ddlPasswordFormat = (PasswordFormatDropDownList)FindControl( "ddlPasswordFormat" );
			optEnableCOPPA = (YesNoRadioButtonList)FindControl( "optEnableCOPPA" );
            optEnableBannedUsersToLogin = (YesNoRadioButtonList) FindControl( "optEnableBannedUsersToLogin" );
			#endregion

			#region User Profile

			optAllowSignatures = (YesNoRadioButtonList)FindControl( "optAllowSignatures" );
			optEnableSignatures = (YesNoRadioButtonList)FindControl( "optEnableSignatures" );
			txtSignatureMaxLength = (TextBox)FindControl( "txtSignatureMaxLength" );
			optAllowGender = (YesNoRadioButtonList)FindControl( "optAllowGender" );
			optAllowUserToSelectTheme = (YesNoRadioButtonList)FindControl( "optAllowUserToSelectTheme" );
			optEnableUserReferrer = (YesNoRadioButtonList)FindControl( "optEnableUserReferrer" );

			#endregion

			#region Avatar

			optEnableAvatars = (YesNoRadioButtonList)FindControl( "optEnableAvatars" );
			optEnableRemoteAvatars = (YesNoRadioButtonList)FindControl( "optEnableRemoteAvatars" );
			txtAvatarHeight = (TextBox)FindControl( "txtAvatarHeight" );
			txtAvatarWidth = (TextBox)FindControl( "txtAvatarWidth" );

			#endregion
            
            #region Misc

            optEnableUserModerationCounters = (YesNoRadioButtonList)FindControl( "optEnableUserModerationCounters" );

            #endregion

			btnSave = (Button)FindControl( "btnSave" );
			btnReset = (Button)FindControl( "btnReset" );

			InitializeChildControls();
		}

		private void InitializeChildControls() {

			btnSave.Click += new EventHandler(Save_Click);
			btnReset.Click += new EventHandler(Reset_Click);

			btnSave.Text = ResourceManager.GetString("Save");
			btnReset.Text = ResourceManager.GetString("Reset");

			btnSave.Attributes["onclick"] = "if ( !confirm('" + string.Format(ResourceManager.GetString("Cache_Warning"), CSContext.Current.SiteSettings.SiteSettingsCacheWindowInMinutes).Replace("'", @"\'") + "') ) { return false; } ";								
		}

		#endregion

		#region Command Handlers
		private void Reset_Click(Object sender, EventArgs e) {
            SiteSettings current = CSContext.Current.SiteSettings;
			SiteSettings settings = new SiteSettings();
			settings.SiteDomain = current.SiteDomain;
            settings.SiteKey = current.SiteKey;
            settings.SettingsID = current.SettingsID;
            settings.ApplicationName = current.ApplicationName;
			ResetSettings( settings );
			DataBind();
		}

		private void Save_Click(Object sender, EventArgs e) {

			if (!Page.IsValid)
				return;
			
			SiteSettings settings = CSContext.Current.SiteSettings; 
			SaveSettings( settings );
			DataBind();

			Label statusLabel = (Label)FindControl( "StatusLabel" );
			statusLabel.Text = ResourceManager.GetString( "MemberSettings_StatusSuccess" );
			statusLabel.Visible = true;
		}
		#endregion

		#region Command Implementations
		protected virtual void ResetSettings( SiteSettings settings ) {
            SiteSettingsManager.Save(settings);
			//settings.Save();
		}

		protected virtual void SaveSettings( SiteSettings settings ) {
			
			#region Registration
			try { settings.UsernameMaxLength = int.Parse(txtUsernameMaxLength.Text); }
			catch { ((RequiredFieldValidator)FindControl( "UsernameMaxLengthValidator" )).IsValid = false; }
			
			try { settings.UsernameMinLength = int.Parse(txtUsernameMinLength.Text); }
			catch { ((RequiredFieldValidator)FindControl( "UsernameMinLengthValidator" )).IsValid = false; }

			settings.UsernameRegex = txtUserNameRegEx.Text;
			settings.PasswordRegex = txtPasswordRegEx.Text;
			settings.AllowLogin = optAllowLogin.SelectedValue;
			settings.AllowNewUserRegistration = optAllowNewUserRegistration.SelectedValue;
			settings.NewUserModerationLevel = ddlNewUserModerationLevel.SelectedValue;
			//TODO Save optAutoRegisterForWindowsAuthentication.SelectedValue;
			settings.AccountActivation = optAccountActivation.SelectedValue;
			settings.PasswordRecovery = optPasswordRecovery.SelectedValue;
			settings.PasswordFormat = ddlPasswordFormat.SelectedValue;
            settings.EnableBannedUsersToLogin = optEnableBannedUsersToLogin.SelectedValue;
			//TODO Save optEnableCOPPA.SelectedValue

			#endregion

			#region User Profile

			settings.AllowUserSignatures = optAllowSignatures.SelectedValue;
			settings.EnableUserSignatures = optEnableSignatures.SelectedValue;
			settings.UserSignatureMaxLength = Int32.Parse( txtSignatureMaxLength.Text );
			settings.AllowGender = optAllowGender.SelectedValue;
			settings.EnableUserThemeSelection = optAllowUserToSelectTheme.SelectedValue;
			//TODO Save optEnableUserReferrer

			#endregion

			#region Avatars

			settings.EnableAvatars = optEnableAvatars.SelectedValue;
			settings.EnableRemoteAvatars = optEnableRemoteAvatars.SelectedValue;
			settings.AvatarHeight = Int32.Parse( txtAvatarHeight.Text);
			settings.AvatarWidth = Int32.Parse( txtAvatarWidth.Text);
			
			#endregion
            
            #region Misc
            
            settings.EnableUserModerationCounters = optEnableUserModerationCounters.SelectedValue;

            #endregion

            SiteSettingsManager.Save(settings);
			
		}
		#endregion

		protected override void OnLoad(EventArgs e) {
			if ( !Page.IsPostBack ) {
				this.DataBind();
			}
			base.OnLoad( e );
			FindControl( "StatusLabel" ).Visible = false;
		}

		public override void DataBind(){
			base.DataBind();

			SiteSettings settings = CSContext.Current.SiteSettings;
    
			#region Registration
			optAllowLogin.SelectedValue = settings.AllowLogin;
			optAllowNewUserRegistration.SelectedValue = settings.AllowNewUserRegistration;
			ddlNewUserModerationLevel.SelectedValue = settings.NewUserModerationLevel;
			txtUsernameMinLength.Text = settings.UsernameMinLength.ToString();
			txtUserNameRegEx.Text = settings.UsernameRegex;
			txtPasswordRegEx.Text = settings.PasswordRegex;
			txtUsernameMaxLength.Text = settings.UsernameMaxLength.ToString();
			//TODO Load optAutoRegisterForWindowsAuthentication.SelectedValue;
			optAccountActivation.SelectedValue = settings.AccountActivation;
			optPasswordRecovery.SelectedValue = settings.PasswordRecovery;
			ddlPasswordFormat.SelectedValue = settings.PasswordFormat;
            optEnableBannedUsersToLogin.SelectedValue = settings.EnableBannedUsersToLogin;
			//TODO Load optEnableCOPPA.SelectedValue

			#endregion

			#region User Profile

			optAllowSignatures.SelectedValue = settings.AllowUserSignatures;
			optEnableSignatures.SelectedValue = settings.EnableUserSignatures;
			txtSignatureMaxLength.Text = settings.UserSignatureMaxLength.ToString();
			optAllowGender.SelectedValue = settings.AllowGender;
			optAllowUserToSelectTheme.SelectedValue = settings.EnableUserThemeSelection;
			//TODO Load optEnableUserReferrer

			#endregion

			#region Avatars

			optEnableAvatars.SelectedValue = settings.EnableAvatars;
			optEnableRemoteAvatars.SelectedValue = settings.EnableRemoteAvatars;
			txtAvatarHeight.Text = settings.AvatarHeight.ToString();
			txtAvatarWidth.Text = settings.AvatarWidth.ToString();
			
			#endregion
            
            #region Misc

            optEnableUserModerationCounters.SelectedValue = settings.EnableUserModerationCounters;

            #endregion
		}

	}
}

⌨️ 快捷键说明

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