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

using System;

namespace CommunityServer.Components
{
	/// <summary>
	/// Module which can be used to create a copy of a post before
	/// it gets deleted
	/// </summary>
	public class AuditDeletedPostContentModule : ICSModule
	{
		public AuditDeletedPostContentModule()
		{
        }
        #region ICSModule Members

        public void Init(CSApplication csa, System.Xml.XmlNode node)
        {
            csa.PrePostUpdate +=new CSPostEventHandler(csa_PrePostUpdate);
        }

        #endregion

        private void csa_PrePostUpdate(IContent content, CSPostEventArgs e)
        {
            if(e.State == ObjectState.Delete)
            {
                Post post = content as Post;
                if(post != null)
                {
                    try
                    {
                        CommonDataProvider.Instance().AuditDeletedPostContent(post);
                    }
                    catch(Exception)
                    {
                    }
                }
            }
        }
    }

}
