using System;
using System.Data;
using CMS.CMSHelper;
using CMS.ExtendedControls;
using CMS.Forums;
using CMS.GlobalHelper;
using CMS.UIControls;
public partial class CMSModules_Forums_Controls_Posts_PostApprove : CMSAdminEditControl
{
#region "Variables"
// Current PostID
private int mPostID = 0;
// Viewer mode
private string mMode = "approval";
// User ID
private int mUserID = 0;
#endregion
#region "Public properties"
///
/// Gets or sets the post ID.
///
public int PostID
{
get
{
return mPostID;
}
set
{
mPostID = value;
}
}
///
/// Gets or sets the user ID.
///
public int UserID
{
get
{
return mUserID;
}
set
{
mUserID = value;
}
}
///
/// Gets or sets mode of control
///
public string Mode
{
get
{
return mMode;
}
set
{
mMode = value;
}
}
#endregion
#region "Page events"
///
/// Handles the Load event of the Page control.
///
protected void Page_Load(object sender, EventArgs e)
{
if ((Mode == "approval") || ((Mode == "subscription") && (CheckSubscription())))
// Load the data
LoadData();
}
///
/// Checks if current user has subscribed given post.
///
/// ID of forum post
/// true if user has subscriptions for given post, false if not
private bool CheckSubscription()
{
if (UserID != CMSContext.CurrentUser.UserID)
{
// Check permissions
if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
{
return false;
}
}
DataSet ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + CMSContext.CurrentUser.UserID + ") AND (SubscriptionPostID = " + PostID + ") AND (ISNULL(SubscriptionApproved, 1) = 1)", null, 0, "SubscriptionID");
if (!DataHelper.DataSourceIsEmpty(ds))
{
return true;
}
return false;
}
#endregion
#region "Private methods"
///
/// Loads the data.
///
private void LoadData()
{
// Get the forum post
ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(ValidationHelper.GetInteger(PostID, 0));
ForumInfo fi = null;
if (fpi != null)
{
fi = ForumInfoProvider.GetForumInfo(fpi.PostForumID);
}
else
{
return;
}
if (fi.ForumEnableAdvancedImage)
{
ltrText.AllowedControls = ControlsHelper.ALLOWED_FORUM_CONTROLS;
}
else
{
ltrText.AllowedControls = "none";
}
// Display converted datetime for live site
lblDate.Text = CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(fpi.PostTime, DateTimeHelper.ZERO_TIME), this).ToString();
lblUser.Text = HTMLHelper.HTMLEncode(fpi.PostUserName);
lblSubject.Text = HTMLHelper.HTMLEncode(fpi.PostSubject);
DiscussionMacroHelper dmh = new DiscussionMacroHelper();
dmh.EnableBold = fi.ForumEnableFontBold;
dmh.EnableItalics = fi.ForumEnableFontItalics;
dmh.EnableStrikeThrough = fi.ForumEnableFontStrike;
dmh.EnableUnderline = fi.ForumEnableFontUnderline;
dmh.EnableCode = fi.ForumEnableCodeSnippet;
dmh.EnableColor = fi.ForumEnableFontColor;
dmh.EnableImage = fi.ForumEnableImage || fi.ForumEnableAdvancedImage;
dmh.EnableQuote = fi.ForumEnableQuote;
dmh.EnableURL = fi.ForumEnableURL || fi.ForumEnableAdvancedURL;
dmh.MaxImageSideSize = fi.ForumImageMaxSideSize;
dmh.QuotePostText = GetString("DiscussionMacroResolver.QuotePostText");
if (fi.ForumHTMLEditor)
{
dmh.EncodeText = false;
dmh.ConvertLineBreaksToHTML = false;
}
else
{
dmh.EncodeText = true;
dmh.ConvertLineBreaksToHTML = true;
}
// Resolve the macros and display the post text
ltrText.Text = dmh.ResolveMacros(fpi.PostText);
}
#endregion
}