private void TopicsDisplay_Init(object sender, System.EventArgs e) { SettingsInfo MainSettings = DataCache.MainSettings(ControlConfig.InstanceId); MemberListMode = MainSettings.MemberListMode; ProfileVisibility = MainSettings.ProfileVisibility; UserNameDisplay = MainSettings.UserNameDisplay; DisableUserProfiles = MainSettings.DisableUserProfiles; if (topicsData == null) { Data.Topics db = new Data.Topics(); topicsData = db.TopicsForDisplayXML(ControlConfig.SiteId, ControlConfig.InstanceId, -1, ForumUser.UserId, PageId, MainSettings.PageSize, ForumUser.IsSuperUser, "ReplyCreated", UserForumsList); } string sTemp = string.Empty; //pt = New Forums.Utils.TimeCalcItem("ForumDisplay") //TODO: Turn cache back on //Dim obj As Object = DataCache.CacheRetrieve(InstanceId & CurrentView) //If obj Is Nothing Then DisplayTemplate = Utilities.ParseTokenConfig(DisplayTemplate, "topic", ControlConfig); sTemp = ParseTemplate(); //Else // sTemp = CType(obj, String) //End If sTemp = Utilities.LocalizeControl(sTemp); //Security if (!sTemp.Contains(Globals.ControlRegisterAFTag)) { sTemp = Globals.ControlRegisterAFTag + sTemp; } sTemp = sTemp.Replace("[CREATEROLES]", "1;"); sTemp = sTemp.Replace("[USERROLES]", ForumUser.UserRoles); sTemp = sTemp.Replace("[THEMEPATH]", ThemePath); sTemp = Utilities.ParseSecurityTokens(sTemp, ForumUser.UserRoles); Control ctl = Page.ParseControl(sTemp); LinkControls(ctl.Controls); this.Controls.Add(ctl); }
private string SaveTopic() { int topicId = -1; int forumId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (topicId > 0) { TopicsController tc = new TopicsController(); TopicInfo t = tc.Topics_Get(PortalId, ModuleId, topicId); Data.ForumsDB db = new Data.ForumsDB(); forumId = db.Forum_GetByTopicId(topicId); ForumController fc = new ForumController(); Forum f = fc.Forums_Get(PortalId, -1, forumId, this.UserId, true, false, -1); if (Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles)) { string subject = Params["subject"].ToString(); subject = Utilities.XSSFilter(subject, true); if (! (string.IsNullOrEmpty(f.PrefixURL))) { string cleanSubject = Utilities.CleanName(subject).ToLowerInvariant(); if (SimulateIsNumeric.IsNumeric(cleanSubject)) { cleanSubject = "Topic-" + cleanSubject; } string topicUrl = cleanSubject; string urlPrefix = "/"; if (! (string.IsNullOrEmpty(f.ForumGroup.PrefixURL))) { urlPrefix += f.ForumGroup.PrefixURL + "/"; } if (! (string.IsNullOrEmpty(f.PrefixURL))) { urlPrefix += f.PrefixURL + "/"; } string urlToCheck = urlPrefix + cleanSubject; Data.Topics topicsDb = new Data.Topics(); for (int u = 0; u <= 200; u++) { int tid = topicsDb.TopicIdByUrl(PortalId, f.ModuleId, urlToCheck); if (tid > 0 && tid == topicId) { break; } else if (tid > 0) { topicUrl = (u + 1) + "-" + cleanSubject; urlToCheck = urlPrefix + topicUrl; } else { break; } } if (topicUrl.Length > 150) { topicUrl = topicUrl.Substring(0, 149); topicUrl = topicUrl.Substring(0, topicUrl.LastIndexOf("-")); } t.TopicUrl = topicUrl; //.URL = topicUrl } else { //.URL = String.Empty t.TopicUrl = string.Empty; } t.Content.Subject = subject; t.IsPinned = bool.Parse(Params["pinned"].ToString()); t.IsLocked = bool.Parse(Params["locked"].ToString()); t.Priority = int.Parse(Params["priority"].ToString()); t.StatusId = int.Parse(Params["status"].ToString()); if (f.Properties != null) { StringBuilder tData = new StringBuilder(); tData.Append("<topicdata>"); tData.Append("<properties>"); foreach (PropertiesInfo p in f.Properties) { string pkey = "prop-" + p.PropertyId.ToString(); tData.Append("<property id=\"" + p.PropertyId.ToString() + "\">"); tData.Append("<name><![CDATA["); tData.Append(p.Name); tData.Append("]]></name>"); if (Params[pkey] != null) { tData.Append("<value><![CDATA["); tData.Append(Utilities.XSSFilter(Params[pkey].ToString())); tData.Append("]]></value>"); } else { tData.Append("<value></value>"); } tData.Append("</property>"); } tData.Append("</properties>"); tData.Append("</topicdata>"); t.TopicData = tData.ToString(); } } tc.TopicSave(PortalId, t); if (Params["tags"] != null) { DataProvider.Instance().Tags_DeleteByTopicId(PortalId, f.ModuleId, topicId); string tagForm = string.Empty; if (Params["tags"] != null) { tagForm = Params["tags"].ToString(); } if (! (tagForm == string.Empty)) { string[] Tags = tagForm.Split(','); foreach (string tag in Tags) { string sTag = Utilities.CleanString(PortalId, tag.Trim(), false, EditorTypes.TEXTBOX, false, false, f.ModuleId, string.Empty, false); DataProvider.Instance().Tags_Save(PortalId, f.ModuleId, -1, sTag, 0, 1, 0, topicId, false, -1, -1); } } } if (Params["categories"] != null) { string[] cats = Params["categories"].ToString().Split(';'); DataProvider.Instance().Tags_DeleteTopicToCategory(PortalId, f.ModuleId, -1, topicId); foreach (string c in cats) { int cid = -1; if (! (string.IsNullOrEmpty(c)) && SimulateIsNumeric.IsNumeric(c)) { cid = Convert.ToInt32(c); if (cid > 0) { DataProvider.Instance().Tags_AddTopicToCategory(PortalId, f.ModuleId, cid, topicId); } } } } } return BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false); }
public string Render() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); Data.Topics db = new Data.Topics(); int i = 0; using (IDataReader dr = db.TopicWithReplies(PortalId, TopicId, PageIndex, PageSize)) { while (dr.Read()) { Template = ParseTopic(dr, Template); } dr.NextResult(); string rtemplate = TemplateUtils.GetTemplateSection(Template, "[REPLIES]", "[/REPLIES]"); while (dr.Read()) { sb.Append(ParseReply(dr, rtemplate)); } dr.Close(); } Template = TemplateUtils.ReplaceSubSection(Template, sb.ToString(), "[REPLIES]", "[/REPLIES]"); return Template; }
private void SaveQuickReply() { int iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { UserProfileController upc = new UserProfileController(); UserProfileInfo upi = upc.Profiles_Get(SiteId, InstanceId, this.UserId); if (upi != null) { if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval) { Controls.InfoMessage im = new Controls.InfoMessage(); im.Message = "<div class=\"afmessage\">" + string.Format(Utilities.GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>"; plhMessage.Controls.Add(im); return; } } } //TODO: Fix for anon //If Not Current.Request.IsAuthenticated Then // If Not ctlCaptcha.IsValid Or txtUserName.Value = "" Then // Exit Sub // End If //End If //Dim ui As New UserProfileInfo //If UserId > 0 Then // Dim upc As New UserProfileController // ui = upc.Profiles_Get(PortalId, ForumModuleId, UserId) //Else // ui.TopicCount = 0 // ui.ReplyCount = 0 // ui.RewardPoints = 0 // ui.IsMod = False // ui.TrustLevel = -1 //End If ForumController fc = new ForumController(); Forum forumInfo = fc.Forums_Get(SiteId, InstanceId, ForumId, this.UserId, true, false, TopicId); bool UserIsTrusted = false; UserIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, ControlConfig.User.TrustLevel, Permissions.HasPerm(forumInfo.Security.Trust, ForumUser.UserRoles), forumInfo.AutoTrustLevel, ControlConfig.User.PostCount); bool isApproved = false; isApproved = Convert.ToBoolean(((forumInfo.IsModerated == true) ? false : true)); if (UserIsTrusted || Permissions.HasPerm(forumInfo.Security.ModApprove, ForumUser.UserRoles)) { isApproved = true; } ReplyInfo ri = new ReplyInfo(); Data.Topics db = new Data.Topics(); //im rc As New ReplyController int ReplyId = -1; string sUsername = string.Empty; if (HttpContext.Current.Request.IsAuthenticated) { sUsername = ControlConfig.User.DisplayName; } else { sUsername = Utilities.CleanString(SiteId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, InstanceId, ThemePath, false); } string sBody = string.Empty; //TODO: Check for allowhtml bool allowHtml = false; //If forumInfo.AllowHTML Then // allowHtml = isHTMLPermitted(forumInfo.EditorPermittedUsers, IsTrusted, forumInfo.Security.ModEdit) //End If sBody = Utilities.CleanString(SiteId, HttpContext.Current.Request.Form["txtBody"], allowHtml, EditorTypes.TEXTBOX, forumInfo.UseFilter, forumInfo.AllowScript, InstanceId, ThemePath, forumInfo.AllowEmoticons); DateTime createDate = DateTime.Now; ri.TopicId = TopicId; ri.ReplyToId = TopicId; ri.Content.AuthorId = UserId; ri.Content.AuthorName = sUsername; ri.Content.Body = sBody; ri.Content.DateCreated = createDate; ri.Content.DateUpdated = createDate; ri.Content.IsDeleted = false; ri.Content.Subject = Subject; ri.Content.Summary = string.Empty; ri.IsApproved = isApproved; ri.IsDeleted = false; ri.Content.IPAddress = HttpContext.Current.Request.UserHostAddress; ReplyId = db.Reply_Save(ri); //Check if is subscribed if (HttpContext.Current.Request.Params["chkSubscribe"] != null) { if (HttpContext.Current.Request.Params["chkSubscribe"] == "1" && UserId > 0) { if (!(Subscriptions.IsSubscribed(SiteId, InstanceId, ForumId, TopicId, SubscriptionTypes.Instant, UserId))) { //TODO: Fix Subscriptions //Dim sc As New Data.Tracking //sc.Subscription_Update(SiteId, InstanceId, ForumId, TopicId, 1, UserId) } } } if (isApproved) { //Send Subscriptions try { string sURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); Subscriptions.SendSubscriptions(SiteId, InstanceId, PageId, ForumId, TopicId, ReplyId, UserId); #if !SKU_LITE try { Social oSocial = new Social(); oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", sURL, Subject, sBody); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } #endif } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } //Redirect to show post string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); HttpContext.Current.Response.Redirect(fullURL, false); } else if (isApproved == false) { Email.SendEmailToModerators(forumInfo.ModNotifyTemplateId, SiteId, ForumId, ri.TopicId, ReplyId, InstanceId, PageId, string.Empty); string[] Params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId }; HttpContext.Current.Response.Redirect(Utilities.NavigateUrl(PageId, "", Params), false); } else { string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); #if !SKU_LITE try { Modules.ActiveForums.Social oSocial = new Modules.ActiveForums.Social(); oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", fullURL, Subject, sBody); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } #endif HttpContext.Current.Response.Redirect(fullURL, false); } //End If }
private void TopicDisplay_Init(object sender, System.EventArgs e) { SettingsInfo MainSettings = DataCache.MainSettings(ControlConfig.InstanceId); PageSize = MainSettings.PageSize; string sTemp = string.Empty; if ((ControlConfig != null)) { object obj = DataCache.CacheRetrieve(ControlConfig.InstanceId + CurrentView); if (obj == null) { sTemp = ParseTemplate(); } else { sTemp = Convert.ToString(obj); } if (sTemp.Contains("[NOPAGING]")) { RowIndex = 0; PageSize = int.MaxValue; sTemp = sTemp.Replace("[NOPAGING]", string.Empty); } sTemp = Utilities.ParseTokenConfig(sTemp, "topic", ControlConfig); string Subject = string.Empty; string Body = string.Empty; System.DateTime CreateDate = null; System.DateTime EditDate = null; string Tags = string.Empty; string AuthorRoles = string.Empty; string IPAddress = string.Empty; System.DateTime LastPostDate = null; string LastPostData = string.Empty; UserProfileInfo tAuthor = null; int ReplyCount = 0; Data.Topics tc = new Data.Topics(); int rowCount = 0; int nextTopic = 0; int prevTopic = 0; int statusId = -1; double topicRating = 0; IDataReader dr = tc.TopicForDisplay(ControlConfig.SiteId, ControlConfig.InstanceId, -1, TopicId, UserId, RowIndex, PageSize, "ASC"); while (dr.Read()) { ForumId = int.Parse(dr["ForumId"].ToString()); Subject = dr["Subject"].ToString(); Body = dr["Body"].ToString(); CreateDate = Convert.ToDateTime(dr["DateCreated"].ToString()); EditDate = Convert.ToDateTime(dr["DateUpdated"].ToString()); Tags = dr["Tags"].ToString(); IPAddress = dr["IPAddress"].ToString(); LastPostDate = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["LastPostDate"].ToString()), ControlConfig.InstanceId)); LastPostData = dr["LastPostData"].ToString(); ReplyCount = int.Parse(dr["ReplyCount"].ToString()); nextTopic = int.Parse(dr["NextTopic"].ToString()); prevTopic = int.Parse(dr["PrevTopic"].ToString()); topicRating = double.Parse(dr["TopicRating"].ToString()); UserProfileInfo profile = new UserProfileInfo(); var _with1 = profile; _with1.UserID = int.Parse(dr["AuthorId"].ToString()); if (string.IsNullOrEmpty(dr["DisplayName"].ToString())) { _with1.DisplayName = dr["AuthorName"].ToString(); } else { _with1.DisplayName = dr["DisplayName"].ToString(); } _with1.FirstName = dr["FirstName"].ToString(); _with1.LastName = dr["LastName"].ToString(); _with1.Username = dr["Username"].ToString(); _with1.UserCaption = dr["UserCaption"].ToString(); _with1.AnswerCount = int.Parse(dr["AnswerCount"].ToString()); _with1.AOL = dr["AOL"].ToString(); _with1.Avatar = dr["Avatar"].ToString(); _with1.AvatarType = (AvatarTypes)int.Parse(dr["AvatarType"].ToString()); _with1.DateCreated = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateCreated"].ToString()), ControlConfig.InstanceId)); _with1.DateLastActivity = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastActivity"].ToString()), ControlConfig.InstanceId)); _with1.DateLastPost = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastPost"].ToString()), ControlConfig.InstanceId)); if (!string.IsNullOrEmpty(dr["UserDateUpdated"].ToString())) { _with1.DateUpdated = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateUpdated"].ToString()), ControlConfig.InstanceId)); } _with1.Interests = dr["Interests"].ToString(); _with1.IsUserOnline = bool.Parse(dr["IsUserOnline"].ToString()); _with1.Location = dr["Location"].ToString(); _with1.MSN = dr["MSN"].ToString(); _with1.Occupation = dr["Occupation"].ToString(); _with1.TopicCount = int.Parse(dr["UserTopicCount"].ToString()); _with1.ReplyCount = int.Parse(dr["UserReplyCount"].ToString()); _with1.RewardPoints = int.Parse(dr["RewardPoints"].ToString()); _with1.Roles = dr["UserRoles"].ToString(); _with1.Signature = dr["Signature"].ToString(); _with1.TrustLevel = int.Parse(dr["TrustLevel"].ToString()); _with1.WebSite = dr["WebSite"].ToString(); _with1.Yahoo = dr["Yahoo"].ToString(); tAuthor = profile; if (DataPageId == 1) { sTemp = ParseTopic(sTemp, Subject, CreateDate, Body, Tags, Convert.ToString(EditDate), IPAddress, ForumUser, rowCount); rowCount += 1; } else { sTemp = TemplateUtils.ReplaceSubSection(sTemp, string.Empty, "[TOPIC]", "[/TOPIC]"); } } if (ForumInfo == null) { ForumController fc = new ForumController(); Forum fi = null; fi = fc.Forums_Get(ForumId, UserId, true, true); ForumInfo = fi; } sTemp = sTemp.Replace("[FORUMID]", ForumId.ToString); sTemp = sTemp.Replace("[FORUMNAME]", ForumInfo.ForumName); sTemp = sTemp.Replace("[TOPICID]", TopicId.ToString); sTemp = sTemp.Replace("[CREATEROLES]", ForumInfo.Security.Create); sTemp = sTemp.Replace("[USERROLES]", ForumUser.UserRoles); sTemp = sTemp.Replace("[THEMEPATH]", ThemePath); sTemp = sTemp.Replace("[SUBJECT]", Subject); sTemp = sTemp.Replace("[PAGEID]", PageId.ToString); sTemp = sTemp.Replace("[REPLYROLES]", ForumInfo.Security.Reply); sTemp = sTemp.Replace("AF:SECURITY:MODROLES]", "AF:SECURITY:MODROLES:" + ForumInfo.Security.ModApprove + "]"); sTemp = sTemp.Replace("AF:SECURITY:MODAPPROVE]", "AF:SECURITY:MODAPPROVE:" + ForumInfo.Security.ModApprove + "]"); sTemp = sTemp.Replace("AF:SECURITY:DELETE]", "AF:SECURITY:DELETE:" + ForumInfo.Security.Delete + ForumInfo.Security.ModDelete + "]"); sTemp = sTemp.Replace("AF:SECURITY:EDIT]", "AF:SECURITY:EDIT:" + ForumInfo.Security.Edit + ForumInfo.Security.ModEdit + "]"); sTemp = sTemp.Replace("AF:SECURITY:LOCK]", "AF:SECURITY:LOCK:" + ForumInfo.Security.Lock + ForumInfo.Security.ModLock + "]"); sTemp = sTemp.Replace("AF:SECURITY:MOVE]", "AF:SECURITY:MOVE:" + ForumInfo.Security.ModMove + "]"); sTemp = sTemp.Replace("AF:SECURITY:PIN]", "AF:SECURITY:PIN:" + ForumInfo.Security.Pin + ForumInfo.Security.ModPin + "]"); sTemp = sTemp.Replace("AF:SECURITY:SPLIT]", "AF:SECURITY:SPLIT:" + ForumInfo.Security.ModSplit + "]"); sTemp = sTemp.Replace("AF:SECURITY:REPLY]", "AF:SECURITY:REPLY:" + ForumInfo.Security.Reply + "]"); if (LastPostDate == null) { LastPostDate = CreateDate; } string LastPostAuthor = string.Empty; if (((bRead & tAuthor.UserID == this.UserId)) & statusId >= 0) { sTemp = sTemp.Replace("[AF:CONTROL:STATUS]", "<asp:placeholder id=\"plhStatus\" runat=\"server\" />"); sTemp = sTemp.Replace("[AF:CONTROL:STATUSICON]", "<img alt=\"[RESX:PostStatus" + statusId.ToString() + "]\" src=\"" + ThemePath + "status" + statusId.ToString() + ".png\" />"); } else if (statusId >= 0) { sTemp = sTemp.Replace("[AF:CONTROL:STATUS]", string.Empty); sTemp = sTemp.Replace("[AF:CONTROL:STATUSICON]", "<img alt=\"[RESX:PostStatus" + statusId.ToString() + "]\" src=\"" + ThemePath + "status" + statusId.ToString() + ".png\" />"); } else { sTemp = sTemp.Replace("[AF:CONTROL:STATUS]", string.Empty); sTemp = sTemp.Replace("[AF:CONTROL:STATUSICON]", string.Empty); sTemp = sTemp.Replace("[ACTIONS:ANSWER]", string.Empty); } if (string.IsNullOrEmpty(LastPostData)) { LastPostAuthor = UserProfiles.GetDisplayName(ControlConfig.InstanceId, MainSettings.ProfileVisibility, false, tAuthor.UserID, MainSettings.UserNameDisplay, MainSettings.DisableUserProfiles, tAuthor.Username, tAuthor.FirstName, tAuthor.LastName, tAuthor.DisplayName); } else { Author la = new Author(); System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument(); xDoc.LoadXml(LastPostData); System.Xml.XmlNode xNode = xDoc.SelectSingleNode("//root/lastpost"); if ((xNode != null)) { var _with2 = la; _with2.AuthorId = int.Parse(xNode["authorid"].InnerText.ToString()); _with2.DisplayName = xNode["displayname"].InnerText; _with2.FirstName = xNode["firstname"].InnerText; _with2.LastName = xNode["lastname"].InnerText; _with2.Username = xNode["username"].InnerText; } LastPostAuthor = UserProfiles.GetDisplayName(ControlConfig.InstanceId, MainSettings.ProfileVisibility, false, la.AuthorId, MainSettings.UserNameDisplay, MainSettings.DisableUserProfiles, la.Username, la.FirstName, la.LastName, la.DisplayName); } //TODO:Fix LastPostDate Format sTemp = sTemp.Replace("[AF:LABEL:LastPostDate]", LastPostDate.ToString()); sTemp = sTemp.Replace("[AF:LABEL:LastPostAuthor]", LastPostAuthor); sTemp = sTemp.Replace("[AF:LABEL:ReplyCount]", ReplyCount.ToString()); string sURL = "<a rel=\"nofollow\" href=\"" + Utilities.NavigateUrl(PageId, "", ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, "mid=" + ControlConfig.InstanceId.ToString, "dnnprintmode=true") + "?skinsrc=" + HttpUtility.UrlEncode("[G]" + DotNetNuke.UI.Skins.SkinInfo.RootSkin + "/" + DotNetNuke.Common.glbHostSkinFolder + "/" + "No Skin") + "&containersrc=" + HttpUtility.UrlEncode("[G]" + DotNetNuke.UI.Skins.SkinInfo.RootContainer + "/" + DotNetNuke.Common.glbHostSkinFolder + "/" + "No Container") + "\" target=\"_blank\">"; sURL += "<img src=\"" + ThemePath + "images/spacer.gif\" alt=\"[RESX:PrinterFriendly]\" class=\"aficon aficonprint\" /></a>"; sTemp = sTemp.Replace("[AF:CONTROL:PRINTER]", sURL); if (HttpContext.Current.Request.IsAuthenticated) { sURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ViewType + "=sendto", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId }); sTemp = sTemp.Replace("[AF:CONTROL:EMAIL]", "<a href=\"" + sURL + "\" rel=\"nofollow\"><img src=\"" + ThemePath + "images/spacer.gif\" class=\"aficon aficonemail\" alt=\"[RESX:EmailThis]\" /></a>"); } else { sTemp = sTemp.Replace("[AF:CONTROL:EMAIL]", string.Empty); } if (ForumInfo.AllowRSS) { string Url = null; Url = DotNetNuke.Common.AddHTTP(DotNetNuke.Common.GetDomainName(HttpContext.Current.Request)) + "/DesktopModules/ActiveForums/feeds.aspx?portalid=" + ControlConfig.SiteId + "&forumid=" + ForumId + "&tabid=" + PageId + "&moduleid=" + ControlConfig.InstanceId; sTemp = sTemp.Replace("[RSSLINK]", "<a href=\"" + Url + "\"><img src=\"" + ThemePath + "images/rss.png\" runat=server border=\"0\" alt=\"[RESX:RSS]\" /></a>"); } else { sTemp = sTemp.Replace("[RSSLINK]", string.Empty); } if (nextTopic == 0) { sTemp = sTemp.Replace("[NEXTTOPICID]", string.Empty); sTemp = sTemp.Replace("[HASNEXTTOPIC]", "False"); } else { sTemp = sTemp.Replace("[NEXTTOPICID]", nextTopic.ToString()); sTemp = sTemp.Replace("[HASNEXTTOPIC]", "True"); } if (prevTopic == 0) { sTemp = sTemp.Replace("[PREVTOPICID]", string.Empty); sTemp = sTemp.Replace("[HASPREVTOPIC]", "False"); } else { sTemp = sTemp.Replace("[PREVTOPICID]", prevTopic.ToString()); sTemp = sTemp.Replace("[HASPREVTOPIC]", "True"); } dr.NextResult(); //Process Replies StringBuilder sb = new StringBuilder(); sb.Append(string.Empty); int replyId = 0; while (dr.Read()) { Subject = dr["Subject"].ToString(); Body = dr["Body"].ToString(); CreateDate = Convert.ToDateTime(dr["DateCreated"].ToString()); EditDate = Convert.ToDateTime(dr["DateUpdated"].ToString()); IPAddress = dr["IPAddress"].ToString(); replyId = int.Parse(dr["ReplyId"].ToString()); UserProfileInfo profile = new UserProfileInfo(); var _with3 = profile; _with3.UserID = int.Parse(dr["AuthorId"].ToString()); if (string.IsNullOrEmpty(dr["DisplayName"].ToString())) { _with3.DisplayName = dr["AuthorName"].ToString(); } else { _with3.DisplayName = dr["DisplayName"].ToString(); } _with3.FirstName = dr["FirstName"].ToString(); _with3.LastName = dr["LastName"].ToString(); _with3.Username = dr["Username"].ToString(); _with3.UserCaption = dr["UserCaption"].ToString(); _with3.AnswerCount = int.Parse(dr["AnswerCount"].ToString()); _with3.AOL = dr["AOL"].ToString(); _with3.Avatar = dr["Avatar"].ToString(); _with3.AvatarType = (AvatarTypes)int.Parse(dr["AvatarType"].ToString()); _with3.DateCreated = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateCreated"].ToString()), ControlConfig.InstanceId)); _with3.DateLastActivity = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastActivity"].ToString()), ControlConfig.InstanceId)); if (!string.IsNullOrEmpty(dr["DateLastPost"].ToString())) { _with3.DateLastPost = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["DateLastPost"].ToString()), ControlConfig.InstanceId)); } if (!string.IsNullOrEmpty(dr["UserDateUpdated"].ToString())) { _with3.DateUpdated = System.DateTime.Parse(Utilities.GetDate(System.DateTime.Parse(dr["UserDateUpdated"].ToString()), ControlConfig.InstanceId)); } _with3.Interests = dr["Interests"].ToString(); _with3.IsUserOnline = bool.Parse(dr["IsUserOnline"].ToString()); _with3.Location = dr["Location"].ToString(); _with3.MSN = dr["MSN"].ToString(); _with3.Occupation = dr["Occupation"].ToString(); _with3.TopicCount = int.Parse(dr["UserTopicCount"].ToString()); _with3.ReplyCount = int.Parse(dr["UserReplyCount"].ToString()); _with3.RewardPoints = int.Parse(dr["RewardPoints"].ToString()); _with3.Roles = dr["UserRoles"].ToString(); _with3.Signature = dr["Signature"].ToString(); _with3.TrustLevel = int.Parse(dr["TrustLevel"].ToString()); _with3.WebSite = dr["WebSite"].ToString(); _with3.Yahoo = dr["Yahoo"].ToString(); sb.Append(ParseReply(sTemp, replyId, Subject, CreateDate, Body, Convert.ToString(EditDate), IPAddress, ForumUser, rowCount)); rowCount += 1; } dr.Close(); sTemp = TemplateUtils.ReplaceSubSection(sTemp, sb.ToString(), "[REPLIES]", "[/REPLIES]"); sTemp = Utilities.LocalizeControl(sTemp); sTemp = sTemp.Replace("[TOPICID]", TopicId.ToString); sTemp = sTemp.Replace("[GROUPNAME]", ForumInfo.GroupName); sTemp = sTemp.Replace("[FORUMNAME]", ForumInfo.ForumName); sTemp = sTemp.Replace("[TOPICRATING]", topicRating.ToString()); sTemp = sTemp.Replace("[CURRENTUSERID]", UserId.ToString); sTemp = Utilities.ParseSecurityTokens(sTemp, ForumUser.UserRoles); if (!sTemp.Contains(Globals.ControlRegisterAFTag)) { sTemp = Globals.ControlRegisterAFTag + sTemp; } Control ctl = Page.ParseControl(sTemp); LinkControls(ctl.Controls); this.Controls.Add(ctl); } }
private void SaveQuickReply() { int iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { UserProfileController upc = new UserProfileController(); UserProfileInfo upi = upc.Profiles_Get(SiteId, InstanceId, this.UserId); if (upi != null) { if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval) { Controls.InfoMessage im = new Controls.InfoMessage(); im.Message = "<div class=\"afmessage\">" + string.Format(Utilities.GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>"; plhMessage.Controls.Add(im); return; } } } //TODO: Fix for anon //If Not Current.Request.IsAuthenticated Then // If Not ctlCaptcha.IsValid Or txtUserName.Value = "" Then // Exit Sub // End If //End If //Dim ui As New UserProfileInfo //If UserId > 0 Then // Dim upc As New UserProfileController // ui = upc.Profiles_Get(PortalId, ForumModuleId, UserId) //Else // ui.TopicCount = 0 // ui.ReplyCount = 0 // ui.RewardPoints = 0 // ui.IsMod = False // ui.TrustLevel = -1 //End If ForumController fc = new ForumController(); Forum forumInfo = fc.Forums_Get(SiteId, InstanceId, ForumId, this.UserId, true, false, TopicId); bool UserIsTrusted = false; UserIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, ControlConfig.User.TrustLevel, Permissions.HasPerm(forumInfo.Security.Trust, ForumUser.UserRoles), forumInfo.AutoTrustLevel, ControlConfig.User.PostCount); bool isApproved = false; isApproved = Convert.ToBoolean(((forumInfo.IsModerated == true) ? false : true)); if (UserIsTrusted || Permissions.HasPerm(forumInfo.Security.ModApprove, ForumUser.UserRoles)) { isApproved = true; } ReplyInfo ri = new ReplyInfo(); Data.Topics db = new Data.Topics(); //im rc As New ReplyController int ReplyId = -1; string sUsername = string.Empty; if (HttpContext.Current.Request.IsAuthenticated) { sUsername = ControlConfig.User.DisplayName; } else { sUsername = Utilities.CleanString(SiteId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, InstanceId, ThemePath, false); } string sBody = string.Empty; //TODO: Check for allowhtml bool allowHtml = false; //If forumInfo.AllowHTML Then // allowHtml = isHTMLPermitted(forumInfo.EditorPermittedUsers, IsTrusted, forumInfo.Security.ModEdit) //End If sBody = Utilities.CleanString(SiteId, HttpContext.Current.Request.Form["txtBody"], allowHtml, EditorTypes.TEXTBOX, forumInfo.UseFilter, forumInfo.AllowScript, InstanceId, ThemePath, forumInfo.AllowEmoticons); DateTime createDate = DateTime.Now; ri.TopicId = TopicId; ri.ReplyToId = TopicId; ri.Content.AuthorId = UserId; ri.Content.AuthorName = sUsername; ri.Content.Body = sBody; ri.Content.DateCreated = createDate; ri.Content.DateUpdated = createDate; ri.Content.IsDeleted = false; ri.Content.Subject = Subject; ri.Content.Summary = string.Empty; ri.IsApproved = isApproved; ri.IsDeleted = false; ri.Content.IPAddress = HttpContext.Current.Request.UserHostAddress; ReplyId = db.Reply_Save(ri); //Check if is subscribed if (HttpContext.Current.Request.Params["chkSubscribe"] != null) { if (HttpContext.Current.Request.Params["chkSubscribe"] == "1" && UserId > 0) { if (!(Subscriptions.IsSubscribed(SiteId, InstanceId, ForumId, TopicId, SubscriptionTypes.Instant, UserId))) { //TODO: Fix Subscriptions //Dim sc As New Data.Tracking //sc.Subscription_Update(SiteId, InstanceId, ForumId, TopicId, 1, UserId) } } } if (isApproved) { //Send Subscriptions try { string sURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); Subscriptions.SendSubscriptions(SiteId, InstanceId, PageId, ForumId, TopicId, ReplyId, UserId); #if !SKU_LITE try { Social oSocial = new Social(); oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", sURL, Subject, sBody); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } #endif } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } //Redirect to show post string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); HttpContext.Current.Response.Redirect(fullURL, false); } else if (isApproved == false) { Email oEmail = new Email(); oEmail.SendEmailToModerators(forumInfo.ModNotifyTemplateId, SiteId, ForumId, ri.TopicId, ReplyId, InstanceId, PageId, string.Empty); string[] Params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId }; HttpContext.Current.Response.Redirect(Utilities.NavigateUrl(PageId, "", Params), false); } else { string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); #if !SKU_LITE try { Modules.ActiveForums.Social oSocial = new Modules.ActiveForums.Social(); oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", fullURL, Subject, sBody); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } #endif HttpContext.Current.Response.Redirect(fullURL, false); } //End If }
private string SaveTopic() { int topicId = -1; int forumId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (topicId > 0) { TopicsController tc = new TopicsController(); TopicInfo t = tc.Topics_Get(PortalId, ModuleId, topicId); Data.ForumsDB db = new Data.ForumsDB(); forumId = db.Forum_GetByTopicId(topicId); ForumController fc = new ForumController(); Forum f = fc.Forums_Get(PortalId, -1, forumId, this.UserId, true, false, -1); if (Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles)) { string subject = Params["subject"].ToString(); subject = Utilities.XSSFilter(subject, true); if (!(string.IsNullOrEmpty(f.PrefixURL))) { string cleanSubject = Utilities.CleanName(subject).ToLowerInvariant(); if (SimulateIsNumeric.IsNumeric(cleanSubject)) { cleanSubject = "Topic-" + cleanSubject; } string topicUrl = cleanSubject; string urlPrefix = "/"; if (!(string.IsNullOrEmpty(f.ForumGroup.PrefixURL))) { urlPrefix += f.ForumGroup.PrefixURL + "/"; } if (!(string.IsNullOrEmpty(f.PrefixURL))) { urlPrefix += f.PrefixURL + "/"; } string urlToCheck = urlPrefix + cleanSubject; Data.Topics topicsDb = new Data.Topics(); for (int u = 0; u <= 200; u++) { int tid = topicsDb.TopicIdByUrl(PortalId, f.ModuleId, urlToCheck); if (tid > 0 && tid == topicId) { break; } else if (tid > 0) { topicUrl = (u + 1) + "-" + cleanSubject; urlToCheck = urlPrefix + topicUrl; } else { break; } } if (topicUrl.Length > 150) { topicUrl = topicUrl.Substring(0, 149); topicUrl = topicUrl.Substring(0, topicUrl.LastIndexOf("-")); } t.TopicUrl = topicUrl; //.URL = topicUrl } else { //.URL = String.Empty t.TopicUrl = string.Empty; } t.Content.Subject = subject; t.IsPinned = bool.Parse(Params["pinned"].ToString()); t.IsLocked = bool.Parse(Params["locked"].ToString()); t.Priority = int.Parse(Params["priority"].ToString()); t.StatusId = int.Parse(Params["status"].ToString()); if (f.Properties != null) { StringBuilder tData = new StringBuilder(); tData.Append("<topicdata>"); tData.Append("<properties>"); foreach (PropertiesInfo p in f.Properties) { string pkey = "prop-" + p.PropertyId.ToString(); tData.Append("<property id=\"" + p.PropertyId.ToString() + "\">"); tData.Append("<name><![CDATA["); tData.Append(p.Name); tData.Append("]]></name>"); if (Params[pkey] != null) { tData.Append("<value><![CDATA["); tData.Append(Utilities.XSSFilter(Params[pkey].ToString())); tData.Append("]]></value>"); } else { tData.Append("<value></value>"); } tData.Append("</property>"); } tData.Append("</properties>"); tData.Append("</topicdata>"); t.TopicData = tData.ToString(); } } tc.TopicSave(PortalId, t); if (Params["tags"] != null) { DataProvider.Instance().Tags_DeleteByTopicId(PortalId, f.ModuleId, topicId); string tagForm = string.Empty; if (Params["tags"] != null) { tagForm = Params["tags"].ToString(); } if (!(tagForm == string.Empty)) { string[] Tags = tagForm.Split(','); foreach (string tag in Tags) { string sTag = Utilities.CleanString(PortalId, tag.Trim(), false, EditorTypes.TEXTBOX, false, false, f.ModuleId, string.Empty, false); DataProvider.Instance().Tags_Save(PortalId, f.ModuleId, -1, sTag, 0, 1, 0, topicId, false, -1, -1); } } } if (Params["categories"] != null) { string[] cats = Params["categories"].ToString().Split(';'); DataProvider.Instance().Tags_DeleteTopicToCategory(PortalId, f.ModuleId, -1, topicId); foreach (string c in cats) { int cid = -1; if (!(string.IsNullOrEmpty(c)) && SimulateIsNumeric.IsNumeric(c)) { cid = Convert.ToInt32(c); if (cid > 0) { DataProvider.Instance().Tags_AddTopicToCategory(PortalId, f.ModuleId, cid, topicId); } } } } } return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); }
public string Render() { ForumController fc = new ForumController(); string fs = fc.GetForumsForUser(ForumUser.UserRoles, PortalId, ModuleId, "CanEdit"); if (! (string.IsNullOrEmpty(fs))) { _canEdit = true; } System.Text.StringBuilder sb = new System.Text.StringBuilder(); string forumPrefix = string.Empty; string groupPrefix = string.Empty; _mainSettings = DataCache.MainSettings(ModuleId); if (_mainSettings.URLRewriteEnabled) { if (ForumId > 0) { Forum f = fc.GetForum(PortalId, ModuleId, ForumId); if (f != null) { forumPrefix = f.PrefixURL; groupPrefix = f.ForumGroup.PrefixURL; } } else if (ForumGroupId > 0) { ForumGroupController grp = new ForumGroupController(); ForumGroupInfo g = grp.Groups_Get(ModuleId, ForumGroupId); if (g != null) { groupPrefix = g.PrefixURL; } } } string tmp = string.Empty; Data.Topics db = new Data.Topics(); int recordCount = 0; int i = 0; sb.Append(HeaderTemplate); using (IDataReader dr = db.TopicsList(PortalId, PageIndex, PageSize, ForumIds, CategoryId, TagId)) { while (dr.Read()) { if (recordCount == 0) { recordCount = int.Parse(dr["RecordCount"].ToString()); } tmp = ParseDataRow(dr, Template); if (i % 2 == 0) { tmp = tmp.Replace("[ROWCSS]", ItemCss); } else { tmp = tmp.Replace("[ROWCSS]", AltItemCSS); } i += 1; sb.Append(tmp); } dr.Close(); } sb.Append(FooterTemplate); int pageCount = 1; pageCount = Convert.ToInt32(System.Math.Ceiling((double)recordCount / PageSize)); ControlUtils cUtils = new ControlUtils(); string otherPrefix = string.Empty; if (TagId > 0 | CategoryId > 0) { int id = -1; if (TagId > 0) { id = TagId; } else { id = CategoryId; } using (IDataReader dr = DataProvider.Instance().Tags_Get(PortalId, ModuleId, id)) { while (dr.Read()) { otherPrefix = Utilities.CleanName(dr["TagName"].ToString()); } dr.Close(); } } sb.Append(cUtils.BuildPager(TabId, ModuleId, groupPrefix, forumPrefix, ForumGroupId, ForumId, TagId, CategoryId, otherPrefix, PageIndex, pageCount)); return sb.ToString(); }
private void cb_Callback(object sender, CallBackEventArgs e) { Data.Topics db = new Data.Topics(); if (e.Parameters.Length > 0) { int rate = Convert.ToInt32(e.Parameter); if (rate >= 1 && rate <= 5) { RatingValue = db.Topics_AddRating(TopicId, UserId, rate, string.Empty, HttpContext.Current.Request.UserHostAddress.ToString()); } } CallBackContent cbContent = new CallBackContent(); cbContent.Controls.Add(new LiteralControl(RenderRating())); cb.Content = cbContent; cb.Content.RenderControl(e.Output); }