protected void btnCreateTopic_Click(object sender, EventArgs e) { string subject = Member.GetCurrentMember().Text + " suggests a meetup"; string extrabody = ""; if (Request["event"] != null) { umbraco.presentation.nodeFactory.Node ev = new umbraco.presentation.nodeFactory.Node(Convert.ToInt32(Request["event"])); subject = "New event in your area: " + ev.Name; extrabody = string.Format( "<br/><br/>Check out the event details <a href='{0}'>here</a>", "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ev.NiceUrl); NewTopicContainer.Visible = false; } else { uForum.Businesslogic.Topic meetupTopic = uForum.Businesslogic.Topic.Create(1184, Member.GetCurrentMember().Text + " suggests a meetup", TextBox1.Text, Member.GetCurrentMember().Id); Member current = Member.GetCurrentMember(); current.getProperty("lastMeetupSuggestDate").Value = DateTime.Now; current.getProperty("lastMeetupTopicId").Value = meetupTopic.Id; current.Save(); lnkNewTopic.NavigateUrl = uForum.Library.Xslt.NiceTopicUrl(meetupTopic.Id); } if (SendMails && Request["event"] != null) { foreach (string memberId in ViewState["MemberLocatorMemberIds"].ToString().Split(';')) { Member member = new Member(int.Parse(memberId)); if (member.getProperty("bugMeNot").Value.ToString() == "0" || member.getProperty("bugMeNot").Value.ToString() == null || member.getProperty("bugMeNot").Value.ToString() == "") { MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**", "Our umbraco"); mail.Subject = subject; mail.To.Add(new MailAddress(new Member(int.Parse(memberId)).Email)); //mail.To.Add(new MailAddress("*****@*****.**")); mail.Body = TextBox1.Text.Replace("\n", "<br/>") + extrabody; mail.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Send(mail); } } } pnlCreateTopic.Visible = false; pnlCreateTopicSuccess.Visible = true; }
public override bool SendNotification(System.Xml.XmlNode details, params object[] args) { try { SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText); c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText); MailAddress from = new MailAddress( details.SelectSingleNode("//from/email").InnerText, details.SelectSingleNode("//from/name").InnerText); string subject = details.SelectSingleNode("//subject").InnerText; string body = details.SelectSingleNode("//body").InnerText; string domain = details.SelectSingleNode("//domain").InnerText; int topicId = int.Parse(args[0].ToString()); int memberId = int.Parse(args[1].ToString()); uForum.Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicId); Member m = new Member(memberId); body = string.Format(body, t.Title, "http://" + domain + args[2].ToString()); if (m.getProperty("bugMeNot").Value.ToString() != "1") { MailMessage mm = new MailMessage(); mm.Subject = subject; mm.Body = body; mm.To.Add(m.Email); mm.From = from; c.Send(mm); } SqlConnection conn = new SqlConnection(details.SelectSingleNode("//conn").InnerText); conn.Open(); string insert = "Insert into notificationMarkAsSolution(topicId, memberID, timestamp) values(@topicId, @memberID, getdate())"; SqlCommand icomm = new SqlCommand(insert, conn); icomm.Parameters.AddWithValue("@topicId", topicId); icomm.Parameters.AddWithValue("@memberID", m.Id); icomm.ExecuteNonQuery(); conn.Close(); } catch (Exception e) { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "[Notifications]" + e.Message); } return true; }
void Topic_AfterCreate(object sender, uForum.Businesslogic.CreateEventArgs e) { uForum.Businesslogic.Topic t = (uForum.Businesslogic.Topic)sender; Member mem = new Member(t.MemberId); int posts = 0; int.TryParse(mem.getProperty("forumPosts").Value.ToString(), out posts); mem.getProperty("forumPosts").Value = posts++; mem.Save(); mem.XmlGenerate(new System.Xml.XmlDocument()); Member.RemoveMemberFromCache(mem.Id); Member.AddMemberToCache(mem); }
public static string EditTopic(int topicId) { int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicId); if (t.Editable(_currentMember)) { string title = HttpContext.Current.Request["title"]; string body = HttpContext.Current.Request["body"]; t.Body = body; t.Title = title; t.Save(false); return Library.Xslt.NiceTopicUrl(t.Id); } else { return "0"; } }
void Topic_AfterCreate(object sender, uForum.Businesslogic.CreateEventArgs e) { uForum.Businesslogic.Topic t = (uForum.Businesslogic.Topic)sender; //WB added to show these events are firing... umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, t.Id, "Topic_AfterCreate in ForumPostsCounter() class is starting"); Member mem = new Member(t.MemberId); int posts = 0; int.TryParse(mem.getProperty("forumPosts").Value.ToString(), out posts); mem.getProperty("forumPosts").Value = (posts + 1); mem.Save(); mem.XmlGenerate(new System.Xml.XmlDocument()); //Performs the action NewTopic in case we want to reward people for creating new posts. uPowers.BusinessLogic.Action a = new uPowers.BusinessLogic.Action("NewTopic"); a.Perform(mem.Id, t.Id, "New topic created"); //WB added to show these events are firing... umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, t.Id, "Topic_AfterCreate in ForumPostsCounter() class is finishing"); }
public static XPathNodeIterator TopicPager(int topicId, int itemsPerPage, int currentPage) { XmlDocument xd = new XmlDocument(); Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicId); XmlNode pages = umbraco.xmlHelper.addTextNode(xd, "pages", ""); int i = 0; int p = 0; while (i < (t.Replies)) { XmlNode page = umbraco.xmlHelper.addTextNode(xd, "page", ""); page.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "index", p.ToString())); if(p == currentPage){ page.Attributes.Append( umbraco.xmlHelper.addAttribute(xd, "current", "true")); } pages.AppendChild(page); p++; i = (i + itemsPerPage); } return pages.CreateNavigator().Select("."); }
public static XPathNodeIterator TopicComments(int topicID) { XmlDocument xd = new XmlDocument(); Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicID); if (t.Exists) { XmlNode comments = umbraco.xmlHelper.addTextNode(xd, "comments", ""); foreach (Businesslogic.Comment cc in t.Comments()) { comments.AppendChild( cc.ToXml(xd) ); } xd.AppendChild(comments); } return xd.CreateNavigator().Select("."); }
public static XPathNodeIterator Topic(int topicID) { XmlDocument xd = new XmlDocument(); Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicID); if (t.Exists) xd.AppendChild(t.ToXml(xd)); return xd.CreateNavigator().Select("."); }
public static string NiceTopicUrl(int topicId) { Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicId); if (t.Exists) { string _url = umbraco.library.NiceUrl(t.ParentId); if (umbraco.GlobalSettings.UseDirectoryUrls) { return "/" + _url.Trim('/') + "/" + t.Id.ToString() + "-" + t.UrlName; } else { return "/" + _url.Substring(0, _url.LastIndexOf('.')).Trim('/') + "/" + t.Id.ToString() + "-" + t.UrlName + ".aspx"; } } else { return ""; } }
public override bool SendNotification(System.Xml.XmlNode details, params object[] args) { SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText); MailAddress from = new MailAddress( details.SelectSingleNode("//from/email").InnerText, details.SelectSingleNode("//from/name").InnerText); string subject = details.SelectSingleNode("//subject").InnerText; string body = details.SelectSingleNode("//body").InnerText; SqlConnection conn = new SqlConnection(details.SelectSingleNode("//conn").InnerText); string select = @"select id, memberId from forumTopics where answer = 0 and created < getdate() - 7 and created > '2010-06-10 00:00:00' and id not in (select topicId from notificationMarkAsSolution) order by created desc;"; SqlCommand comm = new SqlCommand( select, conn); conn.Open(); SqlDataReader dr = comm.ExecuteReader(); string domain = details.SelectSingleNode("//domain").InnerText; while (dr.Read()) { int topicId = dr.GetInt32(0); uForum.Businesslogic.Topic t = new uForum.Businesslogic.Topic(topicId); string mbody = string.Format(body, t.Title, "http://" + domain + args[1].ToString()); Member m = new Member(dr.GetInt32(1)); if (m.getProperty("bugMeNot") != null || m.getProperty("bugMeNot").Value.ToString() != "1") { MailMessage mm = new MailMessage(); mm.Subject = subject; mm.Body = mbody; mm.To.Add(m.Email); mm.From = from; c.Send(mm); } string insert = "Insert into notificationMarkAsSolution(topicId, memberID, timestamp) values(@topicId, @memberID, getdate())"; SqlCommand icomm = new SqlCommand(insert, conn); icomm.Parameters.AddWithValue("@topicId", topicId); icomm.Parameters.AddWithValue("@memberID", m.Id); icomm.ExecuteNonQuery(); } conn.Close(); return true; }
private void SanitizeTopic(uForum.Businesslogic.Topic t) { //t.Body = our.Utills.Sanitize(t.Body); t.Title = our.Utills.Sanitize(t.Title); }
public override bool SendNotification(System.Xml.XmlNode details, params object[] args) { try { SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText); c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText); MailAddress from = new MailAddress( details.SelectSingleNode("//from/email").InnerText, details.SelectSingleNode("//from/name").InnerText); string subject = details.SelectSingleNode("//subject").InnerText; string body = details.SelectSingleNode("//body").InnerText; string domain = details.SelectSingleNode("//domain").InnerText; int topicId = int.Parse(args[0].ToString()); int memberId = int.Parse(args[1].ToString()); uForum.Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicId); Member m = new Member(memberId); body = string.Format(body, t.Title, "https://" + domain + args[2].ToString()); if (m.getProperty("bugMeNot").Value.ToString() != "1") { MailMessage mm = new MailMessage(); mm.Subject = subject; mm.Body = body; mm.To.Add(m.Email); mm.From = from; c.Send(mm); } SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["umbracoDbDSN"]); conn.Open(); string insert = "Insert into notificationMarkAsSolution(topicId, memberID, timestamp) values(@topicId, @memberID, getdate())"; SqlCommand icomm = new SqlCommand(insert, conn); icomm.Parameters.AddWithValue("@topicId", topicId); icomm.Parameters.AddWithValue("@memberID", m.Id); icomm.ExecuteNonQuery(); conn.Close(); } catch (Exception e) { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "[Notifications]" + e.Message); } return(true); }
public override bool SendNotification(System.Xml.XmlNode details, params object[] args) { SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText); c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText); MailAddress from = new MailAddress( details.SelectSingleNode("//from/email").InnerText, details.SelectSingleNode("//from/name").InnerText); string subject = details.SelectSingleNode("//subject").InnerText; string body = details.SelectSingleNode("//body").InnerText; SqlConnection conn = new SqlConnection(details.SelectSingleNode("//conn").InnerText); string select = @"select id, memberId from forumTopics where answer = 0 and created < getdate() - 7 and created > '2010-06-10 00:00:00' and id not in (select topicId from notificationMarkAsSolution) order by created desc;"; SqlCommand comm = new SqlCommand( select, conn); conn.Open(); SqlDataReader dr = comm.ExecuteReader(); string domain = details.SelectSingleNode("//domain").InnerText; while (dr.Read()) { int topicId = dr.GetInt32(0); uForum.Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicId); string mbody = string.Format(body, t.Title, "http://" + domain + args[1].ToString()); Member m = new Member(dr.GetInt32(1)); if (m.getProperty("bugMeNot") != null || m.getProperty("bugMeNot").Value.ToString() != "1") { MailMessage mm = new MailMessage(); mm.Subject = subject; mm.Body = mbody; mm.To.Add(m.Email); mm.From = from; c.Send(mm); } string insert = "Insert into notificationMarkAsSolution(topicId, memberID, timestamp) values(@topicId, @memberID, getdate())"; SqlCommand icomm = new SqlCommand(insert, conn); icomm.Parameters.AddWithValue("@topicId", topicId); icomm.Parameters.AddWithValue("@memberID", m.Id); icomm.ExecuteNonQuery(); } conn.Close(); return(true); }