public void RenderMessage(string Title, string Message, string ErrorMsg, Exception ex) { var im = new Controls.InfoMessage { Message = Utilities.GetSharedResource(Message) + "<br />" }; if (ex != null) { im.Message = im.Message + ex.Message; } if (ex != null) { Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// Prepares the post form for creating a reply. /// </summary> private void PrepareReply() { ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.Reply; string template; if (_fi.ReplyFormId == 0) { var myFile = Request.MapPath(Common.Globals.ApplicationPath) + "\\DesktopModules\\ActiveForums\\config\\templates\\ReplyEditor.txt"; template = File.ReadAllText(myFile); } else { var tc = new TemplateController(); var ti = tc.Template_Get(_fi.ReplyFormId, PortalId, ForumModuleId); template = ti.TemplateHTML; } if (MainSettings.UseSkinBreadCrumb) template = template.Replace("<div class=\"afcrumb\">[AF:LINK:FORUMMAIN] > [AF:LINK:FORUMGROUP] > [AF:LINK:FORUMNAME]</div>", string.Empty); ctlForm.Template = template; if (!(TopicId > 0)) { //Can't Find Topic var im = new InfoMessage { Message = GetSharedResource("[RESX:Message:LoadTopicFailed]") }; plhContent.Controls.Add(im); } else if (!CanReply) { //No permission to reply var im = new InfoMessage { Message = GetSharedResource("[RESX:Message:AccessDenied]") }; plhContent.Controls.Add(im); } else { var tc = new TopicsController(); var ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, UserId, true); if(ti == null) Response.Redirect(NavigateUrl(ForumTabId)); ctlForm.Subject = Utilities.GetSharedResource("[RESX:SubjectPrefix]") + " " + ti.Content.Subject; ctlForm.TopicSubject = ti.Content.Subject; var body = string.Empty; if (ti.IsLocked && (CurrentUserType == CurrentUserTypes.Anon || CurrentUserType == CurrentUserTypes.Auth)) Response.Redirect(NavigateUrl(ForumTabId)); if (Request.Params[ParamKeys.QuoteId] != null | Request.Params[ParamKeys.ReplyId] != null | Request.Params[ParamKeys.PostId] != null) { //Setup form for Quote or Reply with body display var isQuote = false; var postId = 0; var sPostedBy = Utilities.GetSharedResource("[RESX:PostedBy]") + " {0} {1} {2}"; if (Request.Params[ParamKeys.QuoteId] != null) { isQuote = true; if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.QuoteId])) postId = Convert.ToInt32(Request.Params[ParamKeys.QuoteId]); } else if (Request.Params[ParamKeys.ReplyId] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.ReplyId])) postId = Convert.ToInt32(Request.Params[ParamKeys.ReplyId]); } else if (Request.Params[ParamKeys.PostId] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.PostId])) postId = Convert.ToInt32(Request.Params[ParamKeys.PostId]); } if (postId != 0) { var userDisplay = MainSettings.UserNameDisplay; if (_editorType == EditorTypes.TEXTBOX) userDisplay = "none"; Content ci; if (postId == TopicId) { ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId); ci = ti.Content; sPostedBy = string.Format(sPostedBy, UserProfiles.GetDisplayName(ForumModuleId, true, false, false, ti.Content.AuthorId, ti.Author.Username, ti.Author.FirstName, ti.Author.LastName, ti.Author.DisplayName), Utilities.GetSharedResource("On.Text"), GetServerDateTime(ti.Content.DateCreated)); } else { var rc = new ReplyController(); var ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, postId); ci = ri.Content; sPostedBy = string.Format(sPostedBy, UserProfiles.GetDisplayName(ForumModuleId, true, false, false, ri.Content.AuthorId, ri.Author.Username, ri.Author.FirstName, ri.Author.LastName, ri.Author.DisplayName), Utilities.GetSharedResource("On.Text"), GetServerDateTime(ri.Content.DateCreated)); } if (ci != null) body = ci.Body; } if (_allowHTML && _editorType != EditorTypes.TEXTBOX) { if (body.ToUpper().Contains("<CODE") | body.ToUpper().Contains("[CODE]")) { var objCode = new CodeParser(); body = CodeParser.ParseCode(Utilities.HTMLDecode(body)); } } else { body = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, body, _allowHTML, _editorType); } if (isQuote) { ctlForm.EditorMode = SubmitForm.EditorModes.Quote; if (_allowHTML && _editorType != EditorTypes.TEXTBOX) { body = "<blockquote>" + System.Environment.NewLine + sPostedBy + System.Environment.NewLine + "<br />" + System.Environment.NewLine + body + System.Environment.NewLine + "</blockquote><br /><br />"; } else { body = "[quote]" + System.Environment.NewLine + sPostedBy + System.Environment.NewLine + body + System.Environment.NewLine + "[/quote]" + System.Environment.NewLine; } } else { ctlForm.EditorMode = SubmitForm.EditorModes.ReplyWithBody; body = sPostedBy + "<br />" + body; } ctlForm.Body = body; } } if (ctlForm.EditorMode != SubmitForm.EditorModes.EditReply && _canModApprove) { ctlForm.ShowModOptions = false; } }
private void LoadTopic() { ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.EditTopic; var tc = new TopicsController(); var ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, UserId, true); if (ti == null) { Response.Redirect(NavigateUrl(ForumTabId)); } else if ((ti.Content.AuthorId != UserId && _canModEdit == false) | (ti.Content.AuthorId == UserId && _canEdit == false) | (_canEdit == false && _canModEdit)) { Response.Redirect(NavigateUrl(ForumTabId)); } else if (!_canModEdit && (ti.Content.AuthorId == UserId && _canEdit && MainSettings.EditInterval > 0 & SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, ti.Content.DateCreated, DateTime.Now) > MainSettings.EditInterval)) { var im = new InfoMessage { Message = "<div class=\"afmessage\">" + string.Format(GetSharedResource("[RESX:Message:EditIntervalReached]"), MainSettings.EditInterval) + "</div>" }; plhMessage.Controls.Add(im); plhContent.Controls.Clear(); } else { //User has acccess var sBody = ti.Content.Body; var sSubject = ti.Content.Subject; sBody = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, sBody, _allowHTML, _editorType); sSubject = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, sSubject, false, EditorTypes.TEXTBOX); ctlForm.Subject = sSubject; ctlForm.Summary = ti.Content.Summary; ctlForm.Body = sBody; ctlForm.AnnounceEnd = ti.AnnounceEnd; ctlForm.AnnounceStart = ti.AnnounceStart; ctlForm.Locked = ti.IsLocked; ctlForm.Pinned = ti.IsPinned; ctlForm.TopicIcon = ti.TopicIcon; ctlForm.Tags = ti.Tags; ctlForm.Categories = ti.Categories; ctlForm.IsApproved = ti.IsApproved; ctlForm.StatusId = ti.StatusId; ctlForm.TopicPriority = ti.Priority; if (ti.Author.AuthorId > 0) ctlForm.Subscribe = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, ti.Author.AuthorId); _contentId = ti.ContentId; _authorId = ti.Author.AuthorId; if (!(string.IsNullOrEmpty(ti.TopicData))) { var pl = new List<PropertiesInfo>(); var xDoc = new XmlDocument(); xDoc.LoadXml(ti.TopicData); XmlNode xRoot = xDoc.DocumentElement; if (xRoot != null) { var xNodeList = xRoot.SelectNodes("//properties/property"); if (xNodeList != null && xNodeList.Count > 0) { for (var i = 0; i < xNodeList.Count; i++) { var pName = Utilities.HTMLDecode(xNodeList[i].ChildNodes[0].InnerText); var pValue = Utilities.HTMLDecode(xNodeList[i].ChildNodes[1].InnerText); var xmlAttributeCollection = xNodeList[i].Attributes; if (xmlAttributeCollection == null) continue; var pId = Convert.ToInt32(xmlAttributeCollection["id"].Value); var p = new PropertiesInfo {Name = pName, DefaultValue = pValue, PropertyId = pId}; pl.Add(p); } } } ctlForm.TopicProperties = pl; } if (ti.TopicType == TopicTypes.Poll) { //Get Poll var ds = DataProvider.Instance().Poll_Get(ti.TopicId); if (ds.Tables.Count > 0) { var pollRow = ds.Tables[0].Rows[0]; ctlForm.PollQuestion = pollRow["Question"].ToString(); ctlForm.PollType = pollRow["PollType"].ToString(); foreach (DataRow dr in ds.Tables[1].Rows) ctlForm.PollOptions += dr["OptionName"] + System.Environment.NewLine; } } if (ti.Content.AuthorId != UserId && _canModApprove) ctlForm.ShowModOptions = true; } }
private void LoadReply() { //Edit a Reply ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.EditReply; var rc = new ReplyController(); var ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, PostId); if (ri == null) Response.Redirect(NavigateUrl(ForumTabId)); else if ((ri.Content.AuthorId != UserId && _canModEdit == false) | (ri.Content.AuthorId == UserId && _canEdit == false) | (_canEdit == false && _canModEdit)) Response.Redirect(NavigateUrl(ForumTabId)); else if (!_canModEdit && (ri.Content.AuthorId == UserId && _canEdit && MainSettings.EditInterval > 0 & SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, ri.Content.DateCreated, DateTime.Now) > MainSettings.EditInterval)) { var im = new Controls.InfoMessage { Message = "<div class=\"afmessage\">" + string.Format(GetSharedResource("[RESX:Message:EditIntervalReached]"), MainSettings.EditInterval.ToString()) + "</div>" }; plhMessage.Controls.Add(im); plhContent.Controls.Clear(); } else { var sBody = ri.Content.Body; var sSubject = ri.Content.Subject; sBody = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, sBody, _allowHTML, _editorType); sSubject = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, sSubject, false, EditorTypes.TEXTBOX); ctlForm.Subject = sSubject; ctlForm.Body = sBody; ctlForm.IsApproved = ri.IsApproved; _contentId = ri.ContentId; _authorId = ri.Author.AuthorId; if (ri.Author.AuthorId > 0) ctlForm.Subscribe = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, ri.Author.AuthorId); if (ri.Content.AuthorId != UserId && _canModApprove) ctlForm.ShowModOptions = true; } }
private void ctlForm_Click(object sender, EventArgs e) { Page.Validate(); var iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { if (ForumUser != null) { if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, ForumUser.Profile.DateLastPost, DateTime.Now) < iFloodInterval) { var im = new InfoMessage { Message = "<div class=\"afmessage\">" + string.Format(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>" }; plhMessage.Controls.Add(im); return; } } } if (!Page.IsValid || !Utilities.InputIsValid(ctlForm.Body.Trim()) || !Utilities.InputIsValid(ctlForm.Subject)) return; if (TopicId == -1 || (TopicId > 0 && Request.Params["action"] == "te")) { if (ValidateProperties()) SaveTopic(); } else { SaveReply(); } }
private void SaveQuickReply() { SettingsInfo ms = DataCache.MainSettings(ForumModuleId); int iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { UserProfileInfo upi = ForumUser.Profile; if (upi != null) { if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval) { Controls.InfoMessage im = new Controls.InfoMessage(); im.Message = "<div class=\"afmessage\">" + string.Format(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>"; plhMessage.Controls.Add(im); return; } } } if (!Request.IsAuthenticated) { if ((!ctlCaptcha.IsValid) || txtUserName.Value == "") { return; } } UserProfileInfo ui = new UserProfileInfo(); if (UserId > 0) { ui = ForumUser.Profile; } else { ui.TopicCount = 0; ui.ReplyCount = 0; ui.RewardPoints = 0; ui.IsMod = false; ui.TrustLevel = -1; } bool UserIsTrusted = false; UserIsTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ui.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles), ForumInfo.AutoTrustLevel, ui.PostCount); bool isApproved = false; isApproved = Convert.ToBoolean(((ForumInfo.IsModerated == true) ? false : true)); if (UserIsTrusted || Permissions.HasPerm(ForumInfo.Security.ModApprove, ForumUser.UserRoles)) { isApproved = true; } ReplyInfo ri = new ReplyInfo(); ReplyController rc = new ReplyController(); int ReplyId = -1; string sUsername = string.Empty; if (Request.IsAuthenticated) { switch (MainSettings.UserNameDisplay.ToUpperInvariant()) { case "USERNAME": sUsername = UserInfo.Username.Trim(' '); break; case "FULLNAME": sUsername = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' '); break; case "FIRSTNAME": sUsername = UserInfo.FirstName.Trim(' '); break; case "LASTNAME": sUsername = UserInfo.LastName.Trim(' '); break; case "DISPLAYNAME": sUsername = UserInfo.DisplayName.Trim(' '); break; default: sUsername = UserInfo.DisplayName; break; } } else { sUsername = Utilities.CleanString(PortalId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, ThemePath, false); } //Dim sSubject As String = Server.HtmlEncode(Request.Form("txtSubject")) //If (UseFilter) Then // sSubject = Utilities.FilterWords(PortalId, ForumModuleId, ThemePath, sSubject) //End If string sBody = string.Empty; if (AllowHTML) { AllowHTML = IsHtmlPermitted(ForumInfo.EditorPermittedUsers, IsTrusted, Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles)); } sBody = Utilities.CleanString(PortalId, Request.Form["txtBody"], AllowHTML, EditorTypes.TEXTBOX, UseFilter, AllowScripts, ForumModuleId, ThemePath, ForumInfo.AllowEmoticons); DateTime createDate = DateTime.Now; ri.TopicId = TopicId; ri.ReplyToId = TopicId; ri.Content.AuthorId = UserId; ri.Content.AuthorName = sUsername; ri.Content.Body = sBody; ri.Content.DateCreated = createDate; ri.Content.DateUpdated = createDate; ri.Content.IsDeleted = false; ri.Content.Subject = Subject; ri.Content.Summary = string.Empty; ri.IsApproved = isApproved; ri.IsDeleted = false; ri.Content.IPAddress = Request.UserHostAddress; ReplyId = rc.Reply_Save(PortalId, ri); //Check if is subscribed string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); // Subscribe or unsubscribe if needed if (AllowSubscribe && UserId > 0) { var subscribe = Request.Params["chkSubscribe"] == "1"; var currentlySubscribed = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, UserId); if (subscribe != currentlySubscribed) { // Will need to update this to support multiple subscrition types later // Subscription_Update works as a toggle, so you only call it if you want to change the value. var sc = new SubscriptionController(); sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, UserId, ForumUser.UserRoles); } } ControlUtils ctlUtils = new ControlUtils(); TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false); string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, -1, ReplyId, SocialGroupId); if (fullURL.Contains("~/") || Request.QueryString["asg"] != null) { fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); } if (fullURL.EndsWith("/")) { fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId; } if (isApproved) { //Send Subscriptions try { //Dim sURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) Subscriptions.SendSubscriptions(PortalId, ForumModuleId, TabId, ForumId, TopicId, ReplyId, UserId); try { Social amas = new Social(); amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then // amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) //Else // amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody) //End If } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } //Redirect to show post Response.Redirect(fullURL, false); } else if (isApproved == false) { List<Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId); NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration"); string subject = Utilities.GetSharedResource("NotificationSubjectReply"); subject = subject.Replace("[DisplayName]", UserInfo.DisplayName); subject = subject.Replace("[TopicSubject]", ti.Content.Subject); string body = Utilities.GetSharedResource("NotificationBodyReply"); body = body.Replace("[Post]", sBody); string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId); Notification notification = new Notification(); notification.NotificationTypeID = notificationType.NotificationTypeId; notification.Subject = subject; notification.Body = body; notification.IncludeDismissAction = false; notification.SenderUserID = UserInfo.UserID; notification.Context = notificationKey; NotificationsController.Instance.SendNotification(notification, PortalId, null, mods); var @params = new List<string> { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId }; if (SocialGroupId > 0) { @params.Add("GroupId=" + SocialGroupId); } Response.Redirect(Utilities.NavigateUrl(TabId, "", @params.ToArray()), false); } else { //Dim fullURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) //If MainSettings.UseShortUrls Then // fullURL = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) //End If try { Social amas = new Social(); amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled Then // amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) //Else // amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody) //End If } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } Response.Redirect(fullURL, false); } //End If }
private void SaveQuickReply() { SettingsInfo ms = DataCache.MainSettings(ForumModuleId); int iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { UserProfileInfo upi = ForumUser.Profile; if (upi != null) { if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval) { Controls.InfoMessage im = new Controls.InfoMessage(); im.Message = "<div class=\"afmessage\">" + string.Format(GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>"; plhMessage.Controls.Add(im); return; } } } if (!Request.IsAuthenticated) { if ((!ctlCaptcha.IsValid) || txtUserName.Value == "") { return; } } UserProfileInfo ui = new UserProfileInfo(); if (UserId > 0) { ui = ForumUser.Profile; } else { ui.TopicCount = 0; ui.ReplyCount = 0; ui.RewardPoints = 0; ui.IsMod = false; ui.TrustLevel = -1; } bool UserIsTrusted = false; UserIsTrusted = Utilities.IsTrusted((int)ForumInfo.DefaultTrustValue, ui.TrustLevel, Permissions.HasPerm(ForumInfo.Security.Trust, ForumUser.UserRoles), ForumInfo.AutoTrustLevel, ui.PostCount); bool isApproved = false; isApproved = Convert.ToBoolean(((ForumInfo.IsModerated == true) ? false : true)); if (UserIsTrusted || Permissions.HasPerm(ForumInfo.Security.ModApprove, ForumUser.UserRoles)) { isApproved = true; } ReplyInfo ri = new ReplyInfo(); ReplyController rc = new ReplyController(); int ReplyId = -1; string sUsername = string.Empty; if (Request.IsAuthenticated) { switch (MainSettings.UserNameDisplay.ToUpperInvariant()) { case "USERNAME": sUsername = UserInfo.Username.Trim(' '); break; case "FULLNAME": sUsername = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' '); break; case "FIRSTNAME": sUsername = UserInfo.FirstName.Trim(' '); break; case "LASTNAME": sUsername = UserInfo.LastName.Trim(' '); break; case "DISPLAYNAME": sUsername = UserInfo.DisplayName.Trim(' '); break; default: sUsername = UserInfo.DisplayName; break; } } else { sUsername = Utilities.CleanString(PortalId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, ThemePath, false); } //Dim sSubject As String = Server.HtmlEncode(Request.Form("txtSubject")) //If (UseFilter) Then // sSubject = Utilities.FilterWords(PortalId, ForumModuleId, ThemePath, sSubject) //End If string sBody = string.Empty; if (AllowHTML) { AllowHTML = IsHtmlPermitted(ForumInfo.EditorPermittedUsers, IsTrusted, Permissions.HasPerm(ForumInfo.Security.ModEdit, ForumUser.UserRoles)); } sBody = Utilities.CleanString(PortalId, Request.Form["txtBody"], AllowHTML, EditorTypes.TEXTBOX, UseFilter, AllowScripts, ForumModuleId, ThemePath, ForumInfo.AllowEmoticons); DateTime createDate = DateTime.Now; ri.TopicId = TopicId; ri.ReplyToId = TopicId; ri.Content.AuthorId = UserId; ri.Content.AuthorName = sUsername; ri.Content.Body = sBody; ri.Content.DateCreated = createDate; ri.Content.DateUpdated = createDate; ri.Content.IsDeleted = false; ri.Content.Subject = Subject; ri.Content.Summary = string.Empty; ri.IsApproved = isApproved; ri.IsDeleted = false; ri.Content.IPAddress = Request.UserHostAddress; ReplyId = rc.Reply_Save(PortalId, ri); //Check if is subscribed string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); // Subscribe or unsubscribe if needed if (AllowSubscribe && UserId > 0) { var subscribe = Request.Params["chkSubscribe"] == "1"; var currentlySubscribed = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, UserId); if (subscribe != currentlySubscribed) { // Will need to update this to support multiple subscrition types later // Subscription_Update works as a toggle, so you only call it if you want to change the value. var sc = new SubscriptionController(); sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, UserId, ForumUser.UserRoles); } } ControlUtils ctlUtils = new ControlUtils(); TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false); string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, -1, ReplyId, SocialGroupId); if (fullURL.Contains("~/") || Request.QueryString["asg"] != null) { fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); } if (fullURL.EndsWith("/")) { fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId; } if (isApproved) { //Send Subscriptions try { //Dim sURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) Subscriptions.SendSubscriptions(PortalId, ForumModuleId, TabId, ForumId, TopicId, ReplyId, UserId); try { Social amas = new Social(); amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled And Not ForumInfo.ActiveSocialTopicsOnly Then // amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) //Else // amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody) //End If } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } //Redirect to show post Response.Redirect(fullURL, false); } else if (isApproved == false) { List <Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId); NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration"); string subject = Utilities.GetSharedResource("NotificationSubjectReply"); subject = subject.Replace("[DisplayName]", UserInfo.DisplayName); subject = subject.Replace("[TopicSubject]", ti.Content.Subject); string body = Utilities.GetSharedResource("NotificationBodyReply"); body = body.Replace("[Post]", sBody); string notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId); Notification notification = new Notification(); notification.NotificationTypeID = notificationType.NotificationTypeId; notification.Subject = subject; notification.Body = body; notification.IncludeDismissAction = false; notification.SenderUserID = UserInfo.UserID; notification.Context = notificationKey; NotificationsController.Instance.SendNotification(notification, PortalId, null, mods); var @params = new List <string> { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId }; if (SocialGroupId > 0) { @params.Add("GroupId=" + SocialGroupId); } Response.Redirect(Utilities.NavigateUrl(TabId, "", @params.ToArray()), false); } else { //Dim fullURL As String = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.ViewType & "=" & Views.Topic, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) //If MainSettings.UseShortUrls Then // fullURL = Utilities.NavigateUrl(TabId, "", New String() {ParamKeys.TopicId & "=" & TopicId, ParamKeys.ContentJumpId & "=" & ReplyId}) //End If try { Social amas = new Social(); amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, string.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); //If Request.QueryString["asg"] Is Nothing And Not String.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey) And ForumInfo.ActiveSocialEnabled Then // amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, TopicId, ReplyId, UserId, fullURL, Subject, String.Empty, sBody, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) //Else // amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumreply", fullURL, Subject, sBody) //End If } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } Response.Redirect(fullURL, false); } //End If }
public void RenderMessage(string Title, string Message, string ErrorMsg, Exception ex) { var im = new Controls.InfoMessage {Message = Utilities.GetSharedResource(Message) + "<br />"}; if (ex != null) { im.Message = im.Message + ex.Message; } if (ex != null) { Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }