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 static void SendEmail(int templateId, int portalId, int moduleId, int tabId, int forumId, int topicId, int replyId, string comments, Author author) { var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]); var mainSettings = DataCache.MainSettings(moduleId); var sTemplate = string.Empty; var tc = new TemplateController(); var ti = tc.Template_Get(templateId, portalId, moduleId); var subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, portalSettings.TimeZoneOffset); var bodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, portalSettings.TimeZoneOffset); var bodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, portalSettings.TimeZoneOffset); bodyText = bodyText.Replace("[REASON]", comments); bodyHTML = bodyHTML.Replace("[REASON]", comments); var fc = new ForumController(); var fi = fc.Forums_Get(forumId, -1, false, true); var sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : portalSettings.Email; //Send now var oEmail = new Email(); var subs = new List<SubscriptionInfo>(); var si = new SubscriptionInfo { DisplayName = author.DisplayName, Email = author.Email, FirstName = author.FirstName, LastName = author.LastName, UserId = author.AuthorId, Username = author.Username }; subs.Add(si); oEmail.UseQueue = mainSettings.MailQueue; oEmail.Recipients = subs; oEmail.Subject = subject; oEmail.From = sFrom; oEmail.BodyText = bodyText; oEmail.BodyHTML = bodyHTML; new Thread(oEmail.Send).Start(); }
private void btnSend_Click(object sender, System.EventArgs e) { if (Request.IsAuthenticated) { Email objEmail = new Email(); string Comments = null; Comments = drpReasons.SelectedItem.Value + "<br>"; Comments += Utilities.CleanString(PortalId, txtComments.Text, false, EditorTypes.TEXTBOX, false, false, ModuleId, string.Empty, false); int templateId = 0; TemplateController tc = new TemplateController(); TemplateInfo ti = tc.Template_Get("ModAlert", PortalId, ModuleId); string sUrl = NavigateUrl(Convert.ToInt32(Request.QueryString["TabId"]), "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.AlertSent }); NotificationType notificationType = NotificationsController.Instance.GetNotificationType("AF-ContentAlert"); TopicsController topicController = new TopicsController(); TopicInfo topic = topicController.Topics_Get(PortalId, ModuleId, TopicId, ForumId, -1, false); string sBody = string.Empty; string authorName = string.Empty; string sSubject = string.Empty; string sTopicURL = string.Empty; sTopicURL = topic.TopicUrl; if (ReplyId > 0 & TopicId != ReplyId) { ReplyController rc = new ReplyController(); ReplyInfo reply = rc.Reply_Get(PortalId, ModuleId, TopicId, ReplyId); sBody = reply.Content.Body; sSubject = reply.Content.Subject; authorName = reply.Author.DisplayName; } else { sBody = topic.Content.Body; sSubject = topic.Content.Subject; authorName = topic.Author.DisplayName; } ControlUtils ctlUtils = new ControlUtils(); string fullURL = ctlUtils.BuildUrl(ForumTabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, sTopicURL, -1, -1, string.Empty, 1, ReplyId, SocialGroupId); string subject = Utilities.GetSharedResource("AlertSubject"); subject = subject.Replace("[DisplayName]", authorName); subject = subject.Replace("[Subject]", sSubject); string body = Utilities.GetSharedResource("AlertBody"); body = body.Replace("[Post]", sBody); body = body.Replace("[Comment]", Comments); body = body.Replace("[URL]", fullURL); body = body.Replace("[Reason]", drpReasons.SelectedItem.Value); List<Entities.Users.UserInfo> mods = Utilities.GetListOfModerators(PortalId, ForumId); 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); Response.Redirect(sUrl); } }
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; }
public static void SendSubscriptions(int TemplateId, int PortalId, int ModuleId, int TabId, Forum fi, int TopicId, int ReplyId, int AuthorId) { var _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]); SettingsInfo MainSettings = DataCache.MainSettings(ModuleId); var sc = new SubscriptionController(); List<SubscriptionInfo> subs = sc.Subscription_GetSubscribers(PortalId, fi.ForumID, TopicId, SubscriptionTypes.Instant, AuthorId, fi.Security.Subscribe); if (subs.Count <= 0) { return; } string Subject; string BodyText; string BodyHTML; string sTemplate = string.Empty; var tc = new TemplateController(); TemplateInfo ti; ti = TemplateId > 0 ? tc.Template_Get(TemplateId) : tc.Template_Get("SubscribedEmail", PortalId, ModuleId); TemplateUtils.lstSubscriptionInfo = subs; Subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset); BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset); BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, _portalSettings.TimeZoneOffset); string sFrom; sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email; var oEmail = new Email { Recipients = subs, Subject = Subject, From = sFrom, BodyText = BodyText, BodyHTML = BodyHTML, UseQueue = MainSettings.MailQueue }; var objThread = new System.Threading.Thread(oEmail.Send); objThread.Start(); }
public static void SendEmailToModerators(int templateId, int portalId, int forumId, int topicId, int replyId, int moduleID, int tabID, string comments, UserInfo user) { var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]); var mainSettings = DataCache.MainSettings(moduleID); var fc = new ForumController(); var fi = fc.Forums_Get(forumId, -1, false, true); if (fi == null) return; var subs = new List<SubscriptionInfo>(); var rc = new Security.Roles.RoleController(); var uc = new Entities.Users.UserController(); var modApprove = fi.Security.ModApprove; var modRoles = modApprove.Split('|')[0].Split(';'); foreach (var r in modRoles) { if (string.IsNullOrEmpty(r)) continue; var rid = Convert.ToInt32(r); var rName = rc.GetRole(rid, portalId).RoleName; foreach (UserRoleInfo usr in rc.GetUserRolesByRoleName(portalId, rName)) { var ui = uc.GetUser(portalId, usr.UserID); var si = new SubscriptionInfo { UserId = ui.UserID, DisplayName = ui.DisplayName, Email = ui.Email, FirstName = ui.FirstName, LastName = ui.LastName }; if (! (subs.Contains(si))) { subs.Add(si); } } } if (subs.Count <= 0) return; var sTemplate = string.Empty; var tc = new TemplateController(); var ti = tc.Template_Get(templateId, portalId, moduleID); var subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, portalSettings.TimeZoneOffset); var bodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, portalSettings.TimeZoneOffset); var bodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, portalSettings.TimeZoneOffset); var sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : portalSettings.Email; var oEmail = new Email { Recipients = subs, Subject = subject, From = sFrom, BodyText = bodyText, BodyHTML = bodyHTML, UseQueue = mainSettings.MailQueue }; new Thread(oEmail.Send).Start(); }
private void btnSend_Click(object sender, System.EventArgs e) { Page.Validate(); if (Page.IsValid) { string sSubject = txtRecipSubject.Text; string sEmail = txtRecipEmail.Text; string sEmailName = txtRecipName.Text; string sMessage = txtMessage.Text; sSubject = Utilities.CleanString(PortalId, sSubject.Trim(), false, EditorTypes.TEXTBOX, false, false, ModuleId, string.Empty, false); sMessage = Utilities.CleanString(PortalId, sMessage.Trim(), false, EditorTypes.TEXTBOX, false, false, ModuleId, string.Empty, false); string sUrl = NavigateUrl(Convert.ToInt32(Request.QueryString["TabId"]), "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.SendToComplete }); try { Email oEmail = new Email(); if (!(sMessage == string.Empty) && !(sSubject == string.Empty)) { oEmail.SendNotification(UserInfo.Email, sEmail, sSubject, sMessage, sMessage.Replace(System.Environment.NewLine, "<br />")); } } catch (Exception ex) { //Response.Redirect(NavigateUrl(CInt(Request.QueryString["TabId"]), "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & TopicId, ParamKeys.ViewType & "=confirmaction", ParamKeys.ConfirmActionId & "=" & ConfirmActions.SendToFailed})) } Response.Redirect(sUrl); } }
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); }
public void SendEmailToModerators(int TemplateId, int PortalId, int ForumId, int TopicId, int ReplyId, int ModuleID, int TabID, string Comments, DotNetNuke.Entities.Users.UserInfo User) { var _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]); SettingsInfo MainSettings = DataCache.MainSettings(ModuleID); var fc = new ForumController(); Forum fi = fc.Forums_Get(ForumId, -1, false, true); if (fi == null) { return; } var subs = new List<SubscriptionInfo>(); var rc = new Security.Roles.RoleController(); var uc = new Entities.Users.UserController(); SubscriptionInfo si; string modApprove = fi.Security.ModApprove; string[] modRoles = modApprove.Split('|')[0].Split(';'); if (modRoles != null) { foreach (string r in modRoles) { if (! (string.IsNullOrEmpty(r))) { int rid = Convert.ToInt32(r); string rName = rc.GetRole(rid, PortalId).RoleName; foreach (Entities.Users.UserRoleInfo usr in rc.GetUserRolesByRoleName(PortalId, rName)) { var ui = uc.GetUser(PortalId, usr.UserID); si = new SubscriptionInfo { UserId = ui.UserID, DisplayName = ui.DisplayName, Email = ui.Email, FirstName = ui.FirstName, LastName = ui.LastName }; if (! (subs.Contains(si))) { subs.Add(si); } } } } } if (subs.Count <= 0) { return; } string Subject; string BodyText; string BodyHTML; string sTemplate = string.Empty; var tc = new TemplateController(); TemplateInfo ti = tc.Template_Get(TemplateId, PortalId, ModuleID); Subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleID, TabID, ForumId, TopicId, ReplyId, _portalSettings.TimeZoneOffset); BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleID, TabID, ForumId, TopicId, ReplyId, Comments, User, -1, _portalSettings.TimeZoneOffset); BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleID, TabID, ForumId, TopicId, ReplyId, Comments, User, -1, _portalSettings.TimeZoneOffset); string sFrom; sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email; var oEmail = new Email { Recipients = subs, Subject = Subject, From = sFrom, BodyText = BodyText, BodyHTML = BodyHTML, SmtpServer = Convert.ToString(_portalSettings.HostSettings["SMTPServer"]), SmtpUserName = Convert.ToString(_portalSettings.HostSettings["SMTPUsername"]), SmtpPassword = Convert.ToString(_portalSettings.HostSettings["SMTPPassword"]), SmtpAuthentication = Convert.ToString(_portalSettings.HostSettings["SMTPAuthentication"]) }; //#if SKU_ENTERPRISE oEmail.UseQueue = MainSettings.MailQueue; //#endif var objThread = new System.Threading.Thread(oEmail.Send); objThread.Start(); }
public void SendEmail(int TemplateId, int PortalId, int ModuleId, int TabId, int ForumId, int TopicId, int ReplyId, string Comments, Author author) { var _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]); SettingsInfo MainSettings = DataCache.MainSettings(ModuleId); string Subject; string BodyText; string BodyHTML; string sTemplate = string.Empty; var tc = new TemplateController(); TemplateInfo ti = tc.Template_Get(TemplateId, PortalId, ModuleId); Subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, author.AuthorId, _portalSettings.TimeZoneOffset); BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, author.AuthorId, _portalSettings.TimeZoneOffset); BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, author.AuthorId, _portalSettings.TimeZoneOffset); BodyText = BodyText.Replace("[REASON]", Comments); BodyHTML = BodyHTML.Replace("[REASON]", Comments); string sFrom; var fc = new ForumController(); Forum fi = fc.Forums_Get(ForumId, -1, false, true); sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email; //Send now var oEmail = new Email(); var subs = new List<SubscriptionInfo>(); var si = new SubscriptionInfo { DisplayName = author.DisplayName, Email = author.Email, FirstName = author.FirstName, LastName = author.LastName, UserId = author.AuthorId, Username = author.Username }; subs.Add(si); oEmail.UseQueue = MainSettings.MailQueue; oEmail.Recipients = subs; oEmail.Subject = Subject; oEmail.From = sFrom; oEmail.BodyText = BodyText; oEmail.BodyHTML = BodyHTML; oEmail.SmtpServer = Convert.ToString(_portalSettings.HostSettings["SMTPServer"]); oEmail.SmtpUserName = Convert.ToString(_portalSettings.HostSettings["SMTPUsername"]); oEmail.SmtpPassword = Convert.ToString(_portalSettings.HostSettings["SMTPPassword"]); oEmail.SmtpAuthentication = Convert.ToString(_portalSettings.HostSettings["SMTPAuthentication"]); var objThread = new System.Threading.Thread(oEmail.Send); objThread.Start(); }
public HttpResponseMessage DeletePost(ModerationDTO dto) { var notify = NotificationsController.Instance.GetNotification(dto.NotificationId); ParseNotificationContext(notify.Context); var fc = new ForumController(); var fi = fc.Forums_Get(_forumId, -1, false, true); if (fi == null) return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Forum Not Found" }); if (!(IsMod(_forumId))) return Request.CreateResponse(HttpStatusCode.Forbidden, new { Message = "User is not a moderator for this forum" }); int authorId; var ms = DataCache.MainSettings(_moduleId); if (_replyId > 0 & _replyId != _topicId) { var rc = new ReplyController(); var reply = rc.Reply_Get(PortalSettings.PortalId, _moduleId, _topicId, _replyId); if (reply == null) return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Reply Not Found" }); authorId = reply.Content.AuthorId; rc.Reply_Delete(PortalSettings.PortalId, _forumId, _topicId, _replyId, ms.DeleteBehavior); } else { var tc = new TopicsController(); var topic = tc.Topics_Get(PortalSettings.PortalId, _moduleId, _topicId); if (topic == null) return Request.CreateResponse(HttpStatusCode.OK, new { Message = "Topic Not Found" }); authorId = topic.Content.AuthorId; tc.Topics_Delete(PortalSettings.PortalId, _moduleId, _forumId, _topicId, ms.DeleteBehavior); } if (fi.ModDeleteTemplateId > 0 && authorId > 0) { var uc = new Entities.Users.UserController(); var ui = uc.GetUser(PortalSettings.PortalId, authorId); if (ui != null) { var au = new Author { AuthorId = authorId, DisplayName = ui.DisplayName, Email = ui.Email, FirstName = ui.FirstName, LastName = ui.LastName, Username = ui.Username }; var oEmail = new Email(); oEmail.SendEmail(fi.ModDeleteTemplateId, PortalSettings.PortalId, _moduleId, _tabId, _forumId, _topicId, _replyId, string.Empty, null); } } NotificationsController.Instance.DeleteNotification(dto.NotificationId); return Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" }); }
public HttpResponseMessage RejectPost(ModerationDTO dto) { var notify = NotificationsController.Instance.GetNotification(dto.NotificationId); ParseNotificationContext(notify.Context); var fc = new ForumController(); var fi = fc.Forums_Get(_forumId, -1, false, true); if (fi == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Forum Not Found" })); } if (!(IsMod(_forumId))) { return(Request.CreateResponse(HttpStatusCode.Forbidden, new { Message = "User is not a moderator for this forum" })); } var mc = new ModController(); mc.Mod_Reject(PortalSettings.PortalId, _moduleId, UserInfo.UserID, _forumId, _topicId, _replyId); int authorId; if (_replyId > 0) { var rc = new ReplyController(); var reply = rc.Reply_Get(PortalSettings.PortalId, _moduleId, _topicId, _replyId); if (reply == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Reply Not Found" })); } authorId = reply.Content.AuthorId; } else { var tc = new TopicsController(); var topic = tc.Topics_Get(PortalSettings.PortalId, _moduleId, _topicId); if (topic == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { Message = "Topic Not Found" })); } authorId = topic.Content.AuthorId; } if (fi.ModRejectTemplateId > 0 && authorId > 0) { var uc = new Entities.Users.UserController(); var ui = uc.GetUser(PortalSettings.PortalId, authorId); if (ui != null) { var au = new Author { AuthorId = authorId, DisplayName = ui.DisplayName, Email = ui.Email, FirstName = ui.FirstName, LastName = ui.LastName, Username = ui.Username }; Email.SendEmail(fi.ModRejectTemplateId, PortalSettings.PortalId, _moduleId, _tabId, _forumId, _topicId, _replyId, string.Empty, au); } } NotificationsController.Instance.DeleteNotification(dto.NotificationId); return(Request.CreateResponse(HttpStatusCode.OK, new { Result = "success" })); }