using System;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
using CMS.CMSHelper;
using CMS.ExtendedControls;
using CMS.Forums;
using CMS.GlobalHelper;
using CMS.SettingsProvider;
using CMS.SiteProvider;
public partial class CMSModules_Forums_Controls_Layouts_Tree_Threads : ForumViewer, IPostBackEventHandler
{
#region "Private variables"
private int mSelectedPost = 0;
protected string mUnapproved = String.Empty;
#endregion
#region "Public properties"
public int SelectedPost
{
get
{
return mSelectedPost;
}
set
{
mSelectedPost = value;
}
}
#endregion
#region "Page events"
protected void Page_Load(object sender, EventArgs e)
{
CopyValues(postTreeElem);
// Hide selected area if forum is AdHoc
if (IsAdHocForum)
{
plcHeader.Visible = false;
}
// Handle the Move topic mode
if (ForumContext.CurrentMode != ForumMode.TopicMove)
{
plcMoveThread.Visible = false;
}
else
{
plcMoveThread.Visible = true;
threadMove.TopicMoved += new EventHandler(TopicMoved);
}
if ((hdnSelected.Value == String.Empty) && (QueryHelper.Contains("moveto")))
{
hdnSelected.Value = QueryHelper.GetString("moveto", "");
mSelectedPost = ValidationHelper.GetInteger(hdnSelected.Value, 0);
}
bool newThread = base.IsAvailable(null, ForumActionType.NewThread);
bool newSubscription = base.IsAvailable(null, ForumActionType.SubscribeToForum);
bool newFavorites = base.IsAvailable(null, ForumActionType.AddForumToFavorites);
bool newBreadCrumbs = (ForumBreadcrumbs1.GenerateBreadcrumbs() != "");
// Hide separators according to the link visibility
// Each separator is hidden if the item preceeding the separator is invisible or
// no item is behind the separator.
if (!newThread || (!newSubscription && !newFavorites && !newBreadCrumbs))
{
plcActionSeparator.Visible = false;
}
if (!newSubscription || (!newFavorites && !newBreadCrumbs))
{
plcAddToFavoritesSeparator.Visible = false;
}
if (!newFavorites || !newBreadCrumbs)
{
plcBreadcrumbsSeparator.Visible = false;
}
// postTreeElem.ForumID = ForumContext.CurrentForum.ForumID;
//postTreeElem.ShowMode = ShowModeEnum.TreeMode;
// Unapproved posts are shown only if onsite mangement is enabled and user is moderator
ForumInfo fi = ForumContext.CurrentForum;
postTreeElem.SelectOnlyApproved = !((fi != null) && EnableOnSiteManagement && fi.ForumModerated && ForumContext.UserIsModerator(ForumContext.CurrentForum.ForumID, CommunityGroupID));
if (postTreeElem.ShowMode == ShowModeEnum.DynamicDetailMode)
{
// Set javascript for selected mode
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumTreeDynamic", ScriptHelper.GetScript("function SelectForumNode(nodeElem, selElem) { if (document.getElementById(nodeElem) != null) { document.getElementById(nodeElem).style.display = 'block';} " +
"if (document.getElementById(selElem) != null) {document.getElementById(selElem).style.display = 'none';} return false;}\n "));
}
else
{
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ForumTreeNormal", ScriptHelper.GetScript("function SelectForumNode(nodeElem) { return false; }\n "));
}
// Show post javascript
string showScript = "function ShowPost(id){ document.getElementById('" + hdnSelected.ClientID + "').value = id; " + ControlsHelper.GetPostBackEventReference(this, "") + " }";
//Register show post javascript code
ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowForumPost", ScriptHelper.GetScript(showScript));
// Don't use redirection after action
UseRedirectAfterAction = false;
int selected = ValidationHelper.GetInteger(hdnSelected.Value, ValidationHelper.GetInteger(Request[hdnSelected.UniqueID], 0));
if (selected > 0)
{
ForumPostInfo fpi = ForumPostInfoProvider.GetForumPostInfo(selected);
if (fpi != null)
{
ucAbuse.ReportObjectID = fpi.PostId;
ucAbuse.ReportTitle = ResHelper.GetString("Forums_WebInterface_ForumPost.AbuseReport", SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCulture")) + fpi.PostText;
ucAbuse.CMSPanel.CommunityGroupID = CommunityGroupID;
ucAbuse.CMSPanel.SecurityAccess = AbuseReportAccess;
ucAbuse.CMSPanel.Roles = AbuseReportRoles;
}
}
}
///