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

📄 editprofile.cs

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

using System;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CommunityServer;
using CommunityServer.Components;
using System.ComponentModel;
using System.IO;


namespace CommunityServer.Controls {

	public class EditProfile : SkinnedWebControl {

        #region Member variables and constructor
	    string skinFilename = "Skin-EditProfile.ascx";
	    CSContext csContext = CSContext.Current;

	    // Member variable controls
	    User userToEdit;
	    Literal username;
	    TimezoneDropDownList timezone;
		TextBox commonName;
	    TextBox location;
	    TextBox occupation;
	    TextBox interests;
	    TextBox webAddress;
	    TextBox webLog;
	    TextBox signature;
	    TextBox privateEmail;
	    TextBox publicEmail;
	    TextBox msnIM;
	    TextBox aolIM;
	    TextBox yahooIM;
	    TextBox icq;
	    TextBox avatarUrl;
        TextBox usernameEdit;
	    RadioButtonList enableAvatar;
	    RadioButtonList  hideReadPosts;
	    RadioButtonList enableEmailTracking;
	    RadioButtonList displayInMemberList;
	    RadioButtonList enableHtmlEmail;
        RadioButtonList enableEmail;
        GenderRadioButtonList gender;
	    LanguageDropDownList language;
	    DateFormatDropDownList dateFormat;
        DatePicker birthday;
		Button updateButtonBottom;
		Button avatarUpdateButton;
        DateFilter defaultThreadView;
        CustomValidator signatureMaxLengthValidator;
        HtmlInputFile uploadedAvatar;
        HtmlAnchor changePassword;
        HtmlAnchor changePasswordAnswer;
        ModerationLevelDropDownList moderationLevel;
        YesNoRadioButtonList isAnonymous;
        YesNoRadioButtonList isAvatarApproved;
        YesNoRadioButtonList forceLogin;
        AccountStatusDropDownList accountStatus;
        ThemeDropDownList theme;
	    YesNoRadioButtonList enablePostPreviewPopup;
		YesNoRadioButtonList EnableEmoticons;
        HtmlTable userBanSection;
        UserBanDropDownList userBanPeriod;
        Label bannedUntilDate;
		Label avatarMsg;
		Label enableAvatarMsg;
        HtmlTable userApprovalSection;
        YesNoRadioButtonList isApproved;
		YesNoRadioButtonList enableCollapsingPanels;
		FontSizeDropDownList fontsizeList;
		SortOrderDropDownList sortOrder;
		StatusMessage formStatus;
		#region 新增内容
		TextBox nickname;
		TextBox qq;
		RequiredFieldValidator nicknameValidator;
		#endregion
	    // *********************************************************************
	    //  EditUserInfo
	    //
	    /// <summary>
	    /// Constructor
	    /// </summary>
	    ///
	    // ********************************************************************/
	    public EditProfile() 
        {

			// Set the default skin
			//
			if (SkinFilename == null)
				SkinFilename = skinFilename;

		}
        #endregion

