protected override void OnLoad(EventArgs e) { base.OnLoad(e); string sTemplate = string.Empty; if (System.IO.File.Exists(Server.MapPath(ImagePath + "/_userprofile.txt"))) { sTemplate = Utilities.GetFileContent(Server.MapPath(ImagePath + "/_userprofile.txt")); } else { sTemplate = Utilities.GetFileContent(Server.MapPath("~/DesktopModules/ActiveForums/config/templates/_userprofile.txt")); } sTemplate = Utilities.ParseSpacer(sTemplate); if (ProfileMode == ProfileModes.Edit) { sTemplate = "<%@ Register TagPrefix=\"dnn\" Assembly=\"DotNetNuke\" Namespace=\"DotNetNuke.UI.WebControls\"%>" + sTemplate; } Literal lit = new Literal(); UserController upc = new UserController(); User up = upc.GetUser(PortalId, ModuleId, UID); ForumController fc = new ForumController(); up.UserForums = fc.GetForumsForUser(up.UserRoles, PortalId, ForumModuleId, "CanRead"); sTemplate = TemplateUtils.ParseProfileTemplate(sTemplate, up, PortalId, ModuleId, ImagePath, CurrentUserType, UserInfo.UserID, TimeZoneOffset); sTemplate = RenderModals(sTemplate); sTemplate = sTemplate.Replace("[AM:CONTROLS:AdminProfileSettings]", "<asp:placeholder id=\"plhProfileAdminSettings\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AM:CONTROLS:ProfileMyPreferences]", "<asp:placeholder id=\"plhProfilePrefs\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AM:CONTROLS:ProfileUserAccount]", "<asp:placeholder id=\"plhProfileUserAccount\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AM:CONTROLS:ProfileForumTracker]", "<asp:placeholder id=\"plhTracker\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AF:PROFILE:VIEWUSERPOSTS]", "<a href=\"" + NavigateUrl(TabId, "", ParamKeys.ViewType + "=search&uid=" + UID.ToString()) + "\">[RESX:ViewPostsByUser]</a>"); sTemplate = GetTabsSection(sTemplate); Control ctl = this.ParseControl(sTemplate); this.Controls.Add(ctl); while (!(ctl.Controls.Count == 0)) { this.Controls.Add(ctl.Controls[0]); } //Begin Load Tab Control plhTabs = (PlaceHolder)(this.FindControl("plhTabs")); if (plhTabs != null & amTabs != null) { plhTabs.Controls.Add(amTabs); } LinkControls(Controls); if (plhProfileEditButton != null) { btnProfileEdit = new ImageButton(); btnProfileEdit.ID = "btnProfileEdit"; btnProfileEdit.CssClass = "amimagebutton"; btnProfileEdit.PostBack = true; btnProfileEdit.Height = 50; btnProfileEdit.Width = 50; btnProfileEdit.ImageLocation = "TOP"; btnProfileEdit.Text = "[RESX:Button:Edit]"; btnProfileEdit.ImageUrl = "~/DesktopModules/ActiveForums/images/edit32.png"; btnProfileEdit.Visible = false; plhProfileEditButton.Controls.Add(btnProfileEdit); } if (plhProfileCancelButton != null) { btnProfileCancel = new ImageButton(); btnProfileCancel.ID = "btnProfileCancel"; btnProfileCancel.CssClass = "amimagebutton"; btnProfileCancel.PostBack = true; btnProfileCancel.Height = 50; btnProfileCancel.Width = 50; btnProfileCancel.ImageLocation = "TOP"; btnProfileCancel.Text = "[RESX:Button:Cancel]"; btnProfileCancel.ImageUrl = "~/DesktopModules/ActiveForums/images/cancel32.png"; btnProfileCancel.Visible = false; plhProfileCancelButton.Controls.Add(btnProfileCancel); } if (plhProfileSaveButton != null) { btnProfileSave = new ImageButton(); btnProfileSave.ID = "btnProfileSave"; btnProfileSave.CssClass = "amimagebutton"; btnProfileSave.PostBack = true; btnProfileSave.Height = 50; btnProfileSave.Width = 50; btnProfileSave.ImageLocation = "TOP"; btnProfileSave.Text = "[RESX:Button:Save]"; btnProfileSave.ImageUrl = "~/DesktopModules/ActiveForums/images/save32.png"; btnProfileSave.Visible = false; plhProfileSaveButton.Controls.Add(btnProfileSave); } if (plhProfileAdminSettings != null) { ProfileBase tmpCtl = (ProfileBase)(this.LoadControl("~/DesktopModules/ActiveForums/controls/profile_adminsettings.ascx")); tmpCtl.ModuleConfiguration = this.ModuleConfiguration; tmpCtl.UserProfile = up.Profile; plhProfileAdminSettings.Controls.Add(tmpCtl); } if (plhProfilePrefs != null) { ProfileBase tmpCtl = (ProfileBase)(this.LoadControl("~/DesktopModules/ActiveForums/controls/profile_mypreferences.ascx")); tmpCtl.ModuleConfiguration = this.ModuleConfiguration; tmpCtl.UserProfile = up.Profile; plhProfilePrefs.Controls.Add(tmpCtl); } if (plhProfileUserAccount != null) { ProfileBase tmpCtl = (ProfileBase)(this.LoadControl("~/DesktopModules/ActiveForums/controls/profile_useraccount.ascx")); tmpCtl.ModuleConfiguration = this.ModuleConfiguration; tmpCtl.UserProfile = up.Profile; plhProfileUserAccount.Controls.Add(tmpCtl); } if (plhTracker != null) { ForumView ctlForums = new ForumView(); ctlForums.ModuleConfiguration = this.ModuleConfiguration; ctlForums.DisplayTemplate = DataCache.GetTemplate("ForumTracking.txt"); ctlForums.CurrentUserId = UID; ctlForums.ForumIds = up.UserForums; plhTracker.Controls.Add(ctlForums); } if (btnProfileEdit != null) { if (!(CurrentUserType == CurrentUserTypes.Anon) && (UID == this.UserId || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser))) { if (ProfileMode == ProfileModes.View) { btnProfileEdit.Visible = true; btnProfileCancel.Visible = false; btnProfileSave.Visible = false; } else { btnProfileEdit.Visible = false; btnProfileCancel.Visible = true; btnProfileSave.Visible = true; } } } }
private void BindTopics(string TopicsTemplate) { string sOutput = TopicsTemplate; string subTemplate = string.Empty; //Subforum Template if (sOutput.Contains("[SUBFORUMS]")) { if (dtSubForums.Rows.Count > 0) { subTemplate = TemplateUtils.GetTemplateSection(sOutput, "[SUBFORUMS]", "[/SUBFORUMS]"); } sOutput = TemplateUtils.ReplaceSubSection(sOutput, "<asp:placeholder id=\"plhSubForums\" runat=\"server\" />", "[SUBFORUMS]", "[/SUBFORUMS]"); } //Parse Common Controls sOutput = ParseControls(sOutput); //Parse Topics sOutput = ParseTopics(sOutput, dtTopics, "TOPICS"); //Parse Announce string sAnnounce = TemplateUtils.GetTemplateSection(sOutput, "[ANNOUNCEMENTS]", "[/ANNOUNCEMENTS]"); if (dtAnnounce != null) { if (dtAnnounce.Rows.Count > 0) { sAnnounce = ParseTopics(sAnnounce, dtAnnounce, "ANNOUNCEMENT"); } else { sAnnounce = string.Empty; } } else { sAnnounce = string.Empty; } sOutput = TemplateUtils.ReplaceSubSection(sOutput, sAnnounce, "[ANNOUNCEMENTS]", "[/ANNOUNCEMENTS]"); sOutput = Utilities.LocalizeControl(sOutput); this.Controls.Add(this.ParseControl(sOutput)); BuildPager(); PlaceHolder plh = (PlaceHolder)(this.FindControl("plhQuickJump")); if (plh != null) { ctlForumJump = new af_quickjump(); ctlForumJump.MOID = ModuleId; ctlForumJump.dtForums = null; ctlForumJump.ModuleConfiguration = this.ModuleConfiguration; ctlForumJump.ForumId = ForumId; ctlForumJump.ModuleId = ModuleId; if (ForumId > 0) { ctlForumJump.ForumInfo = ForumInfo; } plh.Controls.Add(ctlForumJump); } plh = (PlaceHolder)(this.FindControl("plhSubForums")); if (plh != null) { ctlForumSubs = (ForumView)(LoadControl(typeof(ForumView), null)); ctlForumSubs.ModuleConfiguration = this.ModuleConfiguration; ctlForumSubs.ForumId = ForumId; ctlForumSubs.ForumTable = dtSubForums; ctlForumSubs.ForumTabId = ForumTabId; ctlForumSubs.ForumModuleId = ForumModuleId; ctlForumSubs.SubsOnly = true; ctlForumSubs.DisplayTemplate = subTemplate; if (ForumId > 0) { ctlForumSubs.ForumInfo = ForumInfo; } plh.Controls.Add(ctlForumSubs); } //Me.Controls.Add(cbActions) //this.Controls.Add(ctlModal); // LoadCallBackScripts() }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string sTemplate = string.Empty; if (System.IO.File.Exists(Server.MapPath(ImagePath + "/_userprofile.txt"))) { sTemplate = Utilities.GetFileContent(Server.MapPath(ImagePath + "/_userprofile.txt")); } else { sTemplate = Utilities.GetFileContent(Server.MapPath("~/DesktopModules/ActiveForums/config/templates/_userprofile.txt")); } sTemplate = Utilities.ParseSpacer(sTemplate); if (ProfileMode == ProfileModes.Edit) { sTemplate = "<%@ Register TagPrefix=\"dnn\" Assembly=\"DotNetNuke\" Namespace=\"DotNetNuke.UI.WebControls\"%>" + sTemplate; } Literal lit = new Literal(); UserController upc = new UserController(); User up = upc.GetUser(PortalId, ModuleId, UID); ForumController fc = new ForumController(); up.UserForums = fc.GetForumsForUser(up.UserRoles, PortalId, ForumModuleId, "CanRead"); sTemplate = TemplateUtils.ParseProfileTemplate(sTemplate, up, PortalId, ModuleId, ImagePath, CurrentUserType, UserInfo.UserID, TimeZoneOffset); sTemplate = RenderModals(sTemplate); sTemplate = sTemplate.Replace("[AM:CONTROLS:AdminProfileSettings]", "<asp:placeholder id=\"plhProfileAdminSettings\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AM:CONTROLS:ProfileMyPreferences]", "<asp:placeholder id=\"plhProfilePrefs\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AM:CONTROLS:ProfileUserAccount]", "<asp:placeholder id=\"plhProfileUserAccount\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AM:CONTROLS:ProfileForumTracker]", "<asp:placeholder id=\"plhTracker\" runat=\"server\" />"); sTemplate = sTemplate.Replace("[AF:PROFILE:VIEWUSERPOSTS]", "<a href=\"" + NavigateUrl(TabId, "", ParamKeys.ViewType + "=search&uid=" + UID.ToString()) + "\">[RESX:ViewPostsByUser]</a>"); sTemplate = GetTabsSection(sTemplate); Control ctl = this.ParseControl(sTemplate); this.Controls.Add(ctl); while (!(ctl.Controls.Count == 0)) { this.Controls.Add(ctl.Controls[0]); } //Begin Load Tab Control plhTabs = (PlaceHolder)(this.FindControl("plhTabs")); if (plhTabs != null & amTabs != null) { plhTabs.Controls.Add(amTabs); } LinkControls(Controls); if (plhProfileEditButton != null) { btnProfileEdit = new ImageButton(); btnProfileEdit.ID = "btnProfileEdit"; btnProfileEdit.CssClass = "amimagebutton"; btnProfileEdit.PostBack = true; btnProfileEdit.Height = 50; btnProfileEdit.Width = 50; btnProfileEdit.ImageLocation = "TOP"; btnProfileEdit.Text = "[RESX:Button:Edit]"; btnProfileEdit.ImageUrl = "~/DesktopModules/ActiveForums/images/edit32.png"; btnProfileEdit.Visible = false; plhProfileEditButton.Controls.Add(btnProfileEdit); } if (plhProfileCancelButton != null) { btnProfileCancel = new ImageButton(); btnProfileCancel.ID = "btnProfileCancel"; btnProfileCancel.CssClass = "amimagebutton"; btnProfileCancel.PostBack = true; btnProfileCancel.Height = 50; btnProfileCancel.Width = 50; btnProfileCancel.ImageLocation = "TOP"; btnProfileCancel.Text = "[RESX:Button:Cancel]"; btnProfileCancel.ImageUrl = "~/DesktopModules/ActiveForums/images/cancel32.png"; btnProfileCancel.Visible = false; plhProfileCancelButton.Controls.Add(btnProfileCancel); } if (plhProfileSaveButton != null) { btnProfileSave = new ImageButton(); btnProfileSave.ID = "btnProfileSave"; btnProfileSave.CssClass = "amimagebutton"; btnProfileSave.PostBack = true; btnProfileSave.Height = 50; btnProfileSave.Width = 50; btnProfileSave.ImageLocation = "TOP"; btnProfileSave.Text = "[RESX:Button:Save]"; btnProfileSave.ImageUrl = "~/DesktopModules/ActiveForums/images/save32.png"; btnProfileSave.Visible = false; plhProfileSaveButton.Controls.Add(btnProfileSave); } if (plhProfileAdminSettings != null) { ProfileBase tmpCtl = (ProfileBase)(this.LoadControl("~/DesktopModules/ActiveForums/controls/profile_adminsettings.ascx")); tmpCtl.ModuleConfiguration = this.ModuleConfiguration; tmpCtl.UserProfile = up.Profile; plhProfileAdminSettings.Controls.Add(tmpCtl); } if (plhProfilePrefs != null) { ProfileBase tmpCtl = (ProfileBase)(this.LoadControl("~/DesktopModules/ActiveForums/controls/profile_mypreferences.ascx")); tmpCtl.ModuleConfiguration = this.ModuleConfiguration; tmpCtl.UserProfile = up.Profile; plhProfilePrefs.Controls.Add(tmpCtl); } if (plhProfileUserAccount != null) { ProfileBase tmpCtl = (ProfileBase)(this.LoadControl("~/DesktopModules/ActiveForums/controls/profile_useraccount.ascx")); tmpCtl.ModuleConfiguration = this.ModuleConfiguration; tmpCtl.UserProfile = up.Profile; plhProfileUserAccount.Controls.Add(tmpCtl); } if (plhTracker != null) { ForumView ctlForums = new ForumView(); ctlForums.ModuleConfiguration = this.ModuleConfiguration; ctlForums.DisplayTemplate = DataCache.GetTemplate("ForumTracking.txt"); ctlForums.CurrentUserId = UID; ctlForums.ForumIds = up.UserForums; plhTracker.Controls.Add(ctlForums); } if (btnProfileEdit != null) { if (!(CurrentUserType == CurrentUserTypes.Anon) && (UID == this.UserId || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser))) { if (ProfileMode == ProfileModes.View) { btnProfileEdit.Visible = true; btnProfileCancel.Visible = false; btnProfileSave.Visible = false; } else { btnProfileEdit.Visible = false; btnProfileCancel.Visible = true; btnProfileSave.Visible = true; } } } }