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

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

namespace CommunityServer.Controls
{
	/// <summary>
	/// Add a user filter to the main search control. 
	/// </summary>
	public class UserSearchFilter : Control
	{
		public UserSearchFilter()
		{
			
		}

        protected override void OnInit(EventArgs e)
        {
            CSContext cntx = CSContext.Current;

            User user = null;

            if(cntx.UserID > 0)
            {
                user = Users.GetUser(cntx.UserID,false,true);
            }
            else if(Context.Request.QueryString["UserName"] != null)
            {
                user = Users.GetUser(-1,Context.Request.QueryString["UserName"],false,true);
            }


            if(user != null)
            {
                TitleBar.AddUsersToSearch(user.UserID,string.Format(ResourceManager.GetString("user_searchfilter"),user.Username),Context);
            }
                                     
            base.OnInit (e);
        }

	}
}