        #region Render functions
		// *********************************************************************
		//  Initializeskin
		//
		/// <summary>
		/// This method populates the user control used to edit a user's information
		/// </summary>
		/// <param name="control">Instance of the user control to populate</param>
		///
		// ***********************************************************************/
        override protected void InitializeSkin(Control skin) {

            // Get the user we are editing
            //
			if ((Mode == ControlUserMode.Administrator) || (Mode == ControlUserMode.Moderator)) {
				userToEdit = Users.GetUserWithWriteableProfile(csContext.UserID,null, false);
                
				// Save actual account status
				this.PrevAccountStatus = userToEdit.AccountStatus;
			} else {
				userToEdit = Users.GetUserWithWriteableProfile();
            }

            // Find the controls we need
            //
			commonName = skin.FindControl("CommonName") as TextBox;
            username = (Literal) skin.FindControl("Username");
            usernameEdit = (TextBox) skin.FindControl("UsernameEdit");
			#region 新增内容
			this.nickname = (TextBox) skin.FindControl("Nickname");
			this.nicknameValidator = (RequiredFieldValidator) skin.FindControl("nicknameValidator");
			this.nicknameValidator.ErrorMessage = ResourceManager.GetString("CreateNewAccount_nicknameValidator").Replace("'", @"\'");
            qq = (TextBox) skin.FindControl("QQ");
			#endregion
			timezone = (TimezoneDropDownList) skin.FindControl("Timezone");
            location = (TextBox) skin.FindControl("Location");
            occupation = (TextBox) skin.FindControl("Occupation");
            interests = (TextBox) skin.FindControl("Interests");
            webAddress = (TextBox) skin.FindControl("WebAddress");
            webLog = (TextBox) skin.FindControl("WebLog");
            privateEmail = (TextBox) skin.FindControl("PrivateEmail");
            publicEmail = (TextBox) skin.FindControl("PublicEmail");
            msnIM = (TextBox) skin.FindControl("MsnIM");
            aolIM = (TextBox) skin.FindControl("AolIM");
            yahooIM = (TextBox) skin.FindControl("YahooIM");
            icq = (TextBox) skin.FindControl("ICQ");
            avatarUrl = (TextBox) skin.FindControl("avatarUrl");
            enableAvatar = (RadioButtonList) skin.FindControl("EnableAvatar");
            hideReadPosts = (RadioButtonList) skin.FindControl("HideReadPosts");
            signature = (TextBox) skin.FindControl("Signature");
            displayInMemberList = (RadioButtonList) skin.FindControl("DisplayInMemberList");
			updateButtonBottom = (Button) skin.FindControl("UpdateButtonBottom");
			avatarUpdateButton = (Button) skin.FindControl("");
            language = (LanguageDropDownList) skin.FindControl("Language");
            dateFormat = (DateFormatDropDownList) skin.FindControl("DateFormat");
            defaultThreadView = (DateFilter) skin.FindControl("DefaultThreadView");
            signatureMaxLengthValidator = (CustomValidator) skin.FindControl("SignatureMaxLengthValidator");
            uploadedAvatar = (HtmlInputFile) skin.FindControl("AvatarUpload");
            avatarUpdateButton = (Button) skin.FindControl("SubmitAvatar");
            gender = (GenderRadioButtonList) skin.FindControl("Gender");
            changePassword = (HtmlAnchor) skin.FindControl("ChangePassword");
            changePasswordAnswer = (HtmlAnchor) skin.FindControl("ChangePasswordAnswer");
            birthday = (DatePicker) skin.FindControl("BirthDate");
            theme = (ThemeDropDownList) skin.FindControl("Theme");
            enableEmailTracking = (RadioButtonList) skin.FindControl("EnableEmailTracking");
            enableHtmlEmail = (RadioButtonList) skin.FindControl("EnableHtmlEmail");
			fontsizeList = (FontSizeDropDownList) skin.FindControl("FontSize");
			avatarMsg = (Label) skin.FindControl("AvatarMsg");
			enableAvatarMsg = (Label) skin.FindControl("EnableAvatarMsg");

			enableEmail = (RadioButtonList) skin.FindControl("ReceiveEmails");
			enableEmail.Enabled = csContext.SiteSettings.EnableEmail;

			sortOrder = (SortOrderDropDownList) skin.FindControl("SortOrder");

			enableCollapsingPanels = (YesNoRadioButtonList) skin.FindControl("EnableCollapsingPanels");
			EnableEmoticons = (YesNoRadioButtonList)skin.FindControl("EnableEmoticons");
			EnableEmoticons.SelectedValue = csContext.User.Profile.EnableEmoticons;

			skin.FindControl("EmoticonRow").Visible = csContext.SiteSettings.EnableEmoticons;

            signatureMaxLengthValidator.ErrorMessage = string.Format(ResourceManager.GetString("EditProfile_SigMaxLength"), csContext.SiteSettings.UserSignatureMaxLength.ToString());

			formStatus = skin.FindControl("formStatus") as StatusMessage;

            // Change password link
            //
            changePassword.InnerText = ResourceManager.GetString("EditProfile_PasswordChange");
            if (Mode == ControlUserMode.User) {
                changePassword.HRef = Globals.GetSiteUrls().UserChangePassword;
            } else {
                changePassword.HRef = Globals.GetSiteUrls().AdminUserPasswordChange(userToEdit.UserID);
            }

            // Change password answer link
            //
            changePasswordAnswer.InnerText = ResourceManager.GetString("EditProfile_PasswordAnswerChange");
            if (Mode == ControlUserMode.User) {
                changePasswordAnswer.HRef = Globals.GetSiteUrls().UserChangePasswordAnswer;
            } 
            else {
                changePasswordAnswer.HRef = Globals.GetSiteUrls().AdminUserPasswordAnswerChange(userToEdit.UserID);
            }

			// Is forgotten password change done through Question/Answer or simply reset?
			if (csContext.SiteSettings.PasswordRecovery == CommunityServer.Components.PasswordRecovery.QuestionAndAnswer)
				skin.FindControl("EnablePasswordQuestionAnswer").Visible = true;

            // Do we allow the user to edit signatures?
            if ( (csContext.SiteSettings.AllowUserSignatures) || (Mode == ControlUserMode.Administrator) || (Mode == ControlUserMode.Moderator))
                skin.FindControl("EnableSignature").Visible = true;
			else
				skin.FindControl("EnableSignature").Visible = false;
			
			// Do we allow the user to select theme?
			if (csContext.SiteSettings.EnableUserThemeSelection) {
				theme.Enabled = true;
			} else {
				theme.Enabled = false;
			}

			// Do we allow the user to specify gender?
            if ( (csContext.SiteSettings.AllowGender) || (Mode == ControlUserMode.Administrator) || (Mode == ControlUserMode.Moderator) ) {
                skin.FindControl("EnableGender").Visible = true;
            }

            // Set form to the current values of logged on user
            //
            username.Text = Globals.HtmlDecode(userToEdit.Username);

            // Do we allow the user to edit his/her username?
            if ((csContext.SiteSettings.EnableUsernameChange) || (Mode == ControlUserMode.Administrator) || (Mode == ControlUserMode.Moderator) ) {
                username.Visible = false;
                usernameEdit.Visible = true;
                usernameEdit.Text = username.Text;
            }

            if ( timezone.Items.FindByValue( userToEdit.Profile.Timezone.ToString() ) != null)
			        timezone.Items.FindByValue( userToEdit.Profile.Timezone.ToString() ).Selected = true;

            // Find controls for Avatar/Post section
            //
			if ( csContext.SiteSettings.EnableAvatars ) {
				if((userToEdit.HasAvatar) && (userToEdit.EnableAvatar) ) {
					UserAvatar avatar = (UserAvatar) skin.FindControl("Avatar");
					avatar.User = userToEdit;
					avatar.Visible = true;
				}

				// has the avatar been approved?
				if (!userToEdit.IsAvatarApproved) {
					enableAvatar.Enabled = false;
					((YesNoRadioButtonList) enableAvatar).SelectedValue = false;
					enableAvatarMsg.Text = ResourceManager.GetString("EditProfile_AvatarsMustBeApprovedByModerator");
				} else {
					enableAvatar.Enabled = true;
					enableAvatarMsg.Text = null;
				}

				if ( csContext.SiteSettings.EnableRemoteAvatars ) {
					avatarUrl.Enabled = true;
					avatarMsg.Text = null;
				} else {
					avatarUrl.Enabled = false;
					avatarMsg.Text = ResourceManager.GetString("EditProfile_RemoteAvatarsDisabled");
				}

			}
			else {
				Control avatarSection = skin.FindControl("AvatarSection");
				if( avatarSection != null )
					avatarSection.Visible = false;
				
			}


            // If the admin has turned on post preview popups then we can turn it on
            this.enablePostPreviewPopup = (YesNoRadioButtonList) skin.FindControl("EnablePostPreviewPopup");
            if( csContext.SiteSettings.EnablePostPreviewPopup  && enablePostPreviewPopup != null ) {
          
                enablePostPreviewPopup.Visible = true;
                enablePostPreviewPopup.Items.FindByValue( userToEdit.Profile.EnablePostPreviewPopup.ToString() ).Selected = true;
            }
            else
				skin.FindControl( "EnablePostPreviewPopupRow" ).Visible = false;

			#region 新增内容
			nickname.Text = Globals.HtmlDecode(userToEdit.Nickname);
			qq.Text = Globals.HtmlDecode(userToEdit.Profile.QQIM);
			#endregion
			commonName.Text = Globals.HtmlDecode(userToEdit.Profile.CommonName);
		    location.Text = Globals.HtmlDecode(userToEdit.Profile.Location);
		    occupation.Text = Globals.HtmlDecode(userToEdit.Profile.Occupation);
		    interests.Text = Globals.HtmlDecode(userToEdit.Profile.Interests);
		    webAddress.Text = Globals.HtmlDecode(userToEdit.Profile.WebAddress);
		    webLog.Text = Globals.HtmlDecode(userToEdit.Profile.WebLog);
		    signature.Text = userToEdit.Profile.Signature;
		    privateEmail.Text = userToEdit.Email;
		    publicEmail.Text = Globals.HtmlDecode(userToEdit.Profile.PublicEmail);
		    msnIM.Text = Globals.HtmlDecode(userToEdit.Profile.MsnIM);
		    aolIM.Text = Globals.HtmlDecode(userToEdit.Profile.AolIM);
		    yahooIM.Text = Globals.HtmlDecode(userToEdit.Profile.YahooIM);
			icq.Text = Globals.HtmlDecode(userToEdit.Profile.IcqIM);
			avatarUrl.Text = Globals.HtmlDecode(userToEdit.AvatarUrl);

			if (birthday != null)
				birthday.SelectedDate = userToEdit.Birthday; // 2005-02-26: 修改

            theme.SelectedValue = userToEdit.Theme;

			// Set the gender
			// 修改BUG
			// gender.Items.FindByValue( ((int) userToEdit.Profile.Gender).ToString() ).Selected = true; //修改前
			gender.SelectedValue = userToEdit.Profile.Gender; //修改后

            // Language Drop Down List
            if (language.Items.FindByValue( userToEdit.Profile.Language ) != null)
                language.Items.FindByValue( userToEdit.Profile.Language ).Selected = true;

            if (dateFormat.Items.FindByValue( userToEdit.Profile.DateFormat ) != null)
			    dateFormat.Items.FindByValue( userToEdit.Profile.DateFormat ).Selected = true;

			if (sortOrder.Items.FindByValue( ((int)userToEdit.PostSortOrder).ToString() ) != null)
				sortOrder.Items.FindByValue( ((int)userToEdit.PostSortOrder).ToString() ).Selected = true;

		    enableAvatar.Items.FindByValue( userToEdit.EnableAvatar.ToString() ).Selected = true;
		    enableEmailTracking.Items.FindByValue ( userToEdit.EnableThreadTracking.ToString() ).Selected = true;
		    enableHtmlEmail.Items.FindByValue ( userToEdit.EnableHtmlEmail.ToString() ).Selected = true;
            enableEmail.Items.FindByValue ( userToEdit.EnableEmail.ToString() ).Selected = true;
		    displayInMemberList.Items.FindByValue( userToEdit.EnableDisplayInMemberList.ToString()).Selected = true;
            ((Literal) skin.FindControl("DateCreated")).Text = userToEdit.GetTimezone( userToEdit.DateCreated ).ToString( userToEdit.Profile.DateFormat );
            ((Literal) skin.FindControl("LastLogin")).Text = userToEdit.GetTimezone( userToEdit.LastLogin ).ToString( userToEdit.Profile.DateFormat );
            ((Literal) skin.FindControl("LastActivity")).Text = userToEdit.GetTimezone( userToEdit.LastActivity ).ToString( userToEdit.Profile.DateFormat );
			enableCollapsingPanels.Items.FindByValue( userToEdit.EnableCollapsingPanels.ToString() ).Selected = true;

            if ((Mode == ControlUserMode.Administrator) || (Mode == ControlUserMode.Moderator)) {
                skin.FindControl("AdministratorMode").Visible = true;
                ((Literal) skin.FindControl("UserID")).Text = userToEdit.UserID.ToString();
                ((Literal) skin.FindControl("PasswordFormat")).Text = userToEdit.PasswordFormat.ToString();

                moderationLevel = (ModerationLevelDropDownList) skin.FindControl("ModerationLevel");
                moderationLevel.SelectedValue = userToEdit.ModerationLevel;

⌨️ 快捷键说明

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