private void LinkControls(ControlCollection ctrls) { foreach (Control ctrl in ctrls) { switch (ctrl.ID) { case "plhProfileAdminSettings": plhProfileAdminSettings = (PlaceHolder)ctrl; break; case "plhProfilePrefs": plhProfilePrefs = (PlaceHolder)ctrl; break; case "plhProfileUserAccount": plhProfileUserAccount = (PlaceHolder)ctrl; break; case "plhTracker": plhTracker = (PlaceHolder)ctrl; break; case "plhProfileEditButton": plhProfileEditButton = (PlaceHolder)ctrl; break; case "plhProfileSaveButton": plhProfileSaveButton = (PlaceHolder)ctrl; break; case "plhProfileCancelButton": plhProfileCancelButton = (PlaceHolder)ctrl; break; case "txtWebSite": txtWebSite = (TextBox)ctrl; break; case "txtOccupation": txtOccupation = (TextBox)ctrl; break; case "txtLocation": txtLocation = (TextBox)ctrl; break; case "txtInterests": txtInterests = (TextBox)ctrl; break; case "trAvatarLinks": trAvatarLinks = (System.Web.UI.HtmlControls.HtmlTableRow)ctrl; break; case "tblAvatars": tblAvatars = (System.Web.UI.HtmlControls.HtmlTable)ctrl; break; case "txtYahoo": txtYahoo = (TextBox)ctrl; break; case "txtMSN": txtMSN = (TextBox)ctrl; break; case "txtICQ": txtICQ = (TextBox)ctrl; break; case "txtAOL": txtAOL = (TextBox)ctrl; break; case "txtSignature": txtSignature = (TextBox)ctrl; break; case "btnProfileEdit": btnProfileEdit = (ImageButton)ctrl; break; case "btnProfileCancel": btnProfileCancel = (ImageButton)ctrl; break; case "btnProfileSave": btnProfileSave = (ImageButton)ctrl; break; case "lblAvatarError": lblAvatarError = (Label)ctrl; break; } if (ctrl.Controls.Count > 0) { LinkControls(ctrl.Controls); } } }
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; } } } }