protected override void OnLoad(EventArgs e) { base.OnLoad(e); SocialGroupId = -1; if (Request.QueryString["GroupId"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["GroupId"])) { SocialGroupId = Convert.ToInt32(Request.QueryString["GroupId"]); } SetupPage(); try { if (MainSettings != null && MainSettings.InstallDate > Utilities.NullDate()) { if (Request.IsAuthenticated && UserLastAccess == Utilities.NullDate()) { if (ForumUser != null) { DateTime dtLastAccess = DateTime.Now; if (!(ForumUser.Profile.DateLastActivity == Utilities.NullDate())) { dtLastAccess = ForumUser.Profile.DateLastActivity; } UserLastAccess = dtLastAccess; } } if (ForumModuleId < 1) { ForumModuleId = ModuleId; } string ctl = DefaultView; string opts = string.Empty; if (Request.Params[ParamKeys.ViewType] != null) { ctl = Request.Params[ParamKeys.ViewType]; } else if (Request.Params["view"] != null) { ctl = Request.Params["view"]; } else if (Request.Params[ParamKeys.ViewType] == null & ForumId > 0 & TopicId <= 0) { ctl = Views.Topics; } else if (Request.Params[ParamKeys.ViewType] == null && Request.Params["view"] == null & TopicId > 0) { ctl = Views.Topic; } else if (Settings["amafDefaultView"] != null) { ctl = Settings["amafDefaultView"].ToString(); } //ctl = "advanced" // If Not cbLoader.IsCallback Then if (Request.QueryString[ParamKeys.PageJumpId] != null) { opts = "PageId=" + Request.QueryString[ParamKeys.PageJumpId]; } //End If currView = ctl; GetControl(ctl, opts); if (Request.IsAuthenticated) { if (MainSettings.UsersOnlineEnabled) { DataProvider.Instance().Profiles_UpdateActivity(PortalId, ForumModuleId, UserId); } } } else { string ctlPath = "~/DesktopModules/activeforums/controls/_default.ascx"; ForumBase ctlDefault = (ForumBase)(LoadControl(ctlPath)); ctlDefault.ID = "ctlConfig"; ctlDefault.ModuleConfiguration = this.ModuleConfiguration; plhLoader.Controls.Clear(); plhLoader.Controls.Add(ctlDefault); } } catch (Exception ex) { //Response.Write(ex.Message) DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
private void GetControl(string view, string options) { try { if (!Page.IsPostBack) { plhLoader.Controls.Clear(); } ForumBase ctl = null; if (view.ToUpperInvariant() == "FORUMVIEW") { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView()); } else if (view.ToUpperInvariant() == "ADVANCED") { ctl = (ForumBase)(LoadControl("~/desktopmodules/activeforums/advanced.ascx")); } else if ((view.ToUpperInvariant() == Views.Topics.ToUpperInvariant()) || (view.ToUpperInvariant() == "topics".ToUpperInvariant())) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.TopicsView()); } else if ((view.ToUpperInvariant() == Views.Topic.ToUpperInvariant()) || (view.ToUpperInvariant() == "topic".ToUpperInvariant())) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.TopicView()); } else if (view.ToUpperInvariant() == "USERSETTINGS".ToUpperInvariant()) { string ctlPath = string.Empty; ctlPath = "~/DesktopModules/ActiveForums/controls/af_profile.ascx"; if (!(System.IO.File.Exists(Server.MapPath(ctlPath)))) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView()); } else { ctl = (ForumBase)(LoadControl(ctlPath)); } } else { // this is where af_post.ascx is used string ctlPath = string.Empty; ctlPath = "~/DesktopModules/ActiveForums/controls/af_" + view + ".ascx"; if (!(System.IO.File.Exists(Server.MapPath(ctlPath)))) { ctl = (ForumBase)(new DotNetNuke.Modules.ActiveForums.Controls.ForumView()); } else { ctl = (ForumBase)(LoadControl(ctlPath)); } } if (ForumId > 0 & ForumInfo != null) { ctl.ForumInfo = ForumInfo; } ctl.ID = view; ctl.ForumId = ForumId; ctl.ForumModuleId = ForumModuleId; if (ForumTabId == -1) { ForumTabId = TabId; } ctl.ForumTabId = ForumTabId; ctl.ForumGroupId = ForumGroupId; ctl.DefaultForumViewTemplateId = DefaultForumViewTemplateId; ctl.DefaultTopicsViewTemplateId = DefaultTopicsViewTemplateId; ctl.DefaultTopicViewTemplateId = DefaultTopicViewTemplateId; ctl.UseTemplatePath = UseTemplatePath; ctl.TemplatePath = TemplatePath; ctl.ParentForumId = ParentForumId; if (string.IsNullOrEmpty(ForumIds)) { ForumIds = UserForumsList; } if (SocialGroupId > 0) { ForumController fc = new ForumController(); ForumIds = fc.GetForumIdsBySocialGroup(PortalId, SocialGroupId); if (string.IsNullOrEmpty(ForumIds)) { RoleController rc = new RoleController(); RoleInfo role = rc.GetRole(SocialGroupId, PortalId); //Create new forum bool isPrivate = false; if (!role.IsPublic) { isPrivate = true; } Entities.Modules.ModuleController objModules = new Entities.Modules.ModuleController(); Hashtable htSettings = objModules.GetTabModuleSettings(TabModuleId); fc.CreateGroupForum(PortalId, ModuleId, SocialGroupId, Convert.ToInt32(htSettings["ForumGroupTemplate"].ToString()), role.RoleName + " Discussions", role.Description, isPrivate, htSettings["ForumConfig"].ToString()); ForumIds = fc.GetForumIdsBySocialGroup(PortalId, SocialGroupId); } } ctl.ForumIds = ForumIds; ctl.SocialGroupId = SocialGroupId; //ctl.PostID = PostID ctl.ModuleConfiguration = this.ModuleConfiguration; if (!(options == string.Empty)) { ctl.Params = options; } ControlsConfig cc = new ControlsConfig(); cc.AppPath = Page.ResolveUrl("~/DesktopModules/ActiveForums/"); cc.ThemePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MainSettings.Theme + "/"); cc.TemplatePath = cc.ThemePath + "templates/"; cc.SiteId = PortalId; cc.PageId = TabId; cc.InstanceId = ModuleId; cc.User = ForumUser; string authorizedViewRoles = ModuleConfiguration.InheritViewPermissions ? TabPermissionController.GetTabPermissions(TabId, PortalId).ToString("VIEW") : ModuleConfiguration.ModulePermissions.ToString("VIEW"); cc.DefaultViewRoles = Permissions.GetRoleIds(authorizedViewRoles.Split(';'), PortalId); cc.AdminRoles = Permissions.GetRoleIds(this.ModuleConfiguration.ModulePermissions.ToString("EDIT").Split(';'), PortalId); cc.ProfileLink = ""; //GetProfileLink() cc.MembersLink = ""; // GetMembersLink() this.ControlConfig = cc; ctl.ControlConfig = cc; LinkControls(ctl.Controls); if (!(plhLoader.Controls.Contains(ctl))) { plhLoader.Controls.Add(ctl); } string sOut = null; sOut = System.Environment.NewLine + "<!-- © 2004 - 2013 DNN Corp., All Rights Reserved -->" + System.Environment.NewLine; sOut += "<!-- Active Forums 5.0 -->" + System.Environment.NewLine; Literal lit = new Literal(); lit.Text = sOut; plhLoader.Controls.Add(lit); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }