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

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

using CommunityServer.Components;
using CommunityServer.Blogs.Components;
using CommunityServer.Mail.Common.Components;

namespace CommunityServer.Blogs.Controls
{
	/// <summary>
	/// Summary description for LoginLinkView.
	/// </summary>
	public class WeblogQuickLinks : WeblogThemedControl
	{
		public WeblogQuickLinks()
		{
			
		}

		protected override void AttachChildControls()
		{
			if(Context.Request.IsAuthenticated)
			{
				if(Permissions.ValidatePermissions(this.CurrentWeblog,Permission.Post,this.CurrentUser))
				{
					HyperLink NewPostLink = FindControl("NewPostLink") as HyperLink;
					HyperLink NewPostEmailLink = FindControl("NewPostEmailLink") as HyperLink;
					HyperLink ManageBlogLink = FindControl("ManageBlogLink") as HyperLink;

					NewPostLink.NavigateUrl = BlogUrls.Instance().PostEditor(CurrentWeblog.SectionID,BlogPostType.Post);
					NewPostLink.Text = ResourceManager.GetString("Weblog_Quick_Post");

					if (CSContext.Current.SiteSettings.EnableMailGateway)
					{
						MailingList list = MailingLists.GetMailingList(CurrentWeblog.SectionID);
						if(list != null && list.IsMailingList && NewPostEmailLink != null)
						{
							NewPostEmailLink.NavigateUrl = "mailto:" + list.DetermineEmailAddress();
							NewPostEmailLink.Text = "New Post by Email";
							NewPostEmailLink.Visible = true;
						}
					}

					ManageBlogLink.NavigateUrl = BlogUrls.Instance().PostControlPanel(this.CurrentWeblog);
					ManageBlogLink.Text = ResourceManager.GetString("Weblog_Quick_Manage");

					return;
				}
			}

			this.Controls.Clear();
		}

	}
}
