public ReplyInfo ApproveReply(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId, int ReplyId) { SettingsInfo ms = DataCache.MainSettings(ModuleId); ForumController fc = new ForumController(); Forum fi = fc.Forums_Get(ForumId, -1, false, true); ReplyController rc = new ReplyController(); ReplyInfo reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId); if (reply == null) { return(null); } reply.IsApproved = true; rc.Reply_Save(PortalId, reply); TopicsController tc = new TopicsController(); tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId, ReplyId); TopicInfo topic = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false); if (fi.ModApproveTemplateId > 0 & reply.Author.AuthorId > 0) { Email oEmail = new Email(); oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, reply.Author); } Subscriptions.SendSubscriptions(PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, reply.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string fullURL = ctlUtils.BuildUrl(TabId, ModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, ForumId, TopicId, topic.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); if (fullURL.Contains("~/")) { fullURL = Utilities.NavigateUrl(TabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); } if (fullURL.EndsWith("/")) { fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId; } Social amas = new Social(); amas.AddReplyToJournal(PortalId, ModuleId, ForumId, TopicId, ReplyId, reply.Author.AuthorId, fullURL, reply.Content.Subject, string.Empty, reply.Content.Body, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } return(reply); }
public ReplyInfo ApproveReply(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId, int ReplyId) { SettingsInfo ms = DataCache.MainSettings(ModuleId); ForumController fc = new ForumController(); Forum fi = fc.Forums_Get(ForumId, -1, false, true); ReplyController rc = new ReplyController(); ReplyInfo reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId); if (reply == null) { return null; } reply.IsApproved = true; rc.Reply_Save(PortalId, reply); TopicsController tc = new TopicsController(); tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId, ReplyId); TopicInfo topic = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false); if (fi.ModApproveTemplateId > 0 & reply.Author.AuthorId > 0) { Email oEmail = new Email(); oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, reply.Author); } Subscriptions.SendSubscriptions(PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, reply.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string fullURL = ctlUtils.BuildUrl(TabId, ModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, ForumId, TopicId, topic.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); if (fullURL.Contains("~/")) { fullURL = Utilities.NavigateUrl(TabId, "", new string[] {ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId}); } if (fullURL.EndsWith("/")) { fullURL += "?" + ParamKeys.ContentJumpId + "=" + ReplyId; } Social amas = new Social(); amas.AddReplyToJournal(PortalId, ModuleId, ForumId, TopicId, ReplyId, reply.Author.AuthorId, fullURL, reply.Content.Subject, string.Empty, reply.Content.Body, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } return reply; }
public TopicInfo ApproveTopic(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId) { SettingsInfo ms = DataCache.MainSettings(ModuleId); ForumController fc = new ForumController(); Forum fi = fc.Forums_Get(ForumId, -1, false, true); TopicsController tc = new TopicsController(); TopicInfo topic = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false); if (topic == null) { return(null); } topic.IsApproved = true; tc.TopicSave(PortalId, topic); tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId); if (fi.ModApproveTemplateId > 0 & topic.Author.AuthorId > 0) { Email oEmail = new Email(); oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ModuleId, TabId, ForumId, TopicId, 0, string.Empty, topic.Author); } Subscriptions.SendSubscriptions(PortalId, ModuleId, TabId, ForumId, TopicId, 0, topic.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string sUrl = ctlUtils.BuildUrl(TabId, ModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, topic.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); Social amas = new Social(); amas.AddTopicToJournal(PortalId, ModuleId, ForumId, TopicId, topic.Author.AuthorId, sUrl, topic.Content.Subject, string.Empty, topic.Content.Body, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } return(topic); }
private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { SettingsInfo ms = DataCache.MainSettings(ForumModuleId); Forum fi = null; if (e.Parameters.Length > 0) { if (ForumId < 1) { SetPermissions(Convert.ToInt32(e.Parameters[1])); ForumController fc = new ForumController(); fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true); } else { fi = ForumInfo; } switch (e.Parameters[0].ToLowerInvariant()) { case "moddel": { if (bModDelete) { int delAction = ms.DeleteBehavior; int tmpForumId = -1; int tmpTopicId = -1; int tmpReplyId = -1; tmpForumId = Convert.ToInt32(e.Parameters[1]); tmpTopicId = Convert.ToInt32(e.Parameters[2]); tmpReplyId = Convert.ToInt32(e.Parameters[3]); Author auth = null; if (fi.ModDeleteTemplateId > 0) { try { //Email.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth); Email.SendEmailToModerators(fi.ModDeleteTemplateId, PortalId, tmpForumId, tmpTopicId, tmpReplyId, ForumModuleId, ForumTabId, string.Empty); } catch (Exception ex) { } } if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0) { TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId); if (ti != null) { auth = ti.Author; } tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction); } else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0) { ReplyController rc = new ReplyController(); ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId); if (ri != null) { auth = ri.Author; } rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction); } } break; } case "modreject": { int tmpForumId = 0; int tmpTopicId = 0; int tmpReplyId = 0; int tmpAuthorId = 0; tmpForumId = Convert.ToInt32(e.Parameters[1]); tmpTopicId = Convert.ToInt32(e.Parameters[2]); tmpReplyId = Convert.ToInt32(e.Parameters[3]); tmpAuthorId = Convert.ToInt32(e.Parameters[4]); ModController mc = new ModController(); mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId); if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0) { DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController(); DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, tmpAuthorId); if (ui != null) { Author au = new Author(); au.AuthorId = tmpAuthorId; au.DisplayName = ui.DisplayName; au.Email = ui.Email; au.FirstName = ui.FirstName; au.LastName = ui.LastName; au.Username = ui.Username; Email.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au); } } break; } case "modappr": { int tmpForumId = -1; int tmpTopicId = -1; int tmpReplyId = -1; tmpForumId = Convert.ToInt32(e.Parameters[1]); tmpTopicId = Convert.ToInt32(e.Parameters[2]); tmpReplyId = Convert.ToInt32(e.Parameters[3]); string sSubject = string.Empty; string sBody = string.Empty; if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0) { TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false); if (ti != null) { sSubject = ti.Content.Subject; sBody = ti.Content.Body; ti.IsApproved = true; tc.TopicSave(PortalId, ti); tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId); //TODO: Add Audit log for who approved topic if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0) { Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author); } Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string sUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId) if (sUrl.Contains("~/") || Request.QueryString["asg"] != null) { sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId); } Social amas = new Social(); if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled) { amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId); } else { amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } } else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0) { ReplyController rc = new ReplyController(); ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId); if (ri != null) { ri.IsApproved = true; sSubject = ri.Content.Subject; sBody = ri.Content.Body; rc.Reply_Save(PortalId, ri); TopicsController tc = new TopicsController(); tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false); //TODO: Add Audit log for who approved topic if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0) { Email.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author); } Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, fi.SocialGroupId); if (fullURL.Contains("~/") || Request.QueryString["asg"] != null) { fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId }); } Social amas = new Social(); if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly) { amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId); } else { amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } } break; } } string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); } BuildModList(); litTopics.RenderControl(e.Output); }
private void SaveTopic() { var subject = ctlForm.Subject; var body = ctlForm.Body; subject = Utilities.CleanString(PortalId, subject, false, EditorTypes.TEXTBOX, ForumInfo.UseFilter, false, ForumModuleId, _themePath, false); body = Utilities.CleanString(PortalId, body, _allowHTML, _editorType, ForumInfo.UseFilter, ForumInfo.AllowScript, ForumModuleId, _themePath, ForumInfo.AllowEmoticons); var summary = ctlForm.Summary; int authorId; string authorName; if (Request.IsAuthenticated) { authorId = UserInfo.UserID; switch (MainSettings.UserNameDisplay.ToUpperInvariant()) { case "USERNAME": authorName = UserInfo.Username.Trim(' '); break; case "FULLNAME": authorName = Convert.ToString(UserInfo.FirstName + " " + UserInfo.LastName).Trim(' '); break; case "FIRSTNAME": authorName = UserInfo.FirstName.Trim(' '); break; case "LASTNAME": authorName = UserInfo.LastName.Trim(' '); break; case "DISPLAYNAME": authorName = UserInfo.DisplayName.Trim(' '); break; default: authorName = UserInfo.DisplayName; break; } } else { authorId = -1; authorName = Utilities.CleanString(PortalId, ctlForm.AuthorName, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, _themePath, false); if (authorName.Trim() == string.Empty) return; } var tc = new TopicsController(); TopicInfo ti; if (TopicId > 0) { ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId); ti.Content.DateUpdated = DateTime.Now; authorId = ti.Author.AuthorId; } else { ti = new TopicInfo(); var dt = DateTime.Now; ti.Content.DateCreated = dt; ti.Content.DateUpdated = dt; } ti.AnnounceEnd = ctlForm.AnnounceEnd; ti.AnnounceStart = ctlForm.AnnounceStart; ti.Priority = ctlForm.TopicPriority; if (!_isEdit) { ti.Content.AuthorId = authorId; ti.Content.AuthorName = authorName; ti.Content.IPAddress = Request.UserHostAddress; } if (Regex.IsMatch(body, "<CODE([^>]*)>", RegexOptions.IgnoreCase)) { foreach (Match m in Regex.Matches(body, "<CODE([^>]*)>(.*?)</CODE>", RegexOptions.IgnoreCase)) body = body.Replace(m.Value, m.Value.Replace("<br>", System.Environment.NewLine)); } if (!(string.IsNullOrEmpty(ForumInfo.PrefixURL))) { var cleanSubject = Utilities.CleanName(subject).ToLowerInvariant(); if (SimulateIsNumeric.IsNumeric(cleanSubject)) cleanSubject = "Topic-" + cleanSubject; var topicUrl = cleanSubject; var urlPrefix = "/"; if (!(string.IsNullOrEmpty(ForumInfo.ForumGroup.PrefixURL))) urlPrefix += ForumInfo.ForumGroup.PrefixURL + "/"; if (!(string.IsNullOrEmpty(ForumInfo.PrefixURL))) urlPrefix += ForumInfo.PrefixURL + "/"; var urlToCheck = urlPrefix + cleanSubject; var topicsDb = new Data.Topics(); for (var u = 0; u <= 200; u++) { var tid = topicsDb.TopicIdByUrl(PortalId, ModuleId, urlToCheck); if (tid > 0 && tid == TopicId) break; if (tid <= 0) break; topicUrl = (u + 1) + "-" + cleanSubject; urlToCheck = urlPrefix + topicUrl; } if (topicUrl.Length > 150) { topicUrl = topicUrl.Substring(0, 149); topicUrl = topicUrl.Substring(0, topicUrl.LastIndexOf("-", StringComparison.Ordinal)); } ti.TopicUrl = topicUrl; } else { //.URL = String.Empty ti.TopicUrl = string.Empty; } ti.Content.Body = body; //Utilities.CleanString(PortalId, Body, fi.AllowHTML, fi.EditorType, fi.UseFilter, fi.AllowScript, ForumModuleId, String.Empty) ti.Content.Subject = subject; ti.Content.Summary = summary; ti.IsAnnounce = ti.AnnounceEnd != Utilities.NullDate() && ti.AnnounceStart != Utilities.NullDate(); if (_canModApprove && _fi.IsModerated) ti.IsApproved = ctlForm.IsApproved; else ti.IsApproved = _isApproved; bool bSend = ti.IsApproved; ti.IsArchived = false; ti.IsDeleted = false; ti.IsLocked = _canLock && ctlForm.Locked; ti.IsPinned = _canPin && ctlForm.Pinned; ti.StatusId = ctlForm.StatusId; ti.TopicIcon = ctlForm.TopicIcon; ti.TopicType = 0; if (ForumInfo.Properties != null) { var tData = new StringBuilder(); tData.Append("<topicdata>"); tData.Append("<properties>"); foreach (var p in ForumInfo.Properties) { var pkey = "afprop-" + p.PropertyId.ToString(); tData.Append("<property id=\"" + p.PropertyId.ToString() + "\">"); tData.Append("<name><![CDATA["); tData.Append(p.Name); tData.Append("]]></name>"); if (Request.Form[pkey] != null) { tData.Append("<value><![CDATA["); tData.Append(Utilities.XSSFilter(Request.Form[pkey])); tData.Append("]]></value>"); } else { tData.Append("<value></value>"); } tData.Append("</property>"); } tData.Append("</properties>"); tData.Append("</topicdata>"); ti.TopicData = tData.ToString(); } TopicId = tc.TopicSave(PortalId, ti); ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false); if (ti != null) { tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId); SaveAttachments(ti.ContentId); if (ti.IsApproved && ti.Author.AuthorId > 0) { var uc = new Data.Profiles(); uc.Profile_UpdateTopicCount(PortalId, ti.Author.AuthorId); } } if (Permissions.HasPerm(ForumInfo.Security.Tag, ForumUser.UserRoles)) { DataProvider.Instance().Tags_DeleteByTopicId(PortalId, ForumModuleId, TopicId); var tagForm = string.Empty; if (Request.Form["txtTags"] != null) tagForm = Request.Form["txtTags"]; if (tagForm != string.Empty) { var tags = tagForm.Split(','); foreach (var tag in tags) { var sTag = Utilities.CleanString(PortalId, tag.Trim(), false, EditorTypes.TEXTBOX, false, false, ForumModuleId, string.Empty, false); DataProvider.Instance().Tags_Save(PortalId, ForumModuleId, -1, sTag, 0, 1, 0, TopicId, false, -1, -1); } } } if (Permissions.HasPerm(ForumInfo.Security.Categorize, ForumUser.UserRoles)) { if (Request.Form["amaf-catselect"] != null) { var cats = Request.Form["amaf-catselect"].Split(';'); DataProvider.Instance().Tags_DeleteTopicToCategory(PortalId, ForumModuleId, -1, TopicId); foreach (var c in cats) { if (string.IsNullOrEmpty(c) || !SimulateIsNumeric.IsNumeric(c)) continue; var cid = Convert.ToInt32(c); if (cid > 0) DataProvider.Instance().Tags_AddTopicToCategory(PortalId, ForumModuleId, cid, TopicId); } } } if (!String.IsNullOrEmpty(ctlForm.PollQuestion) && !String.IsNullOrEmpty(ctlForm.PollOptions)) { //var sPollQ = ctlForm.PollQuestion.Trim(); //sPollQ = Utilities.CleanString(PortalId, sPollQ, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, string.Empty, false); var pollId = DataProvider.Instance().Poll_Save(-1, TopicId, UserId, ctlForm.PollQuestion.Trim(), ctlForm.PollType); if (pollId > 0) { var options = ctlForm.PollOptions.Split(new[] { System.Environment.NewLine }, StringSplitOptions.None); foreach (string opt in options) { if (opt.Trim() != string.Empty) { var value = Utilities.CleanString(PortalId, opt, false, EditorTypes.TEXTBOX, true, false, ForumModuleId, string.Empty, false); DataProvider.Instance().Poll_Option_Save(-1, pollId, value.Trim(), TopicId); } } } ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, -1, false); ti.TopicType = TopicTypes.Poll; tc.TopicSave(PortalId, ti); } try { var cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); if (ctlForm.Subscribe && authorId == UserId) { if (!(Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, authorId))) { var sc = new SubscriptionController(); sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, authorId, ForumUser.UserRoles); } } else if (_isEdit) { bool isSub = Subscriptions.IsSubscribed(PortalId, ForumModuleId, ForumId, TopicId, SubscriptionTypes.Instant, authorId); if (isSub && !ctlForm.Subscribe) { var sc = new SubscriptionController(); sc.Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, authorId, ForumUser.UserRoles); } } if (bSend && !_isEdit) Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, _fi, TopicId, 0, ti.Content.AuthorId); if (ti.IsApproved == false) { var mods = Utilities.GetListOfModerators(PortalId, ForumId); var notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration"); var notifySubject = Utilities.GetSharedResource("NotificationSubjectTopic"); notifySubject = notifySubject.Replace("[DisplayName]", UserInfo.DisplayName); notifySubject = notifySubject.Replace("[TopicSubject]", ti.Content.Subject); var notifyBody = Utilities.GetSharedResource("NotificationBodyTopic"); notifyBody = notifyBody.Replace("[Post]", ti.Content.Body); var notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", TabId, ForumModuleId, ForumId, TopicId, ReplyId); var notification = new Notification { NotificationTypeID = notificationType.NotificationTypeId, Subject = notifySubject, Body = notifyBody, IncludeDismissAction = false, SenderUserID = UserInfo.UserID, Context = notificationKey }; NotificationsController.Instance.SendNotification(notification, PortalId, null, mods); string[] @params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.MessagePending }; Response.Redirect(NavigateUrl(ForumTabId, "", @params), false); } else { if (ti != null) ti.TopicId = TopicId; var ctlUtils = new ControlUtils(); var sUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, SocialGroupId); if (sUrl.Contains("~/") || Request.QueryString["asg"] != null) sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId); if (!_isEdit) { try { var amas = new Social(); amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, TopicId, UserId, sUrl, subject, summary, body, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read, SocialGroupId); if (Request.QueryString["asg"] == null && !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && ForumInfo.ActiveSocialEnabled) { // amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, UserId, sUrl, Subject, Summary, Body, ForumInfo.ActiveSocialSecurityOption, ForumInfo.Security.Read) } else { amas.AddForumItemToJournal(PortalId, ForumModuleId, UserId, "forumtopic", sUrl, subject, body); } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); } } Response.Redirect(sUrl, false); } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); } }
private XmlRpcStruct NewTopic(int forumId, string subject, string body, string prefixId, IEnumerable<string> attachmentIds, string groupId) { var aftContext = ActiveForumsTapatalkModuleContext.Create(Context); Context.Response.AddHeader("Mobiquo_is_login", aftContext.UserId > 0 ? "true" : "false"); var portalId = aftContext.Module.PortalID; var forumModuleId = aftContext.ModuleSettings.ForumModuleId; var fc = new AFTForumController(); var forumInfo = fc.GetForum(portalId, forumModuleId, forumId); // Verify Post Permissions if (!ActiveForums.Permissions.HasPerm(forumInfo.Security.Create, aftContext.ForumUser.UserRoles)) { return new XmlRpcStruct { {"result", "false"}, //"true" for success {"result_text", "Not Authorized to Post".ToBytes()}, }; } // Build User Permissions var canModApprove = ActiveForums.Permissions.HasPerm(forumInfo.Security.ModApprove, aftContext.ForumUser.UserRoles); var canTrust = ActiveForums.Permissions.HasPerm(forumInfo.Security.Trust, aftContext.ForumUser.UserRoles); var userProfile = aftContext.UserId > 0 ? aftContext.ForumUser.Profile : new UserProfileInfo { TrustLevel = -1 }; var userIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, userProfile.TrustLevel, canTrust, forumInfo.AutoTrustLevel, userProfile.PostCount); // Determine if the post should be approved var isApproved = !forumInfo.IsModerated || userIsTrusted || canModApprove; var mainSettings = new SettingsInfo { MainSettings = new Entities.Modules.ModuleController().GetModuleSettings(forumModuleId) }; var dnnUser = Entities.Users.UserController.GetUserById(portalId, aftContext.UserId); var authorName = GetAuthorName(mainSettings, dnnUser); var themePath = string.Format("{0}://{1}{2}", Context.Request.Url.Scheme, Context.Request.Url.Host, VirtualPathUtility.ToAbsolute("~/DesktopModules/activeforums/themes/" + mainSettings.Theme + "/")); subject = Utilities.CleanString(portalId, subject, false, EditorTypes.TEXTBOX, forumInfo.UseFilter, false, forumModuleId, themePath, false); body = Utilities.CleanString(portalId, TapatalkToHtml(body), forumInfo.AllowHTML, EditorTypes.HTMLEDITORPROVIDER, forumInfo.UseFilter, false, forumModuleId, themePath, forumInfo.AllowEmoticons); // Create the topic var ti = new TopicInfo(); var dt = DateTime.Now; ti.Content.DateCreated = dt; ti.Content.DateUpdated = dt; ti.Content.AuthorId = aftContext.UserId; ti.Content.AuthorName = authorName; ti.Content.IPAddress = Context.Request.UserHostAddress; ti.TopicUrl = string.Empty; ti.Content.Body = body; ti.Content.Subject = subject; ti.Content.Summary = string.Empty; ti.IsAnnounce = false; ti.IsPinned = false; ti.IsLocked = false; ti.IsDeleted = false; ti.IsArchived = false; ti.StatusId = -1; ti.TopicIcon = string.Empty; ti.TopicType = 0; ti.IsApproved = isApproved; // Save the topic var tc = new TopicsController(); var topicId = tc.TopicSave(portalId, ti); ti = tc.Topics_Get(portalId, forumModuleId, topicId, forumId, -1, false); if (ti == null) { return new XmlRpcStruct { {"result", "false"}, //"true" for success {"result_text", "Error Creating Post".ToBytes()}, }; } // Update stats tc.Topics_SaveToForum(forumId, topicId, portalId, forumModuleId); if (ti.IsApproved && ti.Author.AuthorId > 0) { var uc = new ActiveForums.Data.Profiles(); uc.Profile_UpdateTopicCount(portalId, ti.Author.AuthorId); } try { // Clear the cache var cachekey = string.Format("AF-FV-{0}-{1}", portalId, forumModuleId); DataCache.CacheClearPrefix(cachekey); // Subscribe the user if they have auto-subscribe set. if (userProfile.PrefSubscriptionType != SubscriptionTypes.Disabled && !(Subscriptions.IsSubscribed(portalId, forumModuleId, forumId, topicId, SubscriptionTypes.Instant, aftContext.UserId))) { new SubscriptionController().Subscription_Update(portalId, forumModuleId, forumId, topicId, (int)userProfile.PrefSubscriptionType, aftContext.UserId, aftContext.ForumUser.UserRoles); } if (isApproved) { // Send User Notifications Subscriptions.SendSubscriptions(portalId, forumModuleId, aftContext.ModuleSettings.ForumTabId, forumInfo, topicId, 0, ti.Content.AuthorId); // Add Journal entry var forumTabId = aftContext.ModuleSettings.ForumTabId; var fullURL = new ControlUtils().BuildUrl(forumTabId, forumModuleId, forumInfo.ForumGroup.PrefixURL, forumInfo.PrefixURL, forumInfo.ForumGroupId, forumInfo.ForumID, topicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, forumInfo.SocialGroupId); new Social().AddTopicToJournal(portalId, forumModuleId, forumId, topicId, ti.Author.AuthorId, fullURL, ti.Content.Subject, string.Empty, ti.Content.Body, forumInfo.ActiveSocialSecurityOption, forumInfo.Security.Read, forumInfo.SocialGroupId); } else { // Send Mod Notifications var mods = Utilities.GetListOfModerators(portalId, forumId); var notificationType = NotificationsController.Instance.GetNotificationType("AF-ForumModeration"); var notifySubject = Utilities.GetSharedResource("NotificationSubjectTopic"); notifySubject = notifySubject.Replace("[DisplayName]", dnnUser.DisplayName); notifySubject = notifySubject.Replace("[TopicSubject]", ti.Content.Subject); var notifyBody = Utilities.GetSharedResource("NotificationBodyTopic"); notifyBody = notifyBody.Replace("[Post]", ti.Content.Body); var notificationKey = string.Format("{0}:{1}:{2}:{3}:{4}", aftContext.ModuleSettings.ForumTabId, forumModuleId, forumId, topicId, 0); var notification = new Notification { NotificationTypeID = notificationType.NotificationTypeId, Subject = notifySubject, Body = notifyBody, IncludeDismissAction = false, SenderUserID = dnnUser.UserID, Context = notificationKey }; NotificationsController.Instance.SendNotification(notification, portalId, null, mods); } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); } var result = new XmlRpcStruct { {"result", true}, //"true" for success // {"result_text", "OK".ToBytes()}, {"topic_id", ti.TopicId.ToString()}, }; if (!isApproved) result.Add("state", 1); return result; }
public TopicInfo ApproveTopic(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId) { SettingsInfo ms = DataCache.MainSettings(ModuleId); ForumController fc = new ForumController(); Forum fi = fc.Forums_Get(ForumId, -1, false, true); TopicsController tc = new TopicsController(); TopicInfo topic = tc.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false); if (topic == null) { return null; } topic.IsApproved = true; tc.TopicSave(PortalId, topic); tc.Topics_SaveToForum(ForumId, TopicId, PortalId, ModuleId); if (fi.ModApproveTemplateId > 0 & topic.Author.AuthorId > 0) { Email oEmail = new Email(); oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ModuleId, TabId, ForumId, TopicId, 0, string.Empty, topic.Author); } Subscriptions.SendSubscriptions(PortalId, ModuleId, TabId, ForumId, TopicId, 0, topic.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string sUrl = ctlUtils.BuildUrl(TabId, ModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, topic.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); Social amas = new Social(); amas.AddTopicToJournal(PortalId, ModuleId, ForumId, TopicId, topic.Author.AuthorId, sUrl, topic.Content.Subject, string.Empty, topic.Content.Body, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } return topic; }
private void cbMod_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { SettingsInfo ms = DataCache.MainSettings(ForumModuleId); Forum fi = null; if (e.Parameters.Length > 0) { if (ForumId < 1) { SetPermissions(Convert.ToInt32(e.Parameters[1])); ForumController fc = new ForumController(); fi = fc.Forums_Get(Convert.ToInt32(e.Parameters[1]), -1, false, true); } else { fi = ForumInfo; } switch (e.Parameters[0].ToLowerInvariant()) { case "moddel": { if (bModDelete) { int delAction = ms.DeleteBehavior; int tmpForumId = -1; int tmpTopicId = -1; int tmpReplyId = -1; tmpForumId = Convert.ToInt32(e.Parameters[1]); tmpTopicId = Convert.ToInt32(e.Parameters[2]); tmpReplyId = Convert.ToInt32(e.Parameters[3]); Author auth = null; if (fi.ModDeleteTemplateId > 0) { try { Email oEmail = new Email(); oEmail.SendEmail(fi.ModDeleteTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, auth); } catch (Exception ex) { } } if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0) { TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId); if (ti != null) { auth = ti.Author; } tc.Topics_Delete(PortalId, ModuleId, tmpForumId, tmpTopicId, delAction); } else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0) { ReplyController rc = new ReplyController(); ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId); if (ri != null) { auth = ri.Author; } rc.Reply_Delete(PortalId, tmpForumId, tmpTopicId, tmpReplyId, delAction); } } break; } case "modreject": { int tmpForumId = 0; int tmpTopicId = 0; int tmpReplyId = 0; int tmpAuthorId = 0; tmpForumId = Convert.ToInt32(e.Parameters[1]); tmpTopicId = Convert.ToInt32(e.Parameters[2]); tmpReplyId = Convert.ToInt32(e.Parameters[3]); tmpAuthorId = Convert.ToInt32(e.Parameters[4]); ModController mc = new ModController(); mc.Mod_Reject(PortalId, ForumModuleId, UserId, tmpForumId, tmpTopicId, tmpReplyId); if (fi.ModRejectTemplateId > 0 & tmpAuthorId > 0) { DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController(); DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, tmpAuthorId); if (ui != null) { Author au = new Author(); au.AuthorId = tmpAuthorId; au.DisplayName = ui.DisplayName; au.Email = ui.Email; au.FirstName = ui.FirstName; au.LastName = ui.LastName; au.Username = ui.Username; Email oEmail = new Email(); oEmail.SendEmail(fi.ModRejectTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, au); } } break; } case "modappr": { int tmpForumId = -1; int tmpTopicId = -1; int tmpReplyId = -1; tmpForumId = Convert.ToInt32(e.Parameters[1]); tmpTopicId = Convert.ToInt32(e.Parameters[2]); tmpReplyId = Convert.ToInt32(e.Parameters[3]); string sSubject = string.Empty; string sBody = string.Empty; if (tmpForumId > 0 & tmpTopicId > 0 && tmpReplyId == 0) { TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false); if (ti != null) { sSubject = ti.Content.Subject; sBody = ti.Content.Body; ti.IsApproved = true; tc.TopicSave(PortalId, ti); tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId); //TODO: Add Audit log for who approved topic if (fi.ModApproveTemplateId > 0 & ti.Author.AuthorId > 0) { Email oEmail = new Email(); oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ti.Author); } Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, 0, ti.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string sUrl = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); // Utilities.NavigateUrl(ForumTabId, "", ParamKeys.ViewType & "=" & Views.Topic & "&" & ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId) if (sUrl.Contains("~/") || Request.QueryString["asg"] != null) { sUrl = Utilities.NavigateUrl(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId); } Social amas = new Social(); if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled) { amas.AddTopicToJournal(PortalId, ForumModuleId, ForumId, ti.TopicId, ti.Author.AuthorId, sUrl, sSubject, ti.Content.Summary, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, SocialGroupId); } else { amas.AddForumItemToJournal(PortalId, ForumModuleId, ti.Author.AuthorId, "forumtopic", sUrl, sSubject, sBody); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } } else if (tmpForumId > 0 & tmpTopicId > 0 & tmpReplyId > 0) { ReplyController rc = new ReplyController(); ReplyInfo ri = rc.Reply_Get(PortalId, ForumModuleId, tmpTopicId, tmpReplyId); if (ri != null) { ri.IsApproved = true; sSubject = ri.Content.Subject; sBody = ri.Content.Body; rc.Reply_Save(PortalId, ri); TopicsController tc = new TopicsController(); tc.Topics_SaveToForum(tmpForumId, tmpTopicId, PortalId, ModuleId, tmpReplyId); TopicInfo ti = tc.Topics_Get(PortalId, ForumModuleId, tmpTopicId, tmpForumId, -1, false); //TODO: Add Audit log for who approved topic if (fi.ModApproveTemplateId > 0 & ri.Author.AuthorId > 0) { Email oEmail = new Email(); oEmail.SendEmail(fi.ModApproveTemplateId, PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, string.Empty, ri.Author); } Subscriptions.SendSubscriptions(PortalId, ForumModuleId, ForumTabId, tmpForumId, tmpTopicId, tmpReplyId, ri.Content.AuthorId); try { ControlUtils ctlUtils = new ControlUtils(); string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, fi.ForumGroup.PrefixURL, fi.PrefixURL, fi.ForumGroupId, fi.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, fi.SocialGroupId); if (fullURL.Contains("~/") || Request.QueryString["asg"] != null) { fullURL = Utilities.NavigateUrl(ForumTabId, "", new string[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId }); } Social amas = new Social(); if (Request.QueryString["asg"] == null & !(string.IsNullOrEmpty(MainSettings.ActiveSocialTopicsKey)) && fi.ActiveSocialEnabled && !fi.ActiveSocialTopicsOnly) { amas.AddReplyToJournal(PortalId, ForumModuleId, ForumId, ri.TopicId, ri.ReplyId, ri.Author.AuthorId, fullURL, ri.Content.Subject, string.Empty, sBody, fi.ActiveSocialSecurityOption, fi.Security.Read, fi.SocialGroupId); } else { amas.AddForumItemToJournal(PortalId, ForumModuleId, ri.Author.AuthorId, "forumreply", fullURL, sSubject, sBody); } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } } } break; } } string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); } BuildModList(); litTopics.RenderControl(e.Output); }