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

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommunityServer.Components;

namespace CommunityServer.Controls
{
    public class BannedUser : TemplatedWebControl
    {
        protected override void OnInit(EventArgs e) 
        {
            if (SkinName == null)                
                ExternalSkinFileName = "Skin-Message.ascx";
            else 
                ExternalSkinFileName = SkinName;
			
            base.OnInit(e);
        }
				
        #region Skin
                
        protected override void AttachChildControls() 
        {
            Label messageTitle = (Label) FindControl( "MessageTitle" );
            Label messageBody = (Label) FindControl( "MessageBody" );
            
            if (messageTitle != null)
                messageTitle.Text = ResourceManager.GetString( "UserBanned_Title" );

        	CSContext cntx = CSContext.Current;
        	User user = cntx.User;

            if (messageBody != null)
            {
                messageBody.Text = string.Format( ResourceManager.GetString( "UserBanned_Message" ),
                    user.BannedUntil.ToString( user.Profile.DateFormat ), user.BannedUntil.ToString( cntx.SiteSettings.TimeFormat ), 
                    ResourceManager.GetString( "Utility_UserBanReason_" + user.BanReason.ToString() ) );
            }
        }
		        
        #endregion
    }
}
