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

using System;
using System.Xml;
using CommunityServer.Components;

namespace CommunityServer.Components
{
	public class PollHtmlScrubbingModule : ICSModule
	{
		public void Init(CSApplication csa, XmlNode node)
		{
			csa.PrePostUpdate +=new CSPostEventHandler(csa_BeforeProcessPost);
		}

		private void csa_BeforeProcessPost(IContent content, CSPostEventArgs e)
		{
			if(e.State == ObjectState.Create || e.State == ObjectState.Update)
			{
				Post p = content as Post;
				if(p != null && p.HasPoll)
				{
					p.PollDescription = HtmlScrubber.Clean(p.PollDescription, false, true);
				}
			}
		}
	}
}