protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { ForumModuleId = MID; if (ForumId < 1) { ForumId = FID; } if (Request.QueryString["GroupId"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["GroupId"])) { SocialGroupId = Convert.ToInt32(Request.QueryString["GroupId"]); } //Put user code to initialize the page here txtSearch.Attributes.Add("onkeydown", "if(event.keyCode == 13){document.getElementById('" + lnkSearch.ClientID + "').click();}"); } catch (Exception exc) { Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc); } }
private string SubscribeTopic() { if (UserId <= 0) { return(BuildOutput(string.Empty, OutputCodes.AuthenticationFailed, true)); } int iStatus = 0; SubscriptionController sc = new SubscriptionController(); int forumId = -1; int topicId = -1; if (Params.ContainsKey("forumid") && SimulateIsNumeric.IsNumeric(Params["forumid"])) { forumId = int.Parse(Params["forumid"].ToString()); } if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } iStatus = sc.Subscription_Update(PortalId, ModuleId, forumId, topicId, 1, this.UserId, ForumUser.UserRoles); if (iStatus == 1) { return(BuildOutput("{\"subscribed\":true,\"text\":\"" + Utilities.JSON.EscapeJsonString(Utilities.GetSharedResource("[RESX:TopicSubscribe:TRUE]")) + "\"}", OutputCodes.Success, true, true)); } else { return(BuildOutput("{\"subscribed\":false,\"text\":\"" + Utilities.JSON.EscapeJsonString(Utilities.GetSharedResource("[RESX:TopicSubscribe:FALSE]")) + "\"}", OutputCodes.Success, true, true)); } }
private string DeleteTopic() { 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(forumId, this.UserId, true); if (f != null) { if (Permissions.HasPerm(f.Security.ModDelete, ForumUser.UserRoles) || (t.Author.AuthorId == this.UserId && Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles))) { tc.Topics_Delete(PortalId, ModuleId, forumId, topicId, MainSettings.DeleteBehavior); return(BuildOutput(string.Empty, OutputCodes.Success, true)); } } } return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Request.Params["view"] != null) { string sUrl; string sParams = string.Empty; if (Request.Params["forumid"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["ForumId"])) { sParams = ParamKeys.ForumId + "=" + Request.Params["ForumId"]; } } if (Request.Params["postid"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["postid"])) { sParams += "|" + ParamKeys.TopicId + "=" + Request.Params["postid"]; } } sParams += "|" + ParamKeys.ViewType + "=" + Request.Params["view"]; sUrl = NavigateUrl(TabId, "", sParams.Split('|')); Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", sUrl); } Framework.jQuery.RequestRegistration(); }
private string MoveTopic() { int topicId = -1; int forumId = -1; int targetForumId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (Params.ContainsKey("forumid") && SimulateIsNumeric.IsNumeric(Params["forumid"])) { targetForumId = int.Parse(Params["forumid"].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(forumId, this.UserId, true); if (f != null) { if (Permissions.HasPerm(f.Security.ModMove, ForumUser.UserRoles)) { tc.Topics_Move(PortalId, ModuleId, targetForumId, topicId); DataCache.ClearAllCache(ModuleId, TabId); return(BuildOutput(string.Empty, OutputCodes.Success, true)); } } } return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); }
private string MarkAnswer() { int topicId = -1; int forumId = -1; int replyId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (Params.ContainsKey("replyid") && SimulateIsNumeric.IsNumeric(Params["replyid"])) { replyId = int.Parse(Params["replyid"].ToString()); } if (topicId > 0 & UserId > 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(forumId, this.UserId, true); if ((this.UserId == t.Author.AuthorId && !t.IsLocked) || Permissions.HasAccess(f.Security.ModEdit, ForumUser.UserRoles)) { DataProvider.Instance().Reply_UpdateStatus(PortalId, ModuleId, topicId, replyId, UserId, 1, Permissions.HasAccess(f.Security.ModEdit, ForumUser.UserRoles)); } return(BuildOutput(string.Empty, OutputCodes.Success, true)); } else { return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); } }
private void agFilters_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { try { if (!(e.Parameters[4] == "")) { string sAction = e.Parameters[4].Split(':')[0]; int FilterId = Convert.ToInt32(e.Parameters[4].Split(':')[1]); switch (sAction.ToUpper()) { case "DELETE": if (SimulateIsNumeric.IsNumeric(FilterId)) { DataProvider.Instance().Filters_Delete(PortalId, ModuleId, FilterId); } break; case "DEFAULTS": DataProvider.Instance().Filters_DeleteByModuleId(PortalId, ModuleId); Utilities.ImportFilter(PortalId, ModuleId); break; } } int PageIndex = Convert.ToInt32(e.Parameters[0]); int PageSize = Convert.ToInt32(e.Parameters[1]); string SortColumn = e.Parameters[2].ToString(); string Sort = e.Parameters[3].ToString(); agFilters.Datasource = DataProvider.Instance().Filters_List(PortalId, ModuleId, PageIndex, PageSize, Sort, SortColumn); agFilters.Refresh(e.Output); } catch (Exception ex) { } }
private string DeletePost() { int replyId = -1; int TopicId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { TopicId = int.Parse(Params["topicid"].ToString()); } if (Params.ContainsKey("replyid") && SimulateIsNumeric.IsNumeric(Params["replyid"])) { replyId = int.Parse(Params["replyid"].ToString()); } int forumId = -1; Data.ForumsDB db = new Data.ForumsDB(); forumId = db.Forum_GetByTopicId(TopicId); ForumController fc = new ForumController(); Forum f = fc.Forums_Get(forumId, this.UserId, true); if (TopicId > 0 & replyId < 1) { TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ModuleId, TopicId); if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ti.Content.AuthorId == UserId && ti.IsLocked == false)) { DataProvider.Instance().Topics_Delete(forumId, TopicId, MainSettings.DeleteBehavior); string journalKey = string.Format("{0}:{1}", forumId.ToString(), TopicId.ToString()); JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey); } else { return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); } } else { ReplyController rc = new ReplyController(); ReplyInfo ri = rc.Reply_Get(PortalId, ModuleId, TopicId, replyId); if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ri.Content.AuthorId == UserId)) { DataProvider.Instance().Reply_Delete(forumId, TopicId, replyId, MainSettings.DeleteBehavior); string journalKey = string.Format("{0}:{1}:{2}", forumId.ToString(), TopicId.ToString(), replyId.ToString()); JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey); } else { return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); } } string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); return(BuildOutput(TopicId + "|" + replyId, OutputCodes.Success, true)); }
private void agTags_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { try { if (!(e.Parameters[4] == "")) { string sAction = e.Parameters[4].Split(':')[0]; switch (sAction.ToUpper()) { case "DELETE": { int TagId = Convert.ToInt32(e.Parameters[4].Split(':')[1]); if (SimulateIsNumeric.IsNumeric(TagId)) { DataProvider.Instance().Tags_Delete(PortalId, ModuleId, TagId); } break; } case "SAVE": { string[] sParams = e.Parameters[4].Split(':'); string TagName = sParams[1].Trim(); int TagId = 0; if (sParams.Length > 2) { TagId = Convert.ToInt32(sParams[2]); } if (!(TagName == string.Empty)) { DataProvider.Instance().Tags_Save(PortalId, ModuleId, TagId, TagName, 0, 0, 0, -1, false, -1, -1); } break; } } } agTags.DefaultParams = string.Empty; int PageIndex = Convert.ToInt32(e.Parameters[0]); int PageSize = Convert.ToInt32(e.Parameters[1]); string SortColumn = e.Parameters[2].ToString(); string Sort = e.Parameters[3].ToString(); agTags.Datasource = DataProvider.Instance().Tags_List(PortalId, ModuleId, false, PageIndex, PageSize, Sort, SortColumn, -1, -1); agTags.Refresh(e.Output); } catch (Exception ex) { } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Put user code to initialize the page here Response.ContentType = "text/xml"; Response.ContentEncoding = Encoding.UTF8; int intPortalId = -1; if (Request.QueryString["portalid"] != null) { if (SimulateIsNumeric.IsNumeric(Request.QueryString["portalid"])) { intPortalId = Convert.ToInt32(Request.QueryString["portalid"]); } } //PortalSettings.PortalId int intTabId = -1; if (Request.QueryString["tabid"] != null) { if (SimulateIsNumeric.IsNumeric(Request.QueryString["tabid"])) { intTabId = Convert.ToInt32(Request.QueryString["tabid"]); } } if (Request.QueryString["moduleid"] != null) { if (SimulateIsNumeric.IsNumeric(Request.QueryString["moduleid"])) { ModuleID = Convert.ToInt32(Request.QueryString["moduleid"]); } } int intPosts = 10; bool bolSecurity = false; bool bolBody = true; int ForumID = -1; if (Request.QueryString["ForumID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.QueryString["ForumId"])) { ForumID = Int32.Parse(Request.QueryString["ForumID"]); } } if (intPortalId >= 0 && intTabId > 0 & ModuleID > 0 & ForumID > 0) { Response.Write(BuildRSS(intPortalId, intTabId, ModuleID, intPosts, ForumID, bolSecurity, bolBody)); } }
protected override void Render(HtmlTextWriter writer) { Controls.TopicBrowser tb = new Controls.TopicBrowser(); tb.PortalId = PortalId; tb.ModuleId = ForumModuleId; tb.TabId = ForumTabId; if (tb.TabId <= 0) { tb.TabId = int.Parse(Request.QueryString["TabID"]); } tb.ForumGroupId = ForumGroupId; tb.ForumId = ForumId; if (ForumId > 0) { if (Permissions.HasAccess(ForumInfo.Security.View, ForumUser.UserRoles)) { tb.ForumIds = ForumId.ToString(); } else { writer.Write(string.Empty); return; } } else { tb.ForumIds = UserForumsList; } if (Request.QueryString["atg"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["atg"])) { tb.TagId = int.Parse(Request.QueryString["atg"]); } if (Request.QueryString["act"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["act"])) { tb.CategoryId = int.Parse(Request.QueryString["act"]); } tb.ForumUser = ForumUser; tb.PageIndex = PageId; tb.PageSize = MainSettings.PageSize; tb.Template = ItemTemplate.Text; tb.HeaderTemplate = HeaderTemplate.Text; tb.FooterTemplate = FooterTemplate.Text; tb.ImagePath = Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MainSettings.Theme); tb.TopicId = TopicId; tb.TimeZoneOffset = TimeZoneOffset; writer.Write(tb.Render()); }
public static string Pair(string name, string value, bool isObject) { if (string.IsNullOrEmpty(value)) { value = ((char)(34)).ToString() + ((char)(34)).ToString(); } else if (!(SimulateIsNumeric.IsNumeric(value)) & !(value.ToLower() == "true" || value.ToLower() == "false") && isObject == false) { value = ((char)(34)).ToString() + JSON.EscapeJsonString(value) + ((char)(34)).ToString(); } else if (value.Trim().ToLowerInvariant() == "true" || value.Trim().ToLowerInvariant() == "false") { value = value.Trim().ToLower(); } return(((char)(34)).ToString() + name + ((char)(34)).ToString() + ":" + value); }
private string LikePost() { int userId = 0; int contentId = 0; if (Params.ContainsKey("userId") && SimulateIsNumeric.IsNumeric(Params["userId"])) { userId = int.Parse(Params["userId"].ToString()); } if (Params.ContainsKey("contentId") && SimulateIsNumeric.IsNumeric(Params["contentId"])) { contentId = int.Parse(Params["contentId"].ToString()); } var likeController = new LikesController(); likeController.Like(contentId, UserId); return(BuildOutput(userId + "|" + contentId, OutputCodes.Success, true)); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string sDisplayName = string.Empty; int tUid = -1; if (Request.Params["UID"] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params["UID"])) { tUid = Convert.ToInt32(Request.Params["UID"]); DotNetNuke.Entities.Users.UserController uc = new DotNetNuke.Entities.Users.UserController(); DotNetNuke.Entities.Users.UserInfo ui = uc.GetUser(PortalId, tUid); if (ui != null) { sDisplayName = UserProfiles.GetDisplayName(ModuleId, ui.UserID, ui.Username, ui.FirstName, ui.LastName, ui.DisplayName); } } } else { tUid = UserId; sDisplayName = UserProfiles.GetDisplayName(ModuleId, UserId, UserInfo.Username, UserInfo.FirstName, UserInfo.LastName, UserInfo.DisplayName); } lblHeader.Text = string.Format(Utilities.GetSharedResource("[RESX:ProfileForUser]"), sDisplayName); if (MainSettings.UseSkinBreadCrumb) { Environment.UpdateBreadCrumb(Page.Controls, "<a href=\"" + Utilities.NavigateUrl(TabId, "", new string[] { "afv=profile", "uid=" + tUid.ToString() }) + "\">" + lblHeader.Text + "</a>"); } DotNetNuke.Framework.CDefault tempVar = this.BasePage; Environment.UpdateMeta(ref tempVar, "[VALUE] - " + lblHeader.Text, "[VALUE]", "[VALUE]"); SettingsBase ctl = null; ctl = (SettingsBase)(new DotNetNuke.Modules.ActiveForums.Controls.UserProfile()); ctl.ModuleConfiguration = this.ModuleConfiguration; if (!(this.Params == string.Empty)) { ctl.Params = this.Params; } plhProfile.Controls.Add(ctl); }
private string RateTopic() { int r = 0; int topicId = -1; if (Params.ContainsKey("rate") && SimulateIsNumeric.IsNumeric(Params["rate"])) { r = int.Parse(Params["rate"].ToString()); } if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { topicId = int.Parse(Params["topicid"].ToString()); } if (r >= 1 && r <= 5 && topicId > 0) { DataProvider.Instance().Topics_AddRating(topicId, UserId, r, string.Empty, HttpContext.Current.Request.UserHostAddress.ToString()); } r = DataProvider.Instance().Topics_GetRating(topicId); return(BuildOutput(r.ToString(), OutputCodes.Success, true, false)); }
protected override void Render(HtmlTextWriter writer) { Controls.CategoriesList tb = new Controls.CategoriesList(PortalId, ModuleId, ForumId, ForumGroupId); tb.TabId = TabId; tb.Template = ItemTemplate.Text; tb.HeaderTemplate = HeaderTemplate.Text; tb.FooterTemplate = FooterTemplate.Text; tb.CSSClass = CssClass; if (HttpContext.Current.Request.QueryString["act"] != null && SimulateIsNumeric.IsNumeric(HttpContext.Current.Request.QueryString["act"])) { tb.SelectedCategory = int.Parse(HttpContext.Current.Request.QueryString["act"]); } if (RenderMode == 0) { writer.Write(tb.RenderView()); } else { writer.Write(tb.RenderEdit()); } }
private void cbMyFiles_Callback(object sender, Modules.ActiveForums.Controls.CallBackEventArgs e) { string attachIds = e.Parameters[1].ToString(); switch (e.Parameters[0].ToLowerInvariant()) { case "del": if (SimulateIsNumeric.IsNumeric(e.Parameters[2])) { int aid = Convert.ToInt32(e.Parameters[2]); Data.AttachController ac = new Data.AttachController(); int uid = -1; if (SimulateIsNumeric.IsNumeric(e.Parameters[3])) { uid = Convert.ToInt32(e.Parameters[3]); } if ((uid == this.UserId && !(this.UserId == -1)) | Permissions.HasPerm(ForumInfo.Security.ModDelete, ForumUser.UserRoles) || UserInfo.IsSuperUser) { ac.Attach_Delete(aid, -1, uid); } } break; } PendingAttach = 0; plhMyFiles.Controls.Clear(); BindMyFiles(); System.IO.StringWriter stringWriter = new System.IO.StringWriter(); HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); plhMyFiles.RenderControl(htmlWriter); string html = stringWriter.GetStringBuilder().ToString(); html = Utilities.LocalizeControl(html); LiteralControl lit = new LiteralControl(); lit.Text = html; lit.RenderControl(e.Output); }
public static WhatsNewModuleSettings CreateFromModuleSettings(Hashtable moduleSettings) { if (moduleSettings == null) { return(new WhatsNewModuleSettings { Rows = DefaultRows, Forums = DefaultForums, RSSEnabled = DefaultRSSEnabled, RSSIgnoreSecurity = DefaultRSSIgnoreSecurity, RSSIncludeBody = DefaultRSSIncludeBody, RSSCacheTimeout = DefaultRSSCacheTimeout, TopicsOnly = DefaultTopicsOnly, RandomOrder = DefaultRandomOrder, Tags = DefaultTags, Header = DefaultHeader, Footer = DefaultFooter, Format = DefaultFormat }); } return(new WhatsNewModuleSettings { Rows = SimulateIsNumeric.IsNumeric(moduleSettings[RowsSettingsKey]) ? Convert.ToInt32(moduleSettings[RowsSettingsKey]) : DefaultRows, Forums = (moduleSettings[ForumsSettingsKey] != null) ? Convert.ToString(moduleSettings[ForumsSettingsKey]) : DefaultForums, RSSEnabled = SimulateIsNumeric.IsNumeric(moduleSettings[RSSEnabledSettingsKey]) ? Convert.ToBoolean(moduleSettings[RSSEnabledSettingsKey]) : DefaultRSSEnabled, RSSIgnoreSecurity = SimulateIsNumeric.IsNumeric(moduleSettings[RSSIgnoreSecuritySettingsKey]) ? Convert.ToBoolean(moduleSettings[RSSIgnoreSecuritySettingsKey]) : DefaultRSSIgnoreSecurity, RSSIncludeBody = SimulateIsNumeric.IsNumeric(moduleSettings[RSSIncludeBodySettingsKey]) ? Convert.ToBoolean(moduleSettings[RSSIncludeBodySettingsKey]) : DefaultRSSIncludeBody, RSSCacheTimeout = SimulateIsNumeric.IsNumeric(moduleSettings[RSSCacheTimeoutSettingsKey]) ? Convert.ToInt32(moduleSettings[RSSCacheTimeoutSettingsKey]) : DefaultRSSCacheTimeout, TopicsOnly = SimulateIsNumeric.IsNumeric(moduleSettings[TopicsOnlySettingsKey]) ? Convert.ToBoolean(moduleSettings[TopicsOnlySettingsKey]) : DefaultTopicsOnly, RandomOrder = SimulateIsNumeric.IsNumeric(moduleSettings[RandomOrderSettingsKey]) ? Convert.ToBoolean(moduleSettings[RandomOrderSettingsKey]) : DefaultRandomOrder, Tags = (moduleSettings[TagsSettingsKey] != null) ? Convert.ToString(moduleSettings[TagsSettingsKey]) : DefaultTags, Header = (moduleSettings[HeaderSettingsKey] != null) ? Convert.ToString(moduleSettings[HeaderSettingsKey]) : DefaultHeader, Footer = (moduleSettings[FooterSettingsKey] != null) ? Convert.ToString(moduleSettings[FooterSettingsKey]) : DefaultFooter, Format = (moduleSettings[FormatSettingsKey] != null) ? Convert.ToString(moduleSettings[FormatSettingsKey]) : DefaultFormat }); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); SocialGroupId = -1; if (Request.QueryString["GroupId"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["GroupId"])) { SocialGroupId = Convert.ToInt32(Request.QueryString["GroupId"]); } SetupPage(); try { if (MainSettings != null && MainSettings.InstallDate > Utilities.NullDate()) { if (Request.IsAuthenticated && UserLastAccess == Utilities.NullDate()) { if (ForumUser != null) { DateTime dtLastAccess = DateTime.Now; if (!(ForumUser.Profile.DateLastActivity == Utilities.NullDate())) { dtLastAccess = ForumUser.Profile.DateLastActivity; } UserLastAccess = dtLastAccess; } } if (ForumModuleId < 1) { ForumModuleId = ModuleId; } string ctl = DefaultView; string opts = string.Empty; if (Request.Params[ParamKeys.ViewType] != null) { ctl = Request.Params[ParamKeys.ViewType]; } else if (Request.Params["view"] != null) { ctl = Request.Params["view"]; } else if (Request.Params[ParamKeys.ViewType] == null & ForumId > 0 & TopicId <= 0) { ctl = Views.Topics; } else if (Request.Params[ParamKeys.ViewType] == null && Request.Params["view"] == null & TopicId > 0) { ctl = Views.Topic; } else if (Settings["amafDefaultView"] != null) { ctl = Settings["amafDefaultView"].ToString(); } //ctl = "advanced" // If Not cbLoader.IsCallback Then if (Request.QueryString[ParamKeys.PageJumpId] != null) { opts = "PageId=" + Request.QueryString[ParamKeys.PageJumpId]; } //End If currView = ctl; GetControl(ctl, opts); if (Request.IsAuthenticated) { if (MainSettings.UsersOnlineEnabled) { DataProvider.Instance().Profiles_UpdateActivity(PortalId, ForumModuleId, UserId); } } } else { string ctlPath = "~/DesktopModules/activeforums/controls/_default.ascx"; ForumBase ctlDefault = (ForumBase)(LoadControl(ctlPath)); ctlDefault.ID = "ctlConfig"; ctlDefault.ModuleConfiguration = this.ModuleConfiguration; plhLoader.Controls.Clear(); plhLoader.Controls.Add(ctlDefault); } } catch (Exception ex) { //Response.Write(ex.Message) DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
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)); }
private string LoadTopic() { 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 (f != null) { if (Permissions.HasPerm(f.Security.ModEdit, ForumUser.UserRoles)) { StringBuilder sb = new StringBuilder(); sb.Append("{"); sb.Append(Utilities.JSON.Pair("topicid", t.TopicId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("subject", t.Content.Subject)); sb.Append(","); sb.Append(Utilities.JSON.Pair("authorid", t.Content.AuthorId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("locked", t.IsLocked.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("pinned", t.IsPinned.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("priority", t.Priority.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("status", t.StatusId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("forumid", forumId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("forumname", f.ForumName)); sb.Append(","); sb.Append(Utilities.JSON.Pair("tags", t.Tags)); sb.Append(","); sb.Append(Utilities.JSON.Pair("categories", t.Categories)); sb.Append(","); sb.Append("\"properties\":["); string sCats = string.Empty; if (f.Properties != null) { int i = 0; foreach (PropertiesInfo p in f.Properties) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("propertyid", p.PropertyId.ToString())); sb.Append(","); sb.Append(Utilities.JSON.Pair("datatype", p.DataType)); sb.Append(","); sb.Append(Utilities.JSON.Pair("propertyname", p.Name)); sb.Append(","); string pvalue = p.DefaultValue; foreach (PropertiesInfo tp in t.TopicProperties) { if (tp.PropertyId == p.PropertyId) { pvalue = tp.DefaultValue; } } sb.Append(Utilities.JSON.Pair("propertyvalue", pvalue)); if (p.DataType.Contains("list")) { sb.Append(",\"listdata\":["); if (p.DataType.Contains("list|categories")) { using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, f.ModuleId, true, 0, 200, "ASC", "TagName", forumId, f.ForumGroupId)) { dr.NextResult(); while (dr.Read()) { sCats += "{"; sCats += Utilities.JSON.Pair("id", dr["TagId"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("name", dr["TagName"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("selected", IsSelected(dr["TagName"].ToString(), t.Categories).ToString()); sCats += "},"; } dr.Close(); } if (!(string.IsNullOrEmpty(sCats))) { sCats = sCats.Substring(0, sCats.Length - 1); } sb.Append(sCats); } else { DotNetNuke.Common.Lists.ListController lists = new DotNetNuke.Common.Lists.ListController(); string lName = p.DataType.Substring(p.DataType.IndexOf("|") + 1); DotNetNuke.Common.Lists.ListEntryInfoCollection lc = lists.GetListEntryInfoCollection(lName, string.Empty); int il = 0; foreach (DotNetNuke.Common.Lists.ListEntryInfo l in lc) { sb.Append("{"); sb.Append(Utilities.JSON.Pair("itemId", l.Value)); sb.Append(","); sb.Append(Utilities.JSON.Pair("itemName", l.Text)); sb.Append("}"); il += 1; if (il < lc.Count) { sb.Append(","); } } } sb.Append("]"); } sb.Append("}"); i += 1; if (i < f.Properties.Count) { sb.Append(","); } } } sb.Append("],\"categories\":["); sCats = string.Empty; using (IDataReader dr = DataProvider.Instance().Tags_List(PortalId, f.ModuleId, true, 0, 200, "ASC", "TagName", forumId, f.ForumGroupId)) { dr.NextResult(); while (dr.Read()) { sCats += "{"; sCats += Utilities.JSON.Pair("id", dr["TagId"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("name", dr["TagName"].ToString()); sCats += ","; sCats += Utilities.JSON.Pair("selected", IsSelected(dr["TagName"].ToString(), t.Categories).ToString()); sCats += "},"; } dr.Close(); } if (!(string.IsNullOrEmpty(sCats))) { sCats = sCats.Substring(0, sCats.Length - 1); } sb.Append(sCats); sb.Append("]"); sb.Append("}"); return(BuildOutput(sb.ToString(), OutputCodes.Success, true, true)); } } } return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); }
public override void ProcessRequest(HttpContext context) { AdminRequired = false; base.AdminRequired = false; base.ProcessRequest(context); string sOut = "{\"result\":\"success\"}"; Actions action = Actions.None; if (Params != null && Params.Count > 0) { if (Params["action"] != null && SimulateIsNumeric.IsNumeric(Params["action"])) { action = (Actions)(Convert.ToInt32(Params["action"].ToString())); } } else if (HttpContext.Current.Request.QueryString["action"] != null && SimulateIsNumeric.IsNumeric(HttpContext.Current.Request.QueryString["action"])) { if (int.Parse(HttpContext.Current.Request.QueryString["action"]) == 11) { action = Actions.TagsAutoComplete; } } switch (action) { case Actions.UserPing: sOut = UserOnline(); break; case Actions.GetUsersOnline: sOut = GetUserOnlineList(); break; case Actions.TopicSubscribe: sOut = SubscribeTopic(); break; case Actions.ForumSubscribe: sOut = SubscribeForum(); break; case Actions.RateTopic: sOut = RateTopic(); break; case Actions.DeleteTopic: sOut = DeleteTopic(); break; case Actions.MoveTopic: sOut = MoveTopic(); break; case Actions.PinTopic: sOut = PinTopic(); break; case Actions.LockTopic: sOut = LockTopic(); break; case Actions.MarkAnswer: sOut = MarkAnswer(); break; case Actions.TagsAutoComplete: sOut = TagsAutoComplete(); break; case Actions.DeletePost: sOut = DeletePost(); break; case Actions.LoadTopic: sOut = LoadTopic(); break; case Actions.SaveTopic: sOut = SaveTopic(); break; case Actions.ForumList: sOut = ForumList(); break; } context.Response.ContentType = "text/plain"; context.Response.Write(sOut); }
public void OnBeginRequest(object s, EventArgs e) { _forumId = -1; _tabId = -1; _moduleId = -1; _topicId = -1; _page = 1; _contentId = -1; _archived = 0; _forumgroupId = -1; _mainSettings = null; _categoryId = -1; _tagId = -1; HttpApplication app = (HttpApplication)s; HttpServerUtility Server = app.Server; HttpRequest Request = app.Request; HttpResponse Response = app.Response; string requestedPath = app.Request.Url.AbsoluteUri; HttpContext Context = ((HttpApplication)s).Context; int PortalId = -1; DotNetNuke.Entities.Portals.PortalAliasInfo objPortalAliasInfo = null; string sUrl = HttpContext.Current.Request.RawUrl.Replace("http://", string.Empty).Replace("https://", string.Empty); objPortalAliasInfo = PortalAliasController.Instance.GetPortalAlias(HttpContext.Current.Request.Url.Host); if (Request.RawUrl.ToLowerInvariant().Contains("404.aspx")) { string sEx = ".jpg,.gif,.png,.swf,.js,.css,.html,.htm,desktopmodules,portals,.ashx,.ico,.txt,.doc,.docx,.pdf,.xml,.xls,.xlsx,.ppt,.pptx,.csv,.zip,.asmx,.aspx"; foreach (string sn in sEx.Split(',')) { if (sUrl.Contains(sn)) { // IO.File.AppendAllText(sPath, Request.RawUrl & "165<br />") return; } } } if (Request.Url.LocalPath.ToLower().Contains("scriptresource.axd") || Request.Url.LocalPath.ToLower().Contains("webresource.axd") || Request.Url.LocalPath.ToLower().Contains("viewer.aspx") || Request.Url.LocalPath.ToLower().Contains("cb.aspx") || Request.Url.LocalPath.ToLower().Contains("filesupload.aspx") || Request.Url.LocalPath.ToLower().Contains(".gif") || Request.Url.LocalPath.ToLower().Contains(".jpg") || Request.Url.LocalPath.ToLower().Contains(".css") || Request.Url.LocalPath.ToLower().Contains(".png") || Request.Url.LocalPath.ToLower().Contains(".swf") || Request.Url.LocalPath.ToLower().Contains(".htm") || Request.Url.LocalPath.ToLower().Contains(".html") || Request.Url.LocalPath.ToLower().Contains(".ashx") || Request.Url.LocalPath.ToLower().Contains(".cur") || Request.Url.LocalPath.ToLower().Contains(".ico") || Request.Url.LocalPath.ToLower().Contains(".txt") || Request.Url.LocalPath.ToLower().Contains(".pdf") || Request.Url.LocalPath.ToLower().Contains(".xml") || Request.Url.LocalPath.ToLower().Contains("/portals/") || Request.Url.LocalPath.ToLower().Contains("/desktopmodules/") || Request.Url.LocalPath.ToLower().Contains("evexport.aspx") || Request.Url.LocalPath.ToLower().Contains("signupjs.aspx") || Request.Url.LocalPath.ToLower().Contains("evsexport.aspx") || Request.Url.LocalPath.ToLower().Contains("fbcomm.aspx") || Request.Url.LocalPath.ToLower().Contains(".aspx") || Request.Url.LocalPath.ToLower().Contains(".js")) { return; } if (Request.Url.LocalPath.ToLower().Contains("install.aspx") || Request.Url.LocalPath.ToLower().Contains("installwizard.aspx") || Request.Url.LocalPath.ToLower().Contains("captcha.aspx") || Request.RawUrl.Contains("viewer.aspx") || Request.RawUrl.Contains("blank.html") || Request.RawUrl.Contains("default.htm") || Request.RawUrl.Contains("autosuggest.aspx")) { return; } PortalId = objPortalAliasInfo.PortalID; string searchURL = sUrl; searchURL = searchURL.Replace(objPortalAliasInfo.HTTPAlias, string.Empty); if (searchURL.Length < 2) { return; } string query = string.Empty; if (searchURL.Contains("?")) { query = searchURL.Substring(searchURL.IndexOf("?")); searchURL = searchURL.Substring(0, searchURL.IndexOf("?") - 1); } string newSearchURL = string.Empty; foreach (string up in searchURL.Split('/')) { if (!(string.IsNullOrEmpty(up))) { if (!(SimulateIsNumeric.IsNumeric(up))) { newSearchURL += up + "/"; } } } bool canContinue = false; Data.Common db = new Data.Common(); string tagName = string.Empty; string catName = string.Empty; if (newSearchURL.Contains("/category/") || newSearchURL.Contains("/tag/")) { if (newSearchURL.Contains("/category/")) { string cat = "/category/"; int iEnd = newSearchURL.IndexOf("/", newSearchURL.IndexOf(cat) + cat.Length + 1); string catString = newSearchURL.Substring(newSearchURL.IndexOf(cat), iEnd - newSearchURL.IndexOf(cat)); catName = catString.Replace(cat, string.Empty); catName = catName.Replace("/", string.Empty); newSearchURL = newSearchURL.Replace(catString, string.Empty); } if (newSearchURL.Contains("/tag/")) { string tag = "/tag/"; int iEnd = newSearchURL.IndexOf("/", newSearchURL.IndexOf(tag) + tag.Length + 1); string tagString = newSearchURL.Substring(newSearchURL.IndexOf(tag), iEnd - newSearchURL.IndexOf(tag)); tagName = tagString.Replace(tag, string.Empty); tagName = tagName.Replace("/", string.Empty); newSearchURL = newSearchURL.Replace(tagString, string.Empty); } } if ((sUrl.Contains("afv") && sUrl.Contains("post")) | (sUrl.Contains("afv") && sUrl.Contains("confirmaction")) | (sUrl.Contains("afv") && sUrl.Contains("sendto")) | (sUrl.Contains("afv") && sUrl.Contains("modreport")) | (sUrl.Contains("afv") && sUrl.Contains("search")) | sUrl.Contains("dnnprintmode") || sUrl.Contains("asg") || (sUrl.Contains("afv") && sUrl.Contains("modtopics"))) { return; } try { using (IDataReader dr = db.URLSearch(PortalId, newSearchURL)) { while (dr.Read()) { _tabId = int.Parse(dr["TabID"].ToString()); _moduleId = int.Parse(dr["ModuleId"].ToString()); _forumgroupId = int.Parse(dr["ForumGroupId"].ToString()); _forumId = int.Parse(dr["ForumId"].ToString()); _topicId = int.Parse(dr["TopicId"].ToString()); _archived = int.Parse(dr["Archived"].ToString()); _otherId = int.Parse(dr["OtherId"].ToString()); _urlType = int.Parse(dr["UrlType"].ToString()); canContinue = true; } dr.Close(); } } catch (Exception ex) { } if (!(string.IsNullOrEmpty(catName))) { _categoryId = db.Tag_GetIdByName(PortalId, _moduleId, catName, true); _otherId = _categoryId; _urlType = 2; } if (!(string.IsNullOrEmpty(tagName))) { _tagId = db.Tag_GetIdByName(PortalId, _moduleId, tagName, false); _otherId = _tagId; _urlType = 3; } if (_archived == 1) { sUrl = db.GetUrl(_moduleId, _forumgroupId, _forumId, _topicId, _userId, -1); if (!(string.IsNullOrEmpty(sUrl))) { string sHost = objPortalAliasInfo.HTTPAlias; if (sUrl.StartsWith("/")) { sUrl = sUrl.Substring(1); } if (!(sHost.EndsWith("/"))) { sHost += "/"; } sUrl = sHost + sUrl; if (!(sUrl.EndsWith("/"))) { sUrl += "/"; } if (!(sUrl.StartsWith("http"))) { if (Request.IsSecureConnection) { sUrl = "https://" + sUrl; } else { sUrl = "http://" + sUrl; } } Response.Clear(); Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", sUrl); Response.End(); } } if (_moduleId > 0) { Entities.Modules.ModuleController objModules = new Entities.Modules.ModuleController(); SettingsInfo objSettings = new SettingsInfo(); objSettings.MainSettings = objModules.GetModuleSettings(_moduleId); _mainSettings = objSettings; // DataCache.MainSettings(_moduleId) } if (_mainSettings == null) { return; } if (!_mainSettings.URLRewriteEnabled) { return; } if (!canContinue && (Request.RawUrl.Contains(ParamKeys.TopicId) || Request.RawUrl.Contains(ParamKeys.ForumId) || Request.RawUrl.Contains(ParamKeys.GroupId))) { sUrl = HandleOldUrls(Request.RawUrl, objPortalAliasInfo.HTTPAlias); if (!(string.IsNullOrEmpty(sUrl))) { if (!(sUrl.StartsWith("http"))) { if (Request.IsSecureConnection) { sUrl = "https://" + sUrl; } else { sUrl = "http://" + sUrl; } } Response.Clear(); Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", sUrl); Response.End(); } } if (!canContinue) { string topicUrl = string.Empty; if (newSearchURL.EndsWith("/")) { newSearchURL = newSearchURL.Substring(0, newSearchURL.Length - 1); } if (newSearchURL.Contains("/")) { topicUrl = newSearchURL.Substring(newSearchURL.LastIndexOf("/")); } topicUrl = topicUrl.Replace("/", string.Empty); if (!(string.IsNullOrEmpty(topicUrl))) { Data.Topics topicsDb = new Data.Topics(); _topicId = topicsDb.TopicIdByUrl(PortalId, _moduleId, topicUrl.ToLowerInvariant()); if (_topicId > 0) { sUrl = db.GetUrl(_moduleId, _forumgroupId, _forumId, _topicId, _userId, -1); } else { sUrl = string.Empty; } if (!(string.IsNullOrEmpty(sUrl))) { string sHost = objPortalAliasInfo.HTTPAlias; if (sHost.EndsWith("/") && sUrl.StartsWith("/")) { sUrl = sHost.Substring(0, sHost.Length - 1) + sUrl; } else if (!(sHost.EndsWith("/")) && !(sUrl.StartsWith("/"))) { sUrl = sHost + "/" + sUrl; } else { sUrl = sHost + sUrl; } if (sUrl.StartsWith("/")) { sUrl = sUrl.Substring(1); } if (!(sUrl.StartsWith("http"))) { if (Request.IsSecureConnection) { sUrl = "https://" + sUrl; } else { sUrl = "http://" + sUrl; } } if (!(string.IsNullOrEmpty(sUrl))) { Response.Clear(); Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", sUrl); Response.End(); } } } } if (canContinue) { if (searchURL != newSearchURL) { string urlTail = searchURL.Replace(newSearchURL, string.Empty); if (urlTail.StartsWith("/")) { urlTail = urlTail.Substring(1); } if (urlTail.EndsWith("/")) { urlTail = urlTail.Substring(0, urlTail.Length - 1); } if (urlTail.Contains("/")) { urlTail = urlTail.Substring(0, urlTail.IndexOf("/") - 1); } if (SimulateIsNumeric.IsNumeric(urlTail)) { _page = Convert.ToInt32(urlTail); } } string sPage = string.Empty; sPage = "&afpg=" + _page.ToString(); string qs = string.Empty; if (sUrl.Contains("?")) { qs = "&" + sUrl.Substring(sUrl.IndexOf("?") + 1); } string catQS = string.Empty; if (_categoryId > 0) { catQS = "&act=" + _categoryId.ToString(); } string sendTo = string.Empty; if (_topicId > 0) { sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + "&aft=" + _topicId + sPage + qs); } else if (_forumId > 0) { sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + "&aff=" + _forumId + sPage + qs + catQS); } else if (_forumgroupId > 0) { sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + "&afg=" + _forumgroupId + sPage + qs + catQS); } else if (_urlType == 2 && _otherId > 0) { sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + "&act=" + _otherId + sPage + qs); } else if (_urlType == 3 && _otherId > 0) { sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + "&afv=grid&afgt=tags&aftg=" + _otherId + sPage + qs); } else if (_urlType == 1) { string v = string.Empty; switch (_otherId) { case 1: v = "unanswered"; break; case 2: v = "notread"; break; case 3: v = "mytopics"; break; case 4: v = "activetopics"; break; case 5: v = "afprofile"; break; } sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + "&afv=grid&afgt=" + v + sPage + qs); } else if (_tabId > 0) { sendTo = ResolveUrl(app.Context.Request.ApplicationPath, "~/default.aspx?tabid=" + _tabId + sPage + qs); } RewriteUrl(app.Context, sendTo); } }
public override void ProcessRequest(HttpContext context) { AdminRequired = true; base.AdminRequired = true; base.ProcessRequest(context); string sOut = string.Empty; Actions action = Actions.None; if (IsValid) { if (Params != null) { if (Params["action"] != null && SimulateIsNumeric.IsNumeric(Params["action"])) { action = (Actions)(Convert.ToInt32(Params["action"].ToString())); } } try { sOut = "{\"result\":\"success\"}"; switch (action) { case Actions.PropertySave: PropertySave(); break; case Actions.PropertyDelete: PropertyDelete(); break; case Actions.PropertyList: sOut = "[" + Utilities.LocalizeControl(PropertyList()) + "]"; break; case Actions.PropertySortSwitch: UpdateSort(); break; case Actions.ListOfLists: sOut = GetLists(); break; case Actions.LoadView: sOut = LoadView(); break; case Actions.RankGet: sOut = GetRank(); break; case Actions.RankSave: RankSave(); break; case Actions.RankDelete: RankDelete(); break; case Actions.FilterGet: sOut = FilterGet(); break; case Actions.FilterSave: FilterSave(); break; case Actions.FilterDelete: FilterDelete(); break; } } catch (Exception ex) { Exceptions.LogException(ex); sOut = "{"; sOut += Utilities.JSON.Pair("result", "failed"); sOut += ","; sOut += Utilities.JSON.Pair("message", ex.Message); sOut += "}"; } } else { sOut = "{"; sOut += Utilities.JSON.Pair("result", "failed"); sOut += ","; sOut += Utilities.JSON.Pair("message", "Invalid Request"); sOut += "}"; } context.Response.ContentType = "text/plain"; context.Response.Write(sOut); }
private string BuildRSS(int PortalId, int TabId, int ModuleId, int intPosts, int ForumID, bool IngnoreSecurity, bool IncludeBody) { DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalSettings ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); DotNetNuke.Entities.Users.UserInfo ou = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo(); UserController uc = new UserController(); User u = uc.GetUser(PortalId, ModuleId); DataSet ds = DataProvider.Instance().UI_TopicsView(PortalId, ModuleId, ForumID, ou.UserID, 0, 20, ou.IsSuperUser, SortColumns.ReplyCreated); if (ds.Tables.Count > 0) { offSet = Convert.ToInt32(ps.TimeZone.BaseUtcOffset.TotalMinutes); if (ds.Tables[0].Rows.Count == 0) { return(string.Empty); } drForum = ds.Tables[0].Rows[0]; drSecurity = ds.Tables[1].Rows[0]; dtTopics = ds.Tables[3]; if (dtTopics.Rows.Count == 0) { return(string.Empty); } bView = Permissions.HasPerm(drSecurity["CanView"].ToString(), u.UserRoles); bRead = Permissions.HasPerm(drSecurity["CanRead"].ToString(), u.UserRoles); StringBuilder sb = new StringBuilder(1024); if (bRead) { ForumName = drForum["ForumName"].ToString(); GroupName = drForum["GroupName"].ToString(); ForumDescription = drForum["ForumDesc"].ToString(); //TopicsTemplateId = CInt(drForum("TopicsTemplateId")) bAllowRSS = Convert.ToBoolean(drForum["AllowRSS"]); if (bAllowRSS) { sb.Append("<?xml version=\"1.0\" ?>" + System.Environment.NewLine); sb.Append("<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:cf=\"http://www.microsoft.com/schemas/rss/core/2005\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\">" + System.Environment.NewLine); string[] Params = { ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics }; string URL = string.Empty; if (Request.QueryString["asg"] == null) { URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params); } else if (SimulateIsNumeric.IsNumeric(Request.QueryString["asg"])) { Params = new string[] { "asg=" + Request.QueryString["asg"], ParamKeys.ForumId + "=" + ForumID, ParamKeys.ViewType + "=" + Views.Topics }; URL = DotNetNuke.Common.Globals.NavigateURL(TabId, "", Params); } if (URL.IndexOf(Request.Url.Host) == -1) { URL = DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host) + URL; } // build channel sb.Append(WriteElement("channel", 1)); sb.Append(WriteElement("title", HttpUtility.HtmlEncode(ps.PortalName) + " " + ForumName, 2)); sb.Append(WriteElement("link", URL, 2)); sb.Append(WriteElement("description", ForumDescription, 2)); sb.Append(WriteElement("language", PortalSettings.DefaultLanguage, 2)); sb.Append(WriteElement("generator", "ActiveForums 5.0", 2)); sb.Append(WriteElement("copyright", PortalSettings.FooterText, 2)); sb.Append(WriteElement("lastBuildDate", "[LASTBUILDDATE]", 2)); if (!(ps.LogoFile == string.Empty)) { string sLogo = "<image><url>http://" + Request.Url.Host + ps.HomeDirectory + ps.LogoFile + "</url>"; sLogo += "<title>" + ps.PortalName + " " + ForumName + "</title>"; sLogo += "<link>" + URL + "</link></image>"; sb.Append(sLogo); } foreach (DataRow dr in dtTopics.Rows) { if (DotNetNuke.Security.PortalSecurity.IsInRoles(PortalSettings.ActiveTab.TabPermissions.ToString("VIEW"))) { //objModule = objModules.GetModule(ModuleId, TabId) //If DotNetNuke.Security.PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) = True Then // sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId)) //End If sb.Append(BuildItem(dr, TabId, 2, IncludeBody, PortalId)); } } sb.Append("<atom:link href=\"http://" + Request.Url.Host + HttpUtility.HtmlEncode(Request.RawUrl) + "\" rel=\"self\" type=\"application/rss+xml\" />"); sb.Append(WriteElement("/channel", 1)); sb.Replace("[LASTBUILDDATE]", LastBuildDate.ToString("r")); sb.Append("</rss>"); //Cache.Insert("RSS" & ModuleId & ForumID, sb.ToString, Nothing, DateTime.Now.AddMinutes(dblCacheTimeOut), TimeSpan.Zero) return(sb.ToString()); } } } return(string.Empty); }
private string BuildItem(DataRow dr, int PostTabID, int Indent, bool IncludeBody, int PortalId) { SettingsInfo MainSettings = DataCache.MainSettings(ModuleID); StringBuilder sb = new StringBuilder(1024); string[] Params = { ParamKeys.ForumId + "=" + dr["ForumID"].ToString(), ParamKeys.TopicId + "=" + dr["TopicId"].ToString(), ParamKeys.ViewType + "=" + Views.Topic }; string URL = DotNetNuke.Common.Globals.NavigateURL(PostTabID, "", Params); if (Request.QueryString["asg"] != null) { if (SimulateIsNumeric.IsNumeric(Request.QueryString["asg"])) { Params = new string[] { "asg=" + Request.QueryString["asg"], ParamKeys.ForumId + "=" + dr["ForumId"].ToString(), ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + dr["TopicId"].ToString() }; URL = DotNetNuke.Common.Globals.NavigateURL(PostTabID, "", Params); } } else if (MainSettings.URLRewriteEnabled && !(string.IsNullOrEmpty(dr["FullUrl"].ToString()))) { string sTopicURL = string.Empty; if (!(string.IsNullOrEmpty(MainSettings.PrefixURLBase))) { sTopicURL = "/" + MainSettings.PrefixURLBase; } sTopicURL += dr["FullUrl"].ToString(); URL = sTopicURL; } if (URL.IndexOf(Request.Url.Host) == -1) { URL = DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host) + URL; } if (LastBuildDate == new DateTime()) { LastBuildDate = Convert.ToDateTime(dr["DateCreated"]).AddMinutes(offSet); } else { if (Convert.ToDateTime(dr["DateCreated"]).AddMinutes(offSet) > LastBuildDate) { LastBuildDate = Convert.ToDateTime(dr["DateCreated"]).AddMinutes(offSet); } } sb.Append(WriteElement("item", Indent)); string body = dr["Body"].ToString(); if (body.IndexOf("<body>") > 0) { body = TemplateUtils.GetTemplateSection(body, "<body>", "</body>"); } /* * if (body.Contains("[IMAGE:")) * { * string strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(Request)) + "/"; * string pattern = "([IMAGE:(.+?)])"; * Regex regExp = new Regex(pattern); * MatchCollection matches = null; * matches = regExp.Matches(body); * foreach (Match match in matches) * { * string sImage = ""; * sImage = "<img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleID + "&attachid=" + match.Groups[2].Value + "\" border=\"0\" />"; * body = body.Replace(match.Value, sImage); * } * } * if (body.Contains("[THUMBNAIL:")) * { * string strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(Request)) + "/"; * string pattern = "([THUMBNAIL:(.+?)])"; * Regex regExp = new Regex(pattern); * MatchCollection matches = null; * matches = regExp.Matches(body); * foreach (Match match in matches) * { * string sImage = ""; * string thumbId = match.Groups[2].Value.Split(':')[0]; * string parentId = match.Groups[2].Value.Split(':')[1]; * sImage = "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleID + "&attachid=" + parentId + "\" target=\"_blank\"><img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleID + "&attachid=" + thumbId + "\" border=\"0\" /></a>"; * body = body.Replace(match.Value, sImage); * } * } */ body = body.Replace("src=\"/Portals", "src=\"" + DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host) + "/Portals"); body = Utilities.ManageImagePath(body, DotNetNuke.Common.Globals.AddHTTP(Request.Url.Host)); sb.Append(WriteElement("title", dr["Subject"].ToString(), Indent + 1)); sb.Append(WriteElement("description", body, Indent + 1)); sb.Append(WriteElement("link", URL, Indent + 1)); sb.Append(WriteElement("dc:creator", UserProfiles.GetDisplayName(ModuleID, -1, dr["AuthorUserName"].ToString(), dr["AuthorFirstName"].ToString(), dr["AuthorLastName"].ToString(), dr["AuthorDisplayName"].ToString(), null), Indent + 1)); sb.Append(WriteElement("pubDate", Convert.ToDateTime(dr["DateCreated"]).AddMinutes(offSet).ToString("r"), Indent + 1)); sb.Append(WriteElement("guid", URL, Indent + 1)); sb.Append(WriteElement("slash:comments", dr["ReplyCount"].ToString(), Indent + 1)); sb.Append(WriteElement("/item", Indent)); return(sb.ToString()); }
private void BindPosts(string sort = "ASC") { _pageSize = MainSettings.PageSize; if (UserId > 0) { _pageSize = UserDefaultPageSize; } if (_pageSize < 5) { _pageSize = 10; } _rowIndex = (PageId == 1) ? 0 : ((PageId * _pageSize) - _pageSize); var db = new Data.Common(); var fc = new ForumController(); var forumIds = fc.GetForumsForUser(ForumUser.UserRoles, PortalId, ModuleId, "CanRead"); var sCrumb = "<a href=\"" + Utilities.NavigateUrl(TabId, "", new[] { ParamKeys.ViewType + "=grid", "afgt=xxx" }) + "\">yyyy</a>"; sCrumb = sCrumb.Replace("xxx", "{0}").Replace("yyyy", "{1}"); if (Request.Params["afgt"] != null) { var gview = Utilities.XSSFilter(Request.Params["afgt"]).ToLowerInvariant(); switch (gview) { case "notread": if (UserId != -1) { lblHeader.Text = GetSharedResource("[RESX:NotRead]"); _dtResults = db.UI_NotReadView(PortalId, ModuleId, UserId, _rowIndex, _pageSize, sort, forumIds).Tables[0]; if (_dtResults.Rows.Count > 0) { _rowCount = _dtResults.Rows[0].GetInt("RecordCount"); btnMarkRead.Visible = true; btnMarkRead.InnerText = GetSharedResource("[RESX:MarkAllRead]"); } } else { Response.Redirect(NavigateUrl(TabId), true); } break; case "unanswered": lblHeader.Text = GetSharedResource("[RESX:Unanswered]"); _dtResults = db.UI_UnansweredView(PortalId, ModuleId, UserId, _rowIndex, _pageSize, sort, forumIds).Tables[0]; if (_dtResults.Rows.Count > 0) { _rowCount = _dtResults.Rows[0].GetInt("RecordCount"); } break; case "tags": var tagId = -1; if (Request.QueryString["aftg"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["aftg"])) { tagId = int.Parse(Request.QueryString["aftg"]); } lblHeader.Text = GetSharedResource("[RESX:Tags]"); _dtResults = db.UI_TagsView(PortalId, ModuleId, UserId, _rowIndex, _pageSize, sort, forumIds, tagId).Tables[0]; if (_dtResults.Rows.Count > 0) { _rowCount = _dtResults.Rows[0].GetInt("RecordCount"); } break; case "mytopics": if (UserId != -1) { lblHeader.Text = GetSharedResource("[RESX:MyTopics]"); _dtResults = db.UI_MyTopicsView(PortalId, ModuleId, UserId, _rowIndex, _pageSize, sort, forumIds).Tables[0]; if (_dtResults.Rows.Count > 0) { _rowCount = _dtResults.Rows[0].GetInt("RecordCount"); } } else { Response.Redirect(NavigateUrl(TabId), true); } break; case "activetopics": lblHeader.Text = GetSharedResource("[RESX:ActiveTopics]"); /* * if (UserLastAccess != Utilities.NullDate()) * { * timeFrame = Convert.ToInt32(SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, UserLastAccess, DateTime.Now)); * drpTimeFrame.Items.Insert(0, new ListItem(GetDate(UserLastAccess), "~" + timeFrame.ToString())); * } */ var timeFrame = Utilities.SafeConvertInt(Request.Params["ts"], 1440); if (timeFrame < 15 | timeFrame > 80640) { timeFrame = 1440; } drpTimeFrame.Visible = true; drpTimeFrame.SelectedIndex = drpTimeFrame.Items.IndexOf(drpTimeFrame.Items.FindByValue(timeFrame.ToString())); _dtResults = db.UI_ActiveView(PortalId, ModuleId, UserId, _rowIndex, _pageSize, sort, timeFrame, forumIds).Tables[0]; if (_dtResults.Rows.Count > 0) { _rowCount = Convert.ToInt32(_dtResults.Rows[0]["RecordCount"]); } break; default: Response.Redirect(NavigateUrl(TabId), true); break; } sCrumb = string.Format(sCrumb, gview, lblHeader.Text); if (MainSettings.UseSkinBreadCrumb) { Environment.UpdateBreadCrumb(Page.Controls, sCrumb); } var tempVar = BasePage; Environment.UpdateMeta(ref tempVar, "[VALUE] - " + lblHeader.Text, "[VALUE]", "[VALUE]"); } if (_dtResults != null && _dtResults.Rows.Count > 0) { litRecordCount.Text = string.Format(GetSharedResource("[RESX:SearchRecords]"), _rowIndex + 1, _rowIndex + _dtResults.Rows.Count, _rowCount); pnlMessage.Visible = false; try { rptTopics.Visible = true; rptTopics.DataSource = _dtResults; rptTopics.DataBind(); BuildPager(PagerTop); BuildPager(PagerBottom); } catch (Exception ex) { litMessage.Text = ex.Message; pnlMessage.Visible = true; rptTopics.Visible = false; } } else { litMessage.Text = GetSharedResource("[RESX:SearchNoResults]"); pnlMessage.Visible = true; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); ClientResourceManager.RegisterScript(Page, "~/desktopmodules/activeforums/scripts/jquery-forumSelector.js"); try { if (Request.QueryString["GroupId"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["GroupId"])) { SocialGroupId = Convert.ToInt32(Request.QueryString["GroupId"]); } btnSearch.Click += btnSearch_Click; btnSearch2.Click += btnSearch_Click; if (Page.IsPostBack) { return; } // Bind the intial values for the forum // Options litInputError.Text = GetSharedResource("[RESX:SearchInputError]"); litOptions.Text = GetSharedResource("[RESX:SearchOptions]"); lblSearch.Text = GetSharedResource("[RESX:SearchKeywords]"); txtSearch.Text = SearchText; ListItem selectedItem = drpSearchColumns.Items.FindByValue(SearchColumns.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } selectedItem = drpSearchType.Items.FindByValue(SearchType.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } lblUserName.Text = GetSharedResource("[RESX:SearchByUser]"); txtUserName.Text = AuthorUsername; lblTags.Text = GetSharedResource("[RESX:SearchByTag]"); txtTags.Text = Tags; // Additional Options litAdditionalOptions.Text = GetSharedResource("[RESX:SearchOptionsAdditional]"); lblForums.Text = GetSharedResource("[RESX:SearchInForums]"); BindForumList(); lblSearchDays.Text = GetSharedResource("[RESX:SearchTimeFrame]"); BindSearchRange(); lblResultType.Text = GetSharedResource("[RESX:SearchResultType]"); selectedItem = drpResultType.Items.FindByValue(ResultType.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } lblSortType.Text = GetSharedResource("[RESX:SearchSort]"); selectedItem = drpSort.Items.FindByValue(Sort.ToString()); if (selectedItem != null) { selectedItem.Selected = true; } // Buttons btnSearch.Text = GetSharedResource("[RESX:Search]"); btnSearch2.Text = GetSharedResource("[RESX:Search]"); btnReset.InnerText = GetSharedResource("[RESX:Reset]"); btnReset2.InnerText = GetSharedResource("[RESX:Reset]"); // Update Meta Data var basePage = BasePage; Environment.UpdateMeta(ref basePage, "[VALUE] - " + GetSharedResource("[RESX:SearchAdvanced]"), "[VALUE]", "[VALUE]"); } catch (Exception ex) { Controls.Clear(); RenderMessage("[RESX:ERROR]", "[RESX:ERROR:Search]", ex.Message, ex); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); rptPosts.ItemCreated += RepeaterOnItemCreated; rptTopics.ItemCreated += RepeaterOnItemCreated; try { if (Request.QueryString["GroupId"] != null && SimulateIsNumeric.IsNumeric(Request.QueryString["GroupId"])) { SocialGroupId = Convert.ToInt32(Request.QueryString["GroupId"]); } litSearchTitle.Text = GetSharedResource("[RESX:SearchTitle]"); List <Keyword> keywords; // Note: Filter out any keywords that are not at least 3 characters in length if (SearchType == 2 && !string.IsNullOrWhiteSpace(SearchText) && SearchText.Trim().Length >= 3) //Exact Match { keywords = new List <Keyword> { new Keyword { Value = "\"" + SearchText.Trim() + "\"" } } } ; else { keywords = SearchText.Split(' ').Where(kw => !string.IsNullOrWhiteSpace(kw) && kw.Trim().Length >= 3).Select(kw => new Keyword { Value = kw }).ToList(); } if (keywords.Count > 0) { phKeywords.Visible = true; rptKeywords.DataSource = keywords; rptKeywords.DataBind(); } if (!string.IsNullOrWhiteSpace(AuthorUsername)) { phUsername.Visible = true; litUserName.Text = Server.HtmlEncode(AuthorUsername); } if (!string.IsNullOrWhiteSpace(Tags)) { phTag.Visible = true; litTag.Text = Server.HtmlEncode(Tags); } BindPosts(); // Update Meta Data var tempVar = BasePage; Environment.UpdateMeta(ref tempVar, "[VALUE] - " + GetSharedResource("[RESX:Search]") + " - " + SearchText, "[VALUE]", "[VALUE]"); } catch (Exception ex) { Controls.Clear(); RenderMessage("[RESX:ERROR]", "[RESX:ERROR:Search]", ex.Message, ex); } }
private string DeletePost() { int replyId = -1; int TopicId = -1; if (Params.ContainsKey("topicid") && SimulateIsNumeric.IsNumeric(Params["topicid"])) { TopicId = int.Parse(Params["topicid"].ToString()); } if (Params.ContainsKey("replyid") && SimulateIsNumeric.IsNumeric(Params["replyid"])) { replyId = int.Parse(Params["replyid"].ToString()); } int forumId = -1; Data.ForumsDB db = new Data.ForumsDB(); forumId = db.Forum_GetByTopicId(TopicId); ForumController fc = new ForumController(); Forum f = fc.Forums_Get(forumId, this.UserId, true); // Need to get the list of attachments BEFORE we remove the post recods var attachmentController = new Data.AttachController(); var attachmentList = (MainSettings.DeleteBehavior == 0) ? attachmentController.ListForPost(TopicId, replyId) : null; if (TopicId > 0 & replyId < 1) { TopicsController tc = new TopicsController(); TopicInfo ti = tc.Topics_Get(PortalId, ModuleId, TopicId); if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ti.Content.AuthorId == UserId && ti.IsLocked == false)) { DataProvider.Instance().Topics_Delete(forumId, TopicId, MainSettings.DeleteBehavior); string journalKey = string.Format("{0}:{1}", forumId.ToString(), TopicId.ToString()); JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey); } else { return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); } } else { ReplyController rc = new ReplyController(); ReplyInfo ri = rc.Reply_Get(PortalId, ModuleId, TopicId, replyId); if (Permissions.HasAccess(f.Security.ModDelete, ForumUser.UserRoles) || (Permissions.HasAccess(f.Security.Delete, ForumUser.UserRoles) && ri.Content.AuthorId == UserId)) { DataProvider.Instance().Reply_Delete(forumId, TopicId, replyId, MainSettings.DeleteBehavior); string journalKey = string.Format("{0}:{1}:{2}", forumId.ToString(), TopicId.ToString(), replyId.ToString()); JournalController.Instance.DeleteJournalItemByKey(PortalId, journalKey); } else { return(BuildOutput(string.Empty, OutputCodes.UnsupportedRequest, false)); } } // If it's a hard delete, delete associated attachments // attachmentList will only be populated if the DeleteBehavior is 0 if (attachmentList != null) { var fileManager = FileManager.Instance; var folderManager = FolderManager.Instance; var attachmentFolder = folderManager.GetFolder(PortalId, "activeforums_Attach"); foreach (var attachment in attachmentList) { attachmentController.Delete(attachment.AttachmentId); var file = attachment.FileId.HasValue ? fileManager.GetFile(attachment.FileId.Value) : fileManager.GetFile(attachmentFolder, attachment.FileName); // Only delete the file if it exists in the attachment folder if (file != null && file.FolderId == attachmentFolder.FolderID) { fileManager.DeleteFile(file); } } } // Return the result string cachekey = string.Format("AF-FV-{0}-{1}", PortalId, ModuleId); DataCache.CacheClearPrefix(cachekey); return(BuildOutput(TopicId + "|" + replyId, OutputCodes.Success, true)); }