public static XPathNodeIterator TopicPager(int topicId, int itemsPerPage, int currentPage) { XmlDocument xd = new XmlDocument(); Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(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 Topic(int topicID) { XmlDocument xd = new XmlDocument(); Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicID); if (t.Exists) { xd.AppendChild(t.ToXml(xd)); } return(xd.CreateNavigator().Select(".")); }
public static string DeleteTopic(int topicId) { var currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; if (Xslt.IsMemberInGroup("admin", currentMember)) { var topic = new Businesslogic.Topic(topicId); topic.Delete(); return "true"; } return "false"; }
public static string EditTopic(int topicId) { var currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; var topic = new Businesslogic.Topic(topicId); if (topic.Editable(currentMember)) { var title = HttpContext.Current.Request["title"]; var body = HttpContext.Current.Request["body"]; topic.Body = body; topic.Title = title; topic.Save(false); return Xslt.NiceTopicUrl(topic.Id); } return "0"; }
public static XPathNodeIterator TopicComments(int topicID) { XmlDocument xd = new XmlDocument(); Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(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 string NiceTopicUrl(int topicId) { Businesslogic.Topic t = uForum.Businesslogic.Topic.GetTopic(topicId); if (t != null && 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 static string MoveTopic(int topicId, int newForumId) { var currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; if (Xslt.IsMemberInGroup("admin", currentMember)) { var topic = new Businesslogic.Topic(topicId); topic.Move(newForumId); return Xslt.NiceTopicUrl(topic.Id); } return "false"; }