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

📄 userprofile.cs

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

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


namespace CommunityServer.Controls {

    public class UserProfile : SkinnedWebControl {
        User user;
        CSContext csContext = CSContext.Current;
        string skinFilename = "View-UserProfile.ascx";

        // *********************************************************************
        //  UserProfile
        //
        /// <summary>
        /// Constructor
        /// </summary>
        /// 
        // ********************************************************************/
        public UserProfile() {
			int userid = csContext.UserID;
            
			// Do we have a valid UserID?
			//
			if(userid <= 0) {

				// Is there a username?
				if (Context.Request.QueryString["UserName"] == string.Empty)
					throw new CSException(CSExceptionType.UserNotFound);
				else
					user = Users.GetUser(0, Context.Request.QueryString["UserName"], false, true);
			} else {
				user = Users.GetUser(csContext.UserID, false, true);
			}

            if(user.IsAnonymous)
            {
                Context.Response.Redirect(Globals.GetSiteUrls().Home);
                Context.Response.End();

            }
            
            // Set the skin
            //
            if (SkinFilename == null)
                SkinFilename = skinFilename;
        }
	
        // *********************************************************************
        //  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) {

            // Find controls for About section
            //
			//if (user.Profile.CommonName != string.Empty)
				//((Literal) skin.FindControl("Username")).Text = user.Profile.CommonName;
			//else
				((Literal) skin.FindControl("Username")).Text = user.Username + "("+ user.Nickname +")";

            ((Literal) skin.FindControl("TimeZone")).Text = user.Profile.Timezone.ToString();
            ((Literal) skin.FindControl("Location")).Text = user.Profile.Location.ToString();
            ((Literal) skin.FindControl("Occupation")).Text = user.Profile.Occupation.ToString();
            ((Literal) skin.FindControl("Interests")).Text = user.Profile.Interests.ToString();

            // Format the output
            //
            if (!csContext.User.IsAnonymous) {
                User u = csContext.User;

                ((Literal) skin.FindControl("JoinedDate")).Text = user.DateCreated.ToString( u.Profile.DateFormat );
                ((Literal) skin.FindControl("LastActivityDate")).Text = user.LastActivity.ToString( u.Profile.DateFormat );
            } else {
                ((Literal) skin.FindControl("JoinedDate")).Text = user.DateCreated.ToString();
                ((Literal) skin.FindControl("LastActivityDate")).Text = user.LastActivity.ToString();
            }

            
            // Does the user have a web url?
            //
            if (user.Profile.WebAddress.Length > 0) {
                HyperLink url = (HyperLink) skin.FindControl("WebURL");
                url.NavigateUrl = user.Profile.WebAddress;
                url.Text = user.Profile.WebAddress;
            }

            // Does the user have a blog url?
            //
            if (user.Profile.WebLog.Length > 0) {
                HyperLink url = (HyperLink) skin.FindControl("BlogURL");
                url.NavigateUrl = user.Profile.WebLog;
                url.Text = user.Profile.WebLog;
            }

            // Does the user have a public email?
            if (user.Profile.PublicEmail.Length > 0) {
                HyperLink url = (HyperLink) skin.FindControl("Email");
                url.NavigateUrl = "mailto:" + user.Profile.PublicEmail;
                url.Text = ResourceManager.GetString("ViewUserProfile_Email");
            }

			// Does the user have private messages enabled?
			if (user.EnablePrivateMessages) {
				HyperLink url = skin.FindControl("PrivateMessage") as HyperLink;
                if(url != null)
                {
                    url.NavigateUrl = "mailto:" + user.Profile.PublicEmail;
                    url.Text = ResourceManager.GetString("ForumMembers_PrivateMessages");
                }
			}

  
             skin.FindControl("GuestBook_Row").Visible = !CSContext.Current.SiteSettings.GuestBookDisabled;
              HyperLink guestBookLink = skin.FindControl("GuestBookLink") as HyperLink;
               guestBookLink.NavigateUrl = Globals.GetSiteUrls().GuestBook(user.Username);
               guestBookLink.Text = ResourceManager.GetString("ViewUserProfile_GuestBook");

            // Find controls for Avatar/Post section
            //
            if ( (user.HasAvatar) && (user.EnableAvatar) && (user.IsAvatarApproved) ) {
                UserAvatar avatar = (UserAvatar) skin.FindControl("Avatar");

                if (avatar != null)
                    avatar.Visible = true;
            }

            ((Literal) skin.FindControl("Skin")).Text = user.Theme;
            //((Literal) skin.FindControl("Signature")).Text = Transforms.FormatPost(user.Profile.Signature, PostType.BBCode);
			((Literal) skin.FindControl("Signature")).Text = user.Profile.SignatureFormatted;


            // Find controls in Contact section
            //
            ((Literal) skin.FindControl("MSNIM")).Text = user.Profile.MsnIM;
            ((Literal) skin.FindControl("AOLIM")).Text = user.Profile.AolIM;
            ((Literal) skin.FindControl("YahooIM")).Text = user.Profile.YahooIM;
            ((Literal) skin.FindControl("ICQ")).Text = user.Profile.IcqIM;


            // Post statistics rank, etc.
            //
            ((Literal) skin.FindControl("TotalPosts")).Text = user.TotalPosts.ToString("n0");
			((Literal) skin.FindControl("Rank")).Text = ((int)user.PostRank[0]).ToString();

            if ((Mode == ControlUserMode.User) && (!user.IsAnonymous)) {
                HyperLink SearchForPostsByUserButton = skin.FindControl("SearchForPostsByUserButton")as HyperLink;
                if(SearchForPostsByUserButton != null)
                {
                    SearchForPostsByUserButton.Text = String.Format(ResourceManager.GetString("UserImageButtons_SearchFor"), user.Username + "("+ user.Nickname +")");
                    SearchForPostsByUserButton.NavigateUrl = Globals.GetSiteUrls().SearchForText( string.Empty, string.Empty, CommunityServer.Search.ForumsToSearchEncode(user.UserID.ToString()) );
                    SearchForPostsByUserButton.Visible = true;
                }
            }
        }

        // *********************************************************************
        //  RenderTopPosts
        //
        /// <summary>
        /// Renders the top n posts used in the DisplayViewControl
        /// </summary>
        /// <param name="control">Table of posts</param>
        /// 
        // ********************************************************************/
        private void DisplayMostRecentPost(int postsToRender, Control skin) {

        }

    }
}

⌨️ 快捷键说明

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