public static void LoadTemplateCache(int moduleID) { var tc = new TemplateController(); foreach (var ti in tc.Template_List(-1, moduleID)) { DataCache.CacheStore(ti.Title + moduleID, ti.Template); DataCache.CacheStore(ti.Subject + "_Subject_" + moduleID, ti.Subject); } }
private static TemplateInfo GetTemplateByName(string templateName, int moduleId, int portalId) { var tc = new TemplateController(); TemplateInfo ti; try { ti = tc.Template_Get(templateName, portalId, moduleId); } catch (Exception ex) { ti = new TemplateInfo {TemplateHTML = "Error loading " + templateName + " template."}; ti.TemplateText = ti.TemplateHTML; } return ti; }
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, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); var bodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); var bodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); 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(); }
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, Convert.ToInt32(_portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, Convert.ToInt32(_portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, fi.ForumID, TopicId, ReplyId, string.Empty, AuthorId, Convert.ToInt32(_portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); 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 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 LoadForm(int TemplateId) { TemplateInfo ti = null; TemplateController tc = new TemplateController(); ti = tc.Template_Get(TemplateId, PortalId, ModuleId); if (ti != null) { txtTitle.Text = ti.Title; txtSubject.Text = ti.Subject; txtPlainText.Text = ti.TemplateText; txtEditor.Text = Server.HtmlDecode(ti.TemplateHTML.Replace("[RESX:", "[TRESX:")); drpTemplateType.SelectedIndex = drpTemplateType.Items.IndexOf(drpTemplateType.Items.FindByValue(Convert.ToString(Convert.ToInt32(Enum.Parse(typeof(Templates.TemplateTypes), ti.TemplateType.ToString()))))); hidTemplateId.Value = Convert.ToString(ti.TemplateId); if (ti.IsSystem) { btnDelete.Visible = false; txtTitle.ReadOnly = true; drpTemplateType.Enabled = false; } } }
private void LoadForm(int TemplateId) { TemplateInfo ti = null; TemplateController tc = new TemplateController(); ti = tc.Template_Get(TemplateId, PortalId, ModuleId); if (ti != null) { txtTitle.Text = ti.Title; txtSubject.Text = ti.Subject; txtPlainText.Text = ti.TemplateText; txtEditor.Text = Server.HtmlDecode(ti.TemplateHTML.Replace("[RESX:", "[TRESX:")); drpTemplateType.SelectedIndex = drpTemplateType.Items.IndexOf(drpTemplateType.Items.FindByValue(Convert.ToString(Convert.ToInt32(Enum.Parse(typeof(Templates.TemplateTypes), ti.TemplateType.ToString()))))); hidTemplateId.Value = Convert.ToString(ti.TemplateId); if (ti.IsSystem) { btnDelete.Visible = false; txtTitle.ReadOnly = true; drpTemplateType.Enabled = false; } } }
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 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 rp = RoleProvider.Instance(); 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 rp.GetUserRoles(portalId, null, 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, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); var bodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); var bodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes)); 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(); }
public void BindTemplateDropDown(int ForumModuleId, DropDownList drp, Templates.TemplateTypes TemplateType, string DefaultText, string DefaultValue) { var tc = new TemplateController(); drp.DataTextField = "Title"; drp.DataValueField = "TemplateID"; drp.DataSource = tc.Template_List(PortalId, ForumModuleId, TemplateType); drp.DataBind(); drp.Items.Insert(0, new ListItem(DefaultText, DefaultValue)); }
private void LoadTemplates(int PortalId, int ModuleId) { try { var xDoc = new System.Xml.XmlDocument(); xDoc.Load(sPath); if (xDoc != null) { System.Xml.XmlNode xRoot = xDoc.DocumentElement; System.Xml.XmlNodeList xNodeList = xRoot.SelectNodes("//templates/template"); if (xNodeList.Count > 0) { var tc = new TemplateController(); int i; for (i = 0; i < xNodeList.Count; i++) { var ti = new TemplateInfo { TemplateId = -1, TemplateType = (Templates.TemplateTypes) Enum.Parse(typeof (Templates.TemplateTypes), xNodeList[i].Attributes["templatetype"].Value), IsSystem = true, PortalId = PortalId, ModuleId = ModuleId, Title = xNodeList[i].Attributes["templatetitle"].Value, Subject = xNodeList[i].Attributes["templatesubject"].Value }; string sHTML; sHTML = GetFileContent(xNodeList[i].Attributes["importfilehtml"].Value); string sText; sText = GetFileContent(xNodeList[i].Attributes["importfiletext"].Value); string sTemplate = sText; if (sHTML != string.Empty) { sTemplate = "<template><html>" + HttpContext.Current.Server.HtmlEncode(sHTML) + "</html><plaintext>" + sText + "</plaintext></template>"; } ti.Template = sTemplate; tc.Template_Save(ti); } } } } catch (Exception ex) { } }
private void cbAction_Callback(object sender, Controls.CallBackEventArgs e) { string sMsg = ""; switch (e.Parameters[0].ToLower()) { case "save": { try { //save template TemplateInfo ti = null; TemplateController tc = new TemplateController(); int templateId = 0; if (e.Parameters[1].ToString() != "") { templateId = Convert.ToInt32(e.Parameters[1]); ti = tc.Template_Get(templateId, PortalId, ModuleId); } else { ti = new TemplateInfo(); ti.IsSystem = false; ti.TemplateType = (Templates.TemplateTypes)(Convert.ToInt32(e.Parameters[6])); ti.PortalId = PortalId; ti.ModuleId = ModuleId; } ti.Title = e.Parameters[2].ToString(); ti.Subject = e.Parameters[3].ToString(); if (ti.TemplateType == Templates.TemplateTypes.Email || ti.TemplateType == Templates.TemplateTypes.ModEmail) { ti.Template = "<template><html>" + Server.HtmlEncode(e.Parameters[4]) + "</html><plaintext>" + Utilities.StripHTMLTag(e.Parameters[5].ToString()) + "</plaintext></template>"; } else { ti.Template = "<template><html>" + Server.HtmlEncode(e.Parameters[4]) + "</html><plaintext>" + string.Empty + "</plaintext></template>"; } ti.Template = ti.Template.Replace("[TRESX:", "[RESX:"); templateId = tc.Template_Save(ti); string ckey = ModuleId + templateId + Convert.ToString(Enum.Parse(typeof(Templates.TemplateTypes), ti.TemplateType.ToString())); DataCache.CacheClear(ckey); sMsg = "Template saved successfully!"; } catch (Exception ex) { sMsg = "Error saving template."; } break; } case "delete": { try { //delete template TemplateInfo ti = null; TemplateController tc = new TemplateController(); int templateid = 0; if (e.Parameters[1].ToString() != "") { templateid = Convert.ToInt32(e.Parameters[1]); ti = tc.Template_Get(templateid, PortalId, ModuleId); if (! (ti.IsSystem == true)) { tc.Template_Delete(templateid, PortalId, ModuleId); sMsg = "Template deleted successfully!"; } else { sMsg = "Enable to delete system templates"; } } } catch (Exception ex) { sMsg = "Error deleting template."; } break; } } cbActionMessage.InnerText = sMsg; cbActionMessage.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(); }
/// <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 cbAction_Callback(object sender, Controls.CallBackEventArgs e) { string sMsg = ""; switch (e.Parameters[0].ToLower()) { case "save": { try { //save template TemplateInfo ti = null; TemplateController tc = new TemplateController(); int templateId = 0; if (e.Parameters[1].ToString() != "") { templateId = Convert.ToInt32(e.Parameters[1]); ti = tc.Template_Get(templateId, PortalId, ModuleId); } else { ti = new TemplateInfo(); ti.IsSystem = false; ti.TemplateType = (Templates.TemplateTypes)(Convert.ToInt32(e.Parameters[6])); ti.PortalId = PortalId; ti.ModuleId = ModuleId; } ti.Title = e.Parameters[2].ToString(); ti.Subject = e.Parameters[3].ToString(); if (ti.TemplateType == Templates.TemplateTypes.Email || ti.TemplateType == Templates.TemplateTypes.ModEmail) { ti.Template = "<template><html>" + Server.HtmlEncode(e.Parameters[4]) + "</html><plaintext>" + Utilities.StripHTMLTag(e.Parameters[5].ToString()) + "</plaintext></template>"; } else { ti.Template = "<template><html>" + Server.HtmlEncode(e.Parameters[4]) + "</html><plaintext>" + string.Empty + "</plaintext></template>"; } ti.Template = ti.Template.Replace("[TRESX:", "[RESX:"); templateId = tc.Template_Save(ti); string ckey = ModuleId + templateId + Convert.ToString(Enum.Parse(typeof(Templates.TemplateTypes), ti.TemplateType.ToString())); DataCache.CacheClear(ckey); sMsg = "Template saved successfully!"; } catch (Exception ex) { sMsg = "Error saving template."; } break; } case "delete": { try { //delete template TemplateInfo ti = null; TemplateController tc = new TemplateController(); int templateid = 0; if (e.Parameters[1].ToString() != "") { templateid = Convert.ToInt32(e.Parameters[1]); ti = tc.Template_Get(templateid, PortalId, ModuleId); if (!(ti.IsSystem == true)) { tc.Template_Delete(templateid, PortalId, ModuleId); sMsg = "Template deleted successfully!"; } else { sMsg = "Enable to delete system templates"; } } } catch (Exception ex) { sMsg = "Error deleting template."; } break; } } cbActionMessage.InnerText = sMsg; cbActionMessage.RenderControl(e.Output); }
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 static string GetTemplate(int TemplateId, string TemplateType) { string sOut = string.Empty; try { if (TemplateId == 0) { try { string myFile = HttpContext.Current.Server.MapPath("~/DesktopModules/ActiveForums/config/templates/" + TemplateType + ".txt"); if (System.IO.File.Exists(myFile)) { System.IO.StreamReader objStreamReader = null; try { objStreamReader = System.IO.File.OpenText(myFile); } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); } sOut = objStreamReader.ReadToEnd(); objStreamReader.Close(); sOut = Utilities.ParseSpacer(sOut); } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); } } else { var objTemplates = new TemplateController(); TemplateInfo objTempInfo = objTemplates.Template_Get(TemplateId); if (objTempInfo != null) { sOut = objTempInfo.TemplateHTML; sOut = Utilities.ParseSpacer(sOut); } } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); sOut = "ERROR: Loading template failed"; } return sOut; }
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 = Host.SMTPServer, // Convert.ToString(_portalSettings.HostSettings["SMTPServer"]), SmtpUserName = Host.SMTPUsername, // Convert.ToString(_portalSettings.HostSettings["SMTPUsername"]), SmtpPassword = Host.SMTPPassword, // Convert.ToString(_portalSettings.HostSettings["SMTPPassword"]), SmtpAuthentication = Host.SMTPAuthentication // Convert.ToString(_portalSettings.HostSettings["SMTPAuthentication"]) }; //#if SKU_ENTERPRISE oEmail.UseQueue = MainSettings.MailQueue; //#endif var objThread = new System.Threading.Thread(oEmail.Send); objThread.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 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(); }
private void PrepareTopic() { string template; if (_fi.TopicFormId == 0) { var myFile = Request.MapPath(Common.Globals.ApplicationPath) + "\\DesktopModules\\ActiveForums\\config\\templates\\TopicEditor.txt"; template = File.ReadAllText(myFile); } else { var tc = new TemplateController(); var ti = tc.Template_Get(_fi.TopicFormId, PortalId, ForumModuleId); template = ti.TemplateHTML; } if (MainSettings.UseSkinBreadCrumb) { var sCrumb = "<a href=\"" + NavigateUrl(TabId, "", ParamKeys.GroupId + "=" + ForumInfo.ForumGroupId.ToString()) + "\">" + ForumInfo.GroupName + "</a>|"; sCrumb += "<a href=\"" + NavigateUrl(TabId, "", ParamKeys.ForumId + "=" + ForumInfo.ForumID.ToString()) + "\">" + ForumInfo.ForumName + "</a>"; if (Environment.UpdateBreadCrumb(Page.Controls, sCrumb)) template = template.Replace("<div class=\"afcrumb\">[AF:LINK:FORUMMAIN] > [AF:LINK:FORUMGROUP] > [AF:LINK:FORUMNAME]</div>", string.Empty); } ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.NewTopic; if (Permissions.HasPerm(_fi.Security.ModApprove, ForumUser.UserRoles)) { ctlForm.ShowModOptions = true; } ctlForm.Template = template; ctlForm.IsApproved = _isApproved; }
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(); }